Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(queue): retain denoise image preview while final processes
joshistoast2c9f62db4919
diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsxindex cd6f3aa976..effa871253 100644--- a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx@@ -266,7 +266,7 @@ export const WorkbenchRuntime = () => {return;}- void routeBackendItemResults(routeTarget.project.id, routeTarget.queueItem, backendItemId, dispatch);+ return routeBackendItemResults(routeTarget.project.id, routeTarget.queueItem, backendItemId, dispatch);},onBackendItemCancelled: (localQueueItemId, backendItemId) => {const routeTarget = stateRef.current.projectsdiff --git a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.ts b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.tsindex 366c366c57..53cf461277 100644--- a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.ts+++ b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.ts@@ -328,6 +328,39 @@ describe('queueCoordinator', () => {expect(harness.progressImage.clear).toHaveBeenCalledWith({ itemIndex: 1, queueItemId: 'local-1' });});+ it('keeps the completed progress image until backend item result routing finishes', async () => {+ let finishRouting: () => void = () => undefined;+ const routingPromise = new Promise<void>((resolve) => {+ finishRouting = resolve;+ });++ harness.callbacks.onBackendItemComplete = vi.fn(() => routingPromise);+ harness.coordinator.connect();++ await harness.coordinator.submitGenerate('local-1', generateRequest);+ const resultsPromise = harness.coordinator.waitForResults('local-1', '2026-06-10T00:00:00Z');++ harness.socket.fire('invocation_progress', {+ ...createStatusEvent({ item_id: 1 }),+ image: { dataURL: 'data:image/png;base64,final-denoise', height: 32, width: 64 },+ invocation_source_id: 'denoise',+ message: 'Denoising',+ percentage: 1,+ });+ harness.socket.fire('queue_item_status_changed', createStatusEvent({ item_id: 1 }));++ await resultsPromise;++ expect(harness.callbacks.onBackendItemComplete).toHaveBeenCalledWith('local-1', 1);+ expect(harness.progressImage.clear).not.toHaveBeenCalled();++ finishRouting();+ await routingPromise;+ await Promise.resolve();++ expect(harness.progressImage.clear).toHaveBeenCalledWith({ itemIndex: 1, queueItemId: 'local-1' });+ });+it('notifies when one backend item in a batch completes', async () => {harness.callbacks.onBackendItemComplete = vi.fn();harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', itemIds: [1, 2] });diff --git a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.ts b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.tsindex 47fa92ab7a..82a830aad9 100644--- a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.ts+++ b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.ts@@ -51,7 +51,7 @@ export interface QueueCoordinatorApi {export interface QueueCoordinatorCallbacks {/** Fired when one backend item in a local batch completes, before the whole local batch necessarily settles. */- onBackendItemComplete?(localQueueItemId: string, backendItemId: number): void;+ onBackendItemComplete?(localQueueItemId: string, backendItemId: number): void | Promise<void>;/** Fired when one backend item in a local batch is canceled. */onBackendItemCancelled?(localQueueItemId: string, backendItemId: number): void;/** Coalesced signal that completed generations may have added gallery images. */@@ -263,7 +263,8 @@ export const createQueueCoordinator = (}waits.delete(backendItemId);- progressImage.clear(getProgressImageTarget(wait.localQueueItemId, backendItemId));+ const progressTarget = getProgressImageTarget(wait.localQueueItemId, backendItemId);+ const clearProgressImage = (): void => progressImage.clear(progressTarget);const state = runProgress.get(wait.localQueueItemId);if (state) {@@ -280,13 +281,26 @@ export const createQueueCoordinator = (}if (outcome.status === 'completed') {- callbacks.onBackendItemComplete?.(wait.localQueueItemId, backendItemId);+ const routingPromise = callbacks.onBackendItemComplete?.(wait.localQueueItemId, backendItemId);++ if (routingPromise) {+ void Promise.resolve(routingPromise)+ .finally(clearProgressImage)+ .catch(() => undefined);+ } else {+ clearProgressImage();+ }}if (outcome.status === 'canceled') {+ clearProgressImage();callbacks.onBackendItemCancelled?.(wait.localQueueItemId, backendItemId);}+ if (outcome.status === 'failed') {+ clearProgressImage();+ }+wait.settle(outcome);};