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(workbench): rename graph invocation source ids
joshistoast693cbb34d686
diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsxindex effa871253..b0b16a82c1 100644--- a/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchRuntime.tsx@@ -77,7 +77,7 @@ const routeRunResults = async (// A workflow session reports every image its nodes produced; only the// non-intermediate outputs are user-facing results.const images =- queueItem.snapshot.sourceId === 'project-graph' ? allImages.filter((image) => !image.isIntermediate) : allImages;+ queueItem.snapshot.sourceId === 'workflow' ? allImages.filter((image) => !image.isIntermediate) : allImages;if (queueItem.snapshot.destination === 'gallery') {const selectedBoardId = getSnapshotGalleryBoardId(queueItem);@@ -124,7 +124,7 @@ const routeBackendItemResults = async (try {const allImages = await getQueueItemResultImages(backendItemId, queueItem.id, queueItem.snapshot.submittedAt);const images =- queueItem.snapshot.sourceId === 'project-graph' ? allImages.filter((image) => !image.isIntermediate) : allImages;+ queueItem.snapshot.sourceId === 'workflow' ? allImages.filter((image) => !image.isIntermediate) : allImages;const selectedBoardId = getSnapshotGalleryBoardId(queueItem);if (selectedBoardId && selectedBoardId !== 'none') {@@ -296,7 +296,7 @@ export const WorkbenchRuntime = () => {coordinatorRef.current = coordinator;coordinator.connect();- // Node definitions back project-graph route validation, which can be the+ // Node definitions back workflow route validation, which can be the// persisted invocation source before any workflow surface has mounted.ensureInvocationTemplatesLoaded();@@ -417,7 +417,7 @@ export const WorkbenchRuntime = () => {for (const queueItem of project.queue.items) {if (queueItem.status === 'pending' &&- (queueItem.snapshot.sourceId === 'generate' || queueItem.snapshot.sourceId === 'project-graph') &&+ (queueItem.snapshot.sourceId === 'generate' || queueItem.snapshot.sourceId === 'workflow') &&!startedQueueItemIdsRef.current.has(queueItem.id)) {startedQueueItemIdsRef.current.add(queueItem.id);diff --git a/invokeai/frontend/webv2/src/workbench/generation/api.ts b/invokeai/frontend/webv2/src/workbench/generation/api.tsindex b1b3d9bdc2..26922077c0 100644--- a/invokeai/frontend/webv2/src/workbench/generation/api.ts+++ b/invokeai/frontend/webv2/src/workbench/generation/api.ts@@ -52,7 +52,7 @@ export const enqueueGenerateGraph = async (request: EnqueueGenerateRequest): Proreturn { batchId: result.batch?.batch_id, itemIds: result.item_ids ?? [] };};-/** Enqueue an arbitrary compiled graph — the workflow / project-graph path. */+/** Enqueue an arbitrary compiled graph — the workflow path. */export const enqueueWorkflowGraph = async (request: EnqueueWorkflowRequest): Promise<EnqueueGenerateResult> => {const batchCount = sanitizeBatchCount(request.batchCount);const body = {diff --git a/invokeai/frontend/webv2/src/workbench/generation/types.ts b/invokeai/frontend/webv2/src/workbench/generation/types.tsindex be99df69f7..fa6746b7fa 100644--- a/invokeai/frontend/webv2/src/workbench/generation/types.ts+++ b/invokeai/frontend/webv2/src/workbench/generation/types.ts@@ -155,7 +155,7 @@ export interface QueueItemDTO {};}-/** A source-agnostic graph submission (used by the project-graph / workflow source). */+/** A source-agnostic graph submission (used by the workflow source). */export interface EnqueueWorkflowRequest {batchCount: number;destination: ResultDestination;diff --git a/invokeai/frontend/webv2/src/workbench/invocation.ts b/invokeai/frontend/webv2/src/workbench/invocation.tsindex 34476c7ed1..49bc5d6ba9 100644--- a/invokeai/frontend/webv2/src/workbench/invocation.ts+++ b/invokeai/frontend/webv2/src/workbench/invocation.ts@@ -43,9 +43,9 @@ export interface ResultDestinationMeta {export const invocationSources: InvocationSourceMeta[] = [{ id: 'generate', label: 'Generate', available: true },- { id: 'project-graph', label: 'Workflow', available: true },+ { id: 'workflow', label: 'Workflow', available: true },{ id: 'upscale', label: 'Upscale', available: false },- { id: 'canvas-fill', label: 'Canvas Fill', available: false },+ { id: 'canvas', label: 'Canvas', available: false },];export const resultDestinations: ResultDestinationMeta[] = [@@ -76,9 +76,9 @@ export const defaultInvocationRoute: InvocationRoute = {const validDestinationIds = new Set(resultDestinations.map((destination) => destination.id));const sourceWidgetIds: Partial<Record<InvocationSourceId, WidgetId>> = {- 'canvas-fill': 'canvas',+ canvas: 'canvas',generate: 'generate',- 'project-graph': 'workflow',+ workflow: 'workflow',};export interface InvocationRouteInput {@@ -165,9 +165,7 @@ export const resolveInvocationRouteInput = (// read imperatively, and surfaces that render the route subscribe to the// templates store so the result stays live.const projectGraphReadiness =- sourceId === 'project-graph'- ? getProjectGraphReadiness(input.projectGraph, getInvocationTemplatesSnapshot())- : null;+ sourceId === 'workflow' ? getProjectGraphReadiness(input.projectGraph, getInvocationTemplatesSnapshot()) : null;const validationReasons: string[] = [];if (!isInvocationSourceAvailable(sourceId)) {diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectSync.test.ts b/invokeai/frontend/webv2/src/workbench/projects/projectSync.test.tsindex 78e1905327..56b777f0de 100644--- a/invokeai/frontend/webv2/src/workbench/projects/projectSync.test.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/projectSync.test.ts@@ -47,6 +47,52 @@ describe('project document serialization', () => {expect(deserializeProjectDocument({ id: 'x' })).toBeNull();expect(deserializeProjectDocument({ id: 'x', layout: null, name: 'y' })).toBeNull();});++ it('normalizes legacy project-graph invocation sources to workflow', () => {+ const base = getProject();+ const project = getProject({+ invocation: { destination: 'gallery', destinationLocked: false, sourceId: 'workflow', sourceLocked: false },+ queue: {+ items: [+ {+ cancellable: true,+ id: 'legacy-queue-item',+ snapshot: {+ canvas: base.canvas,+ destination: 'gallery',+ graph: { edges: [], id: 'graph', label: 'Graph', nodes: [], updatedAt: 'now', version: 1 },+ sourceId: 'workflow',+ submittedAt: 'now',+ widgetInstances: {},+ widgetStates: {},+ },+ status: 'pending',+ },+ ],+ },+ });+ const document = serializeProjectDocument(project);++ document.invocation = {+ destination: 'gallery',+ destinationLocked: false,+ sourceId: 'project-graph',+ sourceLocked: false,+ };+ document.queue = {+ items: [+ {+ ...(project.queue.items[0] as object),+ snapshot: { ...project.queue.items[0]?.snapshot, sourceId: 'project-graph' },+ },+ ],+ };++ const deserialized = deserializeProjectDocument(document);++ expect(deserialized?.invocation.sourceId).toBe('workflow');+ expect(deserialized?.queue.items[0]?.snapshot.sourceId).toBe('workflow');+ });});describe('createRecoveredDocument', () => {diff --git a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.tsindex a6047b568c..8169ba46f9 100644--- a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts@@ -93,17 +93,68 @@ export const serializeProjectDocument = (project: Project): Record<string, unknoreturn document;};+const normalizeInvocationSourceId = (sourceId: unknown): unknown => {+ if (sourceId === 'project-graph') {+ return 'workflow';+ }++ if (sourceId === 'canvas-fill') {+ return 'canvas';+ }++ return sourceId;+};++const normalizeLegacyProjectDocument = (data: Record<string, unknown>): Record<string, unknown> => {+ const invocation = data.invocation;+ const queue = data.queue;++ return {+ ...data,+ invocation:+ invocation && typeof invocation === 'object'+ ? { ...invocation, sourceId: normalizeInvocationSourceId((invocation as { sourceId?: unknown }).sourceId) }+ : invocation,+ queue:+ queue && typeof queue === 'object' && Array.isArray((queue as { items?: unknown }).items)+ ? {+ ...queue,+ items: (queue as { items: unknown[] }).items.map((item) => {+ if (!item || typeof item !== 'object') {+ return item;+ }++ const snapshot = (item as { snapshot?: unknown }).snapshot;++ return {+ ...item,+ snapshot:+ snapshot && typeof snapshot === 'object'+ ? {+ ...snapshot,+ sourceId: normalizeInvocationSourceId((snapshot as { sourceId?: unknown }).sourceId),+ }+ : snapshot,+ };+ }),+ }+ : queue,+ };+};+export const deserializeProjectDocument = (data: Record<string, unknown>): Project | null => {+ const normalizedData = normalizeLegacyProjectDocument(data);+if (- typeof data.id !== 'string' ||- typeof data.name !== 'string' ||- typeof data.layout !== 'object' ||- data.layout === null+ typeof normalizedData.id !== 'string' ||+ typeof normalizedData.name !== 'string' ||+ typeof normalizedData.layout !== 'object' ||+ normalizedData.layout === null) {return null;}- return { ...data, undoRedo: { future: [], past: [] } } as unknown as Project;+ return { ...normalizedData, undoRedo: { future: [], past: [] } } as unknown as Project;};const getSyncMapStorageKey = (): string => `${SYNC_MAP_BASE_KEY}${getUserStorageScope()}`;diff --git a/invokeai/frontend/webv2/src/workbench/types.ts b/invokeai/frontend/webv2/src/workbench/types.tsindex 3c0d613f42..a14e241918 100644--- a/invokeai/frontend/webv2/src/workbench/types.ts+++ b/invokeai/frontend/webv2/src/workbench/types.ts@@ -268,7 +268,11 @@ export interface WidgetToolbarApi {export interface WidgetToolbarContribution {id: string;location: 'center.tabs.trailing' | 'status.left' | 'status.right';- items: Array<{ commandId: string; icon?: WidgetIconComponent; label?: string }>;+ items: Array<{+ commandId: string;+ icon?: WidgetIconComponent;+ label?: string;+ }>;}export interface OpenWorkbenchWidgetOptions {@@ -412,16 +416,7 @@ export interface CanvasStateContract {};}-/**- * Invocation sources and destinations.- *- * Phase 1 only needs enough of the Invocation Controller to render a stable,- * fixed-width `Source → Destination` route on the global Invoke control. The- * full resolver (auto vs. locked, validation, dialog focus) arrives in Phase 4,- * but the project-owned shape is modelled now so the control is not a dead- * placeholder.- */-export type InvocationSourceId = 'generate' | 'project-graph' | 'upscale' | 'canvas-fill';+export type InvocationSourceId = 'generate' | 'workflow' | 'upscale' | 'canvas';export type InvocationMode = 'global' | 'dialog';diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsxindex a7622cf76b..a15718c63d 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsx@@ -28,7 +28,7 @@ import { useCallback, useMemo, useState } from 'react';const getPreviewGraph = (project: Project, surface: GraphBearingSurfaceContract): GraphContract | null => {// The project graph compiles fresh for preview so `View Graph` always shows// what Invoke would run right now; widget graphs keep their last compile.- if (surface.sourceId === 'project-graph') {+ if (surface.sourceId === 'workflow') {const templatesSnapshot = getInvocationTemplatesSnapshot();if (templatesSnapshot.status !== 'loaded') {@@ -111,7 +111,7 @@ export const WidgetActionsMenu = ({const handlePreview = useCallback(() => setIsPreviewOpen(true), []);const positionHints = useMemo(() =>- isPreviewOpen && surface?.sourceId === 'project-graph'+ isPreviewOpen && surface?.sourceId === 'workflow'? Object.fromEntries(activeProject.projectGraph.nodes.map((node) => [node.id, node.position])): undefined,[activeProject.projectGraph.nodes, isPreviewOpen, surface?.sourceId]diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/index.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/index.tsindex 2303b39442..3d23982c28 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/index.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/index.ts@@ -8,7 +8,7 @@ export const canvasWidgetManifest: WidgetManifest = {allowMultiple: false,allowedRegions: ['center'],failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },- graphBearing: { defaultGraphId: 'canvas-graph', sourceId: 'canvas-fill', surfaces: ['center'] },+ graphBearing: { defaultGraphId: 'canvas-graph', sourceId: 'canvas', surfaces: ['center'] },icon: WandSparklesIcon,id: 'canvas',label: 'Canvas',diff --git a/invokeai/frontend/webv2/src/workbench/widgets/queue/queueViewModel.ts b/invokeai/frontend/webv2/src/workbench/widgets/queue/queueViewModel.tsindex da6805152b..73589fec60 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/queue/queueViewModel.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue/queueViewModel.ts@@ -42,7 +42,7 @@ export const getPendingQueueCount = (items: readonly QueueItem[]): number =>export const hasPendingWorkflowQueueItem = (items: readonly QueueItem[]): boolean =>items.some(- (item) => item.snapshot.sourceId === 'project-graph' && (item.status === 'running' || item.status === 'pending')+ (item) => item.snapshot.sourceId === 'workflow' && (item.status === 'running' || item.status === 'pending'));const isCancellableQueueItem = (item: QueueItem): boolean =>diff --git a/invokeai/frontend/webv2/src/workbench/widgets/workflow/WorkflowWidgetChrome.tsx b/invokeai/frontend/webv2/src/workbench/widgets/workflow/WorkflowWidgetChrome.tsxindex dcdb76586a..55ef7c0dce 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/workflow/WorkflowWidgetChrome.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/workflow/WorkflowWidgetChrome.tsx@@ -412,7 +412,7 @@ export const WorkflowDialogHost = () => {onClose={() => setNewWorkflowConfirmOpen(false)}onConfirm={() => {dispatch({- document: createProjectGraph(createWorkflowId('project-graph')),+ document: createProjectGraph(createWorkflowId('workflow')),label: 'New workflow',type: 'replaceProjectGraph',});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/workflow/index.ts b/invokeai/frontend/webv2/src/workbench/widgets/workflow/index.tsindex 327bbe10e1..64843dc9c2 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/workflow/index.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/workflow/index.ts@@ -17,7 +17,7 @@ export const workflowWidgetManifest: WidgetManifest = {failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },graphBearing: {defaultGraphId: 'workflow-graph',- sourceId: 'project-graph',+ sourceId: 'workflow',surfaces: ['center', 'left', 'bottom'],},host: WorkflowDialogHost,diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 0a1f357c40..f582db3708 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -836,13 +836,13 @@ describe('workbenchReducer Phase 5 generation flow', () => {it('accepts the project graph source but does not queue an empty project graph', () => {let state = createInitialWorkbenchState();- state = workbenchReducer(state, { sourceId: 'project-graph', type: 'setInvocationSource' });+ state = workbenchReducer(state, { sourceId: 'workflow', type: 'setInvocationSource' });- expect(getActiveProject(state).invocation.sourceId).toBe('project-graph');+ expect(getActiveProject(state).invocation.sourceId).toBe('workflow');state = workbenchReducer(state, {backendSupportsCancellation: true,- route: { destination: 'canvas', destinationLocked: false, sourceId: 'project-graph', sourceLocked: true },+ route: { destination: 'canvas', destinationLocked: false, sourceId: 'workflow', sourceLocked: true },type: 'submitResolvedInvocationSnapshot',});@@ -883,7 +883,7 @@ describe('workbenchReducer Phase 5 generation flow', () => {// and steers the unlocked invocation source to the project graph.expect(project.projectGraph.nodes).toHaveLength(1);expect(project.undoRedo.past.at(-1)?.label).toBe('Add workflow node');- expect(project.invocation.sourceId).toBe('project-graph');+ expect(project.invocation.sourceId).toBe('workflow');state = workbenchReducer(state, { type: 'undoProjectChange' });diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 9423451106..ad2926d869 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -1090,7 +1090,7 @@ const compileInvocationSnapshot = (): { graph: GraphContract; widgetStates: WidgetStateMap } | null => {const widgetStates = getWidgetStatesSnapshot(project.widgetInstances);- if (route.sourceId === 'project-graph') {+ if (route.sourceId === 'workflow') {// Compiles the workflow document into an immutable snapshot. Templates are// read imperatively; route validation already guaranteed they are loaded.const templatesSnapshot = getInvocationTemplatesSnapshot();@@ -1796,14 +1796,14 @@ export const workbenchReducer = (state: WorkbenchState, action: WorkbenchAction)// steer the global Invoke route to the project graph unless locked.const shouldAutoSetSource =!project.invocation.sourceLocked &&- project.invocation.sourceId !== 'project-graph' &&+ project.invocation.sourceId !== 'workflow' &&isHighConfidenceGraphEdit(action.action) &&- isInvocationSourceAvailable('project-graph');+ isInvocationSourceAvailable('workflow');return {...nextProject,invocation: shouldAutoSetSource- ? { ...nextProject.invocation, sourceId: 'project-graph' }+ ? { ...nextProject.invocation, sourceId: 'workflow' }: nextProject.invocation,projectGraph,};diff --git a/invokeai/frontend/webv2/src/workbench/workflows/document.ts b/invokeai/frontend/webv2/src/workbench/workflows/document.tsindex 63e3a378f3..ff2b3b2112 100644--- a/invokeai/frontend/webv2/src/workbench/workflows/document.ts+++ b/invokeai/frontend/webv2/src/workbench/workflows/document.ts@@ -67,7 +67,7 @@ export const normalizeProjectGraph = (candidate: unknown): ProjectGraphState =>const legacyId =typeof (candidate as { id?: unknown } | null)?.id === 'string' ? (candidate as { id: string }).id : null;- return createProjectGraph(legacyId ?? createWorkflowId('project-graph'));+ return createProjectGraph(legacyId ?? createWorkflowId('workflow'));};export const buildInvocationNode = (template: InvocationTemplate, position: XYPosition): WorkflowInvocationNode => {diff --git a/invokeai/frontend/webv2/src/workbench/workflows/workflowJson.ts b/invokeai/frontend/webv2/src/workbench/workflows/workflowJson.tsindex 22dd901c61..c64ea1afe2 100644--- a/invokeai/frontend/webv2/src/workbench/workflows/workflowJson.ts+++ b/invokeai/frontend/webv2/src/workbench/workflows/workflowJson.ts@@ -334,7 +334,7 @@ export const parseWorkflowJson = (raw: unknown): ParsedWorkflow => {description: parsed.data.description,edges,form: parseForm(parsed.data.form, parsed.data.exposedFields, nodeIds, warnings),- id: createWorkflowId('project-graph'),+ id: createWorkflowId('workflow'),libraryWorkflowId: parsed.data.id,name: parsed.data.name,nodes,