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): installed-state must match what the running ComfyUI serves

purple9c495c9583d4
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index 791be83d..b3bded12 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -407,13 +407,6 @@ pub fn find_comfyui_path() -> Option<String> {
}
}
- // 2b. Deep scan user home directory (finds ComfyUI in non-standard paths like Desktop/bs/IMage Gen/ComfyUI)
- let home2 = dirs::home_dir().unwrap_or_default();
- if let Some(found) = scan_for_comfyui(&home2, 7) {
- println!("[ComfyUI] Found via deep home scan: {}", found.display());
- return Some(found.to_string_lossy().to_string());
- }
-
let home = dirs::home_dir().unwrap_or_default();
// 3. Check common fixed locations (including Stability Matrix, portable installs)
@@ -448,6 +441,18 @@ pub fn find_comfyui_path() -> Option<String> {
}
}
+ // 3b. Deep scan of the user home (finds ComfyUI in non-standard paths like
+ // Desktop/bs/IMage Gen/ComfyUI). Runs AFTER config + fixed locations: as a
+ // FIRST candidate its directory-walk order could pick a stale second copy
+ // over the standard install — LU then downloads/checks models in a folder
+ // the running ComfyUI never scans ("installed but not recognized",
+ // pnwpdr4519 Discord 2026-07-27). Same lesson as d9146e3 ("deep home scan
+ // last").
+ if let Some(found) = scan_for_comfyui(&home, 7) {
+ println!("[ComfyUI] Found via deep home scan: {}", found.display());
+ return Some(found.to_string_lossy().to_string());
+ }
+
// 4. Recursive scan of Desktop, Documents, Downloads, and drive roots
let mut scan_roots: Vec<PathBuf> = vec![
home.join("Desktop"),
diff --git a/src/api/__tests__/discover-visibility.test.ts b/src/api/__tests__/discover-visibility.test.ts
new file mode 100644
index 00000000..805429bb
--- /dev/null
+++ b/src/api/__tests__/discover-visibility.test.ts
@@ -0,0 +1,30 @@
+/**
+ * normalizeModelBase — shared identity for the installed-visibility check and
+ * the fuzzy variant fallback (pnwpdr4519: bundle "installed" on disk must not
+ * survive when the running ComfyUI cannot see the file).
+ * Run: npx vitest run src/api/__tests__/discover-visibility.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { normalizeModelBase } from '../discover'
+
+describe('normalizeModelBase', () => {
+ it('strips extension and lowercases', () => {
+ expect(normalizeModelBase('JuggernautXL_v9.safetensors')).toBe('juggernautxl_v9')
+ })
+
+ it('drops nested subdir prefixes ComfyUI enums can carry', () => {
+ expect(normalizeModelBase('SDXL/juggernautXL_v9.safetensors')).toBe('juggernautxl_v9')
+ expect(normalizeModelBase('SDXL\\juggernautXL_v9.safetensors')).toBe('juggernautxl_v9')
+ })
+
+ it('strips common quant suffixes so variants match', () => {
+ expect(normalizeModelBase('z_image_turbo_fp8.safetensors')).toBe('z_image_turbo')
+ expect(normalizeModelBase('z_image_turbo_bf16.safetensors')).toBe('z_image_turbo')
+ })
+
+ it('does NOT substring-match different models (strict base identity)', () => {
+ expect(normalizeModelBase('z_image_turbo.safetensors')).not.toBe(
+ normalizeModelBase('z_image_base.safetensors'),
+ )
+ })
+})
diff --git a/src/api/discover.ts b/src/api/discover.ts
index 43529ca2..a56ee70c 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -129,51 +129,84 @@ export async function checkBundlesInstalled(bundles: ModelBundle[]): Promise<Rec
for (const b of bundles) result[b.name] = false
}
+ // ComfyUI's own model lists — fetched once, used twice: to CONFIRM the
+ // size-check hits (a file the RUNNING ComfyUI cannot see must not count as
+ // installed) and as the fuzzy variant fallback further down.
+ // Issue #51 (adhney): ComfyUI lists partially-downloaded files too, so the
+ // fuzzy fallback would mark an incomplete download as INSTALLED. Drop any
+ // 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(),
+ ])
+ const [checkpoints, diffModels, vaes, clips] = await Promise.all([
+ filterPartialFiles(rawCheckpoints).then(s => Array.from(s)),
+ filterPartialFiles(rawDiffModels).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 }
+ } catch {
+ comfyLists = null // ComfyUI not reachable · size-check verdicts stand
+ }
+
+ // pnwpdr4519 (Discord 2026-07-27): the size check looks at the directory LU
+ // resolves, but the RUNNING ComfyUI may scan a different install (second
+ // copy, moved install). "Installed" from the disk check alone then locks the
+ // user out: the Create picker (fed by ComfyUI's enums) shows nothing AND
+ // re-downloading is refused. When ComfyUI is reachable, a bundle only counts
+ // as installed if ComfyUI can actually see at least one of its listed files.
+ if (comfyLists) {
+ const visible = new Set<string>()
+ for (const arr of Object.values(comfyLists)) for (const n of arr) visible.add(normalizeModelBase(n))
+ for (const bundle of bundles) {
+ if (!result[bundle.name]) continue
+ const enumFiles = bundle.files.filter(f => f.filename && f.subfolder && ENUM_SUBFOLDERS.has(f.subfolder))
+ if (enumFiles.length === 0) continue
+ if (!enumFiles.some(f => visible.has(normalizeModelBase(f.filename!)))) {
+ result[bundle.name] = false
+ log.warn(`[discover] ${bundle.name}: files on disk but invisible to the running ComfyUI · not counting as installed`)
+ }
+ }
+ }
+
// Fallback: for bundles not detected by exact filename, check ComfyUI's model lists
// This catches variant files (e.g. fp8 version of a model with different filename)
// STRICT: only exact base-name match · no substring matching (caused false positives
// where z_image_turbo matched z_image_base, or gemma-4-31b matched gemma-4-e4b)
const undetected = bundles.filter(b => !result[b.name])
- if (undetected.length > 0) {
- try {
- const [rawCheckpoints, rawDiffModels, rawVaes, rawClips] = await Promise.all([
- getCheckpoints(), getDiffusionModels(), getVAEModels(), getCLIPModels(),
- ])
- // Issue #51 (adhney): ComfyUI lists partially-downloaded files too, so the
- // fuzzy fallback below would mark an incomplete download as INSTALLED. Drop
- // any file check_model_sizes confirms is partial before matching.
- const [checkpoints, diffModels, vaes, clips] = await Promise.all([
- filterPartialFiles(rawCheckpoints).then(s => Array.from(s)),
- filterPartialFiles(rawDiffModels).then(s => Array.from(s)),
- filterPartialFiles(rawVaes).then(s => Array.from(s)),
- filterPartialFiles(rawClips).then(s => Array.from(s)),
- ])
- const modelsBySubfolder: Record<string, string[]> = {
- checkpoints, diffusion_models: diffModels, vae: vaes, text_encoders: clips,
- }
- for (const bundle of undetected) {
- const allFound = bundle.files.every(f => {
- if (!f.filename || !f.subfolder) return true
- const models = modelsBySubfolder[f.subfolder] || []
- // Strip extension and common quant suffixes for fuzzy matching
- const base = f.filename.replace(/\.[^.]+$/, '').toLowerCase()
- .replace(/[-_](fp4|fp8|fp16|bf16|e4m3fn|scaled|fp8_e4m3fn_scaled)$/g, '')
- return models.some(m => {
- const mBase = m.replace(/\.[^.]+$/, '').toLowerCase()
- .replace(/[-_](fp4|fp8|fp16|bf16|e4m3fn|scaled|fp8_e4m3fn_scaled)$/g, '')
- return mBase === base
- })
- })
- if (allFound) result[bundle.name] = true
- }
- } catch {
- // ComfyUI not reachable · keep exact-match results
+ if (undetected.length > 0 && comfyLists) {
+ const modelsBySubfolder = comfyLists
+ for (const bundle of undetected) {
+ const allFound = bundle.files.every(f => {
+ if (!f.filename || !f.subfolder) return true
+ const models = modelsBySubfolder[f.subfolder] || []
+ const base = normalizeModelBase(f.filename)
+ return models.some(m => normalizeModelBase(m) === base)
+ })
+ if (allFound) result[bundle.name] = true
}
}
return result
}
+/** 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'])
+
+/** Base identity of a model file: basename only (ComfyUI enums can carry
+ * nested-subdir prefixes), lowercase, extension and common quant suffixes
+ * stripped. Shared by the installed-detection visibility check and the fuzzy
+ * variant fallback so both agree on what "the same model" means. */
+export function normalizeModelBase(name: string): string {
+ const base = name.split(/[\\/]/).pop() ?? name
+ return base.replace(/\.[^.]+$/, '').toLowerCase()
+ .replace(/[-_](fp4|fp8|fp16|bf16|e4m3fn|scaled|fp8_e4m3fn_scaled)$/g, '')
+}
+
/** #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. */
@@ -222,12 +255,36 @@ export async function installBundleComplete(bundle: ModelBundle): Promise<void>
}
} catch { /* can't check · download everything */ }
+ // Lazily fetched ComfyUI visibility set: "already installed" is only true
+ // when the RUNNING ComfyUI lists the file. A file that exists on disk but is
+ // invisible to ComfyUI means LU and ComfyUI look at different model folders
+ // (pnwpdr4519 Discord 2026-07-27) — silently skipping it as installed left
+ // the user with no picker entry AND no way to re-download.
+ let visibleBases: Set<string> | null | undefined
+ const comfyCanSee = async (filename: string): Promise<boolean | null> => {
+ if (visibleBases === undefined) {
+ try {
+ const lists = await Promise.all([getCheckpoints(), getDiffusionModels(), getVAEModels(), getCLIPModels()])
+ visibleBases = new Set(lists.flat().map(normalizeModelBase))
+ } catch {
+ visibleBases = null // ComfyUI unreachable · cannot judge visibility
+ }
+ }
+ return visibleBases ? visibleBases.has(normalizeModelBase(filename)) : null
+ }
+
// Step 1: Start downloads only for files NOT already installed
for (const file of bundle.files) {
if (!file.downloadUrl || !file.filename || !file.subfolder) continue
if (installedFiles.has(file.filename)) {
- log.info(`[discover] Skipping ${file.filename} · already installed`)
- window.dispatchEvent(new CustomEvent('comfyui-download-exists', { detail: { filename: file.filename } }))
+ const visible = ENUM_SUBFOLDERS.has(file.subfolder) ? await comfyCanSee(file.filename) : null
+ if (visible === false) {
+ log.warn(`[discover] ${file.filename} exists on disk but the running ComfyUI does not list it`)
+ window.dispatchEvent(new CustomEvent('comfyui-model-invisible', { detail: { filename: file.filename } }))
+ } else {
+ log.info(`[discover] Skipping ${file.filename} · already installed`)
+ window.dispatchEvent(new CustomEvent('comfyui-download-exists', { detail: { filename: file.filename } }))
+ }
continue
}
try {
diff --git a/src/stores/downloadStore.ts b/src/stores/downloadStore.ts
index 13bc3035..ac04c1a8 100644
--- a/src/stores/downloadStore.ts
+++ b/src/stores/downloadStore.ts
@@ -18,6 +18,7 @@ interface DownloadStoreState {
setMeta: (filename: string, url: string, subfolder: string, destDir?: string) => void
setBundleGroup: (bundleName: string, filenames: string[]) => void
markComplete: (filename: string) => void
+ markInvisible: (filename: string) => void
pause: (id: string) => Promise<void>
cancel: (id: string) => Promise<void>
resume: (id: string) => Promise<void>
@@ -30,6 +31,12 @@ if (typeof window !== 'undefined') {
window.addEventListener('comfyui-download-exists', ((e: CustomEvent<{ filename: string }>) => {
useDownloadStore.getState().markComplete(e.detail.filename)
}) as EventListener)
+ // File exists on disk but the RUNNING ComfyUI does not list it — LU and
+ // ComfyUI are looking at different model folders. Shown as an error row so
+ // the user gets an explanation instead of a silent "already installed".
+ window.addEventListener('comfyui-model-invisible', ((e: CustomEvent<{ filename: string }>) => {
+ useDownloadStore.getState().markInvisible(e.detail.filename)
+ }) as EventListener)
}
export const useDownloadStore = create<DownloadStoreState>()((set, get) => ({
@@ -105,6 +112,18 @@ export const useDownloadStore = create<DownloadStoreState>()((set, get) => ({
}))
},
+ markInvisible: (filename: string) => {
+ set(s => ({
+ downloads: {
+ ...s.downloads,
+ [filename]: {
+ progress: 0, total: 0, speed: 0, filename, status: 'error',
+ error: 'File is already on disk, but your running ComfyUI does not list it — LU and ComfyUI are using different model folders. Point LU at the right ComfyUI install (Settings → AI Backends) or restart ComfyUI from LU, then try again.',
+ },
+ },
+ }))
+ },
+
pause: async (id: string) => {
await pauseDownload(id)
await get().refresh()