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): a finished download waits for ComfyUI to actually list it

purple6ab6eb5a448b
diff --git a/src/api/discover.ts b/src/api/discover.ts
index f5be3074..b9e44f70 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -195,7 +195,7 @@ export async function checkBundlesInstalled(bundles: ModelBundle[]): Promise<Rec
/** Subfolders whose contents ComfyUI enumerates via object_info — the only
* ones the visibility check can reason about (loras/upscale etc. stay on the
* pure size check). */
-const ENUM_SUBFOLDERS = new Set(['checkpoints', 'diffusion_models', 'vae', 'text_encoders'])
+export const ENUM_SUBFOLDERS = new Set(['checkpoints', 'diffusion_models', 'vae', 'text_encoders'])
/** Base identity of a model file: basename only (ComfyUI enums can carry
* nested-subdir prefixes), lowercase, extension and common quant suffixes
diff --git a/src/components/create/experimental/CreateContext.tsx b/src/components/create/experimental/CreateContext.tsx
index babe3166..ea66b491 100644
--- a/src/components/create/experimental/CreateContext.tsx
+++ b/src/components/create/experimental/CreateContext.tsx
@@ -3,13 +3,13 @@ import { useCreate } from '../../../hooks/useCreate'
import { useCloudCreate, hasActiveCloudRun } from '../../../hooks/useCloudCreate'
import { useCloudSession } from '../../../hooks/useCloudSession'
import { useCreateStore, type GalleryItem } from '../../../stores/createStore'
-import { getLoraModels, getVAEModels, checkComfyConnection, refreshComfyModels } from '../../../api/comfyui'
+import { getLoraModels, getVAEModels, getCheckpoints, getDiffusionModels, getCLIPModels, checkComfyConnection, refreshComfyModels } from '../../../api/comfyui'
import { getAllNodeInfo, clearNodeCache } from '../../../api/comfyui-nodes'
-import { installCustomNodes, getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, startModelDownload, getDownloadProgress } from '../../../api/discover'
+import { installCustomNodes, getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, startModelDownload, getDownloadProgress, normalizeModelBase, ENUM_SUBFOLDERS } from '../../../api/discover'
import { backendCall, isMacOS } from '../../../api/backend'
import { installMlxStack } from '../../../api/mlx-install'
import { useDownloadStore } from '../../../stores/downloadStore'
-import { downloadBundleFiles, waitOrAbort } from '../../../lib/bundle-install'
+import { downloadBundleFiles, waitOrAbort, waitForModelsVisible } from '../../../lib/bundle-install'
import { ensureLocalFilename } from './loadImage'
import { comfyStartupError } from './comfyError'
import type { CloudQuota } from '../../../lib/render/cloud-jobs'
@@ -369,9 +369,52 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
},
)
onProgress?.('Refreshing the model list…')
- await refreshComfyModels().catch(() => false)
- clearNodeCache()
- await fetchModels()
+ const refreshLists = async () => {
+ await refreshComfyModels().catch(() => false)
+ clearNodeCache()
+ await fetchModels()
+ }
+ await refreshLists()
+
+ // A finished download is not a finished install. ComfyUI only offers what
+ // its own directory scan has picked up, and on the big video bundles that
+ // scan is still running when the last byte lands. Without this the card
+ // stayed on "Refreshing the model list…" forever (C8, Voxyl AI and Aldrich
+ // Ironhart 2026-08-13): the install returned happy, and Stage keeps the
+ // card up until the lists refill.
+ const enumFiles = files.filter((f) => ENUM_SUBFOLDERS.has(f.subfolder!))
+ if (enumFiles.length > 0) {
+ const wanted = enumFiles.map((f) => f.filename!)
+ const stillMissing = async (): Promise<string[]> => {
+ try {
+ const lists = await Promise.all([getCheckpoints(), getDiffusionModels(), getVAEModels(), getCLIPModels()])
+ const visible = new Set(lists.flat().map(normalizeModelBase))
+ return wanted.filter((n) => !visible.has(normalizeModelBase(n)))
+ } catch {
+ return wanted // engine unreachable, so it has confirmed nothing
+ }
+ }
+ let missing = await waitForModelsVisible({
+ missing: stillMissing, refresh: refreshLists, onStatus: onProgress, signal,
+ })
+ if (missing.length > 0) {
+ // Heal before complaining: a restart rebuilds the model index for
+ // certain, and it is the same move that registers a new node pack.
+ onProgress?.('Restarting ComfyUI so it picks up the new files…')
+ await restartComfyForNewNodes().catch(() => { /* diagnosed below */ })
+ missing = await waitForModelsVisible({
+ missing: stillMissing, refresh: refreshLists, onStatus: onProgress, signal, attempts: 10,
+ })
+ }
+ if (missing.length > 0) {
+ throw new Error(
+ `The files downloaded fine, but ComfyUI still does not list ${missing.join(', ')}. ` +
+ 'Either it is reading a different model folder than LU writes to, or it was started ' +
+ 'outside LU and cannot be restarted from here. The Model Manager shows where the ' +
+ 'files landed.',
+ )
+ }
+ }
}, [ensureComfyRunning, fetchModels])
const value: CreateExpValue = {
diff --git a/src/lib/__tests__/model-visible-wait.test.ts b/src/lib/__tests__/model-visible-wait.test.ts
new file mode 100644
index 00000000..d8ff0de9
--- /dev/null
+++ b/src/lib/__tests__/model-visible-wait.test.ts
@@ -0,0 +1,126 @@
+/**
+ * A finished download is not a finished install.
+ *
+ * Voxyl AI, Discord #general 2026-08-13 17:00 UTC with a screenshot, confirmed
+ * five minutes later by Aldrich Ironhart: on Extend Video and Animate Image the
+ * Download and install button runs to the end and then sits on "Refreshing the
+ * model list…" for good. Both have ComfyUI.
+ *
+ * Nothing was hanging. installModelBundle refreshed the list once, returned
+ * happy, and Stage keeps the install card up until the model lists actually
+ * refill. ComfyUI's directory scan was still running, so the lists came back
+ * without the new file. That is not an error, which is why the retry loop in
+ * useCreate (guarded on modelLoadError) never engaged either. Two dead ends
+ * meeting at one frozen line of text. Image bundles fit through the old window
+ * because they are a fraction of the size.
+ *
+ * This file covers the loop that was missing. The engine-facing half is
+ * asserted at the source level below, the same way the codex gate test does it:
+ * a React context around a live ComfyUI is not what should be mocked here.
+ *
+ * Run: npx vitest run src/lib/__tests__/model-visible-wait.test.ts
+ */
+import { describe, it, expect, vi } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve } from 'node:path'
+import { waitForModelsVisible, InstallCancelled } from '../bundle-install'
+
+const WANTED = ['wan2.2_s2v_14B_fp8.safetensors', 'wav2vec2_large_english.safetensors']
+
+/** A ComfyUI whose scan finishes after `rounds` refreshes. */
+function engine(rounds: number, missing = WANTED) {
+ let seen = 0
+ return {
+ refresh: vi.fn(async () => { seen++ }),
+ missing: vi.fn(async () => (seen >= rounds ? [] : missing)),
+ }
+}
+
+describe('waiting for ComfyUI to list what was just downloaded', () => {
+ it('returns at once when the files are already there', async () => {
+ const e = engine(0)
+ const left = await waitForModelsVisible({ missing: e.missing, refresh: e.refresh, delayMs: 1 })
+ expect(left).toEqual([])
+ expect(e.refresh).not.toHaveBeenCalled()
+ })
+
+ it('keeps refreshing until the scan catches up', async () => {
+ const e = engine(3)
+ const left = await waitForModelsVisible({ missing: e.missing, refresh: e.refresh, delayMs: 1 })
+ expect(left).toEqual([])
+ expect(e.refresh).toHaveBeenCalledTimes(3)
+ })
+
+ it('gives up after the attempt budget instead of spinning forever', async () => {
+ const e = engine(999)
+ const left = await waitForModelsVisible({ missing: e.missing, refresh: e.refresh, delayMs: 1, attempts: 4 })
+ expect(left).toEqual(WANTED)
+ expect(e.refresh).toHaveBeenCalledTimes(4)
+ })
+
+ it('reports only what is still missing, not the whole bundle', async () => {
+ const e = engine(999, [WANTED[1]])
+ const left = await waitForModelsVisible({ missing: e.missing, refresh: e.refresh, delayMs: 1, attempts: 2 })
+ expect(left).toEqual([WANTED[1]])
+ })
+
+ it('the status line counts up, which is the whole point of the fix', async () => {
+ // The bug the user saw was a line of text that never changed again. A
+ // wait that says nothing is indistinguishable from a hang.
+ const e = engine(3)
+ const seen: string[] = []
+ await waitForModelsVisible({ missing: e.missing, refresh: e.refresh, delayMs: 1000, onStatus: (m) => seen.push(m) })
+ expect(seen).toEqual([
+ 'Waiting for ComfyUI to list the new files… 0s',
+ 'Waiting for ComfyUI to list the new files… 1s',
+ 'Waiting for ComfyUI to list the new files… 2s',
+ ])
+ })
+
+ it('cancel gets out of the wait, it does not have to sit out the timer', async () => {
+ const e = engine(999)
+ const ac = new AbortController()
+ const p = waitForModelsVisible({ missing: e.missing, refresh: e.refresh, delayMs: 60_000, signal: ac.signal })
+ ac.abort()
+ await expect(p).rejects.toBeInstanceOf(InstallCancelled)
+ })
+})
+
+describe('the install path uses it, and says something honest when it runs out', () => {
+ const src = readFileSync(
+ resolve(dirname(fileURLToPath(import.meta.url)), '../../components/create/experimental/CreateContext.tsx'),
+ 'utf8',
+ )
+
+ it('only the subfolders ComfyUI enumerates are checked', () => {
+ // loras and upscale models never show up in these enums, so demanding
+ // them would turn every install into a failure.
+ expect(src).toMatch(/files\.filter\(\(f\) => ENUM_SUBFOLDERS\.has\(f\.subfolder!\)\)/)
+ })
+
+ it('an engine it cannot reach counts as nothing confirmed', () => {
+ expect(src).toMatch(/catch \{\s*\n\s*return wanted/)
+ })
+
+ it('it restarts the engine once before giving up', () => {
+ // Self-heal before complaining: a restart rebuilds the model index for
+ // certain. The old code had no second move at all.
+ const wait = src.indexOf('waitForModelsVisible')
+ const restart = src.indexOf('Restarting ComfyUI so it picks up the new files')
+ const give = src.indexOf('but ComfyUI still does not list')
+ expect(wait).toBeGreaterThan(-1)
+ expect(restart).toBeGreaterThan(wait)
+ expect(give).toBeGreaterThan(restart)
+ })
+
+ it('the last word is a thrown error, so the card turns red instead of freezing', () => {
+ expect(src).toMatch(/throw new Error\(\s*\n\s*`The files downloaded fine, but ComfyUI still does not list/)
+ })
+
+ it('the error names the two things that actually cause it', () => {
+ expect(src).toContain('reading a different model folder')
+ expect(src).toContain('started ')
+ expect(src).toContain('outside LU')
+ })
+})
diff --git a/src/lib/bundle-install.ts b/src/lib/bundle-install.ts
index c46a7e1f..121a1f8e 100644
--- a/src/lib/bundle-install.ts
+++ b/src/lib/bundle-install.ts
@@ -206,3 +206,43 @@ export async function downloadBundleFiles(files: BundleFile[], deps: DownloadDep
}
}
}
+
+/**
+ * Wait until the running ComfyUI actually LISTS the files that were just
+ * downloaded, and report what is still missing when it does not.
+ *
+ * Voxyl AI and Aldrich Ironhart, Discord 2026-08-13, both on Extend Video and
+ * Animate Image: the download runs to the end and the card then sits on
+ * "Refreshing the model list…" for good. Nothing was hanging. The install
+ * refreshed once, called itself done, and left the card on its last status
+ * line, because the card only disappears when the model lists refill and
+ * ComfyUI had not finished its directory scan yet. A fetch that succeeds but
+ * simply does not contain the new model is not an error either, so the retry
+ * loop in useCreate never engaged: two dead ends meeting at a frozen line of
+ * text. Image bundles fit through the old window because they are a fraction
+ * of the size; the two lanes that broke carry the biggest files we ship.
+ *
+ * This knows nothing about ComfyUI on purpose. The caller says what is still
+ * missing and how to refresh, which keeps every branch testable without a live
+ * engine. `missing` must report everything as missing when it cannot reach the
+ * engine at all: an answer we could not get is not a file we have seen.
+ */
+export async function waitForModelsVisible(opts: {
+ missing: () => Promise<string[]>
+ refresh: () => Promise<unknown>
+ onStatus?: (msg: string) => void
+ signal?: AbortSignal
+ attempts?: number
+ delayMs?: number
+}): Promise<string[]> {
+ const { missing, refresh, onStatus, signal, attempts = 20, delayMs = 3000 } = opts
+ let left = await missing()
+ const step = Math.max(1, Math.round(delayMs / 1000))
+ for (let i = 0; left.length > 0 && i < attempts; i++) {
+ onStatus?.(`Waiting for ComfyUI to list the new files… ${i * step}s`)
+ await waitOrAbort(delayMs, signal)
+ await refresh()
+ left = await missing()
+ }
+ return left
+}