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 bundle card reads its own downloads, not its neighbours

purple6abf5701ea5a
diff --git a/src/api/__tests__/bundles-installed-gguf.test.ts b/src/api/__tests__/bundles-installed-gguf.test.ts
new file mode 100644
index 00000000..a246103c
--- /dev/null
+++ b/src/api/__tests__/bundles-installed-gguf.test.ts
@@ -0,0 +1,85 @@
+/**
+ * GH #113, second half: the installed check has to know the GGUF loader.
+ *
+ * checkBundlesInstalled confirms its disk verdict against the running
+ * ComfyUI, so a bundle that sits in a folder ComfyUI does not read cannot
+ * claim to be installed (pnwpdr4519). It built that visible-set from
+ * checkpoints, diffusion_models, vae and text_encoders, and UNETLoader only
+ * enumerates .safetensors and .sft. GGUF quants are listed by ComfyUI-GGUF's
+ * own loader, which the Create probe learned in b8531b6 and this one did not.
+ *
+ * Both Unfiltered video bundles are GGUF (NSFW Wan 14B, Wan 2.2 Rapid AIO),
+ * which is the "unfiltered models doesn't shown as installed" in the title.
+ *
+ * Run: npx vitest run src/api/__tests__/bundles-installed-gguf.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+const backendCall = vi.fn<(cmd: string, args?: unknown) => Promise<unknown>>()
+const ggufUnets = vi.fn<() => Promise<string[]>>(async () => [])
+
+vi.mock('../backend', () => ({
+ backendCall: (...a: unknown[]) => backendCall(...(a as [string, unknown])),
+ fetchExternal: vi.fn(),
+}))
+
+vi.mock('../comfyui', () => ({
+ // The engine lists nothing through the four loaders this check used to ask.
+ getCheckpoints: async () => [],
+ getDiffusionModels: async () => [],
+ getVAEModels: async () => [],
+ getCLIPModels: async () => [],
+ getGgufUnetModels: () => ggufUnets(),
+ filterPartialFiles: async (names: string[]) => new Set(names),
+}))
+
+import { checkBundlesInstalled } from '../discover'
+import type { ModelBundle } from '../discover'
+
+const GGUF_BUNDLE = {
+ name: 'Wan 2.2 Rapid AIO (Uncensored I2V, GGUF)',
+ description: '',
+ tags: [],
+ totalSizeGB: 16.6,
+ vramRequired: '10-12 GB',
+ files: [
+ {
+ name: '', description: '', pulls: '', tags: [], updated: '',
+ filename: 'wan2.2-i2v-rapid-aio-v10-nsfw-Q4_K_M.gguf',
+ subfolder: 'diffusion_models', sizeGB: 10.1,
+ },
+ ],
+} as unknown as ModelBundle
+
+describe('a GGUF bundle on disk is confirmed against the loader that lists it', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ // The disk says every file is there at full size.
+ backendCall.mockResolvedValue([
+ { filename: 'wan2.2-i2v-rapid-aio-v10-nsfw-Q4_K_M.gguf', exists: true, actualBytes: 1, complete: true },
+ ])
+ })
+
+ it('counts as installed when ComfyUI-GGUF lists the quant', async () => {
+ ggufUnets.mockResolvedValue(['wan2.2-i2v-rapid-aio-v10-nsfw-Q4_K_M.gguf'])
+ const out = await checkBundlesInstalled([GGUF_BUNDLE])
+ expect(out[GGUF_BUNDLE.name]).toBe(true)
+ })
+
+ it('NEGATIVE CONTROL: a file no loader lists is still not installed', async () => {
+ // Same disk answer, same engine, only the GGUF loader silent as well.
+ // This one is green before and after on purpose: it pins that the fix
+ // taught the check a fifth list rather than weakening the gate. The
+ // pnwpdr4519 case, a model folder ComfyUI does not read, must still be
+ // caught. The test above is the one that was red before the fix.
+ ggufUnets.mockResolvedValue([])
+ const out = await checkBundlesInstalled([GGUF_BUNDLE])
+ expect(out[GGUF_BUNDLE.name]).toBe(false)
+ })
+
+ it('the GGUF loader is asked once, not per bundle', async () => {
+ ggufUnets.mockResolvedValue(['wan2.2-i2v-rapid-aio-v10-nsfw-Q4_K_M.gguf'])
+ await checkBundlesInstalled([GGUF_BUNDLE, { ...GGUF_BUNDLE, name: 'second' } as ModelBundle])
+ expect(ggufUnets).toHaveBeenCalledTimes(1)
+ })
+})
diff --git a/src/api/discover.ts b/src/api/discover.ts
index 9427929a..1e478426 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -137,16 +137,27 @@ export async function checkBundlesInstalled(bundles: ModelBundle[]): Promise<Rec
// file check_model_sizes confirms is partial before matching.
let comfyLists: Record<string, string[]> | null = null
try {
- const [rawCheckpoints, rawDiffModels, rawVaes, rawClips] = await Promise.all([
- getCheckpoints(), getDiffusionModels(), getVAEModels(), getCLIPModels(),
+ // getGgufUnetModels for the same reason the Create probe needs it
+ // (b8531b6): UNETLoader only enumerates .safetensors and .sft, and GGUF
+ // quants are listed by ComfyUI-GGUF's own loader. Both Unfiltered video
+ // bundles are GGUF, so without it this cannot see the one file that makes
+ // them what they are, and the fuzzy fallback below can never confirm them.
+ const [rawCheckpoints, rawDiffModels, rawGgufUnets, rawVaes, rawClips] = await Promise.all([
+ getCheckpoints(), getDiffusionModels(), getGgufUnetModels(), getVAEModels(), getCLIPModels(),
])
- const [checkpoints, diffModels, vaes, clips] = await Promise.all([
+ const [checkpoints, diffModels, ggufUnets, vaes, clips] = await Promise.all([
filterPartialFiles(rawCheckpoints).then(s => Array.from(s)),
filterPartialFiles(rawDiffModels).then(s => Array.from(s)),
+ filterPartialFiles(rawGgufUnets).then(s => Array.from(s)),
filterPartialFiles(rawVaes).then(s => Array.from(s)),
filterPartialFiles(rawClips).then(s => Array.from(s)),
])
- comfyLists = { checkpoints, diffusion_models: diffModels, vae: vaes, text_encoders: clips }
+ comfyLists = {
+ checkpoints,
+ diffusion_models: [...diffModels, ...ggufUnets],
+ vae: vaes,
+ text_encoders: clips,
+ }
} catch {
comfyLists = null // ComfyUI not reachable · size-check verdicts stand
}
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsx
index 49140896..1ee3d563 100644
--- a/src/components/models/DiscoverModels.tsx
+++ b/src/components/models/DiscoverModels.tsx
@@ -1,4 +1,5 @@
import { useState, useEffect } from 'react'
+import { bundleIsComplete, bundleIsDownloading, bundleHasErrors } from '../../lib/bundle-state'
import { motion } from 'framer-motion'
import { Search, XCircle, Loader2, Sparkles, Unlock, ShieldCheck, ExternalLink, Download, CheckCircle } from 'lucide-react'
import { X } from 'lucide-react'
@@ -320,34 +321,17 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
dlStore.getState().startPolling()
}
- const isBundleComplete = (bundle: ModelBundle): boolean => {
- // If any file has error status, bundle is NOT complete
- const hasError = bundle.files.some(f => f.filename && downloads[f.filename]?.status === 'error')
- if (hasError) return false
- // Check 1: Download store says all files complete (current session downloads)
- const dlComplete = bundle.files.every(f => f.filename && downloads[f.filename]?.status === 'complete')
- if (dlComplete) return true
- // Check 2: Disk check says all files are complete (size validated)
- return bundleStatuses[bundle.name] === true
- }
+ // The three card states live in lib/bundle-state.ts, pure, because bundles
+ // share files and the reasoning about whose row is whose is the whole of
+ // GH #113. See that file for what one shared row used to do to this list.
+ const isBundleComplete = (bundle: ModelBundle): boolean =>
+ bundleIsComplete(bundle.files, downloads, bundleStatuses[bundle.name] === true)
- const isBundleDownloading = (bundle: ModelBundle): boolean => {
- return bundle.files.some(f => f.filename && (downloads[f.filename]?.status === 'downloading' || downloads[f.filename]?.status === 'connecting'))
- }
+ const isBundleDownloading = (bundle: ModelBundle): boolean =>
+ bundleIsDownloading(bundle.files, downloads)
- const hasBundleErrors = (bundle: ModelBundle): boolean => {
- // Check for explicit error status in download store
- if (bundle.files.some(f => f.filename && downloads[f.filename]?.status === 'error')) return true
- // Also check: some files show complete in store but bundle is NOT fully installed on disk
- // This catches the case where error entries were dismissed but the bundle is still incomplete
- const hasAnyDownloadEntry = bundle.files.some(f => f.filename && downloads[f.filename])
- if (hasAnyDownloadEntry && !bundleStatuses[bundle.name]) {
- const someComplete = bundle.files.some(f => f.filename && downloads[f.filename]?.status === 'complete')
- const allComplete = bundle.files.every(f => f.filename && downloads[f.filename]?.status === 'complete')
- if (someComplete && !allComplete) return true
- }
- return false
- }
+ const hasBundleErrors = (bundle: ModelBundle): boolean =>
+ bundleHasErrors(bundle.files, downloads, bundleStatuses[bundle.name] === true)
const getModelDownloadState = (model: DiscoverModel): DownloadProgress | null => {
if (!model.filename) return null
diff --git a/src/lib/__tests__/bundle-state.test.ts b/src/lib/__tests__/bundle-state.test.ts
new file mode 100644
index 00000000..10f69dd0
--- /dev/null
+++ b/src/lib/__tests__/bundle-state.test.ts
@@ -0,0 +1,120 @@
+/**
+ * GH #113, JonnFlauty (Windows 11, RTX 5070 Ti, "unfiltered models doesn't
+ * shown as installed, even if the downloaded model has a checkmark and say's
+ * installed").
+ *
+ * A video download failed midway, he retried, and afterwards the model was
+ * missing from Installed while "every model in the list shown retry".
+ *
+ * The download store is keyed by filename and bundles share files: seven of
+ * the thirteen video bundles ship the same umt5_xxl_fp8_e4m3fn_scaled text
+ * encoder, six the same wan_2.1_vae. One attempt on one bundle therefore
+ * wrote rows that every other bundle in the list read as if they were about
+ * itself. Both halves of his report come out of that one fact.
+ *
+ * Run: npx vitest run src/lib/__tests__/bundle-state.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { bundleIsComplete, bundleIsDownloading, bundleHasErrors } from '../bundle-state'
+
+/** The three files of Wan 2.2 Rapid AIO (Uncensored I2V, GGUF), the bundle
+ * from the issue. The last two are the shared ones. */
+const RAPID = [
+ { filename: 'wan2.2-i2v-rapid-aio-v10-nsfw-Q4_K_M.gguf' },
+ { filename: 'wan_2.1_vae.safetensors' },
+ { filename: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors' },
+]
+
+/** Wan 2.1 14B FP8, the bundle that did install for him. Shares two files. */
+const WAN21 = [
+ { filename: 'wan2.1_t2v_14B_fp8_scaled.safetensors' },
+ { filename: 'wan_2.1_vae.safetensors' },
+ { filename: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors' },
+]
+
+const rows = (m: Record<string, string>) =>
+ Object.fromEntries(Object.entries(m).map(([k, status]) => [k, { status }]))
+
+/** What one finished install of Wan 2.1 leaves behind in the store. */
+const AFTER_WAN21 = rows({
+ 'wan2.1_t2v_14B_fp8_scaled.safetensors': 'complete',
+ 'wan_2.1_vae.safetensors': 'complete',
+ 'umt5_xxl_fp8_e4m3fn_scaled.safetensors': 'complete',
+})
+
+describe('a bundle reads its own rows, not its neighbours', () => {
+ it('one finished install does not put Retry on every other card', () => {
+ // Rapid AIO was never touched here. Its own model file has no row at all,
+ // the two shared files are complete because Wan 2.1 finished. The old
+ // rule saw "some complete, not all" and offered Retry, on this card and
+ // on every other Wan card in the list.
+ expect(bundleHasErrors(RAPID, AFTER_WAN21, false)).toBe(false)
+ expect(bundleIsComplete(RAPID, AFTER_WAN21, false)).toBe(false)
+ expect(bundleIsDownloading(RAPID, AFTER_WAN21)).toBe(false)
+ })
+
+ it('NEGATIVE CONTROL: the old rule called that untouched bundle half broken', () => {
+ // The old expression, replayed on the same state. This is the whole of
+ // the "every model in the list shown retry" half of the report.
+ const hasAnyRow = RAPID.some((f) => AFTER_WAN21[f.filename])
+ const someComplete = RAPID.some((f) => AFTER_WAN21[f.filename]?.status === 'complete')
+ const allComplete = RAPID.every((f) => AFTER_WAN21[f.filename]?.status === 'complete')
+ expect(hasAnyRow && someComplete && !allComplete).toBe(true)
+ })
+
+ it('a bundle that really did stop halfway still says Retry', () => {
+ // Same shape, one difference that matters: the missing file has a row, so
+ // this bundle WAS attempted and did not finish.
+ const halfway = { ...AFTER_WAN21, 'wan2.2-i2v-rapid-aio-v10-nsfw-Q4_K_M.gguf': { status: 'paused' } }
+ expect(bundleHasErrors(RAPID, halfway, false)).toBe(true)
+ })
+
+ it('an error row is a dead stop whatever file it sits on', () => {
+ // A shared file that cannot be fetched blocks this bundle exactly as much
+ // as its own model would, so that half of the old rule stays.
+ const teFailed = rows({ 'umt5_xxl_fp8_e4m3fn_scaled.safetensors': 'error' })
+ expect(bundleHasErrors(RAPID, teFailed, false)).toBe(true)
+ expect(bundleHasErrors(WAN21, teFailed, false)).toBe(true)
+ })
+
+ it('a bundle that is on disk is installed, even with a stale error row nearby', () => {
+ // The other half of the report. The disk verdict already means every file
+ // is there at full size AND visible to the running ComfyUI, so a leftover
+ // error row on a shared filename has nothing to say about it. The old
+ // order asked the error row first and answered "not installed".
+ const teFailed = rows({ 'umt5_xxl_fp8_e4m3fn_scaled.safetensors': 'error' })
+ expect(bundleIsComplete(WAN21, teFailed, true)).toBe(true)
+ })
+
+ it('NEGATIVE CONTROL: the old rule hid an installed bundle behind that row', () => {
+ const teFailed = rows({ 'umt5_xxl_fp8_e4m3fn_scaled.safetensors': 'error' })
+ const oldHasError = WAN21.some((f) => teFailed[f.filename]?.status === 'error')
+ expect(oldHasError).toBe(true) // and the old code returned false right here
+ })
+
+ it('a session where every file finished counts without asking the disk', () => {
+ // The disk check runs on an event and on tab changes, so the store is the
+ // faster answer right after an install. Kept exactly as it was.
+ expect(bundleIsComplete(WAN21, AFTER_WAN21, false)).toBe(true)
+ })
+
+ it('a bundle with no named files is never installed', () => {
+ expect(bundleIsComplete([], {}, false)).toBe(false)
+ expect(bundleIsComplete([{}], {}, false)).toBe(false)
+ })
+
+ it('downloading is about this bundle and only reads live rows', () => {
+ const live = { ...AFTER_WAN21, 'wan2.2-i2v-rapid-aio-v10-nsfw-Q4_K_M.gguf': { status: 'downloading' } }
+ expect(bundleIsDownloading(RAPID, live)).toBe(true)
+ expect(bundleIsDownloading(WAN21, live)).toBe(false)
+ const connecting = rows({ 'wan_2.1_vae.safetensors': 'connecting' })
+ expect(bundleIsDownloading(RAPID, connecting)).toBe(true)
+ })
+
+ it('Clear leaves a card that offers Install again', () => {
+ // clearBundle dismisses every row of the bundle. Nothing then claims this
+ // bundle is half anything, which is what the_mr_pickles needed.
+ expect(bundleHasErrors(RAPID, {}, false)).toBe(false)
+ expect(bundleIsComplete(RAPID, {}, false)).toBe(false)
+ })
+})
diff --git a/src/lib/bundle-state.ts b/src/lib/bundle-state.ts
new file mode 100644
index 00000000..22992323
--- /dev/null
+++ b/src/lib/bundle-state.ts
@@ -0,0 +1,101 @@
+/**
+ * What a bundle card should say: Installed, Installing, Retry or Get.
+ *
+ * GH #113, JonnFlauty on Windows 11 with an RTX 5070 Ti: a video download
+ * failed midway, he retried, and afterwards the model "doesn't shown in the
+ * installed section and for some reason every model in the list shown retry".
+ *
+ * The download store is keyed by FILENAME, and bundles share files. Seven of
+ * the thirteen video bundles ship the same umt5_xxl_fp8_e4m3fn_scaled text
+ * encoder and six the same wan_2.1_vae, so one attempt on one bundle writes
+ * rows that every other bundle in the list then reads as if they were about
+ * itself:
+ *
+ * - one error row on a shared file made every bundle carrying that filename
+ * count as NOT installed, even the ones sitting complete on disk, because
+ * the error veto ran before the disk answer;
+ * - one FINISHED shared file made every bundle carrying it look half
+ * downloaded, which is the Retry button on every card in the list.
+ *
+ * So the rule is: the disk is the only source that speaks about this bundle
+ * and nothing else, and a download row only says something about this bundle
+ * when it is about a file this bundle is still missing.
+ *
+ * Pure on purpose. The component holds the store and the disk verdicts; the
+ * decision is here where it can be proven without either.
+ */
+
+/** The one field of a download row any of this depends on. */
+export interface DownloadRow {
+ status: string
+}
+
+/** A bundle file, narrowed to what the state machine reads. */
+export interface BundleFileRef {
+ filename?: string
+}
+
+type Rows = Record<string, DownloadRow | undefined>
+
+/** Files of the bundle that actually have a name to look up. */
+function named(files: BundleFileRef[]): string[] {
+ return files.map((f) => f.filename).filter((n): n is string => !!n)
+}
+
+/**
+ * Installed.
+ *
+ * `diskInstalled` is checkBundlesInstalled's verdict: every file present at
+ * its full size AND visible to the running ComfyUI. It is asked FIRST because
+ * it is the only signal that is about this bundle alone. The old order let a
+ * stale error row on a shared filename overrule a bundle that was completely
+ * and verifiably on disk.
+ */
+export function bundleIsComplete(
+ files: BundleFileRef[],
+ downloads: Rows,
+ diskInstalled: boolean,
+): boolean {
+ if (diskInstalled) return true
+ const names = named(files)
+ // Session fallback: everything this bundle needs finished in this run. An
+ // error row cannot pass this either, so the old separate veto bought
+ // nothing here beyond the false negative it caused.
+ return names.length > 0 && names.every((n) => downloads[n]?.status === 'complete')
+}
+
+/** Something of this bundle is moving right now. */
+export function bundleIsDownloading(files: BundleFileRef[], downloads: Rows): boolean {
+ return named(files).some((n) => {
+ const s = downloads[n]?.status
+ return s === 'downloading' || s === 'connecting'
+ })
+}
+
+/**
+ * Retry, meaning this bundle really did stop halfway.
+ *
+ * An explicit error row still counts, whatever it is on: a shared file that
+ * cannot be fetched blocks this bundle just as much as its own.
+ *
+ * The half-downloaded case is the one that had to change. "Some files
+ * complete, not all" is true of every bundle that merely shares a finished
+ * file with an installed sibling, which is how one good install turned the
+ * whole list red. It only means something when the part that is MISSING was
+ * attempted too, so there is a row for a file that is not complete.
+ */
+export function bundleHasErrors(
+ files: BundleFileRef[],
+ downloads: Rows,
+ diskInstalled: boolean,
+): boolean {
+ const names = named(files)
+ if (names.some((n) => downloads[n]?.status === 'error')) return true
+ if (diskInstalled) return false
+ const done = names.filter((n) => downloads[n]?.status === 'complete')
+ if (done.length === 0 || done.length === names.length) return false
+ return names.some((n) => {
+ const row = downloads[n]
+ return row !== undefined && row.status !== 'complete'
+ })
+}