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.

fix(webv2): notify enqueues against the submitting project, not the active one

joshistoast54ec59d997af
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 675b0c9636..e913c954ba 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -2287,6 +2287,50 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(getActiveProject(next).queue.items).toEqual([]);
expect(next.notifications).toHaveLength(notificationCount);
});
+
+ it('notifies for a background-project canvas enqueue', () => {
+ const graph: GraphContract = {
+ edges: [],
+ id: 'canvas-graph',
+ label: 'Canvas',
+ nodes: [],
+ updatedAt: '2026-06-09T00:00:00.000Z',
+ version: 1,
+ };
+
+ let state = createInitialWorkbenchState();
+ const originatingProjectId = state.activeProjectId;
+ state = workbenchReducer(state, { type: 'createProject' });
+ const otherProjectId = state.activeProjectId;
+
+ expect(otherProjectId).not.toBe(originatingProjectId);
+
+ // Project A (originating) stays active; the canvas submission below
+ // targets project B, simulating an async canvas enqueue that lands
+ // after the user has switched away.
+ state = workbenchReducer(state, { projectId: originatingProjectId, type: 'switchProject' });
+
+ expect(state.activeProjectId).toBe(originatingProjectId);
+
+ state = workbenchReducer(state, {
+ backendSupportsCancellation: true,
+ canvas: structuredClone(getProject(state, otherProjectId).canvas),
+ destination: 'canvas',
+ generate: {
+ negativePromptNodeId: 'negative_prompt',
+ positivePromptNodeId: 'positive_prompt',
+ seedNodeId: 'seed',
+ values: createGenerateValues({ positivePrompt: 'canvas prompt', seed: 101, shouldRandomizeSeed: false }),
+ },
+ graph,
+ projectId: otherProjectId,
+ type: 'submitCanvasInvocationSnapshot',
+ });
+
+ expect(getProject(state, otherProjectId).queue.items).toHaveLength(1);
+ expect(state.notifications[0]?.title).toBe('Invocation queued');
+ expect(state.notifications[0]?.projectId).toBe(otherProjectId);
+ });
});
it('accepts the project graph source but does not queue an empty project graph', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index 993063099a..846c7faa1c 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -457,10 +457,14 @@ const addNotification = (state: WorkbenchState, notification: WorkbenchNotificat
return { ...state, notifications: [notification, ...state.notifications].slice(0, NOTIFICATION_LIMIT) };
};
-/** Adds the "Invocation queued" notice iff the reduction actually grew the active queue. */
-const withEnqueueNotification = (state: WorkbenchState, nextState: WorkbenchState): WorkbenchState => {
- const before = state.projects.find((project) => project.id === state.activeProjectId);
- const after = nextState.projects.find((project) => project.id === nextState.activeProjectId);
+/** Adds the "Invocation queued" notice iff the reduction actually grew that project's queue. */
+const withEnqueueNotification = (
+ state: WorkbenchState,
+ nextState: WorkbenchState,
+ projectId: string | null
+): WorkbenchState => {
+ const before = state.projects.find((project) => project.id === projectId);
+ const after = nextState.projects.find((project) => project.id === projectId);
if (!before || !after || before.queue.items.length >= after.queue.items.length) {
return nextState;
@@ -3497,7 +3501,8 @@ export const __workbenchReducerInternal = (
state,
updateActiveProject(state, (project) =>
submitInvocationSnapshot(project, action.backendSupportsCancellation, undefined, action.models)
- )
+ ),
+ state.activeProjectId
);
}
case 'submitResolvedInvocationSnapshot': {
@@ -3511,7 +3516,8 @@ export const __workbenchReducerInternal = (
action.models,
action.positivePrompts
)
- )
+ ),
+ state.activeProjectId
);
}
case 'markQueueItemBackendSubmitted': {
@@ -3912,7 +3918,8 @@ export const __workbenchReducerInternal = (
action.backendSupportsCancellation,
action.canvas
)
- )
+ ),
+ action.projectId
);
}
case 'cancelQueueItem': {