Skip to content

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.

fix(webv2): harden the expert-wiring swap against review findings

Lincoln Stein5ef17d0b09b5
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 4daeeca973..205f9dea8d 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3055,9 +3055,9 @@
"acceleratorBrokenDescription": "One of its LoRAs was removed or disabled, so steps and CFG were restored to the model's defaults.",
"resetAllToModelDefaults": "Reset all settings to the model's defaults",
"expertWiring": {
- "high-as-low": "\"{{lowName}}\" is tagged as the high-noise expert but is wired as the low-noise one. The wiring is authoritative — swap if unintended.",
- "low-as-main": "\"{{mainName}}\" is tagged as the low-noise expert but is wired as the main (high-noise) transformer. The wiring is authoritative — swap if unintended.",
- "single-low": "\"{{mainName}}\" is tagged as the low-noise expert. When running a single expert, the high-noise one is usually the better choice.",
+ "highAsLow": "\"{{lowName}}\" is tagged as the high-noise expert but is wired as the low-noise one. The wiring is authoritative — swap if unintended.",
+ "lowAsMain": "\"{{mainName}}\" is tagged as the low-noise expert but is wired as the main (high-noise) transformer. The wiring is authoritative — swap if unintended.",
+ "singleLow": "\"{{mainName}}\" is tagged as the low-noise expert. When running a single expert, the high-noise one is usually the better choice.",
"swap": "Swap experts",
"swapped": "The filename tags suggest these two experts are swapped. The wiring is authoritative — swap if unintended."
}
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
index 5158f58509..f85c830ab5 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
@@ -569,6 +569,22 @@ describe('getWanExpertWiringWarning', () => {
expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'low', 'm'), null)).toEqual({ kind: 'single-low' });
});
+ it('keeps warning after a role exchange of a same-tag pair, so no swap is offered', () => {
+ // high+high and low+low pairs re-warn with roles exchanged — the UI uses
+ // this simulation to withhold the Swap button rather than loop.
+ const highPair = [tagged('i2v_a14b', 'high', 'm'), tagged('i2v_a14b', 'high', 'l')] as const;
+ const lowPair = [tagged('i2v_a14b', 'low', 'm'), tagged('i2v_a14b', 'low', 'l')] as const;
+
+ expect(getWanExpertWiringWarning(highPair[0], highPair[1])).toEqual({ kind: 'high-as-low' });
+ expect(getWanExpertWiringWarning(highPair[1], highPair[0])).toEqual({ kind: 'high-as-low' });
+ expect(getWanExpertWiringWarning(lowPair[0], lowPair[1])).toEqual({ kind: 'low-as-main' });
+ expect(getWanExpertWiringWarning(lowPair[1], lowPair[0])).toEqual({ kind: 'low-as-main' });
+ // Every swappable kind resolves when roles are exchanged.
+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'high', 'l'), tagged('i2v_a14b', 'low', 'm'))).toBeNull();
+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'high', 'l'), tagged('i2v_a14b', 'none', 'm'))).toBeNull();
+ expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'none', 'l'), tagged('i2v_a14b', 'low', 'm'))).toBeNull();
+ });
+
it('stays silent for correct, untagged, Diffusers, TI2V-5B, and non-Wan wirings', () => {
expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'high', 'm'), tagged('i2v_a14b', 'low', 'l'))).toBeNull();
expect(getWanExpertWiringWarning(tagged('i2v_a14b', 'none', 'm'), tagged('i2v_a14b', 'none', 'l'))).toBeNull();
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsx
index b50b074ca5..1dd136ec88 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoComponentsSection.tsx
@@ -100,9 +100,9 @@ const ComponentSlotRow = memo(function ComponentSlotRow({
// Spelled out rather than interpolated, so the translation-key scan can see
// them and fail the build if a string goes missing.
const EXPERT_WIRING_MESSAGE_KEYS = {
- 'high-as-low': 'widgets.video.expertWiring.high-as-low',
- 'low-as-main': 'widgets.video.expertWiring.low-as-main',
- 'single-low': 'widgets.video.expertWiring.single-low',
+ 'high-as-low': 'widgets.video.expertWiring.highAsLow',
+ 'low-as-main': 'widgets.video.expertWiring.lowAsMain',
+ 'single-low': 'widgets.video.expertWiring.singleLow',
swapped: 'widgets.video.expertWiring.swapped',
} as const;
@@ -115,10 +115,20 @@ const WanExpertWiringNotice = memo(function WanExpertWiringNotice({
}) {
const { t } = useTranslation();
const models = useModelsSelector((snapshot) => snapshot.models);
+ // A selection transition computed against an unloaded catalog would judge
+ // the Lightning pair "not installed" and silently strip the accelerator.
+ const modelsLoaded = useModelsSelector((snapshot) => snapshot.status) === 'loaded';
const warning = useMemo(
() => getWanExpertWiringWarning(values.model, values.wanLowNoiseModel),
[values.model, values.wanLowNoiseModel]
);
+ // Only offer the swap when exchanging roles actually clears the warning: a
+ // high+high or low+low pair would just re-warn about the other file.
+ const swapResolves =
+ warning !== null &&
+ warning.kind !== 'single-low' &&
+ values.wanLowNoiseModel?.format !== 'diffusers' &&
+ getWanExpertWiringWarning(values.wanLowNoiseModel, values.model) === null;
const swapExperts = useCallback(() => {
const previousMain = values.model;
const nextMain = values.wanLowNoiseModel;
@@ -148,7 +158,7 @@ const WanExpertWiringNotice = memo(function WanExpertWiringNotice({
<Text color="fg.warning" flex="1" fontSize="2xs" textWrap="pretty">
{message}
</Text>
- {warning.kind !== 'single-low' ? (
+ {swapResolves && modelsLoaded ? (
<Button flexShrink="0" size="2xs" variant="outline" onClick={swapExperts}>
{t('widgets.video.expertWiring.swap')}
</Button>