Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(video): Wan 2.1 VAE resolution + dual Wan 2.2 in the T2V picker

purpleadde9f4da5ca
diff --git a/src/api/__tests__/model-pick.test.ts b/src/api/__tests__/model-pick.test.ts
index 64b8bb48..f8fda88f 100644
--- a/src/api/__tests__/model-pick.test.ts
+++ b/src/api/__tests__/model-pick.test.ts
@@ -28,6 +28,9 @@ const VIDEO_MODELS = [
{ name: 'svd_xt_1_1.safetensors', type: 'svd', source: 'checkpoint' },
{ name: 'wan2.1_t2v_1.3B_bf16.safetensors', type: 'wan', source: 'diffusion_model' },
{ name: 'FramePackI2V_HY_fp8_e4m3fn.safetensors', type: 'framepack', source: 'diffusion_model' },
+ // Dual T2V/I2V (live find 2026-06-11: the old !isI2VModel negation hid it
+ // from the T2V picker even though it text-to-videos natively).
+ { name: 'wan2.2_ti2v_5B_fp16.safetensors', type: 'wan22', source: 'diffusion_model' },
] as never
/** Resolve the pending pick from the "UI side" as soon as it appears. */
@@ -100,28 +103,30 @@ describe('pickModelForGeneration — image', () => {
})
describe('pickModelForGeneration — video T2V vs I2V', () => {
- it('text-to-video offers ONLY non-I2V models and uses the T2V pref key', async () => {
+ it('text-to-video offers T2V-capable models (incl. dual Wan 2.2) and uses the T2V pref key', async () => {
const p = pickModelForGeneration('video', {})
await vi.waitFor(() => {
if (!useModelPickStore.getState().pending) throw new Error('no pending')
})
const pending = useModelPickStore.getState().pending!
expect(pending.kind).toBe('video-t2v')
- expect(pending.models).toEqual(['wan2.1_t2v_1.3B_bf16.safetensors'])
+ // Wan 2.2 TI2V is dual-capable → it belongs in the T2V list too; the
+ // I2V-only checkpoints (SVD/FramePack) stay excluded.
+ expect(pending.models.sort()).toEqual(['wan2.1_t2v_1.3B_bf16.safetensors', 'wan2.2_ti2v_5B_fp16.safetensors'])
useModelPickStore.getState().choose({ model: 'wan2.1_t2v_1.3B_bf16.safetensors', save: true })
expect(await p).toBe('wan2.1_t2v_1.3B_bf16.safetensors')
expect(useSettingsStore.getState().settings.preferredVideoT2VModel).toBe('wan2.1_t2v_1.3B_bf16.safetensors')
expect(useSettingsStore.getState().settings.preferredVideoI2VModel).toBe('')
})
- it('image-to-video offers ONLY I2V models (SVD/FramePack) and the I2V pref key', async () => {
+ it('image-to-video offers I2V-capable models (SVD/FramePack/Wan 2.2) and the I2V pref key', async () => {
const p = pickModelForGeneration('video', { inputImage: 'ComfyUI_0001.png' })
await vi.waitFor(() => {
if (!useModelPickStore.getState().pending) throw new Error('no pending')
})
const pending = useModelPickStore.getState().pending!
expect(pending.kind).toBe('video-i2v')
- expect(pending.models.sort()).toEqual(['FramePackI2V_HY_fp8_e4m3fn.safetensors', 'svd_xt_1_1.safetensors'])
+ expect(pending.models.sort()).toEqual(['FramePackI2V_HY_fp8_e4m3fn.safetensors', 'svd_xt_1_1.safetensors', 'wan2.2_ti2v_5B_fp16.safetensors'])
useModelPickStore.getState().choose({ model: 'svd_xt_1_1.safetensors', save: true })
expect(await p).toBe('svd_xt_1_1.safetensors')
expect(useSettingsStore.getState().settings.preferredVideoI2VModel).toBe('svd_xt_1_1.safetensors')
diff --git a/src/api/__tests__/wan22-workflow.test.ts b/src/api/__tests__/wan22-workflow.test.ts
index d477189f..1fb87ccb 100644
--- a/src/api/__tests__/wan22-workflow.test.ts
+++ b/src/api/__tests__/wan22-workflow.test.ts
@@ -18,10 +18,16 @@ vi.mock('../comfyui-nodes', async (importOriginal) => {
const actual = await importOriginal<typeof import('../comfyui-nodes')>()
return { ...actual, getAllNodeInfo: vi.fn() }
})
+vi.mock('../backend', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../backend')>()
+ // comfyuiUrl reads `window` (isTauri) — stub it for the node test env.
+ return { ...actual, localFetch: vi.fn(), comfyuiUrl: (p: string) => `http://test${p}` }
+})
import { buildDynamicWorkflow, determineStrategy, snapWanLength } from '../dynamic-workflow'
import { categorizeNodes, getAllNodeInfo, type CategorizedNodes } from '../comfyui-nodes'
-import { classifyModel, isI2VModel, isT2VCapable } from '../comfyui'
+import { classifyModel, isI2VModel, isT2VCapable, findMatchingVAE } from '../comfyui'
+import { localFetch } from '../backend'
import { resolveI2VResolution } from '../vram-handoff'
// Minimal /object_info for a ComfyUI that can run Wan 2.2 5B.
@@ -181,6 +187,35 @@ describe('buildDynamicWorkflow — Wan 2.2 graph', () => {
})
})
+describe('findMatchingVAE — Wan 2.1 vs 2.2 (48-channel regression)', () => {
+ // David's EXACT live VAELoader enum after the Wan 2.2 bundle install. Note
+ // wan2.2_vae sorts BEFORE wan_2.1_vae — the old first-.includes('wan') hit
+ // decoded Wan 2.1 (16-ch latents) with the 2.2 VAE (48-ch) and every Wan 2.1
+ // generation died with "expected input to have 48 channels, but got 16".
+ const LIVE_VAE_ENUM = ['hunyuanvideo15_vae_fp16.safetensors', 'sdxl_vae.safetensors', 'wan2.2_vae.safetensors', 'wan_2.1_vae.safetensors', 'pixel_space']
+
+ beforeEach(() => {
+ vi.mocked(localFetch).mockResolvedValue({
+ ok: true,
+ json: async () => ({ VAELoader: { input: { required: { vae_name: [LIVE_VAE_ENUM] } } } }),
+ } as never)
+ })
+
+ it("'wan' (2.1) picks the 2.1 VAE even though the 2.2 file sorts first", async () => {
+ expect(await findMatchingVAE('wan')).toBe('wan_2.1_vae.safetensors')
+ })
+ it("'wan22' picks the 2.2 VAE", async () => {
+ expect(await findMatchingVAE('wan22')).toBe('wan2.2_vae.safetensors')
+ })
+ it("'wan' without a 2.1 file still refuses the 2.2 VAE (falls to hunyuan)", async () => {
+ vi.mocked(localFetch).mockResolvedValue({
+ ok: true,
+ json: async () => ({ VAELoader: { input: { required: { vae_name: [['wan2.2_vae.safetensors', 'hunyuanvideo15_vae_fp16.safetensors']] } } } }),
+ } as never)
+ expect(await findMatchingVAE('wan')).toBe('hunyuanvideo15_vae_fp16.safetensors')
+ })
+})
+
describe('resolveI2VResolution — wan22 (pixel-budget for 12 GB)', () => {
it('landscape source keeps aspect, snaps to 32, fits the ~0.6 M-px budget', () => {
const r = resolveI2VResolution('wan22', 1920, 1080)
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 5cf81d56..96be2a21 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -687,11 +687,26 @@ export async function findMatchingVAE(modelType: ModelType): Promise<string> {
throw new Error(`No HunyuanVideo VAE found. Download "hunyuanvideo15_vae_fp16.safetensors" from the Model Manager.`)
}
if (modelType === 'wan') {
- const match = vaes.find(v => lower(v).includes('wan'))
+ // Wan 2.1 latents are 16-channel; the Wan 2.2 VAE is 48-channel — decoding
+ // 2.1 output with it fails ("expected input to have 48 channels, but got
+ // 16"). Live regression 2026-06-11: right after the Wan 2.2 bundle install,
+ // wan2.2_vae sorted BEFORE wan_2.1_vae in the enum and the first
+ // .includes('wan') hit broke every Wan 2.1 generation. Prefer the 2.1 file
+ // explicitly and never fall into a 2.2 one.
+ const isWan22Vae = (v: string) => /wan[._]?2[._]?2/.test(lower(v))
+ const match = vaes.find(v => /wan[._]?2[._]?1/.test(lower(v)))
+ || vaes.find(v => lower(v).includes('wan') && !isWan22Vae(v))
|| vaes.find(v => lower(v).includes('hunyuan'))
if (match) return match
throw new Error(`No Wan VAE found. Download "wan_2.1_vae.safetensors" from the Model Manager.`)
}
+ if (modelType === 'wan22') {
+ // Defense in depth — the wan22 builder pins its VAE by name, but if this
+ // resolver is ever hit, ONLY the 2.2 VAE is valid (48-channel latents).
+ const match = vaes.find(v => /wan[._]?2[._]?2/.test(lower(v)))
+ if (match) return match
+ throw new Error(`No Wan 2.2 VAE found. Download "wan2.2_vae.safetensors" from the Model Manager.`)
+ }
if (modelType === 'ltx') {
const match = vaes.find(v => lower(v).includes('ltx'))
if (match) return match
@@ -1116,16 +1131,20 @@ export async function buildWanVideoWorkflow(params: VideoParams): Promise<Record
'8': { class_type: 'VAEDecode', inputs: { samples: ['7', 0], vae: ['3', 0] } },
}
- // Use SaveAnimatedWEBP if available, otherwise fall back to SaveImage (frame sequence)
+ // Use SaveAnimatedWEBP if available, otherwise fall back to SaveImage (frame
+ // sequence). Prompt-based prefix (David 2026-06-11) — the dynamic builder got
+ // this in c40d13f, this legacy T2V path still wrote locally_uncensored_vid.
+ const { promptFilenamePrefix } = await import('./dynamic-workflow')
+ const vidPrefix = promptFilenamePrefix(params.prompt, true)
if (hasSaveWEBP) {
workflow['9'] = {
class_type: 'SaveAnimatedWEBP',
- inputs: { images: ['8', 0], filename_prefix: 'locally_uncensored_vid', fps: params.fps, lossless: false, quality: 90, method: 'default' },
+ inputs: { images: ['8', 0], filename_prefix: vidPrefix, fps: params.fps, lossless: false, quality: 90, method: 'default' },
}
} else {
workflow['9'] = {
class_type: 'SaveImage',
- inputs: { images: ['8', 0], filename_prefix: 'locally_uncensored_vid' },
+ inputs: { images: ['8', 0], filename_prefix: vidPrefix },
}
}
diff --git a/src/api/model-pick.ts b/src/api/model-pick.ts
index db8e6ca6..09755d04 100644
--- a/src/api/model-pick.ts
+++ b/src/api/model-pick.ts
@@ -1,4 +1,4 @@
-import { getImageModels, getVideoModels, isI2VModel } from './comfyui'
+import { getImageModels, getVideoModels, isI2VModel, isT2VCapable } from './comfyui'
import type { ModelPickKind } from '../stores/modelPickStore'
/**
@@ -36,9 +36,12 @@ export async function pickModelForGeneration(
let names: string[]
try {
const models = kind === 'image' ? await getImageModels() : await getVideoModels()
+ // T2V uses isT2VCapable (NOT !isI2VModel): Wan 2.2 TI2V is dual T2V/I2V,
+ // so it must appear in BOTH picker lists — the old negation hid it from
+ // the T2V picker (live find 2026-06-11, first wan22 T2V pick on the 3060).
const eligible = kind === 'image'
? models
- : models.filter((m) => (wantI2V ? isI2VModel(m.name) : !isI2VModel(m.name)))
+ : models.filter((m) => (wantI2V ? isI2VModel(m.name) : isT2VCapable(m.name)))
names = eligible.map((m) => m.name)
} catch {
return null