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(comfyui): separator-insensitive LoRA name resolution

purple17c818e24ada
diff --git a/src/api/__tests__/dynamic-workflow-multi-lora.test.ts b/src/api/__tests__/dynamic-workflow-multi-lora.test.ts
index 30a01b33..c3e909ab 100644
--- a/src/api/__tests__/dynamic-workflow-multi-lora.test.ts
+++ b/src/api/__tests__/dynamic-workflow-multi-lora.test.ts
@@ -91,6 +91,12 @@ describe('resolveLoraNames', () => {
it('unique substring resolves', () => {
expect(resolveLoraNames(['detail'], INSTALLED)).toEqual(['detail-tweaker.safetensors'])
})
+ it('separator-insensitive: "pixel art" (spaces) finds pixel-art-xl (dashes)', () => {
+ // Live E2E 2026-06-10 found this gap: a natural-language "use the pixel
+ // art lora" arrives as 'pixel art' and the dash-only substring missed it.
+ expect(resolveLoraNames(['pixel art'], INSTALLED)).toEqual(['pixel-art-xl.safetensors'])
+ expect(resolveLoraNames(['pixel_art_xl'], INSTALLED)).toEqual(['pixel-art-xl.safetensors'])
+ })
it('a miss throws an actionable error listing installed LoRAs', () => {
expect(() => resolveLoraNames(['does-not-exist'], INSTALLED)).toThrow(/not installed/i)
expect(() => resolveLoraNames(['does-not-exist'], INSTALLED)).toThrow(/pixel-art-xl\.safetensors/)
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index 3019d83f..be7bc073 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -289,6 +289,9 @@ function resolveOneLora(req: string, installed: string[]): string | null {
if (installed.includes(req)) return req
const norm = (s: string) =>
s.toLowerCase().replace(/\.(safetensors|pt|ckpt|bin)$/i, '').replace(/\\/g, '/')
+ // Separator-insensitive form: users/LLMs say "pixel art" for
+ // "pixel-art-xl.safetensors" — spaces, dashes and underscores all collapse.
+ const loose = (s: string) => norm(s).replace(/[-_\s]+/g, '')
const rq = norm(req)
let hits = installed.filter((c) => norm(c) === rq)
if (hits.length === 1) return hits[0]
@@ -296,8 +299,9 @@ function resolveOneLora(req: string, installed: string[]): string | null {
const rqBase = rq.split('/').pop() || rq
hits = installed.filter((c) => (norm(c).split('/').pop() || '') === rqBase)
if (hits.length === 1) return hits[0]
- // Last resort: unique substring either way round.
- hits = installed.filter((c) => norm(c).includes(rq) || rq.includes(norm(c)))
+ // Unique substring either way round (separator-insensitive).
+ const rqLoose = loose(req)
+ hits = installed.filter((c) => loose(c).includes(rqLoose) || rqLoose.includes(loose(c)))
if (hits.length === 1) return hits[0]
return null
}