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.

feat(comfyui): multi-LoRA chaining for image generation (konata)

purpleaa99358759d9
diff --git a/src/api/__tests__/dynamic-workflow-multi-lora.test.ts b/src/api/__tests__/dynamic-workflow-multi-lora.test.ts
new file mode 100644
index 00000000..30a01b33
--- /dev/null
+++ b/src/api/__tests__/dynamic-workflow-multi-lora.test.ts
@@ -0,0 +1,166 @@
+/**
+ * Multi-LoRA chaining (konata 2026-06-09: "agent cannot load multiple loras").
+ *
+ * Before: buildDynamicWorkflow created exactly ONE LoraLoader from a single
+ * string param — an LLM passing "a.safetensors, b.safetensors" sent the
+ * joined string to ComfyUI verbatim and died with "Value not in list".
+ * Now: the lora param accepts string | string[] (plus comma-joined strings),
+ * names are resolved against the real LoraLoader enum with actionable
+ * errors, and N LoRAs chain through N LoraLoader nodes exactly like
+ * stacking them in the ComfyUI graph editor.
+ *
+ * Run: npx vitest run src/api/__tests__/dynamic-workflow-multi-lora.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+vi.mock('../comfyui-nodes', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../comfyui-nodes')>()
+ return { ...actual, getAllNodeInfo: vi.fn() }
+})
+
+import {
+ buildDynamicWorkflow,
+ normalizeLoraList,
+ normalizeLoraStrengths,
+ resolveLoraNames,
+} from '../dynamic-workflow'
+import { getAllNodeInfo } from '../comfyui-nodes'
+
+const INSTALLED = ['pixel-art-xl.safetensors', 'detail-tweaker.safetensors', 'styles/ghibli_v2.safetensors']
+
+// Minimal /object_info for the plain checkpoint (SDXL) strategy, with a
+// LoraLoader whose enum carries the installed LoRAs.
+const CHECKPOINT_NODES = {
+ CheckpointLoaderSimple: { input: { required: { ckpt_name: [['Juggernaut-XL_v9.safetensors']] } } },
+ LoraLoader: { input: { required: { lora_name: [INSTALLED] } } },
+ KSampler: { input: { required: {} } },
+ EmptyLatentImage: { input: { required: {} } },
+ CLIPTextEncode: { input: { required: {} } },
+ VAEDecode: { input: { required: {} } },
+ SaveImage: { input: { required: {} } },
+}
+
+const baseParams = {
+ model: 'Juggernaut-XL_v9.safetensors',
+ prompt: 'a knight', negativePrompt: '',
+ sampler: 'euler', scheduler: 'normal',
+ steps: 20, cfgScale: 7, width: 1024, height: 1024, seed: 42, batchSize: 1,
+}
+
+type LoraNode = { class_type: string; inputs: Record<string, unknown> }
+const loraNodesOf = (wf: Record<string, any>): [string, LoraNode][] =>
+ Object.entries(wf).filter(([, n]) => (n as LoraNode).class_type === 'LoraLoader') as [string, LoraNode][]
+
+describe('normalizeLoraList', () => {
+ it('passes arrays through (trimmed, empties dropped)', () => {
+ expect(normalizeLoraList([' a.safetensors ', '', 'b.safetensors'])).toEqual(['a.safetensors', 'b.safetensors'])
+ })
+ it('splits comma/semicolon-joined strings (the LLM shape that used to break)', () => {
+ expect(normalizeLoraList('a.safetensors, b.safetensors')).toEqual(['a.safetensors', 'b.safetensors'])
+ expect(normalizeLoraList('a;b')).toEqual(['a', 'b'])
+ })
+ it('single name stays a one-element list; undefined → []', () => {
+ expect(normalizeLoraList('a.safetensors')).toEqual(['a.safetensors'])
+ expect(normalizeLoraList(undefined)).toEqual([])
+ })
+})
+
+describe('normalizeLoraStrengths', () => {
+ it('single number applies to every LoRA', () => {
+ expect(normalizeLoraStrengths(1.2, 3)).toEqual([1.2, 1.2, 1.2])
+ })
+ it('array maps per index, missing tail falls back to 0.8', () => {
+ expect(normalizeLoraStrengths([1.0, 0.5], 3)).toEqual([1.0, 0.5, 0.8])
+ })
+ it('undefined → 0.8 for all; non-finite garbage → 0.8', () => {
+ expect(normalizeLoraStrengths(undefined, 2)).toEqual([0.8, 0.8])
+ expect(normalizeLoraStrengths([Number.NaN, Infinity] as number[], 2)).toEqual([0.8, 0.8])
+ })
+})
+
+describe('resolveLoraNames', () => {
+ it('exact names pass through', () => {
+ expect(resolveLoraNames(['pixel-art-xl.safetensors'], INSTALLED)).toEqual(['pixel-art-xl.safetensors'])
+ })
+ it('extension and case are optional', () => {
+ expect(resolveLoraNames(['Pixel-Art-XL'], INSTALLED)).toEqual(['pixel-art-xl.safetensors'])
+ })
+ it('subfolder enum entries match by basename', () => {
+ expect(resolveLoraNames(['ghibli_v2'], INSTALLED)).toEqual(['styles/ghibli_v2.safetensors'])
+ })
+ it('unique substring resolves', () => {
+ expect(resolveLoraNames(['detail'], INSTALLED)).toEqual(['detail-tweaker.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/)
+ })
+})
+
+describe('buildDynamicWorkflow — LoRA chaining', () => {
+ beforeEach(() => {
+ vi.mocked(getAllNodeInfo).mockResolvedValue(CHECKPOINT_NODES as never)
+ })
+
+ it('single LoRA keeps the original single-node behaviour', async () => {
+ const wf = await buildDynamicWorkflow({ ...baseParams, lora: 'pixel-art-xl.safetensors', loraStrength: 0.7 } as never)
+ const loras = loraNodesOf(wf)
+ expect(loras).toHaveLength(1)
+ expect(loras[0][1].inputs.lora_name).toBe('pixel-art-xl.safetensors')
+ expect(loras[0][1].inputs.strength_model).toBe(0.7)
+ })
+
+ it('two LoRAs chain: second consumes the first, sampler + CLIP see the last', async () => {
+ const wf = await buildDynamicWorkflow({
+ ...baseParams,
+ lora: ['pixel-art-xl.safetensors', 'detail-tweaker.safetensors'],
+ loraStrength: [1.0, 0.5],
+ } as never)
+ const loras = loraNodesOf(wf)
+ expect(loras).toHaveLength(2)
+ const [firstId, first] = loras.find(([, n]) => n.inputs.lora_name === 'pixel-art-xl.safetensors')!
+ const [secondId, second] = loras.find(([, n]) => n.inputs.lora_name === 'detail-tweaker.safetensors')!
+ // Chain wiring: second's model AND clip come from the first LoraLoader.
+ expect(second.inputs.model).toEqual([firstId, 0])
+ expect(second.inputs.clip).toEqual([firstId, 1])
+ // Per-LoRA strengths land on the right node.
+ expect(first.inputs.strength_model).toBe(1.0)
+ expect(second.inputs.strength_model).toBe(0.5)
+ // Sampler consumes the LAST LoRA's model output.
+ const sampler = Object.values(wf).find((n: any) => n.class_type === 'KSampler') as LoraNode
+ expect(sampler.inputs.model).toEqual([secondId, 0])
+ // Text encoding consumes the LAST LoRA's clip output (slot 1).
+ const encoders = Object.values(wf).filter((n: any) => n.class_type === 'CLIPTextEncode') as LoraNode[]
+ for (const enc of encoders) expect(enc.inputs.clip).toEqual([secondId, 1])
+ })
+
+ it('a comma-joined string from the LLM chains too (konata repro)', async () => {
+ const wf = await buildDynamicWorkflow({
+ ...baseParams,
+ lora: 'pixel-art-xl, detail-tweaker',
+ } as never)
+ expect(loraNodesOf(wf)).toHaveLength(2)
+ })
+
+ it('the same LoRA may stack twice (different strengths)', async () => {
+ const wf = await buildDynamicWorkflow({
+ ...baseParams,
+ lora: ['pixel-art-xl.safetensors', 'pixel-art-xl.safetensors'],
+ loraStrength: [0.8, 0.3],
+ } as never)
+ const loras = loraNodesOf(wf)
+ expect(loras).toHaveLength(2)
+ expect(loras.map(([, n]) => n.inputs.strength_model).sort()).toEqual([0.3, 0.8])
+ })
+
+ it('an unknown LoRA fails the build with the installed list (never reaches ComfyUI)', async () => {
+ await expect(
+ buildDynamicWorkflow({ ...baseParams, lora: ['pixel-art-xl.safetensors', 'nope-v9'] } as never),
+ ).rejects.toThrow(/not installed.*pixel-art-xl/is)
+ })
+
+ it('no lora param → no LoraLoader nodes (byte-identical baseline)', async () => {
+ const wf = await buildDynamicWorkflow({ ...baseParams } as never)
+ expect(loraNodesOf(wf)).toHaveLength(0)
+ })
+})
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 6d7258df..0ba433af 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -36,10 +36,14 @@ export interface GenerateParams {
batchSize: number
inputImage?: string // I2I source image filename (uploaded to ComfyUI)
denoise?: number // I2I denoise strength (0.0–1.0, default 1.0 = full txt2img)
- // F2 (cinemazverev GH#4): a single LoRA slot. Empty = no LoRA.
- // `loraStrength` mirrors LoraLoader's `strength_model` (0..2 typical).
- lora?: string
- loraStrength?: number
+ // F2 (cinemazverev GH#4), extended for multi-LoRA (konata 2026-06-09:
+ // "agent cannot load multiple loras"): one filename or an ordered list.
+ // Multiple LoRAs are CHAINED — LoraLoader N feeds (model, clip) into
+ // LoraLoader N+1, exactly like stacking them in the ComfyUI graph editor.
+ // `loraStrength` mirrors LoraLoader's `strength_model` (0..2 typical):
+ // a single number applies to every LoRA, an array maps per-LoRA by index.
+ lora?: string | string[]
+ loraStrength?: number | number[]
// F3 (vanja-san GH#4): override the checkpoint's bundled VAE with an
// explicit VAELoader. 'auto' / undefined / empty = keep the
// checkpoint VAE.
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index b3961110..3019d83f 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -239,6 +239,69 @@ export async function checkVideoOutputCapability(): Promise<{ mp4Capable: boolea
}
}
+/** Multi-LoRA (konata 2026-06-09) — normalize the `lora` param into an
+ * ordered list. Accepts a single filename, an array, or a comma/semicolon-
+ * joined string (the most common LLM shape for "use lora A and lora B" —
+ * exactly the failing case where the joined string used to reach ComfyUI
+ * verbatim and die with an opaque "Value not in list"). */
+export function normalizeLoraList(lora: string | string[] | undefined): string[] {
+ if (!lora) return []
+ const arr = Array.isArray(lora) ? lora : lora.split(/[,;]+/)
+ return arr.map((s) => (typeof s === 'string' ? s.trim() : '')).filter(Boolean)
+}
+
+/** One strength per LoRA: a single number applies to all, an array maps by
+ * index (missing/invalid entries fall back to 0.8). No range clamp — the
+ * LoraLoader node itself owns its real min/max (no magic numbers here);
+ * only non-finite garbage is replaced. */
+export function normalizeLoraStrengths(
+ strength: number | number[] | undefined,
+ count: number,
+): number[] {
+ const fallback = 0.8
+ const sane = (v: unknown): number =>
+ typeof v === 'number' && Number.isFinite(v) ? v : fallback
+ if (typeof strength === 'number') return Array(count).fill(sane(strength))
+ if (Array.isArray(strength)) return Array.from({ length: count }, (_, i) => sane(strength[i]))
+ return Array(count).fill(fallback)
+}
+
+/** Resolve requested LoRA names against ComfyUI's installed LoraLoader enum.
+ * Per name: exact → normalized (case/extension/path-separator insensitive)
+ * → basename → unique substring. A miss throws an actionable error listing
+ * what IS installed (same pattern as the Fix-C encoder hint) instead of
+ * letting ComfyUI reject the whole workflow with "Value not in list". */
+export function resolveLoraNames(requested: string[], installed: string[]): string[] {
+ return requested.map((req) => {
+ const hit = resolveOneLora(req, installed)
+ if (!hit) {
+ const list = installed.length ? installed.slice(0, 12).join(', ') : '(none installed)'
+ throw new Error(
+ `LoRA "${req}" is not installed in ComfyUI. Installed LoRAs: ${list}. ` +
+ `Put the .safetensors file into ComfyUI/models/loras and retry, or drop the lora setting.`,
+ )
+ }
+ return hit
+ })
+}
+
+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, '/')
+ const rq = norm(req)
+ let hits = installed.filter((c) => norm(c) === rq)
+ if (hits.length === 1) return hits[0]
+ // Enum entries can be "subfolder/name.safetensors" — try basename equality.
+ 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)))
+ if (hits.length === 1) return hits[0]
+ return null
+}
+
export async function buildDynamicWorkflow(
params: GenerateParams | VideoParams,
modelType?: ModelType,
@@ -447,11 +510,16 @@ export async function buildDynamicWorkflow(
samplerModelId = evolvedId
}
- // ─── Phase 1b: Optional LoRA + VAE + Skip-CLIP injection (F2 + F3) ───
+ // ─── Phase 1b: Optional LoRA chain + VAE + Skip-CLIP injection (F2 + F3) ───
//
- // Single LoRA slot (cinemazverev GH#4): LoraLoader takes (model, clip)
- // and outputs new (model, clip) — we rewire both refs so the rest of
- // the pipeline sees the LoRA-modified versions.
+ // LoRA chain (cinemazverev GH#4; multi-LoRA konata 2026-06-09): each
+ // LoraLoader takes (model, clip) and outputs new (model, clip) — chaining
+ // N loaders applies the LoRAs in order, exactly like stacking them in the
+ // ComfyUI graph editor. We rewire both refs after every link so the rest
+ // of the pipeline sees the fully-stacked versions. Names are resolved
+ // against ComfyUI's real LoraLoader enum (fuzzy: extension/case optional)
+ // and a miss throws an actionable error instead of ComfyUI's opaque
+ // "Value not in list".
//
// VAE override (vanja-san GH#4): VAELoader replaces vaeSourceId. The
// checkpoint's bundled VAE stays unused.
@@ -463,21 +531,28 @@ export async function buildDynamicWorkflow(
// All three are skipped (no extra nodes) when the corresponding
// param is unset, so workflows without F2/F3 enabled stay byte-
// identical to the previous behaviour.
- if (params.lora) {
- const loraId = String(n++)
- workflow[loraId] = {
- class_type: 'LoraLoader',
- inputs: {
- lora_name: params.lora,
- strength_model: params.loraStrength ?? 0.8,
- strength_clip: params.loraStrength ?? 0.8,
- model: [samplerModelId, 0],
- clip: [clipSourceId, clipOutputSlot],
- },
- }
- samplerModelId = loraId
- clipSourceId = loraId
- clipOutputSlot = 1
+ const loraNames = normalizeLoraList(params.lora)
+ if (loraNames.length > 0) {
+ const installed: string[] =
+ (allNodes?.LoraLoader?.input?.required?.lora_name?.[0] as string[] | undefined) ?? []
+ const resolved = resolveLoraNames(loraNames, installed)
+ const strengths = normalizeLoraStrengths(params.loraStrength, resolved.length)
+ resolved.forEach((loraName, i) => {
+ const loraId = String(n++)
+ workflow[loraId] = {
+ class_type: 'LoraLoader',
+ inputs: {
+ lora_name: loraName,
+ strength_model: strengths[i],
+ strength_clip: strengths[i],
+ model: [samplerModelId, 0],
+ clip: [clipSourceId, clipOutputSlot],
+ },
+ }
+ samplerModelId = loraId
+ clipSourceId = loraId
+ clipOutputSlot = 1
+ })
}
if (params.vae && params.vae !== 'auto') {
diff --git a/src/api/mcp/builtin-tools.ts b/src/api/mcp/builtin-tools.ts
index 2ba17b65..b1a05789 100644
--- a/src/api/mcp/builtin-tools.ts
+++ b/src/api/mcp/builtin-tools.ts
@@ -498,8 +498,8 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [
height: { type: 'number', description: 'Output height in px.' },
negativePrompt: { type: 'string', description: 'Things to avoid.' },
denoise: { type: 'number', description: 'Image-to-image strength 0.05–1.0 (only with inputImage).' },
- lora: { type: 'string', description: 'LoRA filename to apply.' },
- loraStrength: { type: 'number', description: 'LoRA strength (~0–2).' },
+ lora: { type: ['string', 'array'], items: { type: 'string' }, description: 'LoRA filename to apply — or an ARRAY of filenames to stack multiple LoRAs (chained in order, like stacking LoraLoader nodes). Names are matched against the installed LoRAs (extension optional); an unknown name is rejected with the installed list.' },
+ loraStrength: { type: ['number', 'array'], items: { type: 'number' }, description: 'LoRA strength (~0–2). Single number = applied to every LoRA; array = one strength per LoRA in the same order.' },
vae: { type: 'string', description: 'Override VAE filename.' },
},
},
diff --git a/src/api/mcp/types.ts b/src/api/mcp/types.ts
index a6512070..dacdbfec 100644
--- a/src/api/mcp/types.ts
+++ b/src/api/mcp/types.ts
@@ -27,7 +27,9 @@ export const DEFAULT_PERMISSIONS: PermissionMap = {
// permissive on purpose: this is forwarded verbatim to the model as the tool's
// `parameters`, not strictly validated here.
export interface JSONSchemaProp {
- type: string
+ /** Single JSON-Schema type or a union (e.g. ['string','array'] for the
+ * multi-LoRA param). The args-validator already understands unions. */
+ type: string | string[]
description?: string
enum?: string[]
items?: JSONSchemaProp
diff --git a/src/api/vram-handoff.ts b/src/api/vram-handoff.ts
index 3163da6e..ada38cb1 100644
--- a/src/api/vram-handoff.ts
+++ b/src/api/vram-handoff.ts
@@ -676,8 +676,19 @@ async function generateImage(prompt: string, model: string, args: VramHandoffArg
height,
seed,
batchSize,
- ...(typeof a.lora === 'string' && a.lora ? { lora: a.lora as string } : {}),
- ...(typeof a.loraStrength === 'number' ? { loraStrength: a.loraStrength as number } : {}),
+ // Multi-LoRA (konata): accept a single name, an array, or a comma-
+ // joined string; same for strengths. buildDynamicWorkflow normalizes
+ // and chains them — invalid shapes are simply dropped here.
+ ...(typeof a.lora === 'string' && a.lora
+ ? { lora: a.lora as string }
+ : Array.isArray(a.lora) && (a.lora as unknown[]).some((x) => typeof x === 'string' && x)
+ ? { lora: (a.lora as unknown[]).filter((x): x is string => typeof x === 'string' && !!x) }
+ : {}),
+ ...(typeof a.loraStrength === 'number'
+ ? { loraStrength: a.loraStrength as number }
+ : Array.isArray(a.loraStrength) && (a.loraStrength as unknown[]).some((x) => typeof x === 'number')
+ ? { loraStrength: (a.loraStrength as unknown[]).filter((x): x is number => typeof x === 'number') }
+ : {}),
...(typeof a.vae === 'string' && a.vae ? { vae: a.vae as string } : {}),
...(typeof a.clipSkip === 'number' ? { clipSkip: a.clipSkip as number } : {}),
...(inputImage ? { inputImage, denoise } : {}),
diff --git a/src/components/create/ParamPanel.tsx b/src/components/create/ParamPanel.tsx
index 6b1a0e0d..b3cf98cc 100644
--- a/src/components/create/ParamPanel.tsx
+++ b/src/components/create/ParamPanel.tsx
@@ -344,30 +344,51 @@ function ExtendedComfyParams() {
<div className="space-y-2 pt-1 border-t border-gray-200 dark:border-white/5">
<div className="text-[0.55rem] uppercase tracking-widest text-gray-500">Extended</div>
- {/* LoRA (F2) — single slot, no chain. Empty option = no LoRA. */}
+ {/* LoRA stack (F2 + multi-LoRA, konata 2026-06-09) — click to stack;
+ applied in click order via chained LoraLoader nodes, each with its
+ own strength slider. */}
<div>
- <label className={lbl}>LoRA {!loaded && <span className="text-gray-400">(loading…)</span>}</label>
- <select
- value={store.selectedLora}
- onChange={(e) => store.setSelectedLora(e.target.value)}
- className={sel}
- disabled={!loaded}
- >
- <option value="">— none —</option>
- {loras.map((l) => (
- <option key={l} value={l}>{l}</option>
- ))}
- </select>
- {store.selectedLora && (
- <SliderControl
- label="LoRA strength"
- value={store.loraStrength}
- min={0}
- max={2}
- step={0.05}
- onChange={store.setLoraStrength}
- />
+ <label className={lbl}>
+ LoRAs {!loaded && <span className="text-gray-400">(loading…)</span>}
+ {store.selectedLoras.length > 1 && (
+ <span className="ml-1 text-gray-400">— {store.selectedLoras.length} stacked, applied in order</span>
+ )}
+ </label>
+ {loaded && loras.length === 0 && (
+ <div className="text-[0.6rem] text-gray-500">No LoRAs installed (ComfyUI/models/loras)</div>
)}
+ <div className="space-y-1 max-h-44 overflow-y-auto scrollbar-thin pr-0.5">
+ {loras.map((l) => {
+ const active = store.selectedLoras.find((x) => x.name === l)
+ return (
+ <div key={l}>
+ <button
+ type="button"
+ onClick={() => store.toggleLora(l)}
+ disabled={!loaded}
+ className={`w-full text-left px-2 py-1 rounded border text-[0.65rem] transition-colors truncate ${
+ active
+ ? 'border-blue-400/40 bg-blue-500/10 text-gray-900 dark:text-gray-100'
+ : 'border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.04] text-gray-600 dark:text-gray-400 hover:border-gray-300 dark:hover:border-white/20'
+ }`}
+ title={l}
+ >
+ {active ? '✓ ' : ''}{l}
+ </button>
+ {active && (
+ <SliderControl
+ label="strength"
+ value={active.strength}
+ min={0}
+ max={2}
+ step={0.05}
+ onChange={(v) => store.setLoraStrengthFor(l, v)}
+ />
+ )}
+ </div>
+ )
+ })}
+ </div>
</div>
{/* VAE override (F3) */}
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index ac8c1d3c..64f4c550 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -242,10 +242,10 @@ export function useCreate() {
mode, prompt, negativePrompt, imageModel, videoModel,
sampler, scheduler, steps, cfgScale, width, height, seed, batchSize, frames, fps, denoise, i2iImage, i2vImage,
// F2 + F3 (cinemazverev / vanja-san GH#4) — extended params surfaced
- // in ParamPanel. selectedLora === '' / clipSkip === 0 / vae === 'auto'
+ // in ParamPanel. selectedLoras === [] / clipSkip === 0 / vae === 'auto'
// are the "do nothing extra" defaults; the workflow builder skips
// adding nodes for those values.
- selectedLora, loraStrength, selectedVae, clipSkip,
+ selectedLoras, selectedVae, clipSkip,
setIsGenerating, setProgress, setCurrentPromptId, setError, addToGallery, addToPromptHistory,
} = state
@@ -291,7 +291,9 @@ export function useCreate() {
...(isI2I && i2iImage ? { inputImage: i2iImage, denoise } : {}),
// F2/F3 — only thread the param when the user actually picked one.
// Empty / 'auto' / 0 means "skip this node".
- ...(selectedLora ? { lora: selectedLora, loraStrength } : {}),
+ ...(selectedLoras.length > 0
+ ? { lora: selectedLoras.map((l) => l.name), loraStrength: selectedLoras.map((l) => l.strength) }
+ : {}),
...(selectedVae && selectedVae !== 'auto' ? { vae: selectedVae } : {}),
...(clipSkip > 0 ? { clipSkip } : {}),
}
diff --git a/src/stores/createStore.ts b/src/stores/createStore.ts
index 63c59b24..fcc10d20 100644
--- a/src/stores/createStore.ts
+++ b/src/stores/createStore.ts
@@ -70,9 +70,11 @@ interface CreateState {
frames: number
fps: number
denoise: number // Denoise strength for I2I (0.0–1.0)
- // F2 (cinemazverev GH#4) — 1 LoRA slot. Empty string = none.
- selectedLora: string
- loraStrength: number // 0..2, mirrors LoraLoader's `strength_model` slider
+ // F2 (cinemazverev GH#4), multi-LoRA (konata 2026-06-09) — ordered LoRA
+ // stack. Each entry chains another LoraLoader in the workflow; per-entry
+ // strength mirrors LoraLoader's `strength_model` slider (0..2 in the UI).
+ // Empty array = no LoRA. Session-only (not in partialize), like before.
+ selectedLoras: { name: string; strength: number }[]
// F3 (vanja-san GH#4) — top extended ComfyUI params surfaced in
// the param panel. selectedVae = 'auto' lets the checkpoint's
// bundled VAE win; an explicit pick overrides with a VAELoader.
@@ -123,8 +125,11 @@ interface CreateState {
setFrames: (frames: number) => void
setFps: (fps: number) => void
setDenoise: (denoise: number) => void
- setSelectedLora: (name: string) => void
- setLoraStrength: (strength: number) => void
+ /** Toggle a LoRA in/out of the stack (added at the end, default 0.8). */
+ toggleLora: (name: string) => void
+ /** Set the strength of one stacked LoRA (clamped 0..2 like the old slider). */
+ setLoraStrengthFor: (name: string, strength: number) => void
+ clearLoras: () => void
setSelectedVae: (name: string) => void
setClipSkip: (skip: number) => void
setI2iImage: (image: string | null) => void
@@ -167,8 +172,7 @@ export const useCreateStore = create<CreateState>()(
frames: 24,
fps: 8,
denoise: 0.7,
- selectedLora: '',
- loraStrength: 0.8,
+ selectedLoras: [],
selectedVae: 'auto',
clipSkip: 0,
i2iImage: null,
@@ -258,8 +262,21 @@ export const useCreateStore = create<CreateState>()(
setFrames: (frames) => set({ frames: Math.max(1, Math.min(120, Math.floor(frames))) }),
setFps: (fps) => set({ fps: Math.max(1, Math.min(60, Math.floor(fps))) }),
setDenoise: (denoise) => set({ denoise: Math.max(0, Math.min(1, denoise)) }),
- setSelectedLora: (name) => set({ selectedLora: name || '' }),
- setLoraStrength: (strength) => set({ loraStrength: Math.max(0, Math.min(2, strength)) }),
+ toggleLora: (name) => set((s) => {
+ if (!name) return {}
+ const exists = s.selectedLoras.some((l) => l.name === name)
+ return {
+ selectedLoras: exists
+ ? s.selectedLoras.filter((l) => l.name !== name)
+ : [...s.selectedLoras, { name, strength: 0.8 }],
+ }
+ }),
+ setLoraStrengthFor: (name, strength) => set((s) => ({
+ selectedLoras: s.selectedLoras.map((l) =>
+ l.name === name ? { ...l, strength: Math.max(0, Math.min(2, strength)) } : l,
+ ),
+ })),
+ clearLoras: () => set({ selectedLoras: [] }),
setSelectedVae: (name) => set({ selectedVae: name || 'auto' }),
setClipSkip: (skip) => set({ clipSkip: Math.max(0, Math.min(12, Math.floor(skip))) }),
setI2iImage: (image) => set({ i2iImage: image }),