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(canvas): inpainted queue items don't get fully regenerated

joshistoast1de0204c4d6c
diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.test.ts b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.test.ts
new file mode 100644
index 0000000000..b82b7f78fd
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.test.ts
@@ -0,0 +1,148 @@
+import { describe, expect, it } from 'vitest';
+
+import type { GenerateWidgetValues, MainModelConfig } from './generation/types';
+import type { GraphContract, Project, QueueItem } from './types';
+
+import { getDefaultGenerateSettings } from './generation/baseGenerationPolicies';
+import { createQueueItemBackendSubmission } from './WorkbenchRuntime';
+import { createInitialWorkbenchState } from './workbenchState';
+
+const model: MainModelConfig = { base: 'sd-1', key: 'sd1', name: 'SD 1.5', type: 'main' };
+
+const createValues = (overrides: Partial<GenerateWidgetValues> = {}): GenerateWidgetValues => ({
+ ...getDefaultGenerateSettings(model),
+ model,
+ modelKey: model.key,
+ negativePrompt: 'low quality',
+ positivePrompt: 'a canvas prompt',
+ seed: 123,
+ shouldRandomizeSeed: true,
+ ...overrides,
+});
+
+const graph: GraphContract = {
+ backendGraph: { edges: [], id: 'backend-graph', nodes: {} },
+ edges: [],
+ id: 'graph-1',
+ label: 'Canvas',
+ nodes: [],
+ updatedAt: '2026-06-09T00:00:00.000Z',
+ version: 1,
+};
+
+const createProject = (): Project => createInitialWorkbenchState().projects[0]!;
+
+const createQueueItem = (project: Project, overrides: Partial<QueueItem['snapshot']>): QueueItem => ({
+ cancellable: true,
+ id: 'local-1',
+ snapshot: {
+ canvas: project.canvas,
+ destination: 'canvas',
+ graph,
+ sourceId: 'canvas',
+ submittedAt: '2026-06-09T00:00:00.000Z',
+ widgetInstances: project.widgetInstances,
+ widgetStates: Object.fromEntries(
+ Object.values(project.widgetInstances).map((instance) => [instance.typeId, instance.state])
+ ),
+ ...overrides,
+ },
+ status: 'pending',
+});
+
+describe('createQueueItemBackendSubmission', () => {
+ it('submits canvas queue items through the generate batch path with resolved prompt and seed metadata', () => {
+ const project = createProject();
+ const values = createValues({
+ batchCount: 4,
+ negativePrompt: 'avoid blur',
+ positivePrompt: 'inpaint prompt',
+ seed: 987,
+ });
+ const queueItem = createQueueItem(project, {
+ generate: {
+ negativePromptNodeId: 'canvas_negative_prompt',
+ positivePromptNodeId: 'canvas_positive_prompt',
+ seedNodeId: 'canvas_seed',
+ values,
+ },
+ sourceId: 'canvas',
+ });
+
+ const submission = createQueueItemBackendSubmission(project, queueItem);
+
+ expect(submission).toEqual({
+ kind: 'generate',
+ request: {
+ batchCount: 4,
+ destination: 'canvas',
+ graph: graph.backendGraph,
+ negativePrompt: 'avoid blur',
+ negativePromptNodeId: 'canvas_negative_prompt',
+ positivePrompt: 'inpaint prompt',
+ positivePromptNodeId: 'canvas_positive_prompt',
+ projectId: project.id,
+ seed: 987,
+ seedNodeId: 'canvas_seed',
+ shouldRandomizeSeed: true,
+ sourceQueueItemId: 'local-1',
+ },
+ });
+ });
+
+ it('falls back to legacy canvas widget-state metadata when a persisted snapshot has no generate payload', () => {
+ const project = createProject();
+ const values = createValues({
+ batchCount: 2,
+ negativePrompt: 'legacy negative',
+ positivePrompt: 'legacy prompt',
+ seed: 321,
+ shouldRandomizeSeed: false,
+ });
+ const queueItem = createQueueItem(project, {
+ sourceId: 'canvas',
+ widgetStates: {
+ ...createQueueItem(project, {}).snapshot.widgetStates,
+ generate: { id: 'generate', label: 'Generate', values: { ...values } as Record<string, unknown>, version: 1 },
+ },
+ });
+
+ const submission = createQueueItemBackendSubmission(project, queueItem);
+
+ expect(submission).toEqual({
+ kind: 'generate',
+ request: {
+ batchCount: 2,
+ destination: 'canvas',
+ graph: graph.backendGraph,
+ negativePrompt: 'legacy negative',
+ negativePromptNodeId: 'negative_prompt',
+ positivePrompt: 'legacy prompt',
+ positivePromptNodeId: 'positive_prompt',
+ projectId: project.id,
+ seed: 321,
+ seedNodeId: 'seed',
+ shouldRandomizeSeed: false,
+ sourceQueueItemId: 'local-1',
+ },
+ });
+ });
+
+ it('keeps workflow queue items on the workflow path', () => {
+ const project = createProject();
+ const queueItem = createQueueItem(project, { destination: 'gallery', sourceId: 'workflow' });
+
+ const submission = createQueueItemBackendSubmission(project, queueItem);
+
+ expect(submission).toEqual({
+ kind: 'workflow',
+ request: {
+ batchCount: 1,
+ destination: 'gallery',
+ graph: graph.backendGraph,
+ projectId: project.id,
+ sourceQueueItemId: 'local-1',
+ },
+ });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx
index 8510663b38..ae2e77e869 100644
--- a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx
+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx
@@ -1,5 +1,6 @@
import { useEffect, useRef, useState, type Dispatch } from 'react';
+import type { EnqueueGenerateRequest, EnqueueWorkflowRequest } from './generation/types';
import type { Project, QueueItem } from './types';
import type { WorkbenchAction } from './workbenchState';
@@ -44,6 +45,91 @@ const getSnapshotBatchCount = (queueItem: QueueItem): number => {
return sanitizeBatchCount(batchCount);
};
+type QueueItemBackendSubmission =
+ | { kind: 'generate'; request: EnqueueGenerateRequest }
+ | { kind: 'workflow'; request: EnqueueWorkflowRequest }
+ | { error: string; kind: 'invalid' };
+
+export const createQueueItemBackendSubmission = (
+ project: Project,
+ queueItem: QueueItem
+): QueueItemBackendSubmission => {
+ const graph = queueItem.snapshot.graph.backendGraph;
+
+ if (!graph) {
+ return { error: `${queueItem.snapshot.sourceId} queue item is missing a compiled backend graph.`, kind: 'invalid' };
+ }
+
+ if (queueItem.snapshot.sourceId === 'generate') {
+ const generateValues = normalizeGenerateSettings(queueItem.snapshot.widgetStates.generate?.values);
+
+ if (!generateValues) {
+ return { error: 'generate queue item is missing generation settings.', kind: 'invalid' };
+ }
+
+ return {
+ kind: 'generate',
+ request: {
+ batchCount: generateValues.batchCount,
+ destination: queueItem.snapshot.destination,
+ graph,
+ negativePrompt: generateValues.negativePromptEnabled ? generateValues.negativePrompt : '',
+ negativePromptNodeId: 'negative_prompt',
+ positivePrompt: generateValues.positivePrompt,
+ positivePromptNodeId: 'positive_prompt',
+ projectId: project.id,
+ seed: generateValues.seed,
+ seedNodeId: 'seed',
+ shouldRandomizeSeed: generateValues.shouldRandomizeSeed,
+ sourceQueueItemId: queueItem.id,
+ },
+ };
+ }
+
+ if (queueItem.snapshot.sourceId === 'canvas') {
+ const generate = queueItem.snapshot.generate;
+ // Persisted canvas queue items from before `snapshot.generate` existed still
+ // carry the generate widget snapshot; use it rather than falling back to
+ // backend primitive defaults for prompt/seed.
+ const generateValues = normalizeGenerateSettings(
+ generate ? generate.values : queueItem.snapshot.widgetStates.generate?.values
+ );
+
+ if (!generateValues) {
+ return { error: 'canvas queue item is missing generation submission metadata.', kind: 'invalid' };
+ }
+
+ return {
+ kind: 'generate',
+ request: {
+ batchCount: generateValues.batchCount,
+ destination: queueItem.snapshot.destination,
+ graph,
+ negativePrompt: generateValues.negativePromptEnabled ? generateValues.negativePrompt : '',
+ negativePromptNodeId: generate?.negativePromptNodeId ?? 'negative_prompt',
+ positivePrompt: generateValues.positivePrompt,
+ positivePromptNodeId: generate?.positivePromptNodeId ?? 'positive_prompt',
+ projectId: project.id,
+ seed: generateValues.seed,
+ seedNodeId: generate?.seedNodeId ?? 'seed',
+ shouldRandomizeSeed: generateValues.shouldRandomizeSeed,
+ sourceQueueItemId: queueItem.id,
+ },
+ };
+ }
+
+ return {
+ kind: 'workflow',
+ request: {
+ batchCount: getSnapshotBatchCount(queueItem),
+ destination: queueItem.snapshot.destination,
+ graph,
+ projectId: project.id,
+ sourceQueueItemId: queueItem.id,
+ },
+ };
+};
+
const selectQueueRevision = createStableSelector((snapshot: { state: { projects: Project[] } }) =>
snapshot.state.projects
.map((project) =>
@@ -157,15 +243,11 @@ const submitQueueItem = (
queueItem: QueueItem,
dispatch: Dispatch<WorkbenchAction>
): void => {
- const graph = queueItem.snapshot.graph.backendGraph;
- const generateValues =
- queueItem.snapshot.sourceId === 'generate'
- ? normalizeGenerateSettings(queueItem.snapshot.widgetStates.generate.values)
- : null;
+ const backendSubmission = createQueueItemBackendSubmission(project, queueItem);
- if (!graph || (queueItem.snapshot.sourceId === 'generate' && !generateValues)) {
+ if (backendSubmission.kind === 'invalid') {
dispatch({
- error: `${queueItem.snapshot.sourceId} queue item is missing a compiled backend graph.`,
+ error: backendSubmission.error,
projectId: project.id,
queueItemId: queueItem.id,
status: 'failed',
@@ -174,28 +256,10 @@ const submitQueueItem = (
return;
}
- const submission = generateValues
- ? coordinator.submitGenerate(queueItem.id, {
- batchCount: generateValues.batchCount,
- destination: queueItem.snapshot.destination,
- graph,
- negativePrompt: generateValues.negativePromptEnabled ? generateValues.negativePrompt : '',
- negativePromptNodeId: 'negative_prompt',
- positivePrompt: generateValues.positivePrompt,
- positivePromptNodeId: 'positive_prompt',
- projectId: project.id,
- seed: generateValues.seed,
- seedNodeId: 'seed',
- shouldRandomizeSeed: generateValues.shouldRandomizeSeed,
- sourceQueueItemId: queueItem.id,
- })
- : coordinator.submitWorkflow(queueItem.id, {
- batchCount: getSnapshotBatchCount(queueItem),
- destination: queueItem.snapshot.destination,
- graph,
- projectId: project.id,
- sourceQueueItemId: queueItem.id,
- });
+ const submission =
+ backendSubmission.kind === 'generate'
+ ? coordinator.submitGenerate(queueItem.id, backendSubmission.request)
+ : coordinator.submitWorkflow(queueItem.id, backendSubmission.request);
submission
.then(({ batchId, itemIds }) => {
diff --git a/invokeai/frontend/webv2/src/workbench/queueSubmission.ts b/invokeai/frontend/webv2/src/workbench/queueSubmission.ts
index b695141b8d..c3d1a2f13f 100644
--- a/invokeai/frontend/webv2/src/workbench/queueSubmission.ts
+++ b/invokeai/frontend/webv2/src/workbench/queueSubmission.ts
@@ -15,8 +15,9 @@
* they stack in the queue as `pending` forever and nothing ever generates. That
* was the canvas→canvas stall: canvas snapshots carry `sourceId: 'canvas'`, which
* was absent from the loop's allow-list, so each Invoke only produced a dead
- * local row. Canvas items route through the coordinator's workflow path (their
- * graph is fully compiled ahead of time, no generate seed/prompt batch data).
+ * local row. Canvas items use the generate-style backend submission path: the
+ * graph is compiled ahead of time, but prompt/seed batch data still has to ride
+ * along so repeated invokes are not silently run with backend primitive defaults.
*
* `upscale` is intentionally excluded: it is not yet an available source
* (`invocation.ts` marks it `available: false`), so it never produces a snapshot.
diff --git a/invokeai/frontend/webv2/src/workbench/types.ts b/invokeai/frontend/webv2/src/workbench/types.ts
index e80f7a76a0..d054e62678 100644
--- a/invokeai/frontend/webv2/src/workbench/types.ts
+++ b/invokeai/frontend/webv2/src/workbench/types.ts
@@ -3,7 +3,7 @@ import type { ComponentType, ExoticComponent, JSXElementConstructor, SVGProps }
// `generation/types.ts` imports value-less (`import type`) symbols back from this
// module; both sides are type-only so this doesn't create a runtime cycle.
-import type { GenerateReferenceImage } from './generation/types';
+import type { GenerateReferenceImage, GenerateWidgetValues } from './generation/types';
import type { WorkbenchLanguage } from './i18n/languages';
import type { ProjectGraphState } from './workflows/types';
@@ -823,6 +823,12 @@ export interface QueueSubmissionSnapshot {
sourceId: InvocationSourceId;
destination: ResultDestination;
graph: GraphContract;
+ generate?: {
+ values: GenerateWidgetValues;
+ negativePromptNodeId: string;
+ positivePromptNodeId: string;
+ seedNodeId: string;
+ };
widgetInstances: Record<WidgetInstanceId, WidgetInstanceContract>;
widgetStates: WidgetStateMap;
canvas: CanvasStateContractV2;
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
index d95a1f8af6..e528dd93f5 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
@@ -83,7 +83,7 @@ interface Harness {
uploadImage: ReturnType<typeof vi.fn>;
flushPendingUploads: ReturnType<typeof vi.fn>;
events: string[];
- submittedGraphs: () => { destination: string; graph: any }[];
+ submittedGraphs: () => Extract<WorkbenchAction, { type: 'submitCanvasInvocationSnapshot' }>[];
notices: () => { message?: string }[];
}
@@ -197,7 +197,7 @@ describe('runCanvasInvocation', () => {
expect(submitted).toHaveLength(1);
expect(submitted[0]?.graph.label).toBe('SD 1.5 txt2img');
// Pure txt2img graph has no image-to-latents encode node.
- expect(submitted[0]?.graph.backendGraph.nodes.canvas_i2l).toBeUndefined();
+ expect(submitted[0]!.graph.backendGraph!.nodes.canvas_i2l).toBeUndefined();
expect(harness.notices()).toHaveLength(0);
});
@@ -212,7 +212,7 @@ describe('runCanvasInvocation', () => {
expect(submitted).toHaveLength(1);
expect(submitted[0]?.graph.label).toBe('SD 1.5 img2img');
- const nodes = submitted[0]?.graph.backendGraph.nodes;
+ const nodes = submitted[0]!.graph.backendGraph!.nodes;
const encode = Object.values(nodes).find((node: any) => node.type === 'i2l') as any;
expect(encode?.image).toEqual({ image_name: 'composite-1.png' });
// sd-1 is linear: denoising_start = 1 - 0.75.
@@ -220,6 +220,33 @@ describe('runCanvasInvocation', () => {
expect(harness.notices()).toHaveLength(0);
});
+ it('dispatches resolved prompt and seed metadata with the compiled canvas graph', async () => {
+ const harness = makeHarness();
+ harness.deps.generateValues = {
+ ...harness.deps.generateValues,
+ negativePrompt: 'low quality',
+ positivePrompt: 'a resolved canvas prompt',
+ seed: 123,
+ shouldRandomizeSeed: false,
+ };
+
+ await runCanvasInvocation(harness.deps);
+
+ const submitted = harness.submittedGraphs();
+ expect(submitted).toHaveLength(1);
+ expect(submitted[0]?.generate).toMatchObject({
+ negativePromptNodeId: 'negative_prompt',
+ positivePromptNodeId: 'positive_prompt',
+ seedNodeId: 'seed',
+ values: {
+ negativePrompt: 'low quality',
+ positivePrompt: 'a resolved canvas prompt',
+ seed: 123,
+ shouldRandomizeSeed: false,
+ },
+ });
+ });
+
it('threads a Gallery destination through to the snapshot and a durable (non-intermediate) output', async () => {
// Empty document → txt2img, so no composite upload noise; we only care about
// the destination + is_intermediate wiring.
@@ -231,7 +258,7 @@ describe('runCanvasInvocation', () => {
expect(submitted).toHaveLength(1);
expect(submitted[0]?.destination).toBe('gallery');
// A Gallery destination must produce a durable image, not a staging intermediate.
- expect(submitted[0]?.graph.backendGraph.nodes.canvas_output.is_intermediate).toBe(false);
+ expect(submitted[0]!.graph.backendGraph!.nodes.canvas_output!.is_intermediate).toBe(false);
});
it('marks the output intermediate for a Canvas destination (staging)', async () => {
@@ -242,7 +269,7 @@ describe('runCanvasInvocation', () => {
const submitted = harness.submittedGraphs();
expect(submitted).toHaveLength(1);
expect(submitted[0]?.destination).toBe('canvas');
- expect(submitted[0]?.graph.backendGraph.nodes.canvas_output.is_intermediate).toBe(true);
+ expect(submitted[0]!.graph.backendGraph!.nodes.canvas_output!.is_intermediate).toBe(true);
});
it('awaits the upload flush before compositing', async () => {
@@ -422,11 +449,11 @@ describe('runCanvasInvocation — inpaint / outpaint dispatch', () => {
const submitted = harness.submittedGraphs();
expect(submitted).toHaveLength(1);
expect(submitted[0]?.graph.label).toBe('SD 1.5 inpaint');
- const nodes = submitted[0]?.graph.backendGraph.nodes;
+ const nodes = submitted[0]!.graph.backendGraph!.nodes;
expect(nodes.create_gradient_mask?.type).toBe('create_gradient_mask');
expect(nodes.canvas_output?.type).toBe('invokeai_img_blend');
// The gradient mask consumes the uploaded grayscale mask (base upload is composite-1).
- expect(nodes.create_gradient_mask?.mask?.image_name).toBeDefined();
+ expect((nodes.create_gradient_mask?.mask as { image_name?: string } | undefined)?.image_name).toBeDefined();
expect(harness.notices()).toHaveLength(0);
// The mask layer was rasterized for the grayscale composite.
expect(harness.events.filter((e) => e === 'getLayerSurface')).not.toHaveLength(0);
@@ -441,7 +468,7 @@ describe('runCanvasInvocation — inpaint / outpaint dispatch', () => {
const submitted = harness.submittedGraphs();
expect(submitted).toHaveLength(1);
expect(submitted[0]?.graph.label).toBe('SD 1.5 outpaint');
- const nodes = submitted[0]?.graph.backendGraph.nodes;
+ const nodes = submitted[0]!.graph.backendGraph!.nodes;
expect(nodes.infill?.type).toBe('infill_lama');
expect(nodes.image_alpha_to_mask?.type).toBe('tomask');
expect(nodes.canvas_output?.type).toBe('invokeai_img_blend');
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts
index fc263e510d..0b47284969 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts
@@ -423,6 +423,12 @@ export const runCanvasInvocation = async (deps: RunCanvasInvocationDeps): Promis
dispatch({
backendSupportsCancellation: true,
destination: deps.destination,
+ generate: {
+ negativePromptNodeId: compiled.negativePromptNodeId,
+ positivePromptNodeId: compiled.positivePromptNodeId,
+ seedNodeId: compiled.seedNodeId,
+ values: settings,
+ },
graph: compiled.graph,
projectId,
type: 'submitCanvasInvocationSnapshot',
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 96a85e6162..8d4a6c3cbf 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -1988,6 +1988,13 @@ describe('workbenchReducer canvas staging auto-switch + canvas submission', () =
expect(getCanvas(state).stagingArea.selectedImageIndex).toBe(0);
});
+ const createCanvasGenerateSnapshot = () => ({
+ negativePromptNodeId: 'negative_prompt',
+ positivePromptNodeId: 'positive_prompt',
+ seedNodeId: 'seed',
+ values: createGenerateValues({ positivePrompt: 'canvas prompt', seed: 101, shouldRandomizeSeed: false }),
+ });
+
const submitCanvasGeneration = (state: WorkbenchState): { queueItemId: string; state: WorkbenchState } => {
const graph: GraphContract = {
edges: [],
@@ -2000,6 +2007,7 @@ describe('workbenchReducer canvas staging auto-switch + canvas submission', () =
const next = workbenchReducer(state, {
backendSupportsCancellation: true,
destination: 'canvas',
+ generate: createCanvasGenerateSnapshot(),
graph,
projectId: state.activeProjectId,
type: 'submitCanvasInvocationSnapshot',
@@ -2062,6 +2070,17 @@ describe('workbenchReducer canvas staging auto-switch + canvas submission', () =
const state = workbenchReducer(initial, {
backendSupportsCancellation: true,
destination: 'canvas',
+ generate: {
+ negativePromptNodeId: 'negative_prompt',
+ positivePromptNodeId: 'positive_prompt',
+ seedNodeId: 'seed',
+ values: createGenerateValues({
+ negativePrompt: 'avoid blur',
+ positivePrompt: 'inpaint prompt',
+ seed: 42,
+ shouldRandomizeSeed: false,
+ }),
+ },
graph,
projectId: initial.activeProjectId,
type: 'submitCanvasInvocationSnapshot',
@@ -2072,6 +2091,18 @@ describe('workbenchReducer canvas staging auto-switch + canvas submission', () =
expect(queueItem?.snapshot.sourceId).toBe('canvas');
expect(queueItem?.snapshot.destination).toBe('canvas');
expect(queueItem?.snapshot.graph.id).toBe('canvas-graph');
+ expect(queueItem?.snapshot.generate).toMatchObject({
+ negativePromptNodeId: 'negative_prompt',
+ positivePromptNodeId: 'positive_prompt',
+ seedNodeId: 'seed',
+ values: { negativePrompt: 'avoid blur', positivePrompt: 'inpaint prompt', seed: 42, shouldRandomizeSeed: false },
+ });
+ expect(queueItem?.snapshot.widgetStates.generate.values).toMatchObject({
+ negativePrompt: 'avoid blur',
+ positivePrompt: 'inpaint prompt',
+ seed: 42,
+ shouldRandomizeSeed: false,
+ });
expect(getActiveProject(state).invocation.sourceId).toBe('canvas');
});
@@ -2089,6 +2120,7 @@ describe('workbenchReducer canvas staging auto-switch + canvas submission', () =
const state = workbenchReducer(initial, {
backendSupportsCancellation: true,
destination: 'gallery',
+ generate: createCanvasGenerateSnapshot(),
graph,
projectId: initial.activeProjectId,
type: 'submitCanvasInvocationSnapshot',
@@ -2124,6 +2156,7 @@ describe('workbenchReducer canvas staging auto-switch + canvas submission', () =
state = workbenchReducer(state, {
backendSupportsCancellation: true,
destination: 'canvas',
+ generate: createCanvasGenerateSnapshot(),
graph,
projectId: originatingProjectId,
type: 'submitCanvasInvocationSnapshot',
@@ -2148,6 +2181,7 @@ describe('workbenchReducer canvas staging auto-switch + canvas submission', () =
const state = workbenchReducer(initial, {
backendSupportsCancellation: true,
destination: 'canvas',
+ generate: createCanvasGenerateSnapshot(),
graph,
projectId: 'not-a-real-project',
type: 'submitCanvasInvocationSnapshot',
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index 9814120910..29d036b0cc 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -109,6 +109,8 @@ type CanvasLayerConfigPatch =
}
| { layerType: 'inpaint_mask'; mask?: Partial<CanvasMaskContract>; noiseLevel?: number; denoiseLimit?: number };
+type QueueGenerateSnapshot = NonNullable<QueueItem['snapshot']['generate']>;
+
type WorkbenchAction =
| { type: 'createProject' }
| { type: 'openProject'; project: Project }
@@ -254,6 +256,7 @@ type WorkbenchAction =
type: 'submitCanvasInvocationSnapshot';
backendSupportsCancellation: boolean;
destination: ResultDestination;
+ generate: QueueGenerateSnapshot;
graph: GraphContract;
projectId: string;
}
@@ -381,6 +384,32 @@ const cloneGraph = (graph: GraphContract): GraphContract => ({
nodes: graph.nodes.map((node) => ({ ...node, inputs: { ...node.inputs } })),
});
+const cloneQueueGenerateSnapshot = (generate: QueueGenerateSnapshot): QueueGenerateSnapshot => ({
+ negativePromptNodeId: generate.negativePromptNodeId,
+ positivePromptNodeId: generate.positivePromptNodeId,
+ seedNodeId: generate.seedNodeId,
+ values: cloneGenerateWidgetValues(generate.values),
+});
+
+const applyQueueGenerateSnapshotToWidgetStates = (
+ widgetStates: WidgetStateMap,
+ generate: QueueGenerateSnapshot | undefined
+): WidgetStateMap => {
+ if (!generate) {
+ return widgetStates;
+ }
+
+ const generateState = widgetStates.generate ?? { id: 'generate', label: 'Generate', values: {}, version: 1 as const };
+
+ return {
+ ...widgetStates,
+ generate: {
+ ...generateState,
+ values: cloneGenerateWidgetValues(generate.values),
+ },
+ };
+};
+
const clonePlacement = (placement: CanvasPlacementContract): CanvasPlacementContract => ({ ...placement });
const createCenteredPlacement = (
@@ -1866,12 +1895,13 @@ const routeQueueItemResults = (project: Project, queueItemId: string, images: Ge
const enqueueCompiledSnapshot = (
project: Project,
route: InvocationRoute,
- compiled: { graph: GraphContract; widgetStates: WidgetStateMap },
+ compiled: { generate?: QueueGenerateSnapshot; graph: GraphContract; widgetStates: WidgetStateMap },
backendSupportsCancellation: boolean
): Project => {
const submittedAt = now();
const queueItemId = createId('queue-item');
- const { graph, widgetStates } = compiled;
+ const { generate, graph } = compiled;
+ const widgetStates = applyQueueGenerateSnapshotToWidgetStates(compiled.widgetStates, generate);
const graphHistorySnapshot = createGraphHistorySnapshot(`Queue snapshot ${queueItemId}`, graph);
const generateSettings =
route.sourceId === 'generate' ? normalizeGenerateSettings(widgetStates.generate.values) : null;
@@ -1881,6 +1911,7 @@ const enqueueCompiledSnapshot = (
snapshot: {
canvas: cloneCanvas(project.canvas),
destination: route.destination,
+ ...(generate ? { generate: cloneQueueGenerateSnapshot(generate) } : {}),
graph,
sourceId: route.sourceId,
submittedAt,
@@ -3053,7 +3084,11 @@ export const workbenchReducer = (state: WorkbenchState, action: WorkbenchAction)
enqueueCompiledSnapshot(
project,
{ ...project.invocation, destination: action.destination, sourceId: 'canvas' },
- { graph: action.graph, widgetStates: getWidgetStatesSnapshot(project.widgetInstances) },
+ {
+ generate: action.generate,
+ graph: action.graph,
+ widgetStates: getWidgetStatesSnapshot(project.widgetInstances),
+ },
action.backendSupportsCancellation
)
);