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
refactor(webv2): add origin discriminator to settings/widget-value actions
joshistoast0d741c41543f
diff --git a/invokeai/frontend/webv2/src/app/UpscaleUiAdapter.tsx b/invokeai/frontend/webv2/src/app/UpscaleUiAdapter.tsxindex 1bf091334b..790180a7d1 100644--- a/invokeai/frontend/webv2/src/app/UpscaleUiAdapter.tsx+++ b/invokeai/frontend/webv2/src/app/UpscaleUiAdapter.tsx@@ -34,7 +34,7 @@ export const UpscaleUiAdapterProvider = ({ children }: { children: ReactNode })() => ({...project,patchPromptDraft: (values) => commands.generation.patchPromptDraft(values, project.projectId),- patchValues: (values) => commands.widgets.patchValues('upscale', values, project.projectId),+ patchValues: (values, origin) => commands.widgets.patchValues('upscale', values, project.projectId, origin),reportError: (message) =>commands.notifications.reportError({ area: 'upscale', message, namespace: 'generation' }),touchGalleryImages: () => commands.gallery.touchImages(),diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateWidgetView.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateWidgetView.tsxindex f4284a4be3..452a3d3378 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateWidgetView.tsx@@ -77,7 +77,7 @@ export const GenerateWidgetView = () => {return;}- ui.settings.patchGenerateSettings(getGenerateFormCommitPatch({ ...nextSettings, model }), projectId);+ ui.settings.patchGenerateSettings(getGenerateFormCommitPatch({ ...nextSettings, model }), projectId, 'system');}, [models, projectId, selectedModel, settings, storedValues, supportedModels, ui]);const commitSettings = useCallback(diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsxindex a4e2d272be..4eccf44725 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx@@ -68,7 +68,7 @@ export interface GenerationUiAdapter {setSectionOpen(sectionId: string, open: boolean): void;};settings: {- patchGenerateSettings(values: Partial<GenerateSettings>, projectId?: string): void;+ patchGenerateSettings(values: Partial<GenerateSettings>, projectId?: string, origin?: 'user' | 'system'): void;};}diff --git a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleUiContext.tsx b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleUiContext.tsxindex 632c77ae87..e197bc0fcf 100644--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleUiContext.tsx@@ -10,7 +10,7 @@ import { createContext, use } from 'react';*/export interface UpscaleUiAdapter {patchPromptDraft(values: ProjectPromptDraftPatch): void;- patchValues(values: Partial<UpscaleWidgetValues>): void;+ patchValues(values: Partial<UpscaleWidgetValues>, origin?: 'user' | 'system'): void;projectId: string;promptDraft: ProjectPromptDraft;rawValues: Record<string, unknown>;diff --git a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsxindex 86111f8e1e..5be39bfe97 100644--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx@@ -192,7 +192,7 @@ const UpscaleModelReconciler = ({return;}- patchValues({ ...values });+ patchValues({ ...values }, 'system');});return null;diff --git a/invokeai/frontend/webv2/src/workbench/canvasDimsSync.ts b/invokeai/frontend/webv2/src/workbench/canvasDimsSync.tsindex 3f30b098dc..f6bc3ad167 100644--- a/invokeai/frontend/webv2/src/workbench/canvasDimsSync.ts+++ b/invokeai/frontend/webv2/src/workbench/canvasDimsSync.ts@@ -225,7 +225,8 @@ export const createCanvasDimsSync = (store: CanvasDimsSyncStore): CanvasDimsSyncheight: result.height,width: result.width,},- project.id+ project.id,+ 'system');} finally {isSyncing = false;diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 642aa83bbe..8ba7c90eea 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -110,6 +110,9 @@ import { normalizeProjectSettings } from './settings/store';type QueueGenerateSnapshot = NonNullable<QueueItem['snapshot']['generate']>;+/** Programmatic dispatches (`'system'`) never auto-switch the Invoke route; absent means `'user'`. */+export type WorkbenchActionOrigin = 'user' | 'system';+type WorkbenchReducerAction =| { type: 'createProject' }| { type: 'openProject'; project: Project }@@ -152,14 +155,25 @@ type WorkbenchReducerAction =}| { type: 'setRegionWidgetCollapsed'; region: WidgetRegion; isCollapsed: boolean }| { type: 'setRegionWidgetSize'; region: WidgetRegion; sizePx: number }- | { type: 'setGenerateSettings'; values: GenerateWidgetValues; projectId?: string }- | { type: 'patchGenerateSettings'; values: Partial<GenerateWidgetValues>; projectId?: string }+ | { type: 'setGenerateSettings'; values: GenerateWidgetValues; projectId?: string; origin?: WorkbenchActionOrigin }+ | {+ type: 'patchGenerateSettings';+ values: Partial<GenerateWidgetValues>;+ projectId?: string;+ origin?: WorkbenchActionOrigin;+ }| { type: 'patchProjectPromptDraft'; values: ProjectPromptDraftPatch; projectId?: string }| { type: 'setGenerateBatchCount'; batchCount: number; projectId?: string }| { type: 'addPromptToHistory'; prompt: PromptHistoryItem; projectId?: string }| { type: 'removePromptFromHistory'; prompt: PromptHistoryItem; projectId?: string }| { type: 'clearPromptHistory'; projectId?: string }- | { type: 'patchWidgetValues'; widgetId: WidgetTypeId; values: Record<string, unknown>; projectId?: string }+ | {+ type: 'patchWidgetValues';+ widgetId: WidgetTypeId;+ values: Record<string, unknown>;+ projectId?: string;+ origin?: WorkbenchActionOrigin;+ }| {type: 'patchWidgetInstanceValues';instanceId: WidgetInstanceId;diff --git a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts b/invokeai/frontend/webv2/src/workbench/workbenchStore.tsindex db0d4e6b56..8b1ad70552 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchStore.ts@@ -137,7 +137,11 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchSt),patchSettings: command('patchGenerateSettings',- (values: ActionPayload<'patchGenerateSettings'>['values'], projectId?: string) => ({ projectId, values })+ (+ values: ActionPayload<'patchGenerateSettings'>['values'],+ projectId?: string,+ origin?: ActionPayload<'patchGenerateSettings'>['origin']+ ) => ({ origin, projectId, values })),removePromptFromHistory: command('removePromptFromHistory',@@ -153,7 +157,11 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchSt),setSettings: command('setGenerateSettings',- (values: ActionPayload<'setGenerateSettings'>['values'], projectId?: string) => ({ projectId, values })+ (+ values: ActionPayload<'setGenerateSettings'>['values'],+ projectId?: string,+ origin?: ActionPayload<'setGenerateSettings'>['origin']+ ) => ({ origin, projectId, values })),setSource: command('setInvocationSource', (sourceId: ActionPayload<'setInvocationSource'>['sourceId']) => ({sourceId,@@ -280,8 +288,10 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchSt(widgetId: ActionPayload<'patchWidgetValues'>['widgetId'],values: Record<string, unknown>,- projectId?: string+ projectId?: string,+ origin?: ActionPayload<'patchWidgetValues'>['origin']) => ({+ origin,projectId,values,widgetId,