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(models): a finished download waits for ComfyUI in the Model Manager too

purple9a4b01e3be59
diff --git a/src/api/discover.ts b/src/api/discover.ts
index b6d91070..9427929a 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -1,5 +1,5 @@
import { backendCall, fetchExternal } from "./backend"
-import { getCheckpoints, getDiffusionModels, getVAEModels, getCLIPModels, filterPartialFiles } from "./comfyui"
+import { getCheckpoints, getDiffusionModels, getVAEModels, getCLIPModels, getGgufUnetModels, filterPartialFiles } from "./comfyui"
import type { ProviderId } from "./providers/types"
import { log } from "../lib/logger"
@@ -207,6 +207,35 @@ export function normalizeModelBase(name: string): string {
.replace(/[-_](fp4|fp8|fp16|bf16|e4m3fn|scaled|fp8_e4m3fn_scaled)$/g, '')
}
+/** Which of `wanted` the RUNNING ComfyUI does not list yet.
+ *
+ * One function, because there are two journeys that end in the same place: a
+ * bundle installed from Create (CreateContext) and a download finished in the
+ * Model Manager (downloadStore). C8 gave the first one a wait and left the
+ * second with a single fetch, so the same slow directory scan that froze
+ * Voxyl AI's card on 2026-08-13 simply left a model out of the Installed tab
+ * instead. Two probes would have been two chances to drift.
+ *
+ * getGgufUnetModels belongs here for the same reason getImageModels needs it
+ * (comfyui.ts:658): UNETLoader only enumerates .safetensors and .sft, GGUF
+ * quants are listed by ComfyUI-GGUF's own loader. The default Talking
+ * Character bundle IS a .gguf in diffusion_models, so without it the probe
+ * can never succeed for that bundle.
+ *
+ * An engine it cannot reach reports everything as missing: an answer we could
+ * not get is not a file we have seen. */
+export async function modelsNotVisibleInComfy(wanted: string[]): Promise<string[]> {
+ try {
+ const lists = await Promise.all([
+ getCheckpoints(), getDiffusionModels(), getVAEModels(), getCLIPModels(), getGgufUnetModels(),
+ ])
+ 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
+ }
+}
+
/** #72: the backend used to resolve a failed `git pull` as
* `{status:"update_failed"}` instead of rejecting · anything but an
* installed/updated status must be treated as a failure, not success. */
diff --git a/src/components/create/experimental/CreateContext.tsx b/src/components/create/experimental/CreateContext.tsx
index a8525691..737ab659 100644
--- a/src/components/create/experimental/CreateContext.tsx
+++ b/src/components/create/experimental/CreateContext.tsx
@@ -3,9 +3,9 @@ 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, getCheckpoints, getDiffusionModels, getCLIPModels, getGgufUnetModels, checkComfyConnection, refreshComfyModels, bundleForVideoIntent } from '../../../api/comfyui'
+import { getLoraModels, getVAEModels, checkComfyConnection, refreshComfyModels, bundleForVideoIntent } from '../../../api/comfyui'
import { getAllNodeInfo, clearNodeCache } from '../../../api/comfyui-nodes'
-import { installCustomNodes, getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, startModelDownload, getDownloadProgress, normalizeModelBase, ENUM_SUBFOLDERS } from '../../../api/discover'
+import { installCustomNodes, getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, ENUM_SUBFOLDERS } from '../../../api/discover'
import { backendCall, isMacOS } from '../../../api/backend'
import { installMlxStack } from '../../../api/mlx-install'
import { useDownloadStore } from '../../../stores/downloadStore'
@@ -436,25 +436,10 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
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 {
- // getGgufUnetModels belongs here for the same reason getImageModels
- // needs it (comfyui.ts:658): UNETLoader only enumerates .safetensors
- // and .sft, GGUF quants are listed by ComfyUI-GGUF's own loader. The
- // default Talking Character bundle IS a .gguf in diffusion_models, so
- // without this the probe can never succeed: 20 rounds of waiting, an
- // uncalled-for engine restart in the middle of whatever the user was
- // rendering, and then an error blaming the model folder for a file
- // ComfyUI lists perfectly well.
- const lists = await Promise.all([
- getCheckpoints(), getDiffusionModels(), getVAEModels(), getCLIPModels(), getGgufUnetModels(),
- ])
- 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
- }
- }
+ // The probe itself lives in discover.ts, because the Model Manager
+ // download path needs exactly the same one and a second copy would be a
+ // second chance to drift (see modelsNotVisibleInComfy).
+ const stillMissing = () => modelsNotVisibleInComfy(wanted)
let missing = await waitForModelsVisible({
missing: stillMissing, refresh: refreshLists, onStatus: onProgress, signal,
})
diff --git a/src/lib/__tests__/model-visible-wait.test.ts b/src/lib/__tests__/model-visible-wait.test.ts
index 58932dc5..a7d8f103 100644
--- a/src/lib/__tests__/model-visible-wait.test.ts
+++ b/src/lib/__tests__/model-visible-wait.test.ts
@@ -92,6 +92,13 @@ describe('the install path uses it, and says something honest when it runs out',
resolve(dirname(fileURLToPath(import.meta.url)), '../../components/create/experimental/CreateContext.tsx'),
'utf8',
)
+ // The probe moved into discover.ts so the Model Manager download path can
+ // use the same one. These assertions moved with it: they exist to catch
+ // drift, which means they have to read the file that owns the code.
+ const discoverSrc = readFileSync(
+ resolve(dirname(fileURLToPath(import.meta.url)), '../../api/discover.ts'),
+ 'utf8',
+ )
it('the video bundle is picked by the lane rule, not by index', () => {
// The bug this pins: the installer took getVideoBundles()[0] whatever the
@@ -110,7 +117,7 @@ describe('the install path uses it, and says something honest when it runs out',
})
it('an engine it cannot reach counts as nothing confirmed', () => {
- expect(src).toMatch(/catch \{\s*\n\s*return wanted/)
+ expect(discoverSrc).toMatch(/catch \{\s*\n\s*return wanted/)
})
it('it restarts the engine once before giving up', () => {
@@ -142,9 +149,15 @@ describe('the install path uses it, and says something honest when it runs out',
// diffusion_models, which IS in ENUM_SUBFOLDERS. Without the GGUF loader
// the probe fails for a file ComfyUI lists perfectly well: 20 rounds of
// waiting, an uncalled-for engine restart, then a wrong diagnosis.
- const probe = src.slice(src.indexOf('const stillMissing'), src.indexOf('let missing'))
+ const probe = discoverSrc.slice(
+ discoverSrc.indexOf('export async function modelsNotVisibleInComfy'),
+ discoverSrc.indexOf('/** #72:'),
+ )
expect(probe).toContain('getGgufUnetModels()')
- expect(src).toMatch(/import \{[^}]*getGgufUnetModels[^}]*\} from '\.\.\/\.\.\/\.\.\/api\/comfyui'/)
+ expect(discoverSrc).toMatch(/import \{[^}]*getGgufUnetModels[^}]*\} from "\.\/comfyui"/)
+ // And the caller still runs it through the wait rather than once.
+ expect(src).toContain('missing: stillMissing, refresh: refreshLists')
+ expect(src).toContain('const stillMissing = () => modelsNotVisibleInComfy(wanted)')
})
it('the heal waits for a live render instead of killing it', () => {
diff --git a/src/stores/__tests__/download-visible-wait.test.ts b/src/stores/__tests__/download-visible-wait.test.ts
new file mode 100644
index 00000000..976557a3
--- /dev/null
+++ b/src/stores/__tests__/download-visible-wait.test.ts
@@ -0,0 +1,278 @@
+/**
+ * C8, the Model Manager half.
+ *
+ * A finished download is not a finished install. ComfyUI serves what its own
+ * directory scan has picked up, and on the big files that scan is still
+ * running when the last byte lands. Create learned to wait for that on
+ * 2026-08-13 (Voxyl AI with a screenshot, confirmed by Aldrich Ironhart) and
+ * the Model Manager path never did: the poller fired one event on the
+ * completion transition, useModels ran one fetch against a stale
+ * /object_info, and the model was simply absent from the Installed tab and
+ * every picker until the user reloaded by hand. Same slow scan, same too
+ * short window, quieter symptom.
+ *
+ * The probe both paths use now lives in discover.ts (modelsNotVisibleInComfy)
+ * so there is one of it, not two.
+ *
+ * Run: npx vitest run src/stores/__tests__/download-visible-wait.test.ts
+ */
+import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest'
+
+const getDownloadProgress = vi.fn(async () => ({}) as Record<string, unknown>)
+const modelsNotVisibleInComfy = vi.fn<(wanted: string[]) => Promise<string[]>>(async () => [])
+const lookupFileMeta = vi.fn<(filename: string) => { url: string; subfolder: string } | null>(() => null)
+const checkComfyConnection = vi.fn(async () => true)
+const refreshComfyModels = vi.fn(async () => true)
+
+vi.mock('../../api/discover', () => ({
+ getDownloadProgress: (...a: unknown[]) => getDownloadProgress(...(a as [])),
+ pauseDownload: vi.fn(async () => {}),
+ cancelDownload: vi.fn(async () => {}),
+ resumeDownload: vi.fn(async () => {}),
+ startModelDownload: vi.fn(async () => {}),
+ startModelDownloadToPath: vi.fn(async () => {}),
+ lookupFileMeta: (...a: unknown[]) => lookupFileMeta(...(a as [string])),
+ modelsNotVisibleInComfy: (...a: unknown[]) => modelsNotVisibleInComfy(...(a as [string[]])),
+ ENUM_SUBFOLDERS: new Set(['checkpoints', 'diffusion_models', 'vae', 'text_encoders']),
+}))
+
+vi.mock('../../api/comfyui', () => ({
+ checkComfyConnection: (...a: unknown[]) => checkComfyConnection(...(a as [])),
+ refreshComfyModels: (...a: unknown[]) => refreshComfyModels(...(a as [])),
+}))
+
+// The real loop, on a short clock. Sleeping the production 3 seconds twenty
+// times is the one thing here a test has no reason to reproduce; everything
+// else, including the attempt budget, is the shipped code.
+vi.mock('../../lib/bundle-install', async (importOriginal) => {
+ const real = await importOriginal<typeof import('../../lib/bundle-install')>()
+ return {
+ ...real,
+ waitForModelsVisible: (opts: Parameters<typeof real.waitForModelsVisible>[0]) =>
+ real.waitForModelsVisible({ ...opts, delayMs: 1 }),
+ }
+})
+
+type StoreModule = typeof import('../downloadStore')
+let useDownloadStore: StoreModule['useDownloadStore']
+let win: EventTarget
+
+beforeAll(async () => {
+ // vitest runs this suite in the node environment, and the store dispatches
+ // its "a model arrived" event on window. Give it one before the module is
+ // evaluated, because it registers listeners at import time.
+ win = new EventTarget()
+ ;(globalThis as unknown as { window: EventTarget }).window = win
+ ;({ useDownloadStore } = await import('../downloadStore'))
+})
+
+/** One finished download, exactly as the Rust progress map reports it. */
+function completed(filename: string) {
+ return { [filename]: { progress: 1, total: 1, speed: 0, filename, status: 'complete' } }
+}
+
+/** Every filename the store announced, in order. */
+function recordAnnouncements() {
+ const seen: Array<string | undefined> = []
+ const handler = (e: Event) => seen.push((e as CustomEvent<{ filename?: string }>).detail?.filename)
+ win.addEventListener('comfyui-model-downloaded', handler)
+ return { seen, stop: () => win.removeEventListener('comfyui-model-downloaded', handler) }
+}
+
+/** The announce loop is deliberately fire and forget, so a test has to wait
+ * for the thing it is asserting rather than for a fixed number of
+ * milliseconds. A 20 round budget on a 1 ms clock is still 20 awaits deep. */
+async function until(pred: () => boolean, budgetMs = 4000): Promise<void> {
+ const deadline = Date.now() + budgetMs
+ while (!pred() && Date.now() < deadline) await new Promise((r) => setTimeout(r, 5))
+ await new Promise((r) => setTimeout(r, 10))
+}
+
+/** Wait until no further round happens. Used to stop one test's loop from
+ * running inside the next one, which is the only way these can interfere. */
+async function quiet(): Promise<void> {
+ let last = -1
+ for (let i = 0; i < 400 && refreshComfyModels.mock.calls.length !== last; i++) {
+ last = refreshComfyModels.mock.calls.length
+ await new Promise((r) => setTimeout(r, 10))
+ }
+}
+
+const settle = () => new Promise((r) => setTimeout(r, 60))
+
+function seed(filename: string, subfolder: string) {
+ useDownloadStore.setState({
+ downloads: {},
+ downloadMeta: { [filename]: { url: 'https://example.test/m', subfolder } },
+ })
+}
+
+describe('a finished download waits for ComfyUI to list it, in the Model Manager too', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ checkComfyConnection.mockResolvedValue(true)
+ refreshComfyModels.mockResolvedValue(true)
+ lookupFileMeta.mockReturnValue(null)
+ useDownloadStore.getState().stopPolling()
+ useDownloadStore.setState({ downloads: {}, downloadMeta: {} })
+ })
+
+ afterEach(async () => {
+ // Whatever a test left in flight, let it see a visible file and stop.
+ modelsNotVisibleInComfy.mockResolvedValue([])
+ await quiet()
+ })
+
+ it('the event says which file arrived', async () => {
+ // Nothing downstream could wait for a specific model before, because the
+ // event carried no detail at all.
+ modelsNotVisibleInComfy.mockResolvedValue([])
+ getDownloadProgress.mockResolvedValue(completed('sdxl.safetensors'))
+ seed('sdxl.safetensors', 'checkpoints')
+ const rec = recordAnnouncements()
+
+ await useDownloadStore.getState().refresh()
+ await settle()
+ rec.stop()
+
+ expect(rec.seen).toEqual(['sdxl.safetensors'])
+ })
+
+ it('it keeps announcing until ComfyUI lists the file', async () => {
+ // Three rounds of scan, which is what a 12 GB video bundle looks like.
+ let rounds = 0
+ modelsNotVisibleInComfy.mockImplementation(async () =>
+ ++rounds >= 3 ? [] : ['wan2.2_s2v_14B_fp8.safetensors'],
+ )
+ getDownloadProgress.mockResolvedValue(completed('wan2.2_s2v_14B_fp8.safetensors'))
+ seed('wan2.2_s2v_14B_fp8.safetensors', 'diffusion_models')
+ const rec = recordAnnouncements()
+
+ await useDownloadStore.getState().refresh()
+ await until(() => rounds >= 3)
+ rec.stop()
+
+ // One on the completion transition plus one per round that rescanned.
+ expect(rec.seen).toEqual([
+ 'wan2.2_s2v_14B_fp8.safetensors',
+ 'wan2.2_s2v_14B_fp8.safetensors',
+ 'wan2.2_s2v_14B_fp8.safetensors',
+ ])
+ expect(refreshComfyModels).toHaveBeenCalledTimes(2)
+ })
+
+ it('NEGATIVE CONTROL: the one event the old path sent arrives too early', async () => {
+ // A listener shaped like useModels: it refetches ComfyUI every time the
+ // event lands. ComfyUI's own scan finishes on the second rescan here. The
+ // FIRST event is all the old code ever sent, and the list it hands that
+ // listener does not have the file in it, so a path that stops there ends
+ // with the model missing from the Installed tab and every picker. The
+ // later announcements are the fix, and the last one carries the model.
+ const FILE = 'wan2.2_s2v_14B_fp8.safetensors'
+ let scanDone = false
+ let rescans = 0
+ refreshComfyModels.mockImplementation(async () => {
+ if (++rescans >= 2) scanDone = true
+ return true
+ })
+ modelsNotVisibleInComfy.mockImplementation(async () => (scanDone ? [] : [FILE]))
+ getDownloadProgress.mockResolvedValue(completed(FILE))
+ seed(FILE, 'diffusion_models')
+
+ // What ComfyUI would answer that listener at the moment it refetches.
+ const listAtRefetch: string[][] = []
+ const handler = () => listAtRefetch.push(scanDone ? [FILE] : [])
+ win.addEventListener('comfyui-model-downloaded', handler)
+ await useDownloadStore.getState().refresh()
+ await until(() => scanDone)
+ win.removeEventListener('comfyui-model-downloaded', handler)
+
+ expect(listAtRefetch[0]).toEqual([])
+ expect(listAtRefetch[listAtRefetch.length - 1]).toEqual([FILE])
+ })
+
+ it('gives up after the budget instead of asking ComfyUI forever', async () => {
+ modelsNotVisibleInComfy.mockResolvedValue(['ghost.safetensors'])
+ getDownloadProgress.mockResolvedValue(completed('ghost.safetensors'))
+ seed('ghost.safetensors', 'vae')
+ const rec = recordAnnouncements()
+
+ await useDownloadStore.getState().refresh()
+ await until(() => refreshComfyModels.mock.calls.length >= 20)
+ rec.stop()
+
+ // waitForModelsVisible's own default budget, unchanged by this caller, and
+ // it stops there rather than polling a stuck engine for good.
+ expect(refreshComfyModels).toHaveBeenCalledTimes(20)
+ expect(rec.seen).toHaveLength(21)
+ })
+
+ it('a subfolder ComfyUI never enumerates is not waited on at all', async () => {
+ // loras, upscale models and the GGUF text downloads do not appear in the
+ // enums the probe reads, so waiting on one would be a minute of certain
+ // failure. The single event still fires, exactly as before.
+ modelsNotVisibleInComfy.mockResolvedValue([])
+ getDownloadProgress.mockResolvedValue(completed('mychar.safetensors'))
+ seed('mychar.safetensors', 'loras')
+ const rec = recordAnnouncements()
+
+ await useDownloadStore.getState().refresh()
+ await settle()
+ rec.stop()
+
+ expect(rec.seen).toEqual(['mychar.safetensors'])
+ expect(checkComfyConnection).not.toHaveBeenCalled()
+ expect(modelsNotVisibleInComfy).not.toHaveBeenCalled()
+ })
+
+ it('an engine that is not running costs one probe, not the whole budget', async () => {
+ checkComfyConnection.mockResolvedValue(false)
+ getDownloadProgress.mockResolvedValue(completed('sdxl.safetensors'))
+ seed('sdxl.safetensors', 'checkpoints')
+ const rec = recordAnnouncements()
+
+ await useDownloadStore.getState().refresh()
+ await settle()
+ rec.stop()
+
+ expect(rec.seen).toEqual(['sdxl.safetensors'])
+ expect(modelsNotVisibleInComfy).not.toHaveBeenCalled()
+ expect(refreshComfyModels).not.toHaveBeenCalled()
+ })
+
+ it('a file that lands twice does not stack two waits', async () => {
+ // dismiss() drops the row, so the next poll reads the completion as new
+ // again. Without the guard that starts a second full wait on top of the
+ // first, and the poller ticks once a second.
+ let release!: () => void
+ const gate = new Promise<void>((r) => { release = r })
+ modelsNotVisibleInComfy.mockImplementation(async () => { await gate; return [] })
+ getDownloadProgress.mockResolvedValue(completed('sdxl.safetensors'))
+ seed('sdxl.safetensors', 'checkpoints')
+
+ await useDownloadStore.getState().refresh()
+ // Same completion read as new, while the first wait is still in flight.
+ useDownloadStore.setState({ downloads: {} })
+ await useDownloadStore.getState().refresh()
+ release()
+ await settle()
+
+ expect(modelsNotVisibleInComfy).toHaveBeenCalledTimes(1)
+ })
+
+ it('a download with no stored meta falls back to the bundle lookup', async () => {
+ // A download restored from a previous session has no downloadMeta entry,
+ // and without the fallback its subfolder is unknown and the wait is
+ // skipped for a file that very much needs it.
+ modelsNotVisibleInComfy.mockResolvedValue([])
+ lookupFileMeta.mockReturnValue({ url: 'https://example.test/m', subfolder: 'checkpoints' })
+ getDownloadProgress.mockResolvedValue(completed('restored.safetensors'))
+ useDownloadStore.setState({ downloads: {}, downloadMeta: {} })
+
+ await useDownloadStore.getState().refresh()
+ await settle()
+
+ expect(lookupFileMeta).toHaveBeenCalledWith('restored.safetensors')
+ expect(modelsNotVisibleInComfy).toHaveBeenCalledWith(['restored.safetensors'])
+ })
+})
diff --git a/src/stores/downloadStore.ts b/src/stores/downloadStore.ts
index 5d102391..eda7d9c3 100644
--- a/src/stores/downloadStore.ts
+++ b/src/stores/downloadStore.ts
@@ -1,7 +1,60 @@
import { create } from 'zustand'
-import { getDownloadProgress, pauseDownload, cancelDownload, resumeDownload, startModelDownload, startModelDownloadToPath, lookupFileMeta, type DownloadProgress } from '../api/discover'
+import { getDownloadProgress, pauseDownload, cancelDownload, resumeDownload, startModelDownload, startModelDownloadToPath, lookupFileMeta, modelsNotVisibleInComfy, ENUM_SUBFOLDERS, type DownloadProgress } from '../api/discover'
+import { waitForModelsVisible } from '../lib/bundle-install'
import { log } from '../lib/logger'
+/** Files whose visibility wait is already running. The poller ticks once a
+ * second and a wait lives for up to a minute, so without this the same file
+ * would start a fresh wait on every tick. */
+const awaitingVisibility = new Set<string>()
+
+/** Tell everyone a model arrived, and keep telling them until ComfyUI can
+ * actually see it.
+ *
+ * The Model Manager half of C8. A finished download is not a finished
+ * install: ComfyUI serves what its own directory scan has picked up, and on
+ * the big files that scan is still running when the last byte lands. Create
+ * learned to wait for that on 2026-08-13 (Voxyl AI, Aldrich Ironhart). This
+ * path never did. It fired one event, useModels ran one fetch against a
+ * stale /object_info, and the model was simply absent from the Installed tab
+ * and every picker until the user reloaded by hand. Same slow scan, same too
+ * short window, quieter symptom.
+ *
+ * Deliberately NOT the healing engine restart Create does. That decision
+ * belongs to a surface that knows whether a render is in flight; a background
+ * poller must never stop the engine under somebody's job.
+ *
+ * Best effort throughout: a file we cannot judge, an engine that is not up
+ * and a probe that throws all leave the single event that was already there. */
+async function announceUntilVisible(filename: string, subfolder: string | undefined): Promise<void> {
+ // Only the enumerated subfolders can be judged at all. loras, upscale models
+ // and the GGUF text downloads never show up in these lists, so waiting on
+ // them would be a minute of certain failure.
+ if (!subfolder || !ENUM_SUBFOLDERS.has(subfolder)) return
+ if (awaitingVisibility.has(filename)) return
+ awaitingVisibility.add(filename)
+ try {
+ const { checkComfyConnection, refreshComfyModels } = await import('../api/comfyui')
+ // One cheap probe first: with the engine down the wait would spend its
+ // whole budget on requests that cannot be answered.
+ if (!(await checkComfyConnection())) return
+ const left = await waitForModelsVisible({
+ missing: () => modelsNotVisibleInComfy([filename]),
+ refresh: async () => {
+ await refreshComfyModels().catch(() => false)
+ window.dispatchEvent(new CustomEvent('comfyui-model-downloaded', { detail: { filename } }))
+ },
+ })
+ if (left.length > 0) {
+ log.warn('[downloads] ComfyUI still does not list the finished download', { filename })
+ }
+ } catch (err) {
+ log.warn('[downloads] visibility wait failed', { filename, err })
+ } finally {
+ awaitingVisibility.delete(filename)
+ }
+}
+
// Maps filename → bundle name for grouped display
type BundleMap = Record<string, string>
@@ -53,10 +106,16 @@ export const useDownloadStore = create<DownloadStoreState>()((set, get) => ({
const prog = await getDownloadProgress()
const prev = get().downloads
- // Detect newly completed downloads and dispatch event
+ // Detect newly completed downloads and dispatch event. The filename
+ // rides along now so a listener can tell WHICH model arrived; every
+ // existing listener ignores the detail, so nothing had to change.
for (const [id, d] of Object.entries(prog)) {
if (d.status === 'complete' && prev[id]?.status !== 'complete') {
- window.dispatchEvent(new CustomEvent('comfyui-model-downloaded'))
+ window.dispatchEvent(new CustomEvent('comfyui-model-downloaded', { detail: { filename: id } }))
+ // And then keep saying it until ComfyUI lists the file, because one
+ // event against a scan that has not finished reaches nobody.
+ const meta = get().downloadMeta[id] ?? lookupFileMeta(id) ?? undefined
+ void announceUntilVisible(id, meta?.subfolder)
}
}