From d5f9121b8469eabe8695948d583dd42571598475 Mon Sep 17 00:00:00 2001 From: princepride Date: Fri, 20 Nov 2026 17:01:58 +0000 Subject: [PATCH 1/2] [fix] canvas: only finish deliveries this session watched start Review findings: editing a generated text node clears its backend asset on every keystroke, which made the node look like it was still waiting for its result and covered the editor with the busy overlay. Undo or a version switch also made an old job's result count as "arriving". A node now waits only while it still shows an older backend asset, and only for jobs this session saw running. Co-Authored-By: Claude Opus 5.5 --- src/canvas/generationActivity.ts | 8 +++++--- src/canvas/workspace/useWorkspaceRuntime.ts | 13 ++++++++++++- tests/canvasPendingResults.test.ts | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/canvas/generationActivity.ts b/src/canvas/generationActivity.ts index bb7ad8a6..19c7f772 100644 --- a/src/canvas/generationActivity.ts +++ b/src/canvas/generationActivity.ts @@ -12,12 +12,14 @@ export function jobActivities( const displayed = new Map(nodes.map((node) => [node.id, node.data.backendAssetId])); return jobs.flatMap((job) => { // A regenerated node keeps its old media until the new result has loaded; - // stay busy until then rather than briefly revealing the old image. + // stay busy until then rather than briefly revealing the old image. A node + // without a backend asset (new, or locally edited text) is not waiting. + const shown = displayed.get(job.nodeId); const delivering = Boolean( job.status === "succeeded" && job.deliveredAssetId && - displayed.has(job.nodeId) && - displayed.get(job.nodeId) !== job.deliveredAssetId, + shown && + shown !== job.deliveredAssetId, ); const finishing = delivering || Boolean( job.toolTask && diff --git a/src/canvas/workspace/useWorkspaceRuntime.ts b/src/canvas/workspace/useWorkspaceRuntime.ts index 15463120..2501156b 100644 --- a/src/canvas/workspace/useWorkspaceRuntime.ts +++ b/src/canvas/workspace/useWorkspaceRuntime.ts @@ -153,6 +153,11 @@ export function useWorkspaceRuntime(): WorkspaceRuntime { const setupChecked = useRef(false); const theme = useTheme(); const serviceRuns = useRef(new Map()); + // Jobs seen running in this session. Only their results can still be + // arriving; historical, undone or version-switched results are never pending. + const watchedJobs = useRef(new Set()); + for (const job of jobs) + if (!job.tool && job.status === "running") watchedJobs.current.add(job.id); const generationByNode = useMemo( () => generationActivities( @@ -167,7 +172,13 @@ export function useWorkspaceRuntime(): WorkspaceRuntime { ), ), ...jobActivities( - jobs.filter((job) => !job.tool), + jobs + .filter((job) => !job.tool) + .map((job) => + job.deliveredAssetId && !watchedJobs.current.has(job.id) + ? { ...job, deliveredAssetId: undefined } + : job, + ), doc.id, doc.nodes, ), diff --git a/tests/canvasPendingResults.test.ts b/tests/canvasPendingResults.test.ts index 0d790b5b..f8a1fc94 100644 --- a/tests/canvasPendingResults.test.ts +++ b/tests/canvasPendingResults.test.ts @@ -423,6 +423,9 @@ test("a regenerated node stays busy until its delivered result is displayed", () const shown = { ...node, data: { ...node.data, backendAssetId: "new-asset" } }; assert.deepEqual(jobActivities([job], "doc", [shown]), []); assert.deepEqual(jobActivities([job], "doc", []), []); + // Local text edits clear the backend asset; such a node is not waiting. + const edited = { ...node, data: { ...node.data, backendAssetId: undefined } }; + assert.deepEqual(jobActivities([job], "doc", [edited]), []); // A succeeded job whose result is not the node's current content stays idle. assert.deepEqual(jobActivities([{ ...job, deliveredAssetId: undefined }], "doc", [node]), []); }); From 1f63804412876fb5126535fcdd6ca3a03fa3ca3a Mon Sep 17 00:00:00 2001 From: princepride Date: Sat, 21 Nov 2026 02:38:31 +0000 Subject: [PATCH 2/2] [fix] canvas: keep a first generation busy until its result shows Requiring a displayed backend asset excluded locally edited text, but also excluded a first generation into an empty node, which again flashed an empty frame between the job finishing and the result loading. An empty node (no media, no text) now waits too; a node with local text still does not. Co-Authored-By: Claude Opus 5.5 --- src/canvas/generationActivity.ts | 15 ++++++++------- tests/canvasPendingResults.test.ts | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/canvas/generationActivity.ts b/src/canvas/generationActivity.ts index 19c7f772..031e7fd8 100644 --- a/src/canvas/generationActivity.ts +++ b/src/canvas/generationActivity.ts @@ -9,17 +9,18 @@ export function jobActivities( documentId: string, nodes: readonly CanvasNode[] = [], ): ActiveGeneration[] { - const displayed = new Map(nodes.map((node) => [node.id, node.data.backendAssetId])); + const byId = new Map(nodes.map((node) => [node.id, node])); return jobs.flatMap((job) => { - // A regenerated node keeps its old media until the new result has loaded; - // stay busy until then rather than briefly revealing the old image. A node - // without a backend asset (new, or locally edited text) is not waiting. - const shown = displayed.get(job.nodeId); + // A node keeps its old media, or shows an empty frame, until the new result + // has loaded; stay busy until then. Locally edited text has content but no + // backend asset, and is not waiting for anything. + const node = byId.get(job.nodeId); + const shown = node?.data.backendAssetId; + const empty = Boolean(node && !node.data.src && !node.data.text); const delivering = Boolean( job.status === "succeeded" && job.deliveredAssetId && - shown && - shown !== job.deliveredAssetId, + (shown ? shown !== job.deliveredAssetId : empty), ); const finishing = delivering || Boolean( job.toolTask && diff --git a/tests/canvasPendingResults.test.ts b/tests/canvasPendingResults.test.ts index f8a1fc94..7ed452fb 100644 --- a/tests/canvasPendingResults.test.ts +++ b/tests/canvasPendingResults.test.ts @@ -424,8 +424,11 @@ test("a regenerated node stays busy until its delivered result is displayed", () assert.deepEqual(jobActivities([job], "doc", [shown]), []); assert.deepEqual(jobActivities([job], "doc", []), []); // Local text edits clear the backend asset; such a node is not waiting. - const edited = { ...node, data: { ...node.data, backendAssetId: undefined } }; + const edited = { ...node, data: { ...node.data, backendAssetId: undefined, text: "draft" } }; assert.deepEqual(jobActivities([job], "doc", [edited]), []); + // A first generation into an empty node waits instead of flashing an empty frame. + const fresh = { ...node, data: { ...node.data, backendAssetId: undefined, src: undefined, text: undefined } }; + assert.equal(jobActivities([job], "doc", [fresh])[0]?.phase, "finishing"); // A succeeded job whose result is not the node's current content stays idle. assert.deepEqual(jobActivities([{ ...job, deliveredAssetId: undefined }], "doc", [node]), []); });