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): backfill queue-status widget for existing projects
joshistoastb5702e7cfc01
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 6cc924987c..6960e9fc98 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -430,6 +430,51 @@ describe('workbench widget region defaults', () => {expect(getActiveProject(customized).widgetRegions.left.instanceIds).toEqual(['generate', 'gallery']);});+ it('adds queue-status to untouched legacy bottom rails while preserving customized rails', () => {+ const initial = createInitialWorkbenchState();+ const withoutQueueStatusInstance = Object.fromEntries(+ Object.entries(getActiveProject(initial).widgetInstances).filter(([id]) => id !== 'queue-status')+ ) as Project['widgetInstances'];+ const withBottomIds = (instanceIds: Project['widgetRegions']['bottom']['instanceIds']): WorkbenchState => ({+ ...initial,+ projects: initial.projects.map((project) => ({+ ...project,+ widgetInstances: withoutQueueStatusInstance,+ widgetRegions: { ...project.widgetRegions, bottom: { ...project.widgetRegions.bottom, instanceIds } },+ })),+ });++ const migrated = workbenchReducer(initial, {+ state: withBottomIds(['server-status', 'gallery:bottom', 'notifications', 'autosave-status']),+ type: 'hydrateWorkbench',+ });+ const customized = workbenchReducer(initial, {+ state: withBottomIds(['server-status', 'notifications']),+ type: 'hydrateWorkbench',+ });+ const alreadyPresent = workbenchReducer(initial, {+ state: withBottomIds(['queue-status', 'server-status', 'gallery:bottom', 'notifications', 'autosave-status']),+ type: 'hydrateWorkbench',+ });++ expect(getActiveProject(migrated).widgetRegions.bottom.instanceIds).toEqual([+ 'server-status',+ 'queue-status',+ 'gallery:bottom',+ 'notifications',+ 'autosave-status',+ ]);+ expect(getActiveProject(migrated).widgetInstances['queue-status']?.typeId).toBe('queue-status');+ expect(getActiveProject(customized).widgetRegions.bottom.instanceIds).toEqual(['server-status', 'notifications']);+ expect(getActiveProject(alreadyPresent).widgetRegions.bottom.instanceIds).toEqual([+ 'queue-status',+ 'server-status',+ 'gallery:bottom',+ 'notifications',+ 'autosave-status',+ ]);+ });+it('migrates a legacy Upscale prompt only when Generate has no prompt content', () => {const initial = createInitialWorkbenchState();const withPrompts = (generatePrompt: string): WorkbenchState => ({diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 884b8efb23..0b6d24bbc1 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -1284,6 +1284,43 @@ const ensureRightRegion = (rightRegion: WidgetRegionState | undefined): WidgetRereturn rightRegion;};+// The shipped bottom-region default before 'queue-status' was added — a+// persisted project whose bottom rail matches this exactly is still running+// the pre-branch defaults, so it should pick up the new widget the same way+// a fresh project would.+const LEGACY_DEFAULT_BOTTOM_REGION_WIDGET_IDS: readonly WidgetInstanceId[] = [+ 'server-status',+ 'gallery:bottom',+ 'notifications',+ 'autosave-status',+];++const isLegacyDefaultBottomRegion = (region: WidgetRegionState): boolean =>+ region.instanceIds.length === LEGACY_DEFAULT_BOTTOM_REGION_WIDGET_IDS.length &&+ region.instanceIds.every((widgetId, index) => widgetId === LEGACY_DEFAULT_BOTTOM_REGION_WIDGET_IDS[index]);++const ensureBottomRegion = (bottomRegion: WidgetRegionState | undefined): WidgetRegionState => {+ const fallback = createWidgetRegions().bottom;++ if (!bottomRegion) {+ return fallback;+ }+ if (bottomRegion.instanceIds.includes('queue-status')) {+ return bottomRegion;+ }++ if (!isLegacyDefaultBottomRegion(bottomRegion)) {+ return bottomRegion;+ }++ const serverStatusIndex = bottomRegion.instanceIds.indexOf('server-status');+ const instanceIds = [...bottomRegion.instanceIds];++ instanceIds.splice(serverStatusIndex === -1 ? instanceIds.length : serverStatusIndex + 1, 0, 'queue-status');++ return { ...bottomRegion, instanceIds };+};+const getCenterWidgetIdFromViewId = (centerViewId: CenterViewId): WidgetInstanceId => {if (centerViewId === 'gallery') {return 'gallery:center';@@ -1338,11 +1375,11 @@ const normalizePromptHistory = (value: unknown): PromptHistoryItem[] => {};export const normalizeWorkbenchProject = (project: Project): Project => {- const defaultWidgetRegions = createWidgetRegions();const legacyWidgetRegions = project.widgetRegions as| Partial<Record<WidgetRegion | 'left-panel' | 'right-panel' | 'status-bar', WidgetRegionState>>| undefined;const leftRegion = ensureLeftRegion(legacyWidgetRegions?.left ?? legacyWidgetRegions?.['left-panel']);+ const bottomRegion = ensureBottomRegion(legacyWidgetRegions?.bottom ?? legacyWidgetRegions?.['status-bar']);const widgetInstances = cloneWidgetInstances(project.widgetInstances ?? createWidgetInstances());const generateInstance = widgetInstances.generate;@@ -1375,6 +1412,10 @@ export const normalizeWorkbenchProject = (project: Project): Project => {widgetInstances.upscale = createWidgetInstance('upscale');}+ if (bottomRegion.instanceIds.includes('queue-status') && !widgetInstances['queue-status']) {+ widgetInstances['queue-status'] = createWidgetInstance('queue-status');+ }+for (const [instanceId, instance] of Object.entries(widgetInstances)) {if (instance.typeId !== 'gallery' || !('recentImages' in instance.state.values)) {continue;@@ -1411,7 +1452,7 @@ export const normalizeWorkbenchProject = (project: Project): Project => {widgetRegions: {left: leftRegion,right: ensureRightRegion(legacyWidgetRegions?.right ?? legacyWidgetRegions?.['right-panel']),- bottom: legacyWidgetRegions?.bottom ?? legacyWidgetRegions?.['status-bar'] ?? defaultWidgetRegions.bottom,+ bottom: bottomRegion,center: ensureCenterRegion(legacyWidgetRegions?.center, project.layout.centerViewId),},widgetInstances,