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 ComfyUI dropdown comes in two shapes, and one of them killed the video tab

purplea15bc17e5b11
diff --git a/src/api/__tests__/comfyui-combo-schema.test.ts b/src/api/__tests__/comfyui-combo-schema.test.ts
new file mode 100644
index 00000000..bd637d71
--- /dev/null
+++ b/src/api/__tests__/comfyui-combo-schema.test.ts
@@ -0,0 +1,289 @@
+/**
+ * Round 3 of B1 / GH #113, from the counter-check on the real 2.6.7 Windows
+ * build (2026-08-29).
+ *
+ * What the box did: opening the Models page logged
+ *
+ * [useModels] ComfyUI video discovery failed
+ * TypeError: (intermediate value).map is not a function
+ *
+ * at warn level, so silently, and the whole video discovery died with it. The
+ * Video tab had no number, Installed said 0 and the list said "No video models
+ * installed", while three cards correctly said Installed because they read the
+ * disk.
+ *
+ * The cause, read straight off that box's ComfyUI on 127.0.0.1:8188 (not
+ * guessed): a dropdown comes back in two different shapes in ONE ComfyUI, and
+ * the AnimateDiff node uses the newer one.
+ *
+ * GET /object_info/CheckpointLoaderSimple
+ * "ckpt_name": [["Realistic_Vision_V6.0_NV_B1_fp16.safetensors", ...],
+ * {"tooltip": "..."}]
+ *
+ * GET /object_info/ADE_LoadAnimateDiffModel
+ * "model_name": ["COMBO", {"multiselect": false,
+ * "options": ["animatediff_lightning_4step_comfyui.safetensors",
+ * "v3_sd15_mm.ckpt"]}]
+ *
+ * Round 2 added that sixth loader and mocked it in the LEGACY shape, which is
+ * why its tests were green while the real box crashed. The bodies below are the
+ * shapes the box actually returned.
+ *
+ * Run: npx vitest run src/api/__tests__/comfyui-combo-schema.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+const localFetch = vi.fn()
+vi.mock('../backend', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../backend')>()),
+ localFetch: (...a: unknown[]) => localFetch(...a),
+ isTauri: () => false,
+ comfyuiUrl: (path: string) => `http://127.0.0.1:8188${path}`,
+}))
+
+import { readComboOptions, nodeComboOptions } from '../comfyui-enum'
+import {
+ getAnimateDiffModels, getAnimateDiffMotionModels, getInstalledVideoModels,
+ getVideoModels, getImageModels, getSamplers, buildAnimateDiffWorkflow,
+} from '../comfyui'
+import { readComfyModelNames } from '../discover'
+import { detectAvailableModels } from '../comfyui-nodes'
+
+const MOTION_LIGHTNING = 'animatediff_lightning_4step_comfyui.safetensors'
+const MOTION_V3 = 'v3_sd15_mm.ckpt'
+const SD15 = 'Realistic_Vision_V6.0_NV_B1_fp16.safetensors'
+const SVD = 'svd_xt_1_1.safetensors'
+const WAN13 = 'wan2.1_t2v_1.3B_bf16.safetensors'
+const WAN5B = 'wan2.2_ti2v_5B_fp16.safetensors'
+const ZIMAGE = 'z_image_bf16.safetensors'
+
+const okJson = (body: unknown) => ({ ok: true, status: 200, json: async () => body })
+
+/** Verbatim shape of the box answer for the AnimateDiff node, options included. */
+const ADE_BODY_REAL = {
+ ADE_LoadAnimateDiffModel: {
+ input: {
+ required: {
+ model_name: ['COMBO', { multiselect: false, options: [MOTION_LIGHTNING, MOTION_V3] }],
+ },
+ optional: { ad_settings: ['AD_SETTINGS', {}] },
+ },
+ output: ['MOTION_MODEL_ADE'],
+ name: 'ADE_LoadAnimateDiffModel',
+ python_module: 'custom_nodes.ComfyUI-AnimateDiff-Evolved',
+ },
+}
+
+/** Verbatim shape of the box answer for the two stock loaders, legacy schema. */
+const CHECKPOINT_BODY_REAL = {
+ CheckpointLoaderSimple: {
+ input: { required: { ckpt_name: [[SD15, 'sd_turbo.safetensors', SVD], { tooltip: 'The name of the checkpoint (model) to load.' }] } },
+ output: ['MODEL', 'CLIP', 'VAE'],
+ },
+}
+const UNET_BODY_REAL = {
+ UNETLoader: {
+ input: {
+ required: {
+ unet_name: [[WAN13, WAN5B, ZIMAGE]],
+ weight_dtype: [['default', 'fp8_e4m3fn', 'fp8_e4m3fn_fast', 'fp8_e5m2'], { advanced: true }],
+ },
+ },
+ output: ['MODEL'],
+ },
+}
+
+/** The box, exactly as it answered on 2026-08-29. `ade` swaps in a broken
+ * answer for the one node, to prove the other lanes survive it. */
+function routeRealBox(ade: unknown = ADE_BODY_REAL) {
+ localFetch.mockImplementation(async (url: string) => {
+ if (url.includes('CheckpointLoaderSimple')) return okJson(CHECKPOINT_BODY_REAL)
+ if (url.includes('UnetLoaderGGUF')) return okJson({}) // pack not installed: ComfyUI answers {} with HTTP 200
+ if (url.includes('UNETLoader')) return okJson(UNET_BODY_REAL)
+ if (url.includes('ADE_LoadAnimateDiffModel')) {
+ if (typeof ade === 'function') return (ade as () => unknown)()
+ return okJson(ade)
+ }
+ return okJson({})
+ })
+}
+
+beforeEach(() => {
+ localFetch.mockReset()
+})
+
+describe('one ComfyUI, two dropdown schemas', () => {
+ it('reads the legacy shape (options in slot 0)', () => {
+ expect(readComboOptions([[SD15, SVD], { tooltip: 'x' }])).toEqual([SD15, SVD])
+ })
+
+ it('THE FIX: reads the newer COMBO shape the AnimateDiff node uses', () => {
+ expect(readComboOptions(['COMBO', { multiselect: false, options: [MOTION_LIGHTNING, MOTION_V3] }]))
+ .toEqual([MOTION_LIGHTNING, MOTION_V3])
+ })
+
+ it('an empty dropdown is an empty list in both shapes, not a failure', () => {
+ expect(readComboOptions([[]])).toEqual([])
+ expect(readComboOptions(['COMBO', { options: [] }])).toEqual([])
+ expect(readComboOptions(['COMBO', {}])).toEqual([])
+ })
+
+ it('a spec that is not a dropdown at all answers null, so the caller can log it', () => {
+ expect(readComboOptions(['INT', { min: 1, max: 100 }])).toBeNull()
+ expect(readComboOptions('<html>404</html>')).toBeNull()
+ expect(readComboOptions(undefined)).toBeNull()
+ expect(readComboOptions(42)).toBeNull()
+ })
+
+ it('a missing node in an /object_info answer is an empty list, never a throw', () => {
+ // ComfyUI answers {} with HTTP 200 for a class it does not know.
+ expect(nodeComboOptions({}, 'ADE_LoadAnimateDiffModel', 'model_name')).toEqual([])
+ expect(nodeComboOptions(null, 'ADE_LoadAnimateDiffModel', 'model_name')).toEqual([])
+ expect(nodeComboOptions('<html>Not Found</html>', 'UNETLoader', 'unet_name')).toEqual([])
+ })
+
+ it('an unreadable spec yields an empty list, never the type name as a filename', () => {
+ const out = nodeComboOptions(
+ { UNETLoader: { input: { required: { unet_name: ['COMBO'] } } } },
+ 'UNETLoader', 'unet_name',
+ )
+ expect(out).toEqual([])
+ expect(out).not.toContain('COMBO')
+ })
+})
+
+describe('the box answer that killed the video discovery', () => {
+ it('THE CRASH: the AnimateDiff loader returns the two files, not the word COMBO', async () => {
+ routeRealBox()
+ const names = await getAnimateDiffModels()
+ expect(Array.isArray(names)).toBe(true)
+ expect(names).toEqual([MOTION_LIGHTNING, MOTION_V3])
+ expect(names).not.toContain('COMBO')
+ })
+
+ it('THE CRASH: getAnimateDiffMotionModels no longer throws on the real answer', async () => {
+ routeRealBox()
+ const models = await getAnimateDiffMotionModels()
+ expect(models.map((m) => m.name)).toEqual([MOTION_LIGHTNING, MOTION_V3])
+ })
+
+ it('THE CRASH: the inventory survives and lists what the cards list', async () => {
+ routeRealBox()
+ const names = (await getInstalledVideoModels()).map((m) => m.name)
+ // the two motion modules whose cards said Installed
+ expect(names).toContain(MOTION_LIGHTNING)
+ expect(names).toContain(MOTION_V3)
+ // the freshly installed SVD-XT that appeared in no list on the box
+ expect(names).toContain(SVD)
+ // the Wan files ComfyUI already knew
+ expect(names).toContain(WAN13)
+ expect(names).toContain(WAN5B)
+ // the SD1.5 half of both AnimateDiff bundles, in the video lane too
+ expect(names).toContain(SD15)
+ expect(new Set(names).size).toBe(names.length)
+ expect(names.length).toBeGreaterThan(0) // the box showed 0
+ })
+
+ it('card, counter and list speak from the same inventory', async () => {
+ routeRealBox()
+ const inventory = await getInstalledVideoModels()
+ // The counter is the length of the list, so pinning both against the same
+ // read is what "the tab number and the list agree" means in code.
+ expect(inventory.length).toBe(new Set(inventory.map((m) => m.name)).size)
+ for (const installed of [MOTION_LIGHTNING, MOTION_V3, SVD]) {
+ expect(inventory.some((m) => m.name === installed)).toBe(true)
+ }
+ })
+
+ it('the Create picker still refuses a motion module as a main model', async () => {
+ routeRealBox()
+ const picker = (await getVideoModels()).map((m) => m.name)
+ expect(picker).toContain(SVD)
+ expect(picker).not.toContain(MOTION_LIGHTNING)
+ expect(picker).not.toContain(MOTION_V3)
+ })
+
+ it('the image lane is unaffected by the newer schema next door', async () => {
+ routeRealBox()
+ const image = (await getImageModels()).map((m) => m.name)
+ expect(image).toContain(SD15)
+ expect(image).toContain(ZIMAGE)
+ expect(image).not.toContain('COMBO')
+ })
+
+ it('the shared visibility reader never carries the word COMBO as a filename', async () => {
+ routeRealBox()
+ const visible = await readComfyModelNames()
+ expect(visible).toContain(MOTION_V3)
+ expect(visible).not.toContain('COMBO')
+ })
+
+ it('THE GENERATION: the AnimateDiff graph carries the file, not one letter of the word COMBO', async () => {
+ // findAnimateDiffModel took models[0] of what the loader returned. On the
+ // bare string "COMBO" that is the character "C", and length 5 sailed past
+ // the "nothing installed" guard, so a video run would have asked ComfyUI
+ // to load a motion model called C.
+ routeRealBox()
+ const workflow = await buildAnimateDiffWorkflow({
+ prompt: 'a cat', negativePrompt: '', model: SD15,
+ sampler: 'euler', scheduler: 'normal', steps: 20, cfgScale: 8,
+ width: 512, height: 512, seed: 1, frames: 16, fps: 8,
+ } as Parameters<typeof buildAnimateDiffWorkflow>[0])
+ const loader = Object.values(workflow).find(
+ (n) => (n as { class_type?: string }).class_type === 'ADE_LoadAnimateDiffModel',
+ ) as { inputs: { model_name: string } }
+ expect(loader.inputs.model_name).toBe(MOTION_LIGHTNING)
+ expect(loader.inputs.model_name).not.toBe('C')
+ })
+
+ it('the AnimateDiff models reach the workflow builder from the newer schema', async () => {
+ const allNodes = { ...ADE_BODY_REAL, ...CHECKPOINT_BODY_REAL } as unknown as Parameters<typeof detectAvailableModels>[0]
+ const available = detectAvailableModels(allNodes)
+ expect(available.motionModels).toEqual([MOTION_LIGHTNING, MOTION_V3])
+ expect(available.checkpoints).toContain(SD15)
+ })
+})
+
+describe('one broken loader never empties the page again', () => {
+ const brokenAnswers: Array<[string, unknown]> = [
+ ['a shape nobody has seen', { ADE_LoadAnimateDiffModel: { input: { required: { model_name: { weird: true } } } } }],
+ ['an error page instead of JSON', () => ({ ok: true, status: 200, json: async () => { throw new Error('Unexpected token < in JSON') } })],
+ ['HTTP 500 from the node', () => ({ ok: false, status: 500, json: async () => ({}) })],
+ ['a hard network failure', () => { throw new Error('fetch failed') }],
+ ['the node missing entirely', {}],
+ ]
+
+ for (const [label, answer] of brokenAnswers) {
+ it(`keeps the video inventory when the AnimateDiff loader gives ${label}`, async () => {
+ routeRealBox(answer)
+ const names = (await getInstalledVideoModels()).map((m) => m.name)
+ expect(names).toContain(SVD)
+ expect(names).toContain(WAN13)
+ expect(names).toContain(WAN5B)
+ expect(names).not.toContain(MOTION_LIGHTNING) // that one lane, and only it, is empty
+ })
+ }
+
+ it('THE ISOLATION: a dead checkpoint loader no longer empties the whole tab', async () => {
+ // The main-model lane throws (ComfyUI answering 500 for its own loader is
+ // the "no engine" case, and getVideoModels still says so). The inventory
+ // must degrade to the lane it CAN read instead of rejecting, because a
+ // rejection here is exactly what left the page at "No video models
+ // installed" on the box.
+ localFetch.mockImplementation(async (url: string) => {
+ if (url.includes('CheckpointLoaderSimple')) return { ok: false, status: 500, json: async () => ({}) }
+ if (url.includes('ADE_LoadAnimateDiffModel')) return okJson(ADE_BODY_REAL)
+ return okJson({})
+ })
+ await expect(getVideoModels()).rejects.toThrow()
+ const names = (await getInstalledVideoModels()).map((m) => m.name)
+ expect(names).toContain(MOTION_LIGHTNING)
+ expect(names).toContain(MOTION_V3)
+ })
+
+ it('a broken KSampler answer still yields usable samplers', async () => {
+ localFetch.mockImplementation(async () =>
+ okJson({ KSampler: { input: { required: { sampler_name: ['COMBO'] } } } }))
+ expect(await getSamplers()).toContain('euler')
+ })
+})
diff --git a/src/api/__tests__/gh113-card-counter-list-chain.test.ts b/src/api/__tests__/gh113-card-counter-list-chain.test.ts
new file mode 100644
index 00000000..1028c2d4
--- /dev/null
+++ b/src/api/__tests__/gh113-card-counter-list-chain.test.ts
@@ -0,0 +1,131 @@
+/**
+ * Round 3 of B1 / GH #113: card, counter and Installed list, driven by ONE set
+ * of answers, and those answers are the ones the real Windows box gave on
+ * 2026-08-29 (read straight off its ComfyUI on 127.0.0.1:8188).
+ *
+ * The point of this file is the chain, not one function. On the box the card
+ * said Installed while the counter had no number and the list said "No video
+ * models installed", and the reason was a single loader answering in the newer
+ * COMBO schema:
+ *
+ * "model_name": ["COMBO", {"multiselect": false, "options": [...]}]
+ *
+ * That answer cost BOTH ends. The inventory threw ("(intermediate value).map is
+ * not a function") and left the page empty. And the card lost its ComfyUI
+ * visibility gate without a word: checkBundlesInstalled hands each loader's
+ * answer to filterPartialFiles, a bare "COMBO" string has no .filter, the throw
+ * landed in the catch that means "ComfyUI not reachable", and the gate that
+ * round 1 built to stop a card trusting the disk alone was simply skipped.
+ *
+ * Run: npx vitest run src/api/__tests__/gh113-card-counter-list-chain.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+import type { ModelBundle } from '../discover'
+
+const localFetch = vi.fn()
+const backendCall = vi.fn<(cmd: string, args?: unknown) => Promise<unknown>>()
+
+vi.mock('../backend', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../backend')>()),
+ localFetch: (...a: unknown[]) => localFetch(...a),
+ backendCall: (...a: unknown[]) => backendCall(...(a as [string, unknown])),
+ isTauri: () => false,
+ comfyuiUrl: (path: string) => `http://127.0.0.1:8188${path}`,
+}))
+
+const { getInstalledVideoModels } = await import('../comfyui')
+const { checkBundlesInstalled, ANIMATEDIFF_SUBFOLDER } = await import('../discover')
+
+const MOTION_LIGHTNING = 'animatediff_lightning_4step_comfyui.safetensors'
+const MOTION_V3 = 'v3_sd15_mm.ckpt'
+const SD15 = 'Realistic_Vision_V6.0_NV_B1_fp16.safetensors'
+
+const okJson = (body: unknown) => ({ ok: true, status: 200, json: async () => body })
+
+/** The AnimateDiff v3 bundle as the catalogue ships it: motion module under
+ * custom_nodes, SD1.5 checkpoint under checkpoints. */
+const ANIMATEDIFF_V3 = {
+ name: 'AnimateDiff v3',
+ description: '', tags: [], totalSizeGB: 3.6, vramRequired: '8 GB',
+ files: [
+ { name: '', description: '', pulls: '', tags: [], updated: '', filename: MOTION_V3, subfolder: ANIMATEDIFF_SUBFOLDER, sizeGB: 1.6 },
+ { name: '', description: '', pulls: '', tags: [], updated: '', filename: SD15, subfolder: 'checkpoints', sizeGB: 2.0 },
+ ],
+} as unknown as ModelBundle
+
+/** Every file of every bundle is on disk at full size, which is what the box
+ * had: 866,8 MB + 1595,7 MB + 2033,8 MB, all complete. */
+function diskIsFull() {
+ backendCall.mockImplementation(async (cmd, args) => {
+ if (cmd !== 'check_model_sizes') return undefined
+ const files = (args as { files: Array<{ filename: string }> }).files
+ return files.map((f) => ({ filename: f.filename, exists: true, actualBytes: 1, complete: true }))
+ })
+}
+
+/** ComfyUI, answering exactly as the box did: stock loaders legacy, the
+ * AnimateDiff node in the newer COMBO schema. `motion` is what that node
+ * lists. */
+function routeComfy(motion: string[]) {
+ localFetch.mockImplementation(async (url: string) => {
+ if (url.includes('CheckpointLoaderSimple')) {
+ return okJson({ CheckpointLoaderSimple: { input: { required: { ckpt_name: [[SD15], { tooltip: 'x' }] } } } })
+ }
+ if (url.includes('UnetLoaderGGUF')) return okJson({})
+ if (url.includes('UNETLoader')) return okJson({ UNETLoader: { input: { required: { unet_name: [[]] } } } })
+ if (url.includes('ADE_LoadAnimateDiffModel')) {
+ return okJson({
+ ADE_LoadAnimateDiffModel: {
+ input: { required: { model_name: ['COMBO', { multiselect: false, options: motion }] } },
+ },
+ })
+ }
+ return okJson({})
+ })
+}
+
+beforeEach(() => {
+ vi.clearAllMocks()
+ localFetch.mockReset()
+ diskIsFull()
+})
+
+describe('card, counter and Installed list read the same shelf', () => {
+ it('THE CHAIN: a bundle whose card says Installed is in the inventory', async () => {
+ routeComfy([MOTION_LIGHTNING, MOTION_V3])
+ const cards = await checkBundlesInstalled([ANIMATEDIFF_V3])
+ expect(cards['AnimateDiff v3']).toBe(true)
+
+ const inventory = (await getInstalledVideoModels()).map((m) => m.name)
+ for (const file of [MOTION_V3, SD15]) {
+ expect(inventory, `card says Installed, inventory must hold ${file}`).toContain(file)
+ }
+ // The counter is the size of that same list, so a card reading Installed
+ // can no longer stand over a tab with no number.
+ expect(inventory.length).toBeGreaterThan(0)
+ })
+
+ it('THE SILENT GATE: a motion module ComfyUI cannot see stops the card again', async () => {
+ // Same full disk, but the running ComfyUI lists no motion module (second
+ // install, moved folder, pack not loaded). Round 1 built this gate; the
+ // COMBO answer disabled it by throwing into the "ComfyUI unreachable"
+ // catch, so the card trusted the disk alone.
+ routeComfy([])
+ const cards = await checkBundlesInstalled([ANIMATEDIFF_V3])
+ expect(cards['AnimateDiff v3']).toBe(false)
+
+ const inventory = (await getInstalledVideoModels()).map((m) => m.name)
+ expect(inventory).not.toContain(MOTION_V3)
+ })
+
+ it('the gate and the inventory agree file by file', async () => {
+ // Only the lightning module is visible, so the v3 bundle is not installed
+ // and its file is not in the inventory, while the visible one is.
+ routeComfy([MOTION_LIGHTNING])
+ const cards = await checkBundlesInstalled([ANIMATEDIFF_V3])
+ const inventory = (await getInstalledVideoModels()).map((m) => m.name)
+ expect(cards['AnimateDiff v3']).toBe(false)
+ expect(inventory).toContain(MOTION_LIGHTNING)
+ expect(inventory).not.toContain(MOTION_V3)
+ })
+})
diff --git a/src/api/comfyui-enum.ts b/src/api/comfyui-enum.ts
new file mode 100644
index 00000000..8053927a
--- /dev/null
+++ b/src/api/comfyui-enum.ts
@@ -0,0 +1,106 @@
+import { log } from '../lib/logger'
+
+/**
+ * One reader for every ComfyUI dropdown (a COMBO input), because ComfyUI
+ * serves that dropdown in more than one shape and every place that guessed
+ * one shape broke on the other.
+ *
+ * Counter-check on the real Windows box, 2026-08-29, ComfyUI answering on
+ * 127.0.0.1:8188. The stock loaders still use the legacy shape, the option
+ * list sitting in slot 0:
+ *
+ * CheckpointLoaderSimple
+ * "ckpt_name": [["Realistic_Vision_V6.0_NV_B1_fp16.safetensors", ...],
+ * {"tooltip": "..."}]
+ *
+ * The AnimateDiff-Evolved node, from custom_nodes, answers in the newer
+ * schema, where slot 0 is the literal type name and the options moved into
+ * the config object:
+ *
+ * ADE_LoadAnimateDiffModel
+ * "model_name": ["COMBO", {"multiselect": false,
+ * "options": ["animatediff_lightning_4step_comfyui.safetensors",
+ * "v3_sd15_mm.ckpt"]}]
+ *
+ * Reading slot 0 there yields the string "COMBO". Everything downstream that
+ * treated it as the list of files then either threw ("(intermediate value).map
+ * is not a function", which took the whole video discovery down with it, GH
+ * #113 round 3) or quietly carried the word COMBO around as if it were a
+ * filename.
+ *
+ * Which shape a node uses is the node author's choice, not ours, and both
+ * shapes are live in the same ComfyUI at the same time. So no caller reads a
+ * spec by hand any more.
+ */
+
+function stringsOf(list: unknown[]): string[] {
+ return list.filter((v): v is string => typeof v === 'string')
+}
+
+/**
+ * The options of one input spec, or `null` when the spec is not a dropdown we
+ * can read (a number widget, a connection input, a shape nobody has seen yet).
+ *
+ * `null` and `[]` are deliberately different answers: `[]` means the dropdown
+ * exists and is empty (no files installed), `null` means we could not read it
+ * and the caller should say so in the log instead of pretending it was empty.
+ */
+export function readComboOptions(spec: unknown): string[] | null {
+ if (Array.isArray(spec)) {
+ const head = spec[0]
+ // Legacy shape: the options themselves sit in slot 0.
+ if (Array.isArray(head)) return stringsOf(head)
+ if (typeof head === 'string') {
+ // Newer schema: slot 0 is the type name, options live in the config.
+ const cfg = spec[1] as { options?: unknown } | undefined
+ if (Array.isArray(cfg?.options)) return stringsOf(cfg.options)
+ // A declared COMBO without an options array is an empty dropdown, not a
+ // shape we failed to read. Any other type name (INT, STRING, IMAGE, ...)
+ // is not a dropdown at all.
+ return head.toUpperCase() === 'COMBO' ? [] : null
+ }
+ return null
+ }
+ if (spec && typeof spec === 'object' && Array.isArray((spec as { options?: unknown }).options)) {
+ return stringsOf((spec as { options: unknown[] }).options)
+ }
+ return null
+}
+
+/** What a spec looks like, for the log line. Never the values themselves: a
+ * model list can be long and a filename is user data. */
+export function describeComboShape(spec: unknown): string {
+ if (spec === undefined) return 'missing'
+ if (spec === null) return 'null'
+ if (Array.isArray(spec)) {
+ const head = spec[0]
+ if (Array.isArray(head)) return `array[array(${head.length}), ...${spec.length - 1}]`
+ return `array[${typeof head === 'string' ? `"${head}"` : typeof head}, ...${spec.length - 1}]`
+ }
+ return typeof spec
+}
+
+/**
+ * The options of one input of one node in an /object_info answer, tolerant of
+ * everything that answer can be: a missing node (ComfyUI replies `{}` with
+ * HTTP 200 for a class it does not know), a missing field, a shape we cannot
+ * read, or an answer that is not an object at all.
+ *
+ * Never throws, never returns anything but an array of strings. An unreadable
+ * spec costs one log line and that one list, never the discovery around it.
+ */
+export function nodeComboOptions(data: unknown, node: string, field: string): string[] {
+ if (!data || typeof data !== 'object') return []
+ const meta = (data as Record<string, unknown>)[node] as
+ | { input?: { required?: Record<string, unknown>; optional?: Record<string, unknown> } }
+ | undefined
+ if (!meta || typeof meta !== 'object') return []
+ const spec = meta.input?.required?.[field] ?? meta.input?.optional?.[field]
+ if (spec === undefined) return []
+ const options = readComboOptions(spec)
+ if (options === null) {
+ log.warn('comfyui.combo_unreadable', { node, field, shape: describeComboShape(spec) })
+ return []
+ }
+ return options
+}
diff --git a/src/api/comfyui-nodes.ts b/src/api/comfyui-nodes.ts
index 560ce2bb..41ade5b4 100644
--- a/src/api/comfyui-nodes.ts
+++ b/src/api/comfyui-nodes.ts
@@ -1,5 +1,6 @@
import { comfyuiUrl, localFetch } from './backend'
import { log } from '../lib/logger'
+import { readComboOptions } from './comfyui-enum'
// Type-only import — erased at runtime, so it cannot form a comfyui.ts ↔
// comfyui-nodes.ts import cycle. classifyModel/MODEL_TYPE_DEFAULTS (runtime
// values) are pulled via a DYNAMIC import inside getModelCapabilities() below.
@@ -177,10 +178,12 @@ export function categorizeNodes(allNodes: Record<string, NodeMetadata>): Categor
// ─── Extract available models from node info ───
export function detectAvailableModels(allNodes: Record<string, NodeMetadata>): AvailableModels {
+ // Shared reader, both schemas. Hand-reading slot 0 here meant motionModels
+ // came back empty on any box where AnimateDiff-Evolved answers in the newer
+ // COMBO schema, which is what a real ComfyUI does (see comfyui-enum.ts).
const extract = (nodeName: string, fieldName: string): string[] => {
const spec = allNodes[nodeName]?.input?.required?.[fieldName]
- if (Array.isArray(spec) && Array.isArray(spec[0])) return spec[0]
- return []
+ return readComboOptions(spec) ?? []
}
return {
@@ -196,14 +199,14 @@ export function detectAvailableModels(allNodes: Record<string, NodeMetadata>): A
export function getSamplerOptions(allNodes: Record<string, NodeMetadata>): string[] {
const spec = allNodes.KSampler?.input?.required?.sampler_name
- if (Array.isArray(spec) && Array.isArray(spec[0])) return spec[0]
- return ['euler']
+ const options = readComboOptions(spec)
+ return options && options.length > 0 ? options : ['euler']
}
export function getSchedulerOptions(allNodes: Record<string, NodeMetadata>): string[] {
const spec = allNodes.KSampler?.input?.required?.scheduler
- if (Array.isArray(spec) && Array.isArray(spec[0])) return spec[0]
- return ['normal']
+ const options = readComboOptions(spec)
+ return options && options.length > 0 ? options : ['normal']
}
// ─── Model capability discovery (v2.5.0 — "every model fully chat-controllable") ───
@@ -298,8 +301,8 @@ export async function getModelCapabilities(model: string): Promise<ModelCapabili
}
const enumOpts = (node: string, field: string): string[] | undefined => {
const spec = allNodes[node]?.input?.required?.[field] ?? allNodes[node]?.input?.optional?.[field]
- if (Array.isArray(spec) && Array.isArray(spec[0]) && spec[0].length > 0) return spec[0] as string[]
- return undefined
+ const options = readComboOptions(spec)
+ return options && options.length > 0 ? options : undefined
}
const frameFrom = (node: string, field: string, fbMin: number, fbMax: number): { min: number; max: number } => {
const r = numRange(node, field)
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 3683fbad..e8e86bba 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -1,6 +1,7 @@
import { comfyuiUrl, localFetch, fetchLocalhostBytes, isTauri, backendCall } from "./backend"
import { log } from "../lib/logger"
import { LU_CLIENT_PREFIX } from "./comfyui-ws"
+import { nodeComboOptions } from "./comfyui-enum"
import { resolveRunSeed } from '../lib/run-seed'
// ─── Control-plane fetch timeouts ───
@@ -544,26 +545,42 @@ async function nodeExists(nodeName: string): Promise<boolean> {
}
}
-export async function getCheckpoints(): Promise<string[]> {
- const res = await localFetch(comfyuiUrl('/object_info/CheckpointLoaderSimple'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) throw new Error(`ComfyUI /object_info/CheckpointLoaderSimple failed (HTTP ${res.status})`)
+/** One /object_info call for one node, read through the shared combo reader.
+ *
+ * `strict` is for the two loaders whose absence means ComfyUI itself is not
+ * answering: those still throw on an HTTP error so the caller can tell "no
+ * models installed" apart from "no engine". Everything else soft-fails to an
+ * empty list, because an optional pack that is not installed is not an error.
+ *
+ * Nothing here reads the spec by hand any more. The AnimateDiff node answers
+ * in the newer COMBO schema while the stock loaders answer in the legacy one
+ * (proven on the box, see comfyui-enum.ts), and one hand-read spec was enough
+ * to take the whole video discovery down. */
+async function fetchNodeOptions(
+ node: string,
+ field: string,
+ opts: { strict?: boolean } = {},
+): Promise<string[]> {
+ const res = await localFetch(comfyuiUrl(`/object_info/${node}`), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
+ if (!res.ok) {
+ if (opts.strict) throw new Error(`ComfyUI /object_info/${node} failed (HTTP ${res.status})`)
+ return []
+ }
const data = await res.json()
- return data?.CheckpointLoaderSimple?.input?.required?.ckpt_name?.[0] ?? []
+ return nodeComboOptions(data, node, field)
+}
+
+export async function getCheckpoints(): Promise<string[]> {
+ return fetchNodeOptions('CheckpointLoaderSimple', 'ckpt_name', { strict: true })
}
export async function getDiffusionModels(): Promise<string[]> {
- const res = await localFetch(comfyuiUrl('/object_info/UNETLoader'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) throw new Error(`ComfyUI /object_info/UNETLoader failed (HTTP ${res.status})`)
- const data = await res.json()
- return data?.UNETLoader?.input?.required?.unet_name?.[0] ?? []
+ return fetchNodeOptions('UNETLoader', 'unet_name', { strict: true })
}
export async function getVAEModels(): Promise<string[]> {
try {
- const res = await localFetch(comfyuiUrl('/object_info/VAELoader'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) return []
- const data = await res.json()
- return data?.VAELoader?.input?.required?.vae_name?.[0] ?? []
+ return await fetchNodeOptions('VAELoader', 'vae_name')
} catch (err) {
log.warn('comfyui.fetch_vae_failed', { err })
return []
@@ -572,10 +589,7 @@ export async function getVAEModels(): Promise<string[]> {
export async function getCLIPModels(): Promise<string[]> {
try {
- const res = await localFetch(comfyuiUrl('/object_info/CLIPLoader'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) return []
- const data = await res.json()
- return data?.CLIPLoader?.input?.required?.clip_name?.[0] ?? []
+ return await fetchNodeOptions('CLIPLoader', 'clip_name')
} catch (err) {
log.warn('comfyui.fetch_clip_failed', { err })
return []
@@ -590,10 +604,7 @@ export async function getCLIPModels(): Promise<string[]> {
*/
export async function getLoraModels(): Promise<string[]> {
try {
- const res = await localFetch(comfyuiUrl('/object_info/LoraLoader'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) return []
- const data = await res.json()
- return data?.LoraLoader?.input?.required?.lora_name?.[0] ?? []
+ return await fetchNodeOptions('LoraLoader', 'lora_name')
} catch (err) {
log.warn('comfyui.fetch_lora_failed', { err })
return []
@@ -602,10 +613,9 @@ export async function getLoraModels(): Promise<string[]> {
export async function getSamplers(): Promise<string[]> {
try {
- const res = await localFetch(comfyuiUrl('/object_info/KSampler'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) throw new Error('Failed')
- const data = await res.json()
- return data?.KSampler?.input?.required?.sampler_name?.[0] ?? []
+ const list = await fetchNodeOptions('KSampler', 'sampler_name')
+ if (list.length === 0) throw new Error('KSampler listed no samplers')
+ return list
} catch {
return ['euler', 'euler_ancestral', 'dpmpp_2m', 'dpmpp_2m_sde', 'dpmpp_sde', 'uni_pc', 'ddim']
}
@@ -613,10 +623,9 @@ export async function getSamplers(): Promise<string[]> {
export async function getSchedulers(): Promise<string[]> {
try {
- const res = await localFetch(comfyuiUrl('/object_info/KSampler'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) throw new Error('Failed')
- const data = await res.json()
- return data?.KSampler?.input?.required?.scheduler?.[0] ?? []
+ const list = await fetchNodeOptions('KSampler', 'scheduler')
+ if (list.length === 0) throw new Error('KSampler listed no schedulers')
+ return list
} catch {
return ['normal', 'karras', 'simple', 'exponential', 'sgm_uniform']
}
@@ -626,14 +635,15 @@ export async function getSchedulers(): Promise<string[]> {
* live under ComfyUI\models: the pack keeps them in
* custom_nodes/ComfyUI-AnimateDiff-Evolved/models, which is why the four
* ComfyUI\models loaders cannot see them and why every surface that only read
- * those four reported an installed AnimateDiff bundle as nothing at all. */
+ * those four reported an installed AnimateDiff bundle as nothing at all.
+ *
+ * This is also the node that answers in the newer COMBO schema on a real box,
+ * so it is the one that used to hand a bare "COMBO" string to callers. */
export async function getAnimateDiffModels(): Promise<string[]> {
try {
- const res = await localFetch(comfyuiUrl('/object_info/ADE_LoadAnimateDiffModel'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) return []
- const data = await res.json()
- return data?.ADE_LoadAnimateDiffModel?.input?.required?.model_name?.[0] ?? []
- } catch {
+ return await fetchNodeOptions('ADE_LoadAnimateDiffModel', 'model_name')
+ } catch (err) {
+ log.warn('comfyui.fetch_animatediff_failed', { err })
return []
}
}
@@ -789,6 +799,28 @@ export async function getAnimateDiffMotionModels(): Promise<ClassifiedModel[]> {
return names.map((name) => ({ name, type: 'animatediff' as ModelType, source: 'motion_module' as const }))
}
+/** One lane of the inventory, read on its own. A lane that fails costs itself
+ * and one log line, never the lanes beside it.
+ *
+ * Counter-check on the Windows box, 2026-08-29: the AnimateDiff lane threw
+ * ("(intermediate value).map is not a function", because that node answers in
+ * the newer COMBO schema) and took the ENTIRE video discovery with it. The
+ * Models page then showed a Video tab with no number, Installed 0 and "No
+ * video models installed" while three cards correctly said Installed, and the
+ * whole thing was a warn line nobody saw. The reader below is fixed at the
+ * root, but a single lane must never again be able to empty the page. */
+async function inventoryLane(
+ lane: string,
+ read: () => Promise<ClassifiedModel[]>,
+): Promise<ClassifiedModel[]> {
+ try {
+ return await read()
+ } catch (err) {
+ log.warn('comfyui.inventory_lane_failed', { lane, err })
+ return []
+ }
+}
+
/** Everything installed in the video lane, for the INVENTORY surfaces: the
* Models rail counter and the Installed tab.
*
@@ -813,10 +845,13 @@ export async function getAnimateDiffMotionModels(): Promise<ClassifiedModel[]> {
* Not used by detectVideoBackend, the Create picker or model-pick: those ask
* for a main model and getVideoModels still answers exactly what it did. */
export async function getInstalledVideoModels(): Promise<ClassifiedModel[]> {
- const [videoModels, motionModels] = await Promise.all([getVideoModels(), getAnimateDiffMotionModels()])
+ const [videoModels, motionModels] = await Promise.all([
+ inventoryLane('video', getVideoModels),
+ inventoryLane('animatediff', getAnimateDiffMotionModels),
+ ])
const out: ClassifiedModel[] = [...videoModels, ...motionModels]
if (motionModels.length > 0) {
- const imageModels = await getImageModels()
+ const imageModels = await inventoryLane('image', getImageModels)
for (const m of imageModels) {
if (m.source !== 'checkpoint') continue
if (out.some((x) => x.name === m.name)) continue
@@ -836,11 +871,9 @@ export async function getInstalledVideoModels(): Promise<ClassifiedModel[]> {
* UNETLoader for UnetLoaderGGUF by extension. */
export async function getGgufUnetModels(): Promise<string[]> {
try {
- const res = await localFetch(comfyuiUrl('/object_info/UnetLoaderGGUF'), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
- if (!res.ok) return []
- const data = await res.json()
- return data?.UnetLoaderGGUF?.input?.required?.unet_name?.[0] ?? []
- } catch {
+ return await fetchNodeOptions('UnetLoaderGGUF', 'unet_name')
+ } catch (err) {
+ log.warn('comfyui.fetch_gguf_failed', { err })
return []
}
}
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index d3140245..c41ff057 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -2,6 +2,7 @@ import { classifyModel, findMatchingVAE, findMatchingCLIP, findFluxCLIPPair } fr
import type { ModelType, GenerateParams, VideoParams } from './comfyui'
import { log } from '../lib/logger'
import { resolveRunSeed } from '../lib/run-seed'
+import { readComboOptions } from './comfyui-enum'
import {
getAllNodeInfo,
categorizeNodes,
@@ -620,7 +621,7 @@ export async function buildDynamicWorkflow(
const loraNames = normalizeLoraList(params.lora)
if (loraNames.length > 0) {
const installed: string[] =
- (allNodes?.LoraLoader?.input?.required?.lora_name?.[0] as string[] | undefined) ?? []
+ readComboOptions(allNodes?.LoraLoader?.input?.required?.lora_name) ?? []
const resolved = resolveLoraNames(loraNames, installed)
const strengths = normalizeLoraStrengths(params.loraStrength, resolved.length)
resolved.forEach((loraName, i) => {
@@ -1045,12 +1046,17 @@ function buildRemoveBgWorkflow(params: GenerateParams, rmbgMeta: any): Record<st
function rmbgWidgetDefault(name: string, spec: any): { set: boolean; value?: any } {
const t = Array.isArray(spec) ? spec[0] : spec
const cfg = Array.isArray(spec) ? spec[1] : undefined
- if (Array.isArray(t)) {
+ // Both dropdown schemas, through the shared reader: a node that declares its
+ // combos the newer way (["COMBO", {options: [...]}]) used to fall through to
+ // "not a widget" here, and RMBG then rejected the graph for the missing
+ // widget it had just declared.
+ const options = readComboOptions(spec)
+ if (options && options.length > 0) {
if (/back\s*ground|(^|_)bg($|_)/i.test(name)) {
- const alpha = t.find((o: any) => typeof o === 'string' && /alpha|transparent/i.test(o))
+ const alpha = options.find((o) => /alpha|transparent/i.test(o))
if (alpha) return { set: true, value: alpha }
}
- return { set: true, value: cfg?.default ?? t[0] }
+ return { set: true, value: cfg?.default ?? options[0] }
}
if (t === 'BOOLEAN') return { set: true, value: cfg?.default ?? false }
if (t === 'INT' || t === 'FLOAT') return { set: true, value: cfg?.default ?? 0 }