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): harden the model-positions migration paths
Lincoln Stein610cb9f0f42a
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.tsindex ec75615ba7..2fe220b4cd 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts@@ -1212,3 +1212,38 @@ describe('ref2va accelerator auto-pick', () => {expect(result.settings.steps).toBe(4);});});++describe('H3 component-source seeding', () => {+ it('defaults seed a component source for a checkpoint main, preferring a full install', () => {+ const checkpoint = h3Model('checkpoint');+ const componentsOnly = { ...h3Model('diffusers', 'h3-components'), components_only: true };+ const full = h3Model();++ expect(getDefaultVideoSettings(checkpoint, [componentsOnly, full]).componentSourceModel?.key).toBe(full.key);+ expect(getDefaultVideoSettings(checkpoint, [componentsOnly]).componentSourceModel?.key).toBe(componentsOnly.key);+ expect(getDefaultVideoSettings(checkpoint, []).componentSourceModel).toBeNull();+ // Diffusers mains never get one seeded.+ expect(getDefaultVideoSettings(full, [full]).componentSourceModel).toBeNull();+ });++ it('model selection fills an empty component-source slot but keeps an explicit pick', () => {+ const checkpoint = h3Model('checkpoint');+ const componentsOnly = { ...h3Model('diffusers', 'h3-components'), components_only: true };+ const full = h3Model();+ const fromEmpty = getVideoModelSelectionResult({+ currentSettings: settingsFor(h3Model(), { modelKey: h3Model().key }),+ model: checkpoint,+ models: [full, componentsOnly],+ });++ expect(fromEmpty.settings.componentSourceModel?.key).toBe(full.key);++ const explicit = getVideoModelSelectionResult({+ currentSettings: settingsFor(checkpoint, { componentSourceModel: componentsOnly, modelKey: checkpoint.key }),+ model: checkpoint,+ models: [full, componentsOnly],+ });++ expect(explicit.settings.componentSourceModel?.key).toBe(componentsOnly.key);+ });+});diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.tsindex 8ca0a4a01d..8bda24cadf 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts@@ -1240,6 +1240,22 @@ export const getWanExpertWiringWarning = (// ---------------------------------------------------------------------------// Defaults & model-selection transitions+/**+ * The H3 Diffusers install a single-file transformer main should draw its+ * components from. A full install is preferred (it also covers the text+ * encoder); a components-only folder qualifies otherwise. Used to seed+ * defaults/reset and to fill an empty slot on model selection — a checkpoint+ * main is un-invokable without one.+ */+const findH3ComponentSource = (models: readonly ModelConfig[]): MainModelConfig | null => {+ const candidates = models.filter(+ (candidate): candidate is ModelConfig & MainModelConfig =>+ candidate.type === 'main' && candidate.base === 'minimax-h3' && candidate.format === 'diffusers'+ );++ return candidates.find((candidate) => !isComponentsOnlyH3Main(candidate)) ?? candidates[0] ?? null;+};+export const getDefaultVideoSettings = (model?: MainModelConfig,models: readonly ModelConfig[] = []@@ -1253,7 +1269,11 @@ export const getDefaultVideoSettings = (batchCount: 1,cfgScale: config.defaults.cfgScale,cfgScaleLowNoise: config.defaults.cfgScaleLowNoise,- componentSourceModel: null,+ // A single-file H3 main cannot run without a Diffusers install in the+ // Model Components slot, so defaults (and reset, which reuses them) seed+ // one from the catalog instead of starting un-invokable.+ componentSourceModel:+ model && model.base === 'minimax-h3' && model.format === 'checkpoint' ? findH3ComponentSource(models) : null,firstFrameImage: null,fps: config.fps.defaultValue,h3TextEncoderModel: null,@@ -1474,6 +1494,14 @@ export const getVideoModelSelectionResult = ({}}+ // A single-file H3 main is un-invokable without a component source; fill an+ // empty slot from the catalog — including one the loop above just cleared+ // (and reported) as incompatible. An explicit compatible pick is never+ // overwritten.+ if (model.base === 'minimax-h3' && model.format === 'checkpoint' && !next.componentSourceModel) {+ next.componentSourceModel = findH3ComponentSource(models);+ }+return { clearedLabels, settings: next };};diff --git a/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.ts b/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.tsindex 39da4d01d9..472814802b 100644--- a/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/widgetValues.test.ts@@ -88,6 +88,26 @@ describe('syncVideoWidgetValuesWithModels', () => {expect(syncVideoWidgetValuesWithModels(synced, [install, checkpoint])).toBe(synced);});+ it('keeps the installed Diffusers main when the legacy transformer override is uninstalled', () => {+ // An uninstalled override must not evict the still-installed install from+ // the top slot (which would auto-pick a different family): the install+ // stays, and the dead override is dropped like any uninstalled component.+ const wan = wanModel('t2v_a14b');+ const install = h3Model();+ const checkpoint = { ...h3Model('checkpoint', 'h3-ckpt'), variant: 'ref2va' };+ const stored = {+ ...createDefaultVideoWidgetValues([wan, install, checkpoint]),+ h3TransformerModel: checkpoint,+ model: install,+ modelKey: install.key,+ };+ const synced = syncVideoWidgetValuesWithModels(stored, [wan, install]);++ expect(synced.model?.key).toBe(install.key);+ expect(synced.h3TransformerModel).toBeNull();+ expect(synced.componentSourceModel).toBeNull();+ });+it('returns the same object when nothing changed', () => {const catalog = [model, WAN_VAE_16];const values = { ...createDefaultVideoWidgetValues(catalog), vae: WAN_VAE_16 };diff --git a/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts b/invokeai/frontend/webv2/src/features/video/core/widgetValues.tsindex b1274666b4..6fdbaf6c8a 100644--- a/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts+++ b/invokeai/frontend/webv2/src/features/video/core/widgetValues.ts@@ -52,14 +52,29 @@ export const syncVideoWidgetValuesWithModels = (// the model identity now — promote it to the top slot and keep the install// as its component source. Runs before anything reads `values.model`, so// the whole sync (and its write-back) sees the new shape.+ //+ // Only a transformer that resolves in the live catalog as an H3 checkpoint+ // main is promoted: an uninstalled (or corrupt) override must not evict the+ // still-installed Diffusers main from the top slot — leaving it in place+ // keeps a runnable H3 panel, and the component pass below drops the dead+ // override (no slot offers it any more).if (values.model?.base === 'minimax-h3' && values.model.format === 'diffusers' && values.h3TransformerModel) {- values = {- ...values,- componentSourceModel: values.model,- h3TransformerModel: null,- model: values.h3TransformerModel,- modelKey: values.h3TransformerModel.key,- };+ const installedTransformer = models.find((candidate) => candidate.key === values.h3TransformerModel?.key);++ if (+ installedTransformer &&+ installedTransformer.type === 'main' &&+ installedTransformer.base === 'minimax-h3' &&+ installedTransformer.format === 'checkpoint'+ ) {+ values = {+ ...values,+ componentSourceModel: values.model,+ h3TransformerModel: null,+ model: installedTransformer as MainModelConfig,+ modelKey: installedTransformer.key,+ };+ }}const modelsByKey = new Map(models.map((model) => [model.key, model]));diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.tsindex e5e33cdebd..0a2d9eed76 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts@@ -527,4 +527,52 @@ describe('model-position recall shapes', () => {expect(result?.values.model?.key).toBe(checkpoint.key);expect(result?.values.componentSourceModel?.key).toBe(install.key);});+ it('promotes the recorded transformer even when the recorded install itself is gone', () => {+ // The transformer defines the run; the panel's current model (a+ // checkpoint) stands in for the missing install and must not suppress the+ // promote — pre-fix the references were dropped as unsupported.+ const panelCheckpoint: MainModelConfig = {+ base: 'minimax-h3',+ format: 'checkpoint',+ key: 'h3-fl2va-ckpt',+ name: 'MiniMax H3 FL2VA Transformer (int8)',+ type: 'main',+ variant: 'fl2va',+ };+ const result = buildVideoRecallSettings({+ currentValues: { ...currentValues, model: panelCheckpoint, modelKey: panelCheckpoint.key },+ kind: 'all',+ metadata: {+ generation_mode: 'minimax_h3_ref2v',+ minimax_h3_references: [{ detail: 'max', image_name: 'ref.png', kind: 'image' }],+ minimax_h3_transformer_model: { key: checkpoint.key },+ model: { key: 'h3-install-gone' },+ num_frames: 124,+ },+ models: [panelCheckpoint, checkpoint],+ });++ expect(result?.values.model?.key).toBe(checkpoint.key);+ expect(result?.fields).toContain('model');+ expect(result?.values.h3TransformerModel).toBeNull();+ expect(result?.mediaNames.references).toHaveLength(1);+ });++ it('drops a corrupt transformer-override recording that names a non-main', () => {+ const result = buildVideoRecallSettings({+ currentValues,+ kind: 'all',+ metadata: {+ generation_mode: 'minimax_h3_ref2v',+ minimax_h3_references: [{ detail: 'max', image_name: 'ref.png', kind: 'image' }],+ minimax_h3_transformer_model: { key: ref2vTurbo.key },+ model: { key: install.key },+ num_frames: 124,+ },+ models: catalog,+ });++ expect(result?.values.model?.key).toBe(install.key);+ expect(result?.values.h3TransformerModel).toBeNull();+ });});diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.tsindex dbe2869a35..a619a7ae08 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts@@ -551,22 +551,38 @@ export const buildVideoRecallSettings = ({fields.push('components');}- // Legacy metadata shape (pre model-positions): `model` recorded as the H3- // Diffusers install with the single-file transformer as an override extra.- // The transformer is the model identity now — promote it, so the- // accelerator derivation below judges the right task, and keep the install- // as the component source.- if (model?.base === 'minimax-h3' && model.format === 'diffusers' && values.h3TransformerModel) {- const componentSource = model;-- model = values.h3TransformerModel;- values = {- ...values,- componentSourceModel: componentSource,- h3TransformerModel: null,- model,- modelKey: model.key,- };+ // Legacy metadata shape (pre model-positions): the run recorded the H3+ // Diffusers install as `model` with the single-file transformer as an+ // override extra. The transformer is the model identity now — promote it,+ // so the accelerator derivation below judges the right task. It promotes+ // whenever the components loop resolved an installed H3 checkpoint into the+ // override slot, even when the recorded install itself is gone (the panel's+ // current model then stands in for `model`): the transformer is what+ // defines the run. Anything else that landed in the slot (corrupt metadata+ // naming a non-main) is dropped rather than left as dangling state.+ if (values.h3TransformerModel) {+ const transformer = values.h3TransformerModel;++ if (transformer.type === 'main' && transformer.base === 'minimax-h3' && transformer.format === 'checkpoint') {+ // The recorded install (when still around) becomes the component+ // source; otherwise whatever the slot already holds is kept.+ const componentSource =+ model?.base === 'minimax-h3' && model.format === 'diffusers' ? model : values.componentSourceModel;++ model = transformer;+ values = {+ ...values,+ componentSourceModel: componentSource,+ h3TransformerModel: null,+ model,+ modelKey: model.key,+ };+ if (!fields.includes('model')) {+ fields.push('model');+ }+ } else {+ values = { ...values, h3TransformerModel: null };+ }}const recordedLoras = getMetadataLoras(metadata);