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): stop image recall persisting a fallback-grid size
Alexander Eichhorn65f257478855
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.tsindex 3219883d55..0b75c8d5fd 100644--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts@@ -1641,7 +1641,12 @@ export const getGenerationValidationReasons = (model: GenerateModelConfig, setti// previewGraph.ts), so gating here is what makes the canvas and the topbar fail closed too,// rather than only the Generate widget's own resolver.if (!hasArchitectureCapabilities()) {- return ['Model capabilities have not loaded yet. Generation is blocked until they arrive.'];+ // Deliberately not state-aware: `core` cannot reach the store that knows loading from+ // failed. Saying "not yet" would be a promise this cannot keep -- after a failed fetch+ // nothing re-kicks it except the Generate panel's retry, so name that instead.+ return [+ 'Model capabilities are not available. Generation is blocked until they load; if this persists, retry from the Generate panel.',+ ];}if (!isSupportedGenerateModel(model)) {diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.tsindex fc1f110948..e7d8fedd4c 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts@@ -6,8 +6,15 @@ import type {VaeModelConfig,} from '@features/generation/contracts';-import { seedArchitectureCapabilities } from '@features/generation/core/architectureCapabilities.testing';-import { describe, expect, it } from 'vitest';+import {+ resetArchitectureCapabilities,+ setArchitectureCapabilities,+} from '@features/generation/core/architectureCapabilities';+import {+ architectureCapabilitiesFixture,+ seedArchitectureCapabilities,+} from '@features/generation/core/architectureCapabilities.testing';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { buildImageRecallSettings, getImageRecallCapabilities } from './imageRecall';@@ -510,6 +517,49 @@ describe('image recall', () => {expect(result?.values.aspectRatioId).toBe('2:3');});+ describe('before the capability table arrives', () => {+ // Recalled dimensions are snapped to the architecture's grid and then persisted into the+ // project. With no table every base reads as grid 8, so a 16- or 32-grid project would+ // store a size its own denoise node rejects -- and nothing re-derives it afterwards.+ beforeEach(() => {+ resetArchitectureCapabilities();+ });++ afterEach(() => {+ setArchitectureCapabilities(architectureCapabilitiesFixture);+ });++ it('recalls no size from the image rather than one snapped to the fallback grid', () => {+ const result = buildImageRecallSettings({+ currentValues: createValues(),+ image,+ kind: 'dimensions',+ metadata: null,+ models: [],+ supportedModels: [],+ vaeModels: [],+ });++ // Without the fix this is ['size'] with the width snapped to the fallback grid 8.+ expect(result?.fields ?? []).not.toContain('size');+ });++ it('recalls no size from metadata either', () => {+ const result = buildImageRecallSettings({+ currentValues: createValues(),+ image,+ kind: 'all',+ metadata: { height: 768, width: 512 },+ models: [],+ supportedModels: [],+ vaeModels: [],+ });++ // Without the fix this is ['size'] with the width snapped to the fallback grid 8.+ expect(result?.fields ?? []).not.toContain('size');+ });+ });+it('only enables standalone CLIP skip when the current model supports it', () => {const sdxlCapabilities = getImageRecallCapabilities({currentValues: createValues({ model: sdxlModel, modelKey: sdxlModel.key }),diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.tsindex 4e2c9e0ee9..b9fe2675bf 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts@@ -9,7 +9,7 @@ import type {import {getCompatibleReferenceImages,- getGenerationDimensions,+ getDimensionGrid,getGenerationUiPolicy,getSettingsWithModelDefaults,isKnownScheduler,@@ -223,7 +223,16 @@ const getImageSize = (image: GalleryImage,model: GenerateModelConfig): Pick<GenerateWidgetValues, 'height' | 'width'> | null => {- const grid = getGenerationDimensions(model).grid;+ // Fail closed: recalled dimensions are snapped to the architecture's grid and then persisted+ // into the project. Without the served table every base reads as grid 8, so a krea-2 or+ // CogView 4 project would store a size its denoise node rejects. Recalling nothing is+ // recoverable; storing the wrong size silently is not.+ const grid = getDimensionGrid(model.base, model.variant);++ if (grid === null) {+ return null;+ }+const width = getImageDimension(image, 'width', grid);const height = getImageDimension(image, 'height', grid);@@ -234,7 +243,14 @@ const getMetadataSize = (metadata: unknown,model: GenerateModelConfig): Partial<Pick<GenerateWidgetValues, 'height' | 'width'>> => {- const grid = getGenerationDimensions(model).grid;+ // Same reason as getImageSize: an empty result means 'no size recalled', which the caller+ // already handles, and the field list then does not claim a size was restored.+ const grid = getDimensionGrid(model.base, model.variant);++ if (grid === null) {+ return {};+ }+const width = getDimension(metadata, 'width', grid);const height = getDimension(metadata, 'height', grid);diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.browser.test.tsxindex 111212fc82..0d13f9c8df 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.browser.test.tsx@@ -81,7 +81,9 @@ describe('useInvocationState and the architecture capability table', () => {root?.render(<Probe />);});- expect(blockingReasons()).toBe('Model capabilities have not loaded yet. Generation is blocked until they arrive.');+ expect(blockingReasons()).toBe(+ 'Model capabilities are not available. Generation is blocked until they load; if this persists, retry from the Generate panel.'+ );// The retry button in the Generate widget, succeeding. Nothing else about the project changes,// so the route resolution has to be driven by the table's arrival alone.