Skip to content

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.

feat(workbench): tag queue submissions with project origin

joshistoast6ca18729d912
diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx
index b0b16a82c1..7bb29d0cb0 100644
--- a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx
+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx
@@ -13,7 +13,7 @@ import {
} from './backend/queueCoordinator';
import { socketHub } from './backend/socketHub';
import { addImagesToGalleryBoard } from './gallery/api';
-import { getQueueItemResultImages } from './generation/api';
+import { getQueueItemResultImages, resumeQueueProcessor } from './generation/api';
import { sanitizeBatchCount } from './generation/batch';
import { normalizeGenerateSettings } from './generation/settings';
import {
@@ -173,6 +173,7 @@ const submitQueueItem = (
negativePromptNodeId: 'negative_prompt',
positivePrompt: generateValues.positivePrompt,
positivePromptNodeId: 'positive_prompt',
+ projectId: project.id,
seed: generateValues.seed,
seedNodeId: 'seed',
shouldRandomizeSeed: generateValues.shouldRandomizeSeed,
@@ -182,6 +183,7 @@ const submitQueueItem = (
batchCount: getSnapshotBatchCount(queueItem),
destination: queueItem.snapshot.destination,
graph,
+ projectId: project.id,
sourceQueueItemId: queueItem.id,
});
@@ -195,6 +197,11 @@ const submitQueueItem = (
type: 'markQueueItemBackendSubmitted',
});
+ // Enqueuing implies intent to run: a paused processor would otherwise leave
+ // the batch stuck "waiting for progress" forever. Mirrors the legacy app's
+ // `anyEnqueued` listener; `resume` is a no-op when already running.
+ void resumeQueueProcessor().catch(() => undefined);
+
return routeRunResults(coordinator, project.id, queueItem, dispatch);
})
.catch((error: unknown) => {
@@ -369,6 +376,7 @@ export const WorkbenchRuntime = () => {
case 'missing': {
dispatch({
error: 'This run is no longer on the backend queue (it may have been cleared).',
+ notify: false,
projectId: project.id,
queueItemId: queueItem.id,
status: 'failed',
diff --git a/invokeai/frontend/webv2/src/workbench/backend/events.ts b/invokeai/frontend/webv2/src/workbench/backend/events.ts
index 439e488b6a..6b898d181c 100644
--- a/invokeai/frontend/webv2/src/workbench/backend/events.ts
+++ b/invokeai/frontend/webv2/src/workbench/backend/events.ts
@@ -28,6 +28,25 @@ export interface QueueItemStatusChangedEvent extends QueueItemEventBase {
session_id: string;
}
+export interface BatchEnqueuedEvent {
+ queue_id: string;
+ batch_id: string;
+ enqueued: number;
+ requested: number;
+ priority: number;
+ origin: string | null;
+ user_id: string;
+}
+
+export interface QueueClearedEvent {
+ queue_id: string;
+}
+
+export interface QueueItemsRetriedEvent {
+ queue_id: string;
+ retried_item_ids: number[];
+}
+
/** Shared shape of per-invocation lifecycle events (`InvocationEventBase` on the backend). */
export interface InvocationEventBase extends QueueItemEventBase {
session_id: string;
@@ -57,6 +76,9 @@ export interface InvocationErrorEvent extends InvocationEventBase {
export interface BackendSocketEvents {
queue_item_status_changed: QueueItemStatusChangedEvent;
+ batch_enqueued: BatchEnqueuedEvent;
+ queue_cleared: QueueClearedEvent;
+ queue_items_retried: QueueItemsRetriedEvent;
invocation_started: InvocationStartedEvent;
invocation_progress: InvocationProgressEvent;
invocation_complete: InvocationCompleteEvent;
@@ -72,9 +94,30 @@ export const isTerminalBackendStatus = (status: BackendQueueItemStatus): status
* and items are re-adopted by decoding their origin.
*/
const QUEUE_ITEM_ORIGIN_PREFIX = 'webv2:';
+const PROJECT_QUEUE_ITEM_ORIGIN_PREFIX = 'webv2:p:';
+
+export const buildProjectQueueItemOriginPrefix = (projectId: string): string =>
+ `${PROJECT_QUEUE_ITEM_ORIGIN_PREFIX}${projectId}:q:`;
-export const buildQueueItemOrigin = (localQueueItemId: string): string =>
- `${QUEUE_ITEM_ORIGIN_PREFIX}${localQueueItemId}`;
+export const buildQueueItemOrigin = (localQueueItemId: string, projectId?: string): string =>
+ projectId
+ ? `${buildProjectQueueItemOriginPrefix(projectId)}${localQueueItemId}`
+ : `${QUEUE_ITEM_ORIGIN_PREFIX}${localQueueItemId}`;
export const parseQueueItemOrigin = (origin: string | null | undefined): string | null =>
- origin?.startsWith(QUEUE_ITEM_ORIGIN_PREFIX) ? origin.slice(QUEUE_ITEM_ORIGIN_PREFIX.length) : null;
+ origin?.startsWith(PROJECT_QUEUE_ITEM_ORIGIN_PREFIX)
+ ? origin.slice(origin.lastIndexOf(':q:') + 3)
+ : origin?.startsWith(QUEUE_ITEM_ORIGIN_PREFIX)
+ ? origin.slice(QUEUE_ITEM_ORIGIN_PREFIX.length)
+ : null;
+
+export const parseQueueItemOriginProjectId = (origin: string | null | undefined): string | null => {
+ if (!origin?.startsWith(PROJECT_QUEUE_ITEM_ORIGIN_PREFIX)) {
+ return null;
+ }
+
+ const rest = origin.slice(PROJECT_QUEUE_ITEM_ORIGIN_PREFIX.length);
+ const separatorIndex = rest.indexOf(':q:');
+
+ return separatorIndex === -1 ? null : rest.slice(0, separatorIndex);
+};
diff --git a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.ts b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.ts
index 53cf461277..149824e651 100644
--- a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.test.ts
@@ -93,6 +93,7 @@ const generateRequest: EnqueueGenerateRequest = {
negativePromptNodeId: 'negative_prompt',
positivePrompt: 'a fjord at dawn',
positivePromptNodeId: 'positive_prompt',
+ projectId: 'project-1',
seed: 1,
seedNodeId: 'seed',
shouldRandomizeSeed: false,
@@ -124,8 +125,8 @@ const createHarness = (options: { galleryRefreshCoalesceMs?: number } = {}): Har
const api = {
cancelQueueItems: vi.fn(() => Promise.resolve()),
cancelQueueItemsByBatchIds: vi.fn(() => Promise.resolve()),
- enqueueGenerateGraph: vi.fn(() => Promise.resolve({ batchId: 'batch-1', itemIds: [1] })),
- enqueueWorkflowGraph: vi.fn(() => Promise.resolve({ batchId: 'batch-1', itemIds: [1] })),
+ enqueueGenerateGraph: vi.fn(() => Promise.resolve({ batchId: 'batch-1', enqueued: 1, itemIds: [1], requested: 1 })),
+ enqueueWorkflowGraph: vi.fn(() => Promise.resolve({ batchId: 'batch-1', enqueued: 1, itemIds: [1], requested: 1 })),
getQueueItem: vi.fn((itemId: number) => Promise.resolve(createQueueItemDTO({ item_id: itemId }))),
getQueueItemResultImages: vi.fn((itemId: number, sourceQueueItemId: string) =>
Promise.resolve([createImage(`image-${itemId}.png`, sourceQueueItemId)])
@@ -174,7 +175,12 @@ describe('queueCoordinator', () => {
});
it('settles submitted runs from terminal socket events without polling', async () => {
- harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', itemIds: [1, 2] });
+ harness.api.enqueueGenerateGraph.mockResolvedValue({
+ batchId: 'batch-1',
+ enqueued: 2,
+ itemIds: [1, 2],
+ requested: 2,
+ });
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
@@ -216,7 +222,12 @@ describe('queueCoordinator', () => {
it('returns completed batch item results when sibling backend items are canceled', async () => {
harness.callbacks.onBackendItemCancelled = vi.fn();
- harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', itemIds: [1, 2, 3] });
+ harness.api.enqueueGenerateGraph.mockResolvedValue({
+ batchId: 'batch-1',
+ enqueued: 3,
+ itemIds: [1, 2, 3],
+ requested: 3,
+ });
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
@@ -236,7 +247,12 @@ describe('queueCoordinator', () => {
});
it('rejects with QueueItemCancelledError when every backend item in a batch is canceled', async () => {
- harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', itemIds: [1, 2] });
+ harness.api.enqueueGenerateGraph.mockResolvedValue({
+ batchId: 'batch-1',
+ enqueued: 2,
+ itemIds: [1, 2],
+ requested: 2,
+ });
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
@@ -262,12 +278,30 @@ describe('queueCoordinator', () => {
expect(images.map((image) => image.imageName)).toEqual(['image-1.png']);
});
+ it('rejects runs when the backend queue accepts no items', async () => {
+ harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', enqueued: 0, itemIds: [], requested: 1 });
+
+ await expect(harness.coordinator.submitGenerate('local-1', generateRequest)).rejects.toThrow(
+ 'The backend queue did not accept this generation.'
+ );
+ });
+
+ it('rejects runs when the backend queue accepts only part of the batch', async () => {
+ harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', enqueued: 1, itemIds: [1], requested: 2 });
+
+ await expect(harness.coordinator.submitGenerate('local-1', generateRequest)).rejects.toThrow(
+ 'The backend queue accepted 1 of 2 requested items.'
+ );
+ });
+
it('coalesces gallery refreshes across a burst of completions', async () => {
vi.useFakeTimers();
harness = createHarness({ galleryRefreshCoalesceMs: 400 });
harness.api.enqueueGenerateGraph.mockResolvedValue({
batchId: 'batch-1',
+ enqueued: 10,
itemIds: Array.from({ length: 10 }, (_, index) => index + 1),
+ requested: 10,
});
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
@@ -286,7 +320,12 @@ describe('queueCoordinator', () => {
it('does not refresh the gallery for failed or canceled items', async () => {
vi.useFakeTimers();
harness = createHarness({ galleryRefreshCoalesceMs: 400 });
- harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', itemIds: [1, 2] });
+ harness.api.enqueueGenerateGraph.mockResolvedValue({
+ batchId: 'batch-1',
+ enqueued: 2,
+ itemIds: [1, 2],
+ requested: 2,
+ });
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
await vi.advanceTimersByTimeAsync(500); // flush the on-connect refresh
@@ -363,7 +402,12 @@ describe('queueCoordinator', () => {
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] });
+ harness.api.enqueueGenerateGraph.mockResolvedValue({
+ batchId: 'batch-1',
+ enqueued: 2,
+ itemIds: [1, 2],
+ requested: 2,
+ });
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
@@ -374,7 +418,12 @@ describe('queueCoordinator', () => {
});
it('routes progress images to the active image slot inside a submitted batch', async () => {
- harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', itemIds: [1, 2] });
+ harness.api.enqueueGenerateGraph.mockResolvedValue({
+ batchId: 'batch-1',
+ enqueued: 2,
+ itemIds: [1, 2],
+ requested: 2,
+ });
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
@@ -433,7 +482,12 @@ describe('queueCoordinator', () => {
});
it('tracks the active image index inside a submitted batch', async () => {
- harness.api.enqueueGenerateGraph.mockResolvedValue({ batchId: 'batch-1', itemIds: [1, 2] });
+ harness.api.enqueueGenerateGraph.mockResolvedValue({
+ batchId: 'batch-1',
+ enqueued: 2,
+ itemIds: [1, 2],
+ requested: 2,
+ });
harness.coordinator.connect();
await harness.coordinator.submitGenerate('local-1', generateRequest);
@@ -552,6 +606,14 @@ describe('queueCoordinator', () => {
expect(harness.api.cancelQueueItemsByBatchIds).toHaveBeenCalledWith(['batch-2']);
});
+ it('treats stale missing backend items as already cancelled', async () => {
+ harness.api.cancelQueueItems.mockRejectedValue(
+ new ApiError('Queue item with id 42 not found in queue default', 404)
+ );
+
+ await expect(harness.coordinator.cancelRun({ backendItemIds: [42] })).resolves.toBeUndefined();
+ });
+
it('detaches socket listeners after dispose', async () => {
harness.coordinator.connect();
diff --git a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.ts b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.ts
index 82a830aad9..7ae831a083 100644
--- a/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.ts
+++ b/invokeai/frontend/webv2/src/workbench/backend/queueCoordinator.ts
@@ -581,6 +581,14 @@ export const createQueueCoordinator = (
): Promise<EnqueueGenerateResult> => {
const result = await api.enqueueGenerateGraph(request);
+ if (result.enqueued === 0) {
+ throw new Error('The backend queue did not accept this generation. The queue may be full.');
+ }
+
+ if (result.requested !== result.enqueued) {
+ throw new Error(`The backend queue accepted ${result.enqueued} of ${result.requested} requested items.`);
+ }
+
beginRun(localQueueItemId, result.itemIds, result.batchId);
return result;
@@ -592,6 +600,14 @@ export const createQueueCoordinator = (
): Promise<EnqueueGenerateResult> => {
const result = await api.enqueueWorkflowGraph(request);
+ if (result.enqueued === 0) {
+ throw new Error('The backend queue did not accept this workflow. The queue may be full.');
+ }
+
+ if (result.requested !== result.enqueued) {
+ throw new Error(`The backend queue accepted ${result.enqueued} of ${result.requested} requested items.`);
+ }
+
beginRun(localQueueItemId, result.itemIds, result.batchId);
return result;
@@ -635,13 +651,21 @@ export const createQueueCoordinator = (
};
const cancelRun = async ({ backendBatchId, backendItemIds }: CancelRunRequest): Promise<void> => {
- if (backendItemIds?.length) {
- await api.cancelQueueItems(backendItemIds);
- return;
- }
+ try {
+ if (backendItemIds?.length) {
+ await api.cancelQueueItems(backendItemIds);
+ return;
+ }
+
+ if (backendBatchId) {
+ await api.cancelQueueItemsByBatchIds([backendBatchId]);
+ }
+ } catch (error) {
+ if (error instanceof ApiError && error.status === 404) {
+ return;
+ }
- if (backendBatchId) {
- await api.cancelQueueItemsByBatchIds([backendBatchId]);
+ throw error;
}
};
diff --git a/invokeai/frontend/webv2/src/workbench/generation/api.test.ts b/invokeai/frontend/webv2/src/workbench/generation/api.test.ts
index 109ce2e556..36d0231039 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/api.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/api.test.ts
@@ -27,6 +27,7 @@ const createRequest = (overrides: Partial<EnqueueGenerateRequest> = {}): Enqueue
negativePromptNodeId: 'negative_prompt',
positivePrompt: 'a fjord at dawn',
positivePromptNodeId: 'positive_prompt',
+ projectId: 'project-1',
seed: 10,
seedNodeId: 'seed',
shouldRandomizeSeed: false,
@@ -38,6 +39,7 @@ const createWorkflowRequest = (overrides: Partial<EnqueueWorkflowRequest> = {}):
batchCount: 2,
destination: 'gallery',
graph: { edges: [], id: 'graph-1', nodes: {} },
+ projectId: 'project-1',
sourceQueueItemId: 'local-1',
...overrides,
});
@@ -50,6 +52,7 @@ const getSubmittedBody = () => {
return JSON.parse(init?.body as string) as {
batch: {
data: { field_name: string; items: unknown[]; node_path: string }[][];
+ origin: string;
runs: number;
};
};
@@ -58,7 +61,12 @@ const getSubmittedBody = () => {
describe('enqueueGenerateGraph', () => {
beforeEach(() => {
mocks.apiFetchJson.mockReset();
- mocks.apiFetchJson.mockResolvedValue({ batch: { batch_id: 'batch-1' }, item_ids: [1, 2, 3] });
+ mocks.apiFetchJson.mockResolvedValue({
+ batch: { batch_id: 'batch-1' },
+ enqueued: 3,
+ item_ids: [1, 2, 3],
+ requested: 3,
+ });
});
it('keeps a fixed seed for every run when randomization is disabled', async () => {
@@ -94,12 +102,25 @@ describe('enqueueGenerateGraph', () => {
{ field_name: 'value', items: ['low quality', 'low quality', 'low quality'], node_path: 'negative_prompt' },
]);
});
+
+ it('includes project-aware webv2 origin metadata', async () => {
+ const { enqueueGenerateGraph } = await import('./api');
+
+ await enqueueGenerateGraph(createRequest());
+
+ expect(getSubmittedBody().batch.origin).toBe('webv2:p:project-1:q:local-1');
+ });
});
describe('enqueueWorkflowGraph', () => {
beforeEach(() => {
mocks.apiFetchJson.mockReset();
- mocks.apiFetchJson.mockResolvedValue({ batch: { batch_id: 'batch-1' }, item_ids: [1, 2] });
+ mocks.apiFetchJson.mockResolvedValue({
+ batch: { batch_id: 'batch-1' },
+ enqueued: 2,
+ item_ids: [1, 2],
+ requested: 2,
+ });
});
it('submits workflow runs for the requested batch count', async () => {
diff --git a/invokeai/frontend/webv2/src/workbench/generation/api.ts b/invokeai/frontend/webv2/src/workbench/generation/api.ts
index 26922077c0..a9bfd7f73e 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/api.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/api.ts
@@ -39,17 +39,24 @@ export const enqueueGenerateGraph = async (request: EnqueueGenerateRequest): Pro
],
destination: request.destination,
graph: request.graph satisfies BackendGraphContract,
- origin: buildQueueItemOrigin(request.sourceQueueItemId),
+ origin: buildQueueItemOrigin(request.sourceQueueItemId, request.projectId),
runs: request.shouldRandomizeSeed ? 1 : batchCount,
},
prepend: false,
};
- const result = await apiFetchJson<{ batch?: { batch_id?: string }; item_ids?: number[] }>(
- '/api/v1/queue/default/enqueue_batch',
- { body: JSON.stringify(body), method: 'POST' }
- );
-
- return { batchId: result.batch?.batch_id, itemIds: result.item_ids ?? [] };
+ const result = await apiFetchJson<{
+ batch?: { batch_id?: string };
+ enqueued?: number;
+ item_ids?: number[];
+ requested?: number;
+ }>('/api/v1/queue/default/enqueue_batch', { body: JSON.stringify(body), method: 'POST' });
+
+ return {
+ batchId: result.batch?.batch_id,
+ enqueued: result.enqueued ?? 0,
+ itemIds: result.item_ids ?? [],
+ requested: result.requested ?? 0,
+ };
};
/** Enqueue an arbitrary compiled graph — the workflow path. */
@@ -59,17 +66,24 @@ export const enqueueWorkflowGraph = async (request: EnqueueWorkflowRequest): Pro
batch: {
destination: request.destination,
graph: request.graph satisfies BackendGraphContract,
- origin: buildQueueItemOrigin(request.sourceQueueItemId),
+ origin: buildQueueItemOrigin(request.sourceQueueItemId, request.projectId),
runs: batchCount,
},
prepend: false,
};
- const result = await apiFetchJson<{ batch?: { batch_id?: string }; item_ids?: number[] }>(
- '/api/v1/queue/default/enqueue_batch',
- { body: JSON.stringify(body), method: 'POST' }
- );
-
- return { batchId: result.batch?.batch_id, itemIds: result.item_ids ?? [] };
+ const result = await apiFetchJson<{
+ batch?: { batch_id?: string };
+ enqueued?: number;
+ item_ids?: number[];
+ requested?: number;
+ }>('/api/v1/queue/default/enqueue_batch', { body: JSON.stringify(body), method: 'POST' });
+
+ return {
+ batchId: result.batch?.batch_id,
+ enqueued: result.enqueued ?? 0,
+ itemIds: result.item_ids ?? [],
+ requested: result.requested ?? 0,
+ };
};
export const getQueueItem = (itemId: number): Promise<QueueItemDTO> =>
diff --git a/invokeai/frontend/webv2/src/workbench/generation/types.ts b/invokeai/frontend/webv2/src/workbench/generation/types.ts
index fa6746b7fa..2384156fbb 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/types.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/types.ts
@@ -139,7 +139,9 @@ export interface CompiledGenerateGraph {
export interface EnqueueGenerateResult {
batchId?: string;
+ enqueued: number;
itemIds: number[];
+ requested: number;
}
export interface QueueItemDTO {
@@ -160,6 +162,7 @@ export interface EnqueueWorkflowRequest {
batchCount: number;
destination: ResultDestination;
graph: BackendGraphContract;
+ projectId: string;
sourceQueueItemId: string;
}
@@ -174,6 +177,7 @@ export interface EnqueueGenerateRequest {
seed: number;
seedNodeId: string;
shouldRandomizeSeed: boolean;
+ projectId: string;
sourceQueueItemId: string;
}
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index f582db3708..f7524c8619 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -281,11 +281,10 @@ describe('workbench layout presets', () => {
sizePx: 450,
});
expect(project.widgetRegions.bottom).toMatchObject({
- activeInstanceId: 'queue:bottom',
+ activeInstanceId: 'gallery:bottom',
instanceIds: [
'server-status',
'diagnostics:bottom',
- 'queue:bottom',
'gallery:bottom',
'notifications',
'autosave-status',
@@ -739,6 +738,26 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(getActiveProject(state).queue.items.map((item) => item.status)).toEqual(['cancelled']);
});
+ it('can mark stale reconciled queue items failed without creating notifications', () => {
+ let state = submitGenerate(primeGenerate());
+ const project = getActiveProject(state);
+ const queueItem = project.queue.items[0];
+ const notificationCount = state.notifications.length;
+
+ state = workbenchReducer(state, {
+ error: 'This run is no longer on the backend queue.',
+ notify: false,
+ projectId: project.id,
+ queueItemId: queueItem.id,
+ status: 'failed',
+ type: 'setQueueItemStatus',
+ });
+
+ expect(getActiveProject(state).queue.items[0]?.status).toBe('failed');
+ expect(getActiveProject(state).queue.items[0]?.error).toBe('This run is no longer on the backend queue.');
+ expect(state.notifications).toHaveLength(notificationCount);
+ });
+
it('keeps cancellation terminal when backend item ids arrive late', () => {
let state = submitGenerate(primeGenerate());
const project = getActiveProject(state);
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index ad2926d869..bf97dc30da 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -154,7 +154,14 @@ type WorkbenchAction =
backendItemIds: number[];
backendBatchId?: string;
}
- | { type: 'setQueueItemStatus'; projectId: string; queueItemId: string; status: QueueItemStatus; error?: string }
+ | {
+ type: 'setQueueItemStatus';
+ projectId: string;
+ queueItemId: string;
+ status: QueueItemStatus;
+ error?: string;
+ notify?: boolean;
+ }
| {
type: 'routeQueueItemPartialResults';
projectId: string;
@@ -659,7 +666,6 @@ const defaultWidgetInstanceTypes: Record<WidgetInstanceId, WidgetTypeId> = {
preview: 'preview',
project: 'project',
queue: 'queue',
- 'queue:bottom': 'queue',
'server-status': 'server-status',
'version-status': 'version-status',
workflow: 'workflow',
@@ -1957,7 +1963,7 @@ export const workbenchReducer = (state: WorkbenchState, action: WorkbenchAction)
}))
);
- if (action.status !== 'failed' && action.status !== 'cancelled') {
+ if (action.notify === false || (action.status !== 'failed' && action.status !== 'cancelled')) {
return nextState;
}