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(create): every local lane asks before it fails on a ComfyUI that is too old

purpledd293e2595bf
diff --git a/src/api/__tests__/vram-handoff.test.ts b/src/api/__tests__/vram-handoff.test.ts
index 0696bbe8..fbc45131 100644
--- a/src/api/__tests__/vram-handoff.test.ts
+++ b/src/api/__tests__/vram-handoff.test.ts
@@ -85,6 +85,20 @@ vi.mock('../dynamic-workflow', () => ({
buildDynamicWorkflow: (...a: unknown[]) => buildDynamicWorkflow(...a),
}))
+// The real question and the real retry (lib/render-fixups.ts). Only the update
+// itself is replaced: it would run git and pip.
+const updateComfy = vi.fn()
+vi.mock('../render-fixup-deps', async () => {
+ const actual = await vi.importActual<typeof import('../render-fixup-deps')>('../render-fixup-deps')
+ return {
+ renderFixupDeps: (...args: Parameters<typeof actual.renderFixupDeps>) => ({
+ ...actual.renderFixupDeps(...args),
+ updateComfy: (...a: unknown[]) => updateComfy(...a),
+ refresh: async () => undefined,
+ }),
+ }
+})
+
vi.mock('../agent-context', () => ({
getActiveAgentModel: () => getActiveAgentModel(),
}))
@@ -348,6 +362,46 @@ function completedHistory() {
}
}
+// ── The version gate in the agent's tool ──────────────────────────
+
+describe('vramHandoffGenerate, a ComfyUI too old for the model', () => {
+ const GATE = 'Qwen-Image 2.1 needs ComfyUI 0.37.0 or newer. Update ComfyUI in Settings.'
+ const tooOld = () => Object.assign(new Error(GATE), { name: 'WorkflowUnavailableError', needsComfyUpdate: true })
+
+ beforeEach(() => {
+ updateComfy.mockReset()
+ updateComfy.mockResolvedValue(undefined)
+ useCreateStore.setState({ fixupPrompt: null } as never)
+ getActiveAgentModel.mockReturnValue({ name: 'gpt-4o', providerId: 'openai', remote: false })
+ getImageModels.mockResolvedValue([{ name: 'qwen_image_2.1_int8_convrot.safetensors', type: 'qwenimage21', source: 'unet' }])
+ submitWorkflow.mockResolvedValue('pid-1')
+ getHistory.mockResolvedValue(completedHistory())
+ })
+
+ it('the image tool asks once, updates on yes, builds again and renders', async () => {
+ buildDynamicWorkflow.mockRejectedValueOnce(tooOld()).mockResolvedValue({ '9': { class_type: 'SaveImage' } })
+ const run = vramHandoffGenerate('image', { prompt: 'a cat' })
+ await vi.waitFor(() => expect(useCreateStore.getState().fixupPrompt).not.toBeNull())
+ expect(useCreateStore.getState().fixupPrompt?.title).toBe('ComfyUI needs an update')
+ useCreateStore.getState().fixupPrompt?.resolve(true)
+ const out = await run
+ expect(updateComfy).toHaveBeenCalledTimes(1)
+ expect(buildDynamicWorkflow).toHaveBeenCalledTimes(2)
+ expect(out).toContain('Image generated: out.png')
+ })
+
+ it('a no is reported to the model as not started, with the reason', async () => {
+ buildDynamicWorkflow.mockRejectedValue(tooOld())
+ const run = vramHandoffGenerate('image', { prompt: 'a cat' })
+ await vi.waitFor(() => expect(useCreateStore.getState().fixupPrompt).not.toBeNull())
+ useCreateStore.getState().fixupPrompt?.resolve(false)
+ const out = await run
+ expect(updateComfy).not.toHaveBeenCalled()
+ expect(submitWorkflow).not.toHaveBeenCalled()
+ expect(out).toBe(`Image generation was not started. ${GATE}`)
+ })
+})
+
// ── 2. cloud/remote SKIP path ─────────────────────────────────────
describe('vramHandoffGenerate — cloud/remote SKIP path', () => {
diff --git a/src/api/__tests__/yue2-is-the-second-music-model.test.ts b/src/api/__tests__/yue2-is-the-second-music-model.test.ts
index a2af171c..efc17acb 100644
--- a/src/api/__tests__/yue2-is-the-second-music-model.test.ts
+++ b/src/api/__tests__/yue2-is-the-second-music-model.test.ts
@@ -144,6 +144,19 @@ describe('the version lock is per model', () => {
expect((caught as WorkflowUnavailableError).needsComfyUpdate).toBe(true)
expect(() => buildMusicWorkflow(params({ model: ACE }), 7, old)).not.toThrow()
})
+
+ // The box, 03.10.2026: "Update ComfyUI" in the sentence is not what Create
+ // asks on, the flag is. A lane whose core nodes are missing is a ComfyUI
+ // that is too old, so it carries the flag like a model with a known release.
+ it('a ComfyUI without the core nodes of a lane is offered the update too', () => {
+ const old = { ...NODES }
+ delete old['TextEncodeAceStepAudio1.5']
+ let caught: unknown
+ try { buildMusicWorkflow(params({ model: ACE }), 7, old) } catch (e) { caught = e }
+ expect(caught).toBeInstanceOf(WorkflowUnavailableError)
+ expect((caught as WorkflowUnavailableError).message).toContain('Update ComfyUI')
+ expect((caught as WorkflowUnavailableError).needsComfyUpdate).toBe(true)
+ })
})
beforeEach(() => { vi.mocked(localFetch).mockReset() })
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index f2f7017e..5d736807 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -2153,6 +2153,8 @@ function requireNodes(allNodes: NodePresence, needed: string[], lane: string): v
throw new WorkflowUnavailableError(
`${lane} needs ComfyUI nodes this install does not have yet (${missing.join(', ')}). ${UPDATE_COMFY_HINT}`,
'unavailable',
+ undefined,
+ { needsComfyUpdate: true },
)
}
}
diff --git a/src/api/render-fixup-deps.ts b/src/api/render-fixup-deps.ts
new file mode 100644
index 00000000..69fe318d
--- /dev/null
+++ b/src/api/render-fixup-deps.ts
@@ -0,0 +1,81 @@
+// The side effects lib/render-fixups.ts needs, wired to the app. One place,
+// because every local render asks the same way: Create (all lanes and the
+// prompt enhancer) and the agent's image and video tool (api/vram-handoff.ts).
+// The question itself is drawn by RenderFixupModal in the app shell.
+
+import { backendCall } from './backend'
+import { checkComfyConnection, refreshComfyModels } from './comfyui'
+import { clearNodeCache } from './comfyui-nodes'
+import { startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, comfyModelTarget, catalogDigestFor } from './discover'
+import { downloadBundleFiles, waitForModelsVisible } from '../lib/bundle-install'
+import type { FixupDeps } from '../lib/render-fixups'
+import { useCreateStore } from '../stores/createStore'
+import { useDownloadStore } from '../stores/downloadStore'
+import { useComfyInstallStore } from '../stores/comfyInstallStore'
+
+/** How long the updated ComfyUI gets to answer. */
+const COMFY_BACK_UP_TRIES = 90
+const POLL_MS = 2000
+
+export function renderFixupDeps(onStatus: (line: string) => void, signal?: AbortSignal): FixupDeps {
+ const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))
+ const refreshLists = async () => {
+ await refreshComfyModels().catch(() => false)
+ clearNodeCache()
+ }
+ return {
+ ask: (prompt) => new Promise<boolean>((resolve) => {
+ useCreateStore.getState().setFixupPrompt({
+ ...prompt,
+ resolve: (go) => { useCreateStore.getState().setFixupPrompt(null); resolve(go) },
+ })
+ }),
+ download: async (files) => {
+ const dl = useDownloadStore.getState()
+ for (const f of files) dl.setMeta(f.downloadFilename, f.downloadUrl, f.subfolder)
+ dl.startPolling()
+ await downloadBundleFiles(
+ files.map((f) => ({ filename: f.downloadFilename, subfolder: f.subfolder, downloadUrl: f.downloadUrl, sizeGB: f.sizeGB, sha256: catalogDigestFor(f.downloadFilename, f.downloadUrl).sha256 })),
+ {
+ start: startModelDownload,
+ progress: getDownloadProgress,
+ onStatus,
+ keepTrayLive: () => useDownloadStore.getState().startPolling(),
+ stop: (filename) => { void useDownloadStore.getState().cancel(filename) },
+ signal,
+ },
+ )
+ // A ComfyUI on another machine cannot list them before they are copied
+ // over; buildWithFixups says so (GH #143).
+ if ((await comfyModelTarget()).remote) return
+ const wanted = files.map((f) => f.downloadFilename)
+ const left = await waitForModelsVisible({ missing: () => modelsNotVisibleInComfy(wanted), refresh: refreshLists, onStatus, signal })
+ if (left.length > 0) throw new Error(`Downloaded ${left.join(', ')}, but ComfyUI does not list ${left.length === 1 ? 'it' : 'them'} yet. Restart ComfyUI and hit Create again.`)
+ },
+ remote: async () => {
+ const t = await comfyModelTarget()
+ return t.remote && t.host && t.root ? { host: t.host, root: t.root } : null
+ },
+ updateComfy: async () => {
+ onStatus('Updating ComfyUI…')
+ await useComfyInstallStore.getState().runUpdate()
+ for (;;) {
+ await sleep(POLL_MS)
+ const st = useComfyInstallStore.getState()
+ if (st.phase === 'error') throw new Error(st.error || 'Updating ComfyUI did not finish.')
+ if (st.phase === 'idle') break
+ const last = st.logs[st.logs.length - 1]
+ if (last) onStatus(String(last))
+ }
+ onStatus('Starting the updated ComfyUI…')
+ await backendCall('start_comfyui').catch(() => undefined)
+ for (let i = 0; i < COMFY_BACK_UP_TRIES; i++) {
+ if (await checkComfyConnection()) return
+ onStatus(`Starting the updated ComfyUI… ${i * 2}s`)
+ await sleep(POLL_MS)
+ }
+ throw new Error('ComfyUI was updated but did not come back up. Start it from Settings and hit Create again.')
+ },
+ refresh: refreshLists,
+ }
+}
diff --git a/src/api/vram-handoff.ts b/src/api/vram-handoff.ts
index 8f9de8da..c4f148a3 100644
--- a/src/api/vram-handoff.ts
+++ b/src/api/vram-handoff.ts
@@ -83,6 +83,8 @@ import { PaceTracker, overBudget, renderBudgetNotice, renderTimeoutNotice, warmu
import { asComfyGpuMode } from '../lib/comfy-cpu-banner'
import { comfyHoldsNoVram } from '../lib/comfy-device'
import { log } from '../lib/logger'
+import { buildWithFixups, wasDeclined } from '../lib/render-fixups'
+import { renderFixupDeps } from './render-fixup-deps'
/**
* Is the ComfyUI we are about to render on running on the processor?
@@ -1241,6 +1243,23 @@ async function runHandoff(
// ── Generation bodies ─────────────────────────────────────────────
+/** The agent's tool builds through the same question Create asks: a model
+ * whose companion file is missing or whose ComfyUI is too old gets the
+ * download or the update offered once, then the build runs again. Without it
+ * the chat only ever read "needs ComfyUI 0.37.0 or newer" as a failure. */
+function buildFixable<T>(kind: 'image' | 'video', build: () => Promise<T>): Promise<T> {
+ return buildWithFixups(build, renderFixupDeps((line) => emitHandoff('loading_image_model', { kind, detail: line })))
+}
+
+/** How a build error reads in the tool result. A no to the question is the
+ * user's own decision, not a failure. */
+function buildErrorResult(kind: 'image' | 'video', err: unknown): string {
+ const message = err instanceof Error ? err.message : String(err)
+ return wasDeclined(err)
+ ? `${label(kind)} generation was not started. ${message}`
+ : `${label(kind)} generation failed: ${message}`
+}
+
/** Image path — mirrors the legacy executeImageGenerate, via buildDynamicWorkflow. */
async function generateImage(
prompt: string,
@@ -1294,7 +1313,7 @@ async function generateImage(
// with the same one.
const { useCreateStore } = await import('../stores/createStore')
const qwenTextEncoder = useCreateStore.getState().qwenTextEncoder
- const workflow = await buildDynamicWorkflow(
+ const workflow = await buildFixable('image', () => buildDynamicWorkflow(
{
prompt,
negativePrompt: typeof args.negativePrompt === 'string' ? args.negativePrompt : '',
@@ -1327,7 +1346,7 @@ async function generateImage(
...(listed?.parts ? { modelParts: listed.parts } : {}),
},
type,
- )
+ ))
// Phase markers (chat-agent hang 2026-06-03): make it obvious in the log
// whether a stall is in the workflow build (/object_info) or the submit
// (/prompt). Both are now timeout-bounded, so neither can strand the
@@ -1347,7 +1366,7 @@ async function generateImage(
return result
} catch (err) {
// Surface ComfyUI's message verbatim — an OOM must NOT be masked.
- return `${label('image')} generation failed: ${err instanceof Error ? err.message : String(err)}`
+ return buildErrorResult('image', err)
}
}
@@ -1421,7 +1440,7 @@ async function generateVideo(
const snapped = snapToVideoGrid(clampInt(av.width, base.width, 64, 2048), clampInt(av.height, base.height, 64, 2048))
const seed = (typeof av.seed === 'number' && Number.isFinite(av.seed)) ? Math.floor(av.seed) : -1
- const workflow = await buildDynamicWorkflow(
+ const workflow = await buildFixable('video', () => buildDynamicWorkflow(
{
prompt,
negativePrompt: typeof args.negativePrompt === 'string' ? args.negativePrompt : '',
@@ -1439,7 +1458,7 @@ async function generateVideo(
...(inputImage ? { inputImage } : {}),
},
type,
- )
+ ))
log.info('vram_handoff.video.submit', { model, mode: inputImage ? 'i2v' : 't2v', family: type, steps: tunSteps, cfg: tunCfg })
const submitted = await submitCancellable(workflow, seq)
if (submitted === CANCELLED) return `${label('video')} generation cancelled.`
@@ -1491,7 +1510,7 @@ async function generateVideo(
)
const seed = (typeof av.seed === 'number' && Number.isFinite(av.seed)) ? Math.floor(av.seed) : -1
const motionBucketId = clampInt(av.motionBucketId ?? av.motion_bucket_id, 90, 1, 255)
- const workflow = await buildDynamicWorkflow(
+ const workflow = await buildFixable('video', () => buildDynamicWorkflow(
{
prompt,
negativePrompt: typeof args.negativePrompt === 'string' ? args.negativePrompt : '',
@@ -1510,7 +1529,7 @@ async function generateVideo(
motionBucketId,
},
type,
- )
+ ))
log.info('vram_handoff.video.submit', { model, i2v: true })
const submitted = await submitCancellable(workflow, seq)
if (submitted === CANCELLED) return `${label('video')} generation cancelled.`
@@ -1558,7 +1577,7 @@ async function generateVideo(
log.info('vram_handoff.video.submitted', { promptId })
return await pollAndExtract(promptId, prompt, label('video'), getVideoTimeoutMs())
} catch (err) {
- return `${label('video')} generation failed: ${err instanceof Error ? err.message : String(err)}`
+ return buildErrorResult('video', err)
}
}
diff --git a/src/components/create/experimental/CreateExperimental.tsx b/src/components/create/experimental/CreateExperimental.tsx
index af58e707..34210bf9 100644
--- a/src/components/create/experimental/CreateExperimental.tsx
+++ b/src/components/create/experimental/CreateExperimental.tsx
@@ -21,7 +21,6 @@ import { Hinweis } from '../../ui/Hinweis'
import { BannerText } from './BannerText'
import { MaskEditor } from './MaskEditor'
import { VhsInstallModal } from './VhsInstallModal'
-import { RenderFixupModal } from './RenderFixupModal'
import { PresetShelf } from './PresetShelf'
import type { CreatePreset } from '../../../lib/render/create-presets'
import { Modal } from '../../ui/Modal'
@@ -504,7 +503,6 @@ function CreateExperimentalInner() {
<Lightbox item={lightbox} onClose={() => setLightbox(null)} onSaveCharacter={setCharacterFrom} />
<SaveCharacterModal item={characterFrom} onClose={() => setCharacterFrom(null)} />
<VhsInstallModal />
- <RenderFixupModal />
</div>
)
}
diff --git a/src/components/create/experimental/RenderFixupModal.tsx b/src/components/create/experimental/RenderFixupModal.tsx
index 852e340b..e3542b43 100644
--- a/src/components/create/experimental/RenderFixupModal.tsx
+++ b/src/components/create/experimental/RenderFixupModal.tsx
@@ -5,8 +5,9 @@ import { Modal } from '../../ui/Modal'
/**
* Discord 2026-09-28: a model that needs a text encoder / VAE that is not on
* disk, or a newer ComfyUI, gets the fix offered right here instead of a
- * sentence pointing at the Model Manager. Same pattern as VhsInstallModal:
- * useCreate sets `fixupPrompt`, this resolves it.
+ * sentence pointing at the Model Manager. api/render-fixup-deps.ts sets
+ * `fixupPrompt`, this resolves it. Mounted in the app shell, because the
+ * agent's image tool asks the same question from Chat.
*/
export function RenderFixupModal() {
const prompt = useCreateStore((s) => s.fixupPrompt)
diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsx
index 5d87b686..4f27c68e 100644
--- a/src/components/layout/AppShell.tsx
+++ b/src/components/layout/AppShell.tsx
@@ -50,6 +50,7 @@ import { CloudGateModal } from '../cloud/CloudGateModal'
import { CloudTeaserModal } from '../cloud/CloudTeaserModal'
import { ReleaseNotesModal } from '../release/ReleaseNotesModal'
import { ShortcutsModal } from './ShortcutsModal'
+import { RenderFixupModal } from '../create/experimental/RenderFixupModal'
import { CommandPalette } from '../ui/CommandPalette'
import { CreditsExhaustedModal } from './CreditsExhaustedModal'
import { Titlebar } from './Titlebar'
@@ -1168,6 +1169,10 @@ export function AppShell() {
{/* Out-of-credits purchase prompt: opens when LU Cloud answers
code:'credits_exhausted' (monthly budget + top-up wallet empty). */}
<CreditsExhaustedModal />
+ {/* "One more file is needed" / "ComfyUI needs an update": asked by every
+ local render, from Create and from the agent's tool in Chat, so it
+ lives here and not inside Create. */}
+ <RenderFixupModal />
</div>
)
}
diff --git a/src/hooks/__tests__/useCreate-version-gate-asks-in-every-lane.test.ts b/src/hooks/__tests__/useCreate-version-gate-asks-in-every-lane.test.ts
new file mode 100644
index 00000000..9b4dfb97
--- /dev/null
+++ b/src/hooks/__tests__/useCreate-version-gate-asks-in-every-lane.test.ts
@@ -0,0 +1,163 @@
+// @vitest-environment jsdom
+/**
+ * The box, 03.10.2026 (RTX 3060, ComfyUI 0.33.0): YuE2 in Music ended with
+ * "Generation failed: YuE2 needs ComfyUI 0.36.0 or newer. Update ComfyUI in
+ * Settings." while Image and Video ask once and update. The lanes with their
+ * own graph (Music, Talking Character, Motion Control) built outside the
+ * question. Every lane that can meet a version gate is driven here through the
+ * real generate path of useCreate: the build fails with the gate, the question
+ * appears, a yes updates and the same build runs again and reaches the submit.
+ *
+ * Character training is not in the table: it is the Rust trainer and never
+ * builds a ComfyUI graph. Using a trained character is the Character lane
+ * below. The prompt enhancer has its own run of this in
+ * useCreate-qwen-enhancer.test.ts, the agent's tool in vram-handoff.test.ts.
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+import { renderHook } from '@testing-library/react'
+
+const seen = vi.hoisted(() => ({
+ order: [] as string[],
+ gate: true,
+}))
+
+const GATE = 'YuE2 needs ComfyUI 0.36.0 or newer. Update ComfyUI in Settings.'
+
+vi.mock('../../api/mlx-image', () => ({
+ isMlxImageHost: () => false,
+ isMlxImageModel: () => false,
+ mlxStatus: vi.fn(async () => ({ installed: false })),
+ listMlxImageModels: vi.fn(async () => []),
+ buildMlxImageModels: vi.fn(() => []),
+ mergeImageModels: vi.fn((a: unknown[]) => a),
+ mlxModelIdFor: vi.fn(() => ''),
+ generateMlxImageDataUrl: vi.fn(),
+}))
+vi.mock('../../api/comfyui', async (orig) => ({
+ ...((await orig()) as Record<string, unknown>),
+ checkComfyConnection: vi.fn(async () => true),
+ uploadMediaFile: vi.fn(async (_blob: Blob, name: string) => name),
+ submitWorkflow: vi.fn(async () => { seen.order.push('submit'); throw new Error('stop here') }),
+}))
+vi.mock('../../api/comfyui-ws', () => ({
+ CLIENT_ID: 'lu-test',
+ comfyWS: { connect: vi.fn(async () => { throw new Error('no socket') }), mark: () => 0 },
+}))
+vi.mock('../../api/vram-handoff', async (orig) => ({
+ ...((await orig()) as Record<string, unknown>),
+ evictChatBackendsForRender: vi.fn(async () => null),
+ restoreChatBackendsAfterRender: vi.fn(),
+}))
+vi.mock('../../api/dynamic-workflow', async (orig) => {
+ const actual = (await orig()) as typeof import('../../api/dynamic-workflow')
+ // The first build meets the gate, the build after the update goes through.
+ const build = (name: string) => vi.fn(async () => {
+ seen.order.push(name)
+ if (seen.gate) throw new actual.WorkflowUnavailableError(GATE, 'unavailable', undefined, { needsComfyUpdate: true })
+ return { '1': { class_type: 'SaveImage', inputs: {} } }
+ })
+ return {
+ ...actual,
+ buildDynamicWorkflow: build('build'),
+ buildLocalOpWorkflow: build('build'),
+ checkVideoOutputCapability: vi.fn(async () => ({ mp4Capable: true, webpOnly: false, missingNodes: [] })),
+ }
+})
+// The real question, the real retry. Only the update itself is replaced: it
+// would run git and pip.
+vi.mock('../../api/render-fixup-deps', async (orig) => {
+ const actual = (await orig()) as typeof import('../../api/render-fixup-deps')
+ return {
+ renderFixupDeps: (...args: Parameters<typeof actual.renderFixupDeps>) => ({
+ ...actual.renderFixupDeps(...args),
+ updateComfy: async () => { seen.order.push('update'); seen.gate = false },
+ refresh: async () => { seen.order.push('refresh') },
+ }),
+ }
+})
+
+import { useCreate } from '../useCreate'
+import { useCreateStore } from '../../stores/createStore'
+import { classifyModel } from '../../api/comfyui'
+import type { CreateIntent } from '../../stores/createStore'
+
+const IMAGE = 'qwen_image_2.1_int8_convrot.safetensors'
+const VIDEO = 'wan2.2_ti2v_5B_fp16.safetensors'
+const MUSIC = 'yue2_3b_int8_convrot.safetensors'
+const LIPSYNC = 'wan2.2_s2v_14B_fp8_scaled.safetensors'
+const MOTION = 'wan2.2_animate_14B_fp8_scaled.safetensors'
+
+const picture = { filename: 'source.png', url: 'blob:source', width: 1024, height: 1024 }
+const media = (name: string) => ({ blob: new Blob(['x']), name, url: `blob:${name}` })
+const listed = (name: string) => [{ name, type: classifyModel(name) }]
+
+interface Lane {
+ lane: string
+ intent: CreateIntent
+ /** Applied after setIntent: the inputs this lane needs before it builds. */
+ inputs?: Record<string, unknown>
+}
+
+const LANES: Lane[] = [
+ { lane: 'Image', intent: 'image' },
+ { lane: 'Edit', intent: 'edit', inputs: { source: picture } },
+ { lane: 'Character (use a trained one)', intent: 'character', inputs: { characterTab: 'use' } },
+ { lane: 'Video', intent: 'video' },
+ { lane: 'Animate', intent: 'animate', inputs: { source: picture } },
+ { lane: 'Extend', intent: 'extend', inputs: { source: picture } },
+ { lane: 'Music', intent: 'music', inputs: { localOpModel: MUSIC, musicLyrics: '[Verse]\nSnow is falling' } },
+ { lane: 'Talking Character', intent: 'lipsync', inputs: { localOpModel: LIPSYNC, source: picture, audioInput: media('voice.wav') } },
+ { lane: 'Motion Control', intent: 'motion', inputs: { localOpModel: MOTION, source: picture, videoInput: media('dance.mp4') } },
+]
+
+beforeEach(() => {
+ seen.order.length = 0
+ seen.gate = true
+ // jsdom never loads media, so the voice length probe would wait for ever.
+ vi.stubGlobal('Audio', class {
+ onerror: (() => void) | null = null
+ set src(_value: string) { queueMicrotask(() => this.onerror?.()) }
+ })
+ if (!URL.createObjectURL) URL.createObjectURL = () => 'blob:probe'
+ if (!URL.revokeObjectURL) URL.revokeObjectURL = () => undefined
+ useCreateStore.setState({
+ backend: 'local', isGenerating: false, error: null, gallery: [], promptHistory: [], fixupPrompt: null,
+ improvePrompt: false, cloudOp: null, utilityOp: null, removebg: false, source: null, mask: null, references: [],
+ selectedLoras: [], hiresFixEnabled: false, transparentBackground: false, seed: 42, batchSources: [],
+ imageModel: IMAGE, imageModelList: listed(IMAGE),
+ videoModel: VIDEO, videoModelList: listed(VIDEO),
+ audioModelList: listed(MUSIC), lipsyncModelList: listed(LIPSYNC), motionModelList: listed(MOTION),
+ } as never)
+})
+
+function enter(lane: Lane) {
+ useCreateStore.getState().setIntent(lane.intent)
+ if (lane.inputs) useCreateStore.setState(lane.inputs as never)
+ useCreateStore.getState().setPrompt('acoustic folk, female vocal, slow')
+}
+
+describe.each(LANES)('a ComfyUI too old for the model, $lane', (lane) => {
+ it('asks once, updates on yes, builds again and starts the run', async () => {
+ enter(lane)
+ const { result } = renderHook(() => useCreate())
+ const done = result.current.generate()
+ await vi.waitFor(() => expect(useCreateStore.getState().fixupPrompt).not.toBeNull())
+ expect(useCreateStore.getState().fixupPrompt?.title).toBe('ComfyUI needs an update')
+ expect(seen.order).toEqual(['build'])
+ useCreateStore.getState().fixupPrompt?.resolve(true)
+ await done
+ expect(seen.order).toEqual(['build', 'update', 'refresh', 'build', 'submit'])
+ expect(useCreateStore.getState().fixupPrompt).toBeNull()
+ })
+
+ it('a no ends the run as not started, with the reason', async () => {
+ enter(lane)
+ const { result } = renderHook(() => useCreate())
+ const done = result.current.generate()
+ await vi.waitFor(() => expect(useCreateStore.getState().fixupPrompt).not.toBeNull())
+ useCreateStore.getState().fixupPrompt?.resolve(false)
+ await done
+ expect(seen.order).toEqual(['build'])
+ expect(useCreateStore.getState().error).toBe(`Not started. ${GATE}`)
+ })
+})
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index fe1cd16a..c3790de1 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -55,11 +55,9 @@ import { buildDynamicWorkflow, buildLocalOpWorkflow, checkVideoOutputCapability
import { getAllNodeInfo, clearNodeCache } from '../api/comfyui-nodes'
import { apiNodes, type ComfyApiGraph, type ComfyExecutionMessage, type ComfyHistoryEntry } from '../types/comfy-graph'
import { restartComfyForNewNodes } from '../api/comfy-restart'
-import { installCustomNodes, startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, comfyModelTarget, catalogDigestFor } from '../api/discover'
-import { downloadBundleFiles, waitForModelsVisible } from '../lib/bundle-install'
-import { buildWithFixups, wasDeclined, type FixupDeps } from '../lib/render-fixups'
-import { useDownloadStore } from '../stores/downloadStore'
-import { useComfyInstallStore } from '../stores/comfyInstallStore'
+import { installCustomNodes } from '../api/discover'
+import { buildWithFixups, wasDeclined } from '../lib/render-fixups'
+import { renderFixupDeps } from '../api/render-fixup-deps'
import { checkPromptSafety, SAFETY_BLOCK_MESSAGE } from '../lib/render/safety'
import { wantsTransparent } from '../lib/transparent-image'
import { scenePromptFor } from '../lib/ltx-multishot'
@@ -102,70 +100,6 @@ function historyMessages(entry: ComfyHistoryEntry | null): [string, ComfyExecuti
return Array.isArray(raw) ? raw : []
}
-/** The side effects lib/render-fixups.ts needs, wired to the app. */
-function renderFixupDeps(onStatus: (line: string) => void, signal?: AbortSignal): FixupDeps {
- const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))
- const refreshLists = async () => {
- await refreshComfyModels().catch(() => false)
- clearNodeCache()
- }
- return {
- ask: (prompt) => new Promise<boolean>((resolve) => {
- useCreateStore.getState().setFixupPrompt({
- ...prompt,
- resolve: (go) => { useCreateStore.getState().setFixupPrompt(null); resolve(go) },
- })
- }),
- download: async (files) => {
- const dl = useDownloadStore.getState()
- for (const f of files) dl.setMeta(f.downloadFilename, f.downloadUrl, f.subfolder)
- dl.startPolling()
- await downloadBundleFiles(
- files.map((f) => ({ filename: f.downloadFilename, subfolder: f.subfolder, downloadUrl: f.downloadUrl, sizeGB: f.sizeGB, sha256: catalogDigestFor(f.downloadFilename, f.downloadUrl).sha256 })),
- {
- start: startModelDownload,
- progress: getDownloadProgress,
- onStatus,
- keepTrayLive: () => useDownloadStore.getState().startPolling(),
- stop: (filename) => { void useDownloadStore.getState().cancel(filename) },
- signal,
- },
- )
- // A ComfyUI on another machine cannot list them before they are copied
- // over; buildWithFixups says so (GH #143).
- if ((await comfyModelTarget()).remote) return
- const wanted = files.map((f) => f.downloadFilename)
- const left = await waitForModelsVisible({ missing: () => modelsNotVisibleInComfy(wanted), refresh: refreshLists, onStatus, signal })
- if (left.length > 0) throw new Error(`Downloaded ${left.join(', ')}, but ComfyUI does not list ${left.length === 1 ? 'it' : 'them'} yet. Restart ComfyUI and hit Create again.`)
- },
- remote: async () => {
- const t = await comfyModelTarget()
- return t.remote && t.host && t.root ? { host: t.host, root: t.root } : null
- },
- updateComfy: async () => {
- onStatus('Updating ComfyUI…')
- await useComfyInstallStore.getState().runUpdate()
- for (;;) {
- await sleep(2000)
- const st = useComfyInstallStore.getState()
- if (st.phase === 'error') throw new Error(st.error || 'Updating ComfyUI did not finish.')
- if (st.phase === 'idle') break
- const last = st.logs[st.logs.length - 1]
- if (last) onStatus(String(last))
- }
- onStatus('Starting the updated ComfyUI…')
- await backendCall('start_comfyui').catch(() => undefined)
- for (let i = 0; i < 90; i++) {
- if (await checkComfyConnection()) return
- onStatus(`Starting the updated ComfyUI… ${i * 2}s`)
- await sleep(2000)
- }
- throw new Error('ComfyUI was updated but did not come back up. Start it from Settings and hit Create again.')
- },
- refresh: refreshLists,
- }
-}
-
export function useCreate() {
const [connected, setConnected] = useState<boolean | null>(null)
const [imageModels, setImageModels] = useState<ClassifiedModel[]>([])
@@ -1143,7 +1077,11 @@ export function useCreate() {
}
setProgress(5, 'Building workflow...')
const laneDefaults = COMFY_MODEL_DEFAULTS[imageModelType] ?? COMFY_MODEL_DEFAULTS.unknown
- workflow = await buildLocalOpWorkflow({
+ // The lanes carry the same version gate as a picture (YuE2, S2V,
+ // Animate): a too-old ComfyUI is offered the update, then the build
+ // runs again. The box, 03.10.2026: Music failed with the update
+ // sentence because this build never went through the question.
+ const laneParams = {
op: localOp,
model: activeModel,
prompt,
@@ -1161,7 +1099,11 @@ export function useCreate() {
audioFile,
refImage: source?.filename || undefined,
drivingVideo,
- })
+ }
+ workflow = await buildWithFixups(
+ () => buildLocalOpWorkflow(laneParams),
+ renderFixupDeps((line) => setProgress(5, line), abortRef.current?.signal),
+ )
builderUsed = 'dynamic'
}