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
fix(webv2): preserve workflow metadata on enqueue
JPPhoto09f25a06c6e1
diff --git a/invokeai/frontend/webv2/src/features/queue/core/types.ts b/invokeai/frontend/webv2/src/features/queue/core/types.tsindex beb5f67e30..e4a9a0c7eb 100644--- a/invokeai/frontend/webv2/src/features/queue/core/types.ts+++ b/invokeai/frontend/webv2/src/features/queue/core/types.ts@@ -43,6 +43,8 @@ interface QueueEnqueueRequestBase {}export interface QueueEnqueueWorkflowRequest extends QueueEnqueueRequestBase {+ /** Serialized parent workflow, compatible with the backend's `WorkflowWithoutID` schema. */+ workflow?: Record<string, unknown>;/** The seed inputs that vary between the `batchCount` runs; the graph carries each one's first seed. */seeds?: QueueWorkflowSeed[];}@@ -81,6 +83,8 @@ export type QueueCompiledSubmission =batchCount: number;graph: QueueBackendGraph;kind: 'workflow';+ /** Serialized parent workflow, compatible with the backend's `WorkflowWithoutID` schema. */+ workflow?: Record<string, unknown>;/** The seed inputs that vary between runs, expanded into one zipped batch group at send time. */seeds?: QueueWorkflowSeed[];/**diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.tsindex 860821b3c3..de2f62152c 100644--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts@@ -113,6 +113,7 @@ const getSubmittedBody = () => {idempotency_key: string;origin: string;runs: number;+ workflow?: Record<string, unknown>;};};};@@ -337,6 +338,28 @@ describe('enqueueWorkflow', () => {expect(getSubmittedBody().batch.batch_id).toBeUndefined();});+ it('includes the serialized parent workflow in the batch', async () => {+ const { enqueueWorkflow } = await import('./submissionApi');+ const workflow = {+ author: '',+ contact: '',+ description: '',+ edges: [],+ exposedFields: [],+ form: null,+ meta: { category: 'user', version: '3.0.0' },+ name: 'Parent workflow',+ nodes: [],+ notes: '',+ tags: '',+ version: '1.0.0',+ };++ await enqueueWorkflow({ ...createWorkflowRequest(), workflow });++ expect(getSubmittedBody().batch.workflow).toEqual(workflow);+ });+it('expands recorded seeds into one zipped group and never redraws them', async () => {const { enqueueWorkflow } = await import('./submissionApi');const seeds = [diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.tsindex 4c9e1d39cb..4446a4dac3 100644--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts@@ -121,6 +121,7 @@ export const enqueueWorkflow = async (request: QueueEnqueueWorkflowRequest): Proproject_id: request.projectId,origin: buildQueueItemOrigin(request.sourceQueueItemId, request.projectId),runs: plan.runs,+ ...(request.workflow ? { workflow: request.workflow } : {}),},prepend: false,}),diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 0018f44d1d..20f2c56362 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -3410,7 +3410,22 @@ describe('workbenchReducer Phase 5 generation flow', () => {batchCount: 3,kind: 'workflow',seeds: [{ fieldName: 'seed', nodeId: 'noise-1', seed: 42, seedStep: 1 }],+ workflow: {+ author: '',+ contact: '',+ description: '',+ edges: [],+ exposedFields: [],+ form: { elements: expect.any(Object), rootElementId: expect.any(String) },+ meta: { category: 'user', version: '3.0.0' },+ name: 'Untitled Workflow',+ nodes: [{ id: 'noise-1' }],+ notes: '',+ tags: '',+ version: '1.0.0',+ },});+ expect(readSubmission(state)).not.toHaveProperty('workflow.id');expect(readSubmission(state)).toMatchObject({ graph: { nodes: { 'noise-1': { seed: 42 } } } });expect(getActiveProject(state).queue.items[0]?.snapshot.presentation.batchCount).toBe(3);expect(readNodeSeed(state)).toBe(45);diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 9b23529d00..1de62ce718 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -147,6 +147,7 @@ import {getProjectGraphUndoEntry,normalizeProjectGraph,projectGraphReducer,+ serializeWorkflowJson,type ProjectGraphAction,} from '@features/workflow/utility';@@ -2497,6 +2498,7 @@ const compileInvocationSnapshot = (): {graph: GraphContract;widgetStates: WidgetStateMap;+ workflowJson?: Record<string, unknown>;workflow?: Omit<WorkflowSubmissionPlan, 'graph'>;} | null => {const widgetStates = getWidgetStatesSnapshot(project.widgetInstances);@@ -2514,8 +2516,9 @@ const compileInvocationSnapshot = (const { graph, ...workflow } = planWorkflowSubmission(project.projectGraph, templatesSnapshot.templates, {batchCount: sanitizeBatchCount(widgetStates.workflow?.values.batchCount),});+ const { id: _id, ...workflowJson } = serializeWorkflowJson(project.projectGraph);- return { graph, widgetStates, workflow };+ return { graph, widgetStates, workflow, workflowJson };}if (route.sourceId === 'upscale') {@@ -3151,6 +3154,8 @@ const enqueueCompiledSnapshot = (graph: GraphContract;positivePrompts?: string[];widgetStates: WidgetStateMap;+ /** The serialized parent workflow, without its library record id. */+ workflowJson?: Record<string, unknown>;/** The workflow route's seed plan: batch data, run count, and the fields to advance. */workflow?: Omit<WorkflowSubmissionPlan, 'graph'>;},@@ -3233,6 +3238,7 @@ const enqueueCompiledSnapshot = (...(compiled.workflow.seeds.length ? { seeds: compiled.workflow.seeds } : {}),graph: backendGraph,kind: 'workflow',+ ...(compiled.workflowJson ? { workflow: compiled.workflowJson } : {}),// Provenance for the completed-run capture: a run submitted from a// library-bound graph knows which record to stamp, even after the// editor has moved on to another workflow. An unbound graph stampsdiff --git a/tests/app/services/image_files/test_image_files_disk.py b/tests/app/services/image_files/test_image_files_disk.pyindex 435f382ff9..8d3eb494f2 100644--- a/tests/app/services/image_files/test_image_files_disk.py+++ b/tests/app/services/image_files/test_image_files_disk.py@@ -891,7 +891,11 @@ class TestProvenanceRoundTrip:def test_saved_provenance_survives_being_read_back(self, disk_storage: DiskImageFileStorage):metadata = '{"positive_prompt": "a cat"}'- workflow = '{"name": "Fixture workflow", "nodes": []}'+ workflow = (+ '{"name": "Fixture workflow", "author": "", "description": "", "version": "1.0.0", '+ '"contact": "", "tags": "", "notes": "", "exposedFields": [], '+ '"meta": {"category": "user", "version": "3.0.0"}, "nodes": [], "edges": [], "form": null}'+ )graph = '{"nodes": {}, "edges": []}'disk_storage.save(@@ -920,6 +924,7 @@ class TestProvenanceRoundTrip:assert reopened.info["invokeai_graph"] == graphassert extracted.invokeai_metadata == metadata+ assert extracted.invokeai_workflow == workflowassert extracted.invokeai_graph == graphdef test_an_image_saved_without_provenance_extracts_none(self, disk_storage: DiskImageFileStorage):