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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(comfyui): actionable encoder-download hint instead of "CLIPLoader: Value not in list" (aldrich)
purplece1c5af9602a
diff --git a/src/api/__tests__/dynamic-workflow-clip-missing.test.ts b/src/api/__tests__/dynamic-workflow-clip-missing.test.tsnew file mode 100644index 00000000..91475873--- /dev/null+++ b/src/api/__tests__/dynamic-workflow-clip-missing.test.ts@@ -0,0 +1,70 @@+/**+ * Bug C (aldrich): FLUX "CLIPLoader: Value not in list".+ *+ * Root cause was buildDynamicWorkflow's silent catch fallback+ * (`clip = models.clips[0] || ''`): when no matching text encoder was found it+ * emitted an empty/wrong clip_name, which ComfyUI rejects with that cryptic+ * error. The fix propagates findMatchingCLIP's actionable "download <encoder>"+ * message as a WorkflowUnavailableError instead.+ *+ * Run: npx vitest run src/api/__tests__/dynamic-workflow-clip-missing.test.ts+ */+import { describe, it, expect, vi, beforeEach } from 'vitest'++// Mock the live-fetch boundary; keep the real pure helpers (classifyModel,+// categorizeNodes, detectAvailableModels, determineStrategy).+vi.mock('../comfyui-nodes', async (importOriginal) => {+ const actual = await importOriginal<typeof import('../comfyui-nodes')>()+ return { ...actual, getAllNodeInfo: vi.fn() }+})+vi.mock('../comfyui', async (importOriginal) => {+ const actual = await importOriginal<typeof import('../comfyui')>()+ return { ...actual, findMatchingCLIP: vi.fn(), findMatchingVAE: vi.fn() }+})++import { buildDynamicWorkflow, WorkflowUnavailableError } from '../dynamic-workflow'+import { getAllNodeInfo } from '../comfyui-nodes'+import { findMatchingCLIP, findMatchingVAE } from '../comfyui'++// Minimal /object_info that categorizes to a FLUX unet strategy.+const FLUX_NODES = {+ UNETLoader: { input: { required: { unet_name: [[]] } } },+ CLIPLoader: { input: { required: { clip_name: [[]] } } },+ VAELoader: { input: { required: { vae_name: [[]] } } },+ KSampler: { input: { required: {} } },+ EmptySD3LatentImage: { input: { required: {} } },+ CLIPTextEncode: { input: { required: {} } },+ VAEDecode: { input: { required: {} } },+ SaveImage: { input: { required: {} } },+}++const fluxParams = {+ model: 'flux1-dev-fp8.safetensors',+ prompt: 'a cat', negativePrompt: '',+ width: 1024, height: 1024, steps: 20, cfg: 1, seed: 1,+} as never++describe('buildDynamicWorkflow — Bug C: missing FLUX text encoder', () => {+ beforeEach(() => {+ vi.mocked(getAllNodeInfo).mockResolvedValue(FLUX_NODES as never)+ vi.mocked(findMatchingVAE).mockResolvedValue('ae.safetensors')+ })++ it('throws an actionable WorkflowUnavailableError instead of emitting clip_name:""', async () => {+ vi.mocked(findMatchingCLIP).mockRejectedValue(+ new Error('No FLUX text encoder (T5) found. Download "t5xxl_fp8_e4m3fn.safetensors" from the Model Manager.'),+ )+ await expect(buildDynamicWorkflow(fluxParams)).rejects.toBeInstanceOf(WorkflowUnavailableError)+ await expect(buildDynamicWorkflow(fluxParams)).rejects.toThrow(/download/i)+ })++ it('uses the resolved encoder (never an empty clip_name) when one is found', async () => {+ vi.mocked(findMatchingCLIP).mockResolvedValue('t5xxl_fp8_e4m3fn.safetensors')+ const wf = await buildDynamicWorkflow(fluxParams)+ const clipLoader = Object.values(wf).find((n) => (n as { class_type?: string }).class_type === 'CLIPLoader') as+ | { inputs: { clip_name: string } }+ | undefined+ expect(clipLoader?.inputs.clip_name).toBe('t5xxl_fp8_e4m3fn.safetensors')+ expect(clipLoader?.inputs.clip_name).not.toBe('')+ })+})diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.tsindex 30f0ff44..30668948 100644--- a/src/api/dynamic-workflow.ts+++ b/src/api/dynamic-workflow.ts@@ -322,12 +322,39 @@ export async function buildDynamicWorkflow(: type === 'cosmos' ? 'cosmos': 'flux'- let vae: string, clip: string- try { vae = await findMatchingVAE(type) } catch { vae = models.vaes[0] || '' }- // Pass the active UNet filename so the resolver can prefer the matching- // quantisation tier (fp4 model → fp4 encoder; fp8/bf16 model → full-- // precision encoder). See findMatchingCLIP's flux2 branch.- try { clip = await findMatchingCLIP(type, params.model) } catch { clip = models.clips[0] || '' }+ // Resolve the text encoder from the LIVE ComfyUI node enum. CRITICAL+ // (Bug C / aldrich "CLIPLoader: Value not in list"): do NOT silently fall+ // back to models.clips[0] / '' on a miss — an empty or wrong clip_name makes+ // ComfyUI reject the prompt with that exact cryptic error. findMatchingCLIP+ // already throws an actionable "download <encoder>" message; propagate it as+ // a WorkflowUnavailableError so the user gets the download hint instead of a+ // raw rejection. Pass the active UNet filename so the resolver prefers the+ // matching quant tier (fp4 model → fp4 encoder; fp8/bf16 → full precision).+ let clip: string+ try {+ clip = await findMatchingCLIP(type, params.model)+ } catch (clipErr) {+ throw new WorkflowUnavailableError(+ clipErr instanceof Error ? clipErr.message : 'Required text encoder not found in ComfyUI.',+ strategy,+ )+ }++ // VAE is only loaded for strategies with a separate VAELoader — LTX bakes it+ // into the pipeline, so a missing VAE there is fine. Validate (same+ // no-silent-fallback rule) only when it will actually be used.+ const needsVAELoader = strategy !== 'unet_ltx'+ let vae = ''+ if (needsVAELoader) {+ try {+ vae = await findMatchingVAE(type)+ } catch (vaeErr) {+ throw new WorkflowUnavailableError(+ vaeErr instanceof Error ? vaeErr.message : 'Required VAE not found in ComfyUI.',+ strategy,+ )+ }+ }workflow[unetId] = {class_type: 'UNETLoader',@@ -338,8 +365,6 @@ export async function buildDynamicWorkflow(inputs: { clip_name: clip, type: clipType, device: 'default' },}- // LTX doesn't need a separate VAE loader — VAE is built into the pipeline- const needsVAELoader = strategy !== 'unet_ltx'let vaeId: stringif (needsVAELoader) {vaeId = String(n++)