The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Originals O1: Settings → LoRAs (folder, civitai key, the library with licences) and unique file names
Claude25c9217e4363
diff --git a/docs/research/fuobe-originals-recipes-5.json b/docs/research/fuobe-originals-recipes-5.jsonindex 08985329..dad7524f 100644--- a/docs/research/fuobe-originals-recipes-5.json+++ b/docs/research/fuobe-originals-recipes-5.json@@ -5295,7 +5295,7 @@"name": "suayptalha Z-Image-Turbo Realism","url": "https://huggingface.co/suayptalha/Z-Image-Turbo-Realism-LoRA/resolve/main/pytorch_lora_weights.safetensors","page": "https://huggingface.co/suayptalha/Z-Image-Turbo-Realism-LoRA",- "file": "pytorch_lora_weights.safetensors",+ "file": "suayptalha-z-image-turbo-realism.safetensors","trigger": "Realism","strength": 0.7,"base": "z-image-turbo",@@ -6711,7 +6711,7 @@"name": "suayptalha Z-Image-Turbo Realism","url": "https://huggingface.co/suayptalha/Z-Image-Turbo-Realism-LoRA/resolve/main/pytorch_lora_weights.safetensors","page": "https://huggingface.co/suayptalha/Z-Image-Turbo-Realism-LoRA",- "file": "pytorch_lora_weights.safetensors",+ "file": "suayptalha-z-image-turbo-realism.safetensors","trigger": "Realism","strength": 0.6,"base": "z-image-turbo",@@ -14631,7 +14631,7 @@"notes": "","hostedEndpoint": "unverified: fal's LoRA endpoints are LTX-2.3; an LTX-2 19B LoRA may not load","checked": "2026-10-23",- "file": "lora_weights_step_02000.safetensors"+ "file": "theburgstall-earthzoomout-ltx2-19b.safetensors"}],"hosted": {diff --git a/docs/research/fuobe-originals-recipes-5.md b/docs/research/fuobe-originals-recipes-5.mdindex 5cded113..5915fb1d 100644--- a/docs/research/fuobe-originals-recipes-5.md+++ b/docs/research/fuobe-originals-recipes-5.md@@ -148,7 +148,7 @@ The data each fal trainer wants is a zip URL: Z-Image Turbo v2 and Qwen 2512 tak### 3.4 Downloading LoRAs-Hugging Face `resolve/main` URLs download without a login (fal, Replicate and ComfyUI can use them as they are). **civitai download URLs answer HTTP 401 without a token**: pass `?token=<the user's civitai API key>` or mirror the file once to Fuobe's or fal's storage (allowed when the civitai permissions include Rent or Sell; whether fal accepts a tokenised civitai URL in `path` is **unverified**). Several civitai files share a name (`V1.safetensors`), so the JSON gives each LoRA a unique local `file` name; Fuobe's `injectLoras` keys on `lora_name`, so names must be unique in `ComfyUI/models/loras`. Gated Hugging Face repos (Lightricks LTX-2.5 LoRAs) need the licence accepted and an HF token.+Hugging Face `resolve/main` URLs download without a login (fal, Replicate and ComfyUI can use them as they are). **civitai download URLs answer HTTP 401 without a token**: pass `?token=<the user's civitai API key>` or mirror the file once to Fuobe's or fal's storage (allowed when the civitai permissions include Rent or Sell; whether fal accepts a tokenised civitai URL in `path` is **unverified**). Several civitai files share a name (`V1.safetensors`), so the JSON gives each LoRA a unique local `file` name; Fuobe's `injectLoras` keys on `lora_name`, so names must be unique in `ComfyUI/models/loras`. Gated Hugging Face repos (Lightricks LTX-2.5 LoRAs) need the licence accepted and an HF token. *Corrected 2026-10-24 (o/lora-plumbing):* two Hugging Face files had names many unrelated LoRAs share (`pytorch_lora_weights.safetensors`, `lora_weights_step_02000.safetensors`), so a file already in ComfyUI's folder under that name could be another LoRA; the JSON now names them `suayptalha-z-image-turbo-realism.safetensors` and `theburgstall-earthzoomout-ltx2-19b.safetensors`, and `scripts/gen-lora-library.py` refuses such names.---diff --git a/scripts/gen-lora-library.py b/scripts/gen-lora-library.pyindex 0889ee88..278be188 100644--- a/scripts/gen-lora-library.py+++ b/scripts/gen-lora-library.py@@ -10,7 +10,8 @@ Hugging Face files) into ComfyUI's loras folder, or mirrors them for the cloud eFails (exit 1) when an entry breaks the licence rules of the build plan:- a civitai entry without a pinned version id or a permission snapshot, or whose commercial / hostedOkflags disagree with its permissions (Image = outputs may be sold, Rent = may run on fal / Replicate);-- two entries with the same local file name but different downloads (ComfyUI keys LoRAs on the name);+- two entries with the same local file name but different downloads (ComfyUI keys LoRAs on the name), or a+ name many unrelated LoRAs share (pytorch_lora_weights.safetensors, lora_weights_step_02000.safetensors…);- a file name that isn't a plain file name.Run: python3 scripts/gen-lora-library.py@@ -25,6 +26,9 @@ DATA = json.loads((ROOT / "docs/research/fuobe-originals-recipes-5.json").read_tAS_OF = DATA["asOf"]DOWNLOADS = {"direct", "civitai-token", "hf-gated"}SAFE_FILE = re.compile(r"^[\w.\-\[\]() ]+\.safetensors$")+# Names many unrelated LoRAs share (diffusers' and trainers' defaults): a file already in ComfyUI's folder under such+# a name may be another LoRA, so the library renames them (research: "file").+GENERIC_FILE = re.compile(r"^(pytorch_lora_weights|adapter_model|diffusion_pytorch_model|model|lora|lora_weights(_step_\d+)?|v\d+)\.safetensors$", re.I)errors = []@@ -83,6 +87,8 @@ def entry(raw, key, group, checked=None, spare=False):# Licence rules (build plan → "Licence rules for Originals" → enforced by tests).if not SAFE_FILE.match(out["file"]) or "/" in out["file"] or ".." in out["file"]:errors.append(f"{where}: file {out['file']!r} is not a plain .safetensors name")+ if GENERIC_FILE.match(out["file"]):+ errors.append(f"{where}: file {out['file']!r} is a name other LoRAs use too; give it a unique one")if out["download"] not in DOWNLOADS:errors.append(f"{where}: unknown download {out['download']!r}")if not url.startswith("https://"):diff --git a/src/app/api/loras/route.ts b/src/app/api/loras/route.tsnew file mode 100644index 00000000..1b2649c4--- /dev/null+++ b/src/app/api/loras/route.ts@@ -0,0 +1,50 @@+import { connection } from "next/server";+import { LORA_LIBRARY, LORA_LIBRARY_AS_OF } from "@/lib/catalog/lora-library.generated";+import { licenceLine } from "@/lib/catalog/loras";+import { downloadToComfy, filesInLoraFolder, listLoraCopies, LoraError } from "@/server/loras";+import { getSetting } from "@/server/settings";++/**+ * The LoRA library for Settings → LoRAs: every researched LoRA with its licence, where it downloads from,+ * whether it is in the LoRA folder and where Fuobe mirrored it. Keys are never in the answer.+ */+export async function GET() {+ await connection();+ const folder = getSetting("comfyLorasDir");+ const inFolder = filesInLoraFolder();+ const mirrored = new Map<string, string[]>();+ for (const c of listLoraCopies()) if (c.target !== "comfyui") mirrored.set(c.file, [...(mirrored.get(c.file) ?? []), c.target]);+ return Response.json({+ asOf: LORA_LIBRARY_AS_OF,+ folder: folder || null,+ civitaiKey: !!getSetting("civitaiKey"),+ loras: LORA_LIBRARY.map((e) => ({+ key: e.key,+ name: e.name,+ file: e.file,+ group: e.group,+ base: e.base,+ ...(e.target && e.target !== "both" && { target: e.target }),+ page: e.page,+ download: e.download,+ licence: licenceLine(e.licence),+ commercial: e.licence.commercial,+ hostedOk: e.licence.hostedOk,+ spare: !!e.spare,+ inFolder: inFolder.has(e.file),+ mirrored: mirrored.get(e.file) ?? [],+ })),+ });+}++/** Download one library LoRA into the LoRA folder now (`{ file }`), instead of before the first run that needs it. */+export async function POST(request: Request) {+ const body = (await request.json().catch(() => ({}))) as { file?: unknown };+ if (typeof body.file !== "string" || !body.file) return Response.json({ error: "Say which LoRA to download" }, { status: 400 });+ try {+ const copy = await downloadToComfy(body.file);+ return Response.json({ file: copy.file, sizeBytes: copy.sizeBytes, sha256: copy.sha256 });+ } catch (e) {+ return Response.json({ error: (e as Error).message }, { status: e instanceof LoraError ? 422 : 500 });+ }+}diff --git a/src/components/lora-settings.tsx b/src/components/lora-settings.tsxnew file mode 100644index 00000000..364a43c4--- /dev/null+++ b/src/components/lora-settings.tsx@@ -0,0 +1,265 @@+"use client";++import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { CheckCircle2, ChevronDown, Download, ExternalLink, Loader2, Lock } from "lucide-react";+import { useId, useState } from "react";+import { toast } from "sonner";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import { Label } from "@/components/ui/label";+import { ConnectField, type PublicSetting } from "@/components/connect-field";+import { saveSettings } from "@/lib/api";+import { CIVITAI_KEYS_URL } from "@/lib/connections";+import { cn } from "@/lib/utils";++interface LibraryLora {+ key: string;+ name: string;+ file: string;+ group: "look" | "motion" | "effect";+ base: string;+ /** One half of a Wan 2.2 pair: the high- or low-noise expert's file. */+ target?: "high" | "low";+ page: string;+ download: "direct" | "civitai-token" | "hf-gated";+ licence: string;+ commercial: boolean;+ hostedOk: boolean;+ spare: boolean;+ inFolder: boolean;+ mirrored: string[];+}++interface Library {+ asOf: string;+ folder: string | null;+ civitaiKey: boolean;+ loras: LibraryLora[];+}++const GROUPS = [+ { value: "look", label: "Looks" },+ { value: "motion", label: "Motions" },+ { value: "effect", label: "Effects" },+] as const;++/** The base a LoRA was trained for, in a few words ("wan2.2-i2v-a14b" → "Wan 2.2"). */+function baseName(base: string): string {+ const known: [RegExp, string][] = [+ [/^z-image/, "Z-Image Turbo"],+ [/^wan2\.2/, "Wan 2.2"],+ [/^wan2\.1/, "Wan 2.1"],+ [/^ltx-2\.3/, "LTX-2.3"],+ [/^ltx-2\.5/, "LTX-2.5"],+ [/^ltx-2-/, "LTX-2"],+ [/^qwen-image-edit/, "Qwen-Image-Edit"],+ ];+ return known.find(([re]) => re.test(base))?.[1] ?? base;+}++const SOURCE: Record<LibraryLora["download"], string> = {+ direct: "Hugging Face",+ "civitai-token": "civitai · needs your key",+ "hf-gated": "Hugging Face · accept its licence first",+};++/** The LoRA folder: a plain path field (no connection to test), saved with its own button. */+function FolderField({ setting }: { setting?: PublicSetting }) {+ const qc = useQueryClient();+ const id = useId();+ const saved = setting?.value ?? "";+ const [draft, setDraft] = useState<string | null>(null);+ const shown = draft ?? saved;+ const changed = draft !== null && draft.trim() !== saved.trim();+ const save = useMutation({+ mutationFn: (value: string) => saveSettings({ comfyLorasDir: value }),+ onSuccess: (_, value) => {+ setDraft(null);+ toast.success(value ? "LoRA folder saved" : "LoRA folder cleared");+ void qc.invalidateQueries({ queryKey: ["settings"] });+ void qc.invalidateQueries({ queryKey: ["loras"] });+ },+ onError: (e: Error) => toast.error(e.message),+ });+ return (+ <div className="min-w-0 space-y-1.5">+ <Label htmlFor={id} className="text-[13px]">+ LoRA folder+ </Label>+ <div className="flex flex-wrap gap-2">+ <Input+ id={id}+ aria-describedby={`${id}-hint`}+ autoComplete="off"+ spellCheck={false}+ value={shown}+ placeholder="/path/to/ComfyUI/models/loras"+ onChange={(e) => setDraft(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter" && changed) {+ e.preventDefault();+ save.mutate(shown.trim());+ }+ }}+ className="min-w-0 flex-1 basis-56 font-mono text-[13px]"+ />+ <Button size="sm" className="h-9 shrink-0" disabled={!changed || save.isPending} onClick={() => save.mutate(shown.trim())}>+ {save.isPending && <Loader2 className="animate-spin" />}+ Save+ </Button>+ </div>+ <p id={`${id}-hint`} className="text-[12px] text-muted-foreground">+ {setting?.fromEnv ? "Set from COMFYUI_LORAS_DIR; a folder saved here wins. " : ""}+ ComfyUI's models/loras folder on this machine. Fuobe downloads the LoRAs a run needs into it (and copies your trained ones). When ComfyUI runs on another machine, leave it empty and put the files in its loras folder.+ </p>+ </div>+ );+}++function LoraRow({ l, folder, onDownload, busy }: { l: LibraryLora; folder: boolean; onDownload: () => void; busy: boolean }) {+ return (+ <li className="flex items-center gap-3 py-2.5">+ <div className="min-w-0 flex-1">+ <a href={l.page} target="_blank" rel="noreferrer" className="inline-flex max-w-full items-center gap-1 text-[13px] font-medium hover:underline">+ <span className="truncate">{l.name}</span>+ <ExternalLink className="size-3 shrink-0 text-muted-foreground" aria-hidden />+ </a>+ <p className="flex flex-wrap gap-x-1.5 text-[12px] text-muted-foreground">+ <span>+ {baseName(l.base)}+ {l.target ? ` · ${l.target}-noise half` : ""}+ </span>+ <span aria-hidden>·</span>+ <span className={cn(!l.commercial && "text-destructive", l.commercial && !l.hostedOk && "text-foreground")}>{l.licence}</span>+ <span aria-hidden>·</span>+ <span>{SOURCE[l.download]}</span>+ {l.mirrored.length > 0 && (+ <>+ <span aria-hidden>·</span>+ <span>Copy on {l.mirrored.map((m) => (m === "fal" ? "fal.ai" : "Replicate")).join(" and ")}</span>+ </>+ )}+ </p>+ </div>+ {l.inFolder ? (+ <span className="inline-flex shrink-0 items-center gap-1 text-[12px] text-success">+ <CheckCircle2 className="size-3.5" /> In folder+ </span>+ ) : l.download === "hf-gated" ? (+ <span className="inline-flex shrink-0 items-center gap-1 text-[12px] text-muted-foreground" title="Accept the licence on Hugging Face, then put the file in the folder">+ <Lock className="size-3.5" /> By hand+ </span>+ ) : (+ <Button+ size="sm"+ variant="secondary"+ className="h-8 shrink-0"+ disabled={!folder || busy}+ title={folder ? undefined : "Set the LoRA folder first"}+ aria-label={`Download ${l.name}`}+ onClick={onDownload}+ >+ {busy ? <Loader2 className="animate-spin" /> : <Download />}+ <span className="hidden sm:inline">Download</span>+ </Button>+ )}+ </li>+ );+}++/** Settings → LoRAs: where LoRA files live, the civitai key, and the library with each file's licence. */+export function LoraSettings({ folder, civitaiKey }: { folder?: PublicSetting; civitaiKey?: PublicSetting }) {+ const qc = useQueryClient();+ const [open, setOpen] = useState(false);+ const [group, setGroup] = useState<LibraryLora["group"]>("look");+ const [pending, setPending] = useState<string | null>(null);+ const library = useQuery({+ queryKey: ["loras"],+ queryFn: async () => (await (await fetch("/api/loras")).json()) as Library,+ });+ const download = useMutation({+ mutationFn: async (l: LibraryLora) => {+ setPending(l.file);+ const res = await fetch("/api/loras", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ file: l.file }) });+ const body = (await res.json().catch(() => ({}))) as { error?: string };+ if (!res.ok) throw new Error(body.error ?? `The download didn't finish (${res.status})`);+ return l;+ },+ onSuccess: (l) => toast.success(`${l.name} is in your LoRA folder`),+ onError: (e: Error) => toast.error(e.message),+ onSettled: () => {+ setPending(null);+ void qc.invalidateQueries({ queryKey: ["loras"] });+ },+ });+ const data = library.data;+ const shown = data?.loras.filter((l) => l.group === group) ?? [];+ const inFolder = data?.loras.filter((l) => l.inFolder).length ?? 0;++ return (+ <>+ <FolderField setting={folder} />+ <ConnectField+ id="civitai"+ name="civitaiKey"+ setting={civitaiKey}+ provider="civitai"+ label="civitai API key"+ placeholder="Paste your civitai key"+ hint={+ <span>+ Downloads the LoRAs that live on civitai (most looks use one). It stays on this server: a cloud run gets a copy Fuobe made of the file, never your key.{" "}+ <a href={CIVITAI_KEYS_URL} target="_blank" rel="noreferrer" className="inline-flex items-center gap-1 text-brand-text hover:underline">+ Get a key <ExternalLink className="size-3" />+ </a>+ </span>+ }+ />+ <div className="rounded-xl border">+ <button+ type="button"+ aria-expanded={open}+ aria-controls="lora-library"+ onClick={() => setOpen((v) => !v)}+ className="flex w-full items-center gap-3 rounded-xl px-4 py-3 text-left transition-colors hover:bg-accent"+ >+ <span className="min-w-0 flex-1">+ <span className="block text-[13px] font-medium">LoRA library</span>+ <span className="block text-[12px] text-muted-foreground">+ {data ? `${data.loras.length} LoRAs · ${inFolder} in your folder · licences read ${data.asOf}` : <span className="mt-1 block h-3.5 w-48 animate-pulse rounded bg-muted" />}+ </span>+ </span>+ <ChevronDown className={cn("size-4 shrink-0 text-muted-foreground transition-transform", open && "rotate-180")} />+ </button>+ {open && (+ <div id="lora-library" className="border-t px-4 pb-2">+ <div role="radiogroup" aria-label="LoRA kind" className="flex gap-1.5 pt-3">+ {GROUPS.map((g) => (+ <button+ key={g.value}+ type="button"+ role="radio"+ aria-checked={group === g.value}+ onClick={() => setGroup(g.value)}+ className={cn(+ "inline-flex h-7 items-center rounded-full border px-2.5 text-[12px] font-medium transition-colors hover:bg-accent",+ group === g.value && "border-primary bg-brand-faint hover:bg-brand-faint",+ )}+ >+ {g.label}+ <span className="ml-1 text-muted-foreground">{data?.loras.filter((l) => l.group === g.value).length ?? ""}</span>+ </button>+ ))}+ </div>+ {!data?.folder && <p className="pt-2 text-[12px] text-muted-foreground">Set the LoRA folder above to download LoRAs ahead of a run. Runs fetch what they need either way.</p>}+ <ul className="max-h-96 divide-y overflow-y-auto">+ {shown.map((l) => (+ <LoraRow key={l.key} l={l} folder={!!data?.folder} busy={pending === l.file} onDownload={() => download.mutate(l)} />+ ))}+ </ul>+ </div>+ )}+ </div>+ </>+ );+}diff --git a/src/components/settings-form.tsx b/src/components/settings-form.tsxindex 803907a1..59ec53f4 100644--- a/src/components/settings-form.tsx+++ b/src/components/settings-form.tsx@@ -11,6 +11,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@import { Skeleton } from "@/components/ui/skeleton";import { ConnectField, useSettings } from "@/components/connect-field";import { GetStarted } from "@/components/get-started";+import { LoraSettings } from "@/components/lora-settings";import { useStatus, type StatusInfo } from "@/lib/api";import { connectionSummary, ENGINE_MODE_LABEL, FAL_KEYS_URL, showFirstRun } from "@/lib/connections";import { cn } from "@/lib/utils";@@ -349,6 +350,14 @@ export function SettingsForm({ prices }: { prices?: string }) {/></Section>+ <Section+ id="loras"+ title="LoRAs · looks, motions and effects"+ description="Looks, camera moves and effects add LoRA files to open models, on your GPU and in the cloud. Fuobe fetches the pinned version a run needs and follows each file's licence: one that may only run on your GPU is never sent to a cloud API."+ >+ <LoraSettings folder={get("comfyLorasDir")} civitaiKey={get("civitaiKey")} />+ </Section>+<Sectionid="text-ai"title="Prompt enhancement · Claude or Ollama"diff --git a/src/lib/catalog/lora-library.generated.ts b/src/lib/catalog/lora-library.generated.tsindex 529b3911..1cb0bff8 100644--- a/src/lib/catalog/lora-library.generated.ts+++ b/src/lib/catalog/lora-library.generated.ts@@ -66,7 +66,7 @@ export const LORA_LIBRARY: LoraEntry[] = [{"key": "realism","name": "suayptalha Z-Image-Turbo Realism",- "file": "pytorch_lora_weights.safetensors",+ "file": "suayptalha-z-image-turbo-realism.safetensors","url": "https://huggingface.co/suayptalha/Z-Image-Turbo-Realism-LoRA/resolve/main/pytorch_lora_weights.safetensors","page": "https://huggingface.co/suayptalha/Z-Image-Turbo-Realism-LoRA","strength": 0.7,@@ -2070,9 +2070,9 @@ export const LORA_LIBRARY: LoraEntry[] = ["hostedEndpoint": "fal-ai/ltx-2.3-22b/image-to-video/lora (IC-LoRAs: fal-ai/ltx-2.3-22b/reference-video-to-video/lora)"},{- "key": "lora-weights-step-02000",+ "key": "theburgstall-earthzoomout-ltx2-19b","name": "TheBurgstall EarthZoomOut (LTX-2)",- "file": "lora_weights_step_02000.safetensors",+ "file": "theburgstall-earthzoomout-ltx2-19b.safetensors","url": "https://huggingface.co/TheBurgstall/EarthZoomOut-LoRA-LTX-2-19b/resolve/main/lora_weights_step_02000.safetensors","page": "https://huggingface.co/TheBurgstall/EarthZoomOut-LoRA-LTX-2-19b","strength": 1.0,@@ -3078,7 +3078,7 @@ export const MOTION_EFFECT_LORAS: MotionEffectLoras[] = [],"status": "add-lora","loras": [- "lora-weights-step-02000"+ "theburgstall-earthzoomout-ltx2-19b"],"bothEnginesToday": false,"newSinceMid2026": false,diff --git a/tests/lora-fetch.test.ts b/tests/lora-fetch.test.tsindex 92e2fda6..c9feebd0 100644--- a/tests/lora-fetch.test.ts+++ b/tests/lora-fetch.test.ts@@ -2,10 +2,13 @@ import crypto from "node:crypto";import fs from "node:fs";import os from "node:os";import path from "node:path";-import { afterAll, afterEach, beforeEach, describe, expect, it } from "vitest";+import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { loraEntry, loraRef } from "@/lib/catalog/loras";import type { LoraRef } from "@/lib/catalog/types";+// The route's GET opts out of prerendering with connection(), which needs a request scope.+vi.mock("next/server", () => ({ connection: async () => {} }));+// The downloader reads the civitai key and the LoRA folder from the settings table: a throwaway data folder.const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-lora-fetch-"));process.env.FUOBE_DATA_DIR = dir;@@ -198,3 +201,31 @@ describe("Before a cloud run", () => {expect(up.sent).toEqual([]);});});++describe("Settings → LoRAs (/api/loras)", () => {+ it("lists the library with licences and what is in the folder, and never the key", async () => {+ const route = await import("@/app/api/loras/route");+ setSetting("civitaiKey", KEY);+ setSetting("comfyLorasDir", folder);+ fs.writeFileSync(path.join(folder, "AWPortrait-Z.safetensors"), "x");+ const res = await route.GET();+ const text = await res.text();+ expect(text).not.toContain(KEY);+ const body = JSON.parse(text) as { folder: string; civitaiKey: boolean; loras: { key: string; inFolder: boolean; licence: string; target?: string }[] };+ expect(body).toMatchObject({ folder, civitaiKey: true });+ expect(body.loras.find((l) => l.key === "awportrait")).toMatchObject({ inFolder: true, licence: "Commercial · GPU and cloud" });+ expect(body.loras.find((l) => l.key === "civitai-2490836-wiggle-redmond")).toMatchObject({ inFolder: false, licence: "Commercial · your GPU only", target: "high" });+ });++ it("downloads one LoRA on request, or says why it can't", async () => {+ const route = await import("@/app/api/loras/route");+ const post = (file: unknown) => route.POST(new Request("http://x/api/loras", { method: "POST", body: JSON.stringify({ file }) }));+ expect((await post("AWPortrait-Z.safetensors")).status).toBe(422);+ expect(await (await post("AWPortrait-Z.safetensors")).json()).toEqual({ error: "Set the LoRA folder first (ComfyUI's models/loras on this machine)" });+ expect((await post("nope.safetensors")).status).toBe(422);+ setSetting("comfyLorasDir", folder);+ net = network(hfRoutes(AW_BODY));+ const ok = await post("AWPortrait-Z.safetensors");+ expect(await ok.json()).toEqual({ file: "AWPortrait-Z.safetensors", sizeBytes: AW_BODY.length, sha256: sha(AW_BODY) });+ });+});