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
Pages: slim models/workflows/storyboard data, color grading fixes, a11y, phone layouts
Claude4e465aababc7
diff --git a/public/samples/grade-sample.jpg b/public/samples/grade-sample.jpgnew file mode 100644index 00000000..a8e2d7cfBinary files /dev/null and b/public/samples/grade-sample.jpg differdiff --git a/src/app/(studio)/models/page.tsx b/src/app/(studio)/models/page.tsxindex 1815dfee..c2901a17 100644--- a/src/app/(studio)/models/page.tsx+++ b/src/app/(studio)/models/page.tsx@@ -1,7 +1,8 @@import type { Metadata } from "next";-import { PageShell } from "@/components/page-shell";-import { PageHeader } from "@/components/preset-gallery";+import { PageHeader, PageShell } from "@/components/page-shell";import { ModelsTable } from "@/components/models-table";+import { MODELS } from "@/lib/catalog";+import { toModelRow } from "@/lib/model-rows";export const metadata: Metadata = { title: "Models" };@@ -10,9 +11,10 @@ export default function Page() {<PageShell wide><PageHeadertitle="Models"- description="Every model Fuobe can drive. Cloud models run through your fal.ai or Replicate key; open-source models run as ComfyUI workflows on your own GPU."+ description="Every model Fuobe can drive. Cloud models run through your fal.ai, Replicate or Higgsfield key; open-source models run as ComfyUI workflows on your own GPU."/>- <ModelsTable />+ {/* Slim rows only: the catalog (field maps, options, LoRAs) stays on the server. */}+ <ModelsTable models={MODELS.map(toModelRow)} /></PageShell>);}diff --git a/src/app/(studio)/storyboard/page.tsx b/src/app/(studio)/storyboard/page.tsxindex c7a387f5..ad6a5955 100644--- a/src/app/(studio)/storyboard/page.tsx+++ b/src/app/(studio)/storyboard/page.tsx@@ -1,8 +1,17 @@import type { Metadata } from "next";import { StoryboardView } from "@/components/storyboard-view";+import { getModel } from "@/lib/catalog";+import { STORYBOARD_MODELS } from "@/lib/catalog/storyboard";export const metadata: Metadata = { title: "Storyboard" };+/** Display names for the few models a storyboard uses, so the view needs no catalog in the browser. */+const MODEL_NAMES = Object.fromEntries(+ Object.values(STORYBOARD_MODELS)+ .flatMap((m) => [m.first, m.firstWithRefs, m.next])+ .map((id) => [id, getModel(id)?.name ?? id]),+);+export default function Page() {- return <StoryboardView />;+ return <StoryboardView modelNames={MODEL_NAMES} />;}diff --git a/src/app/(studio)/workflows/page.tsx b/src/app/(studio)/workflows/page.tsxindex df7514fd..82123b38 100644--- a/src/app/(studio)/workflows/page.tsx+++ b/src/app/(studio)/workflows/page.tsx@@ -1,10 +1,13 @@import type { Metadata } from "next";-import { PageShell } from "@/components/page-shell";-import { PageHeader } from "@/components/preset-gallery";+import { PageHeader, PageShell } from "@/components/page-shell";import { WorkflowsView } from "@/components/workflows-view";+import { MODELS } from "@/lib/catalog";export const metadata: Metadata = { title: "ComfyUI workflows" };+/** Which open models run each workflow; computed here so the view needs no catalog in the browser. */+const ROUTES = MODELS.flatMap((m) => m.routes.filter((r) => r.provider === "comfyui").map((r) => ({ endpoint: r.endpoint, name: m.name })));+export default function Page() {return (<PageShell wide>@@ -12,7 +15,7 @@ export default function Page() {title="ComfyUI workflows"description="The open-source engine. Each workflow is an API-format ComfyUI graph exported from the official templates, with bindings Fuobe uses to inject prompts, images and settings."/>- <WorkflowsView />+ <WorkflowsView routes={ROUTES} /></PageShell>);}diff --git a/src/components/color-grade-view.tsx b/src/components/color-grade-view.tsxindex 142d7a67..bda91b9c 100644--- a/src/components/color-grade-view.tsx+++ b/src/components/color-grade-view.tsx@@ -1,6 +1,6 @@"use client";-import { Columns2, Download, ImagePlus, Loader2, RotateCcw, Save } from "lucide-react";+import { Columns2, Download, ImagePlus, Loader2, RotateCcw, Save, Sparkles } from "lucide-react";import Link from "next/link";import { useSearchParams } from "next/navigation";import { Suspense, useEffect, useMemo, useRef, useState } from "react";@@ -110,6 +110,22 @@ function loadSource(url: string, kind: "image" | "video"): Promise<Source> {const dims = (s: Source) => (s instanceof HTMLVideoElement ? [s.videoWidth, s.videoHeight] : [s.naturalWidth, s.naturalHeight]);+/** Stop a detached video for good (it would keep decoding after the page or the clip changes). */+function release(s: Source | null | undefined) {+ if (!(s instanceof HTMLVideoElement)) return;+ s.pause();+ s.removeAttribute("src");+ s.load();+}++/** Free a WebGL context now instead of waiting for garbage collection (browsers cap live contexts). */+function loseContext(r: GradeRenderer | null | undefined) {+ r?.gl.getExtension("WEBGL_lose_context")?.loseContext();+}++/** Bundled still the looks are previewed on before anything is loaded. */+const SAMPLE = "/samples/grade-sample.jpg";+function Grader() {const sp = useSearchParams();const initial = sp.get("video") ? { url: sp.get("video")!, kind: "video" as const } : sp.get("image") ? { url: sp.get("image")!, kind: "image" as const } : null;@@ -124,23 +140,51 @@ function Grader() {const canvas = useRef<HTMLCanvasElement>(null);const renderer = useRef<GradeRenderer | null>(null);const [view, setView] = useState({ w: 0, h: 0 });+ const [sample, setSample] = useState<HTMLImageElement | null>(null);+ /** False once the page is gone, so a running export stops instead of playing on in the background. */+ const alive = useRef(true);++ useEffect(() => {+ alive.current = true;+ return () => {+ alive.current = false;+ loseContext(renderer.current);+ renderer.current = null;+ };+ }, []);useEffect(() => {if (!input) return;let cancelled = false;+ let loaded: Source | null = null;loadSource(input.url, input.kind).then((s) => {- if (cancelled) return;+ if (cancelled) return release(s);+ loaded = s;setSource(s);if (s instanceof HTMLVideoElement) void s.play().catch(() => {});},- (e) => toast.error((e as Error).message),+ (e) => !cancelled && toast.error((e as Error).message),);return () => {cancelled = true;+ release(loaded);};}, [input]);+ // The looks are previewed on a bundled sample until the user brings their own picture.+ useEffect(() => {+ if (source || sample) return;+ let cancelled = false;+ loadSource(SAMPLE, "image").then(+ (s) => !cancelled && setSample(s as HTMLImageElement),+ () => {},+ );+ return () => {+ cancelled = true;+ };+ }, [source, sample]);+// Fit the preview to the stage.useEffect(() => {if (!source || !box.current) return;@@ -180,10 +224,11 @@ function Grader() {return () => cancelAnimationFrame(raf);}, [source, grade, view, holding]);- // Preset thumbnails, rendered once per source with a throwaway WebGL context.+ // Preset thumbnails, rendered once per source (or on the sample) with a throwaway WebGL context.+ const thumbSource = source ?? sample;const thumbs = useMemo(() => {const out: Record<string, string> = {};- if (!source) return out;+ if (!thumbSource) return out;const c = document.createElement("canvas");let r: GradeRenderer;try {@@ -191,15 +236,15 @@ function Grader() {} catch {return out;}- const [w, h] = dims(source);+ const [w, h] = dims(thumbSource);const s = 120 / Math.max(w, h);for (const p of PRESETS) {- r.render(source, applyPreset(p), Math.round(w * s), Math.round(h * s));+ r.render(thumbSource, applyPreset(p), Math.round(w * s), Math.round(h * s));out[p.id] = c.toDataURL("image/jpeg", 0.8);}- r.gl.getExtension("WEBGL_lose_context")?.loseContext();+ loseContext(r);return out;- }, [source]);+ }, [thumbSource]);const set = (k: keyof Grade, v: number) => {setPreset(undefined);@@ -236,7 +281,7 @@ function Grader() {const s = Math.min(1, r.maxSize / Math.max(w, h));r.render(source, grade, Math.round(w * s), Math.round(h * s));const blob = await new Promise<Blob | null>((res) => c.toBlob(res, "image/png"));- r.gl.getExtension("WEBGL_lose_context")?.loseContext();+ loseContext(r);if (!blob) throw new Error("Couldn't export the image");await record(new File([blob], "graded.png", { type: "image/png" }), "image");} catch (e) {@@ -250,6 +295,7 @@ function Grader() {const exportVideo = async () => {if (!(source instanceof HTMLVideoElement)) return;setSaving(0);+ let clip: HTMLVideoElement | null = null;try {const c = document.createElement("canvas");const r = new GradeRenderer(c);@@ -258,6 +304,7 @@ function Grader() {const W = Math.round((w * s) / 2) * 2;const H = Math.round((h * s) / 2) * 2;const v = (await loadSource(input!.url, "video")) as HTMLVideoElement;+ clip = v;v.loop = false;v.muted = false;v.volume = 0.0001;@@ -276,6 +323,7 @@ function Grader() {await v.play();await new Promise<void>((res) => {const tick = () => {+ if (!alive.current) return res();r.render(v, grade, W, H);setSaving(Math.min(0.99, v.currentTime / (v.duration || 1)));if (v.ended) res();@@ -285,24 +333,30 @@ function Grader() {});rec.stop();await done;- r.gl.getExtension("WEBGL_lose_context")?.loseContext();+ loseContext(r);+ if (!alive.current) return;await record(new File(chunks, "graded.webm", { type: "video/webm" }), "video");} catch (e) {- toast.error((e as Error).message);+ if (alive.current) toast.error((e as Error).message);} finally {- setSaving(null);+ release(clip);+ if (alive.current) setSaving(null);}};const groups = useMemo(() => [...new Set(CONTROLS.map((c) => c.group))], []);const neutral = isNeutral(grade);- const pick = (v: SlotValue | null) => {- if (!v?.ref || v.uploading) return;+ const open = (next: { url: string; kind: "image" | "video" }) => {+ loseContext(renderer.current);renderer.current = null;setSource(null);setSaved(null);- setInput({ url: v.ref, kind: v.kind === "video" ? "video" : "image" });+ setInput(next);+ };+ const pick = (v: SlotValue | null) => {+ if (!v?.ref || v.uploading) return;+ open({ url: v.ref, kind: v.kind === "video" ? "video" : "image" });};return (@@ -328,6 +382,13 @@ function Grader() {<MediaSlot label="Image" kind="image" value={null} onChange={pick} size="lg" /><MediaSlot label="Video" kind="video" value={null} onChange={pick} size="lg" /></div>+ <button+ type="button"+ onClick={() => open({ url: SAMPLE, kind: "image" })}+ className="inline-flex h-8 items-center gap-1.5 rounded-full bg-white/10 px-3 text-[13px] font-medium text-white transition-colors hover:bg-white/20"+ >+ <Sparkles className="size-3.5" /> Try it on the sample photo+ </button></div>) : !source ? (<Loader2 className="size-5 animate-spin text-white/70" />@@ -357,17 +418,23 @@ function Grader() {{PRESETS.map((p) => (<buttonkey={p.id}+ type="button"+ aria-pressed={preset === p.id}+ title={source ? p.name : `${p.name} — opens the sample photo`}onClick={() => {+ // Before anything is loaded, a look opens the sample with that look applied.+ if (!input) open({ url: SAMPLE, kind: "image" });setPreset(p.id);setGrade(applyPreset(p));}}- disabled={!source}- className={cn("group flex flex-col gap-1 rounded-lg p-1 text-left ring-primary transition hover:bg-accent disabled:opacity-50", preset === p.id && "ring-2")}+ className={cn("group flex flex-col gap-1 rounded-lg p-1 text-left ring-primary transition hover:bg-accent", preset === p.id && "ring-2")}><span className="aspect-square w-full overflow-hidden rounded-md bg-muted">- {thumbs[p.id] && (+ {thumbs[p.id] ? (// eslint-disable-next-line @next/next/no-img-element<img src={thumbs[p.id]} alt="" className="size-full object-cover" />+ ) : (+ <span className="block size-full animate-pulse bg-muted" />)}</span><span className="truncate px-0.5 text-[11px] font-medium">{p.name}</span>@@ -381,10 +448,13 @@ function Grader() {{CONTROLS.filter((c) => c.group === g).map((c) => (<div key={c.key} className="space-y-1.5"><div className="flex items-center justify-between text-[13px]">- <span>{c.label}</span>+ <span id={`grade-${c.key}`}>{c.label}</span><button+ type="button"onDoubleClick={() => set(c.key, NEUTRAL[c.key])}+ onKeyDown={(e) => (e.key === "Enter" || e.key === "Backspace") && set(c.key, NEUTRAL[c.key])}title="Double-click to reset"+ aria-label={`Reset ${c.label}`}className={cn("font-mono text-[12px] text-muted-foreground tabular-nums", grade[c.key] !== NEUTRAL[c.key] && "text-brand-text")}>{c.min < 0 && grade[c.key] > 0 ? "+" : ""}@@ -398,6 +468,8 @@ function Grader() {max={c.max}step={1}disabled={!source}+ aria-label={c.group === "Split tone" ? `Split tone ${c.label.toLowerCase()}` : c.label}+ aria-valuetext={`${c.min < 0 && grade[c.key] > 0 ? "+" : ""}${grade[c.key]}${c.max === 360 ? "°" : ""}`}onValueChange={([v]) => set(c.key, v)}/></div>diff --git a/src/components/models-table.tsx b/src/components/models-table.tsxindex 7c538c64..a4bf1ad7 100644--- a/src/components/models-table.tsx+++ b/src/components/models-table.tsx@@ -1,90 +1,171 @@"use client";-import { Cloud, Cpu } from "lucide-react";-import { useState } from "react";-import { Badge } from "@/components/ui/badge";-import { ModelBadges } from "@/components/studio/model-picker";-import { MODELS } from "@/lib/catalog";-import { OPERATION_LABELS, type Engine, type MediaKind } from "@/lib/catalog/types";-import { formatCost } from "@/lib/format";+import { Cloud, Cpu, Info, Search } from "lucide-react";+import { memo, useDeferredValue, useMemo, useState } from "react";+import { useProgressive } from "@/components/use-progressive";+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";import { useEngine } from "@/lib/api";+import type { Engine, MediaKind } from "@/lib/catalog/types";+import { modelSearchText, type ModelRow } from "@/lib/model-rows";import { cn } from "@/lib/utils";-export function ModelsTable() {+const KIND_LABEL: Partial<Record<MediaKind, string>> = { image: "Image", video: "Video", audio: "Audio", text: "Text", model3d: "3D" };++const chip = (active: boolean) =>+ cn(+ "h-8 shrink-0 rounded-full px-3 text-[13px] font-medium whitespace-nowrap text-muted-foreground transition-colors hover:bg-accent",+ active && "bg-secondary text-foreground",+ );++/** Where a model runs, behind a small button (the endpoint list is long and only some people need it). */+function RouteDetails({ row }: { row: ModelRow }) {+ return (+ <Popover>+ <PopoverTrigger asChild>+ <button+ type="button"+ className="inline-flex h-7 items-center gap-1 rounded-full px-2 text-[12px] text-muted-foreground hover:bg-accent hover:text-foreground"+ aria-label={`Where ${row.name} runs`}+ >+ <Info className="size-3.5" />+ <span className="hidden sm:inline">+ {row.routes.length} route{row.routes.length === 1 ? "" : "s"}+ </span>+ </button>+ </PopoverTrigger>+ <PopoverContent align="end" collisionPadding={12} className="w-[min(92vw,420px)] p-3">+ <p className="text-[12px] font-medium">{row.name} runs on</p>+ <ul className="mt-2 space-y-1">+ {row.routes.map((r) => (+ <li key={r} className="font-mono text-[11px] break-all text-muted-foreground">+ {r}+ </li>+ ))}+ </ul>+ <p className="mt-2 font-mono text-[11px] text-subtle-foreground">id {row.id}</p>+ </PopoverContent>+ </Popover>+ );+}++const Row = memo(function Row({ m }: { m: ModelRow }) {+ return (+ <tr className="align-top hover:bg-accent/50">+ <td className="px-3 py-3 sm:px-4">+ <div className="flex flex-wrap items-center gap-1.5 font-medium">+ {m.engine === "open" ? <Cpu className="size-3.5 shrink-0 md:hidden" aria-label="Open source" /> : <Cloud className="size-3.5 shrink-0 md:hidden" aria-label="Cloud" />}+ {m.name}+ {m.badges.map((b) => (+ <span+ key={b}+ className={cn(+ "rounded-[4px] bg-secondary px-1 text-[10px] leading-4 font-medium text-secondary-foreground",+ b === "New" && "bg-highlight text-highlight-foreground",+ b === "Top" && "bg-brand-faint text-brand-text",+ )}+ >+ {b}+ </span>+ ))}+ </div>+ <div className="text-[12px] text-muted-foreground">+ {m.vendor} — {m.tagline}+ </div>+ <div className="mt-1 text-[11px] text-subtle-foreground md:hidden">{m.ops.join(" · ")}</div>+ </td>+ <td className="hidden px-4 py-3 whitespace-nowrap md:table-cell">+ <span className="inline-flex items-center gap-1">+ {m.engine === "open" ? <Cpu className="size-3.5" /> : <Cloud className="size-3.5" />}+ {m.engine === "open" ? "Open source" : "Cloud"}+ </span>+ </td>+ <td className="hidden px-4 py-3 text-[12px] text-muted-foreground md:table-cell">{m.ops.join(" · ")}</td>+ <td className="px-3 py-3 font-mono text-[12px] whitespace-nowrap sm:px-4">{m.price}</td>+ <td className="px-2 py-2.5 text-right">+ <RouteDetails row={m} />+ </td>+ </tr>+ );+});++export function ModelsTable({ models }: { models: ModelRow[] }) {const [engineChoice, setEngine] = useState<Engine | "all">("all");const [, , mode] = useEngine();const engine: Engine | "all" = mode === "both" ? engineChoice : mode;const [kind, setKind] = useState<MediaKind | "all">("all");- const list = MODELS.filter((m) => (engine === "all" || m.engine === engine) && (kind === "all" || m.kind === kind));- const chip = (active: boolean) =>- cn("h-8 rounded-full px-3 text-[13px] font-medium text-muted-foreground hover:bg-accent", active && "bg-secondary text-foreground");+ const [q, setQ] = useState("");+ const term = useDeferredValue(q.trim().toLowerCase());+ const index = useMemo(() => models.map((m) => [m, modelSearchText(m)] as const), [models]);+ const kinds = useMemo(() => [...new Set(models.map((m) => m.kind))], [models]);+ const list = useMemo(+ () => index.filter(([m, text]) => (engine === "all" || m.engine === engine) && (kind === "all" || m.kind === kind) && (!term || text.includes(term))).map(([m]) => m),+ [index, engine, kind, term],+ );+ // 40 rows in the page's HTML, the rest as you scroll.+ const { shown, hasMore, more, sentinel, left } = useProgressive(list.length, `${engine}|${kind}|${term}`, 40, 60);return (<div className="space-y-4">- <div className="flex flex-wrap gap-1">- {(mode === "both" ? (["all", "cloud", "open"] as const) : [mode]).map((e) => (- <button key={e} className={chip(engine === e)} onClick={() => setEngine(e)}>- {e === "all" ? "All engines" : e === "cloud" ? "Cloud" : "Open source"}- </button>- ))}- <span className="mx-2 w-px bg-border" />- {(["all", "image", "video", "audio"] as const).map((k) => (- <button key={k} className={chip(kind === k)} onClick={() => setKind(k)}>- {k === "all" ? "All media" : k[0].toUpperCase() + k.slice(1)}- </button>- ))}- <span className="ml-auto self-center text-[13px] text-muted-foreground">{list.length} models</span>+ <div className="flex flex-col gap-2 lg:flex-row lg:items-center">+ <div className="relative w-full lg:w-72">+ <Search className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />+ <input+ type="search"+ value={q}+ onChange={(e) => setQ(e.target.value)}+ placeholder={`Search ${models.length} models`}+ aria-label="Search models"+ className="h-9 w-full rounded-full border bg-background pr-3 pl-9 text-[14px] outline-none placeholder:text-subtle-foreground focus:border-primary focus:ring-4 focus:ring-brand-faint"+ />+ </div>+ <div className="scrollbar-none -mx-1 flex min-w-0 items-center gap-1 overflow-x-auto px-1">+ {(mode === "both" ? (["all", "cloud", "open"] as const) : [mode]).map((e) => (+ <button key={e} type="button" aria-pressed={engine === e} className={chip(engine === e)} onClick={() => setEngine(e)}>+ {e === "all" ? "All engines" : e === "cloud" ? "Cloud" : "Open source"}+ </button>+ ))}+ <span className="mx-1 h-5 w-px shrink-0 bg-border" />+ {(["all", ...kinds] as const).map((k) => (+ <button key={k} type="button" aria-pressed={kind === k} className={chip(kind === k)} onClick={() => setKind(k)}>+ {k === "all" ? "All media" : (KIND_LABEL[k] ?? k)}+ </button>+ ))}+ </div>+ <span className="text-[13px] whitespace-nowrap text-muted-foreground tabular-nums lg:ml-auto" aria-live="polite">+ {list.length} models+ </span></div><div className="overflow-x-auto rounded-xl border"><table className="w-full text-left text-[13px]"><thead className="bg-muted/50 text-[12px] text-muted-foreground"><tr>- <th className="px-4 py-2.5 font-medium">Model</th>- <th className="px-4 py-2.5 font-medium">Engine</th>- <th className="px-4 py-2.5 font-medium">Can do</th>- <th className="px-4 py-2.5 font-medium">Runs on</th>- <th className="px-4 py-2.5 font-medium">Price</th>+ <th className="px-3 py-2.5 font-medium sm:px-4">Model</th>+ <th className="hidden px-4 py-2.5 font-medium md:table-cell">Engine</th>+ <th className="hidden px-4 py-2.5 font-medium md:table-cell">Can do</th>+ <th className="px-3 py-2.5 font-medium sm:px-4">Price</th>+ <th className="px-2 py-2.5">+ <span className="sr-only">Details</span>+ </th></tr></thead><tbody className="divide-y">- {list.map((m) => (- <tr key={m.id} className="align-top hover:bg-accent/50">- <td className="px-4 py-3">- <div className="flex items-center gap-1.5 font-medium">- {m.name} <ModelBadges model={m} />- </div>- <div className="text-[12px] text-muted-foreground">- {m.vendor} — {m.tagline}- </div>- </td>- <td className="px-4 py-3 whitespace-nowrap">- <span className="inline-flex items-center gap-1">- {m.engine === "open" ? <Cpu className="size-3.5" /> : <Cloud className="size-3.5" />}- {m.engine === "open" ? "Open source" : "Cloud"}- </span>- </td>- <td className="px-4 py-3">- <div className="flex flex-wrap gap-1">- {[...new Set(m.routes.map((r) => r.op))].map((op) => (- <Badge key={op} variant="secondary" className="rounded-[4px] text-[11px] font-normal">- {OPERATION_LABELS[op]}- </Badge>- ))}- </div>- </td>- <td className="px-4 py-3 font-mono text-[11px] text-muted-foreground">- {m.routes.map((r) => (- <div key={`${r.provider}-${r.op}-${r.endpoint}`}>- {r.provider}: {r.endpoint}- </div>- ))}- </td>- <td className="px-4 py-3 font-mono text-[12px] whitespace-nowrap">- {m.engine === "open" ? "Free" : m.pricing ? `${formatCost(m.pricing.usd)} / ${m.pricing.unit}` : "—"}- </td>- </tr>+ {list.slice(0, shown).map((m) => (+ <Row key={m.id} m={m} />))}</tbody></table>+ {hasMore && (+ <div className="flex justify-center border-t p-3">+ <button+ ref={sentinel}+ type="button"+ onClick={more}+ className="h-9 rounded-full border bg-background px-4 text-[13px] font-medium text-muted-foreground hover:bg-accent hover:text-foreground"+ >+ Show more · {left} left+ </button>+ </div>+ )}+ {!list.length && <p className="py-12 text-center text-[13px] text-muted-foreground">No models match{term ? ` “${q.trim()}”` : " these filters"}.</p>}</div></div>);diff --git a/src/components/preset-gallery.tsx b/src/components/preset-gallery.tsxindex 2c758d59..4b1566f9 100644--- a/src/components/preset-gallery.tsx+++ b/src/components/preset-gallery.tsx@@ -2,11 +2,12 @@import Link from "next/link";import { Cloud, Cpu, Lock, Search, Sparkles, X } from "lucide-react";-import { memo, useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";+import { memo, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";import { PageHeader } from "@/components/page-shell";import { PRESET_ICONS } from "@/components/preset-icons";import { PresetPreview, usePreviewPlayback } from "@/components/preset-preview";import { GALLERY_GRID } from "@/components/skeletons";+import { useProgressive } from "@/components/use-progressive";import { useEngineMode } from "@/lib/api";import { searchText, type PresetCardData } from "@/lib/preset-cards";import { cn } from "@/lib/utils";@@ -163,7 +164,6 @@ export function PresetGallery({const [cat, setCat] = useState("All");const [q, setQ] = useState("");const [runsOnChoice, setRunsOn] = useState<RunsOn>("all");- const [shown, setShown] = useState(FIRST_PAGE);// "both" until hydrated, so the server HTML and the first client render agree.const mode = useEngineMode();const locked = mode === "both" ? undefined : mode;@@ -179,24 +179,8 @@ export function PresetGallery({.map(([p]) => p),[index, cat, query, runsOn],);- // A new filter starts from the first page again.- const filterKey = `${cat}|${query}|${runsOn}`;- const [lastKey, setLastKey] = useState(filterKey);- if (lastKey !== filterKey) {- setLastKey(filterKey);- setShown(FIRST_PAGE);- }-- const more = useCallback(() => setShown((n) => n + PAGE), []);- const sentinel = useRef<HTMLButtonElement>(null);- const hasMore = shown < list.length;- useEffect(() => {- const el = sentinel.current;- if (!el || !hasMore || typeof IntersectionObserver === "undefined") return;- const io = new IntersectionObserver((es) => es.some((e) => e.isIntersecting) && more(), { rootMargin: "600px 0px" });- io.observe(el);- return () => io.disconnect();- }, [hasMore, more, shown]);+ // Cards render a page at a time; a new filter starts from the first page again.+ const { shown, hasMore, more, sentinel, left } = useProgressive(list.length, `${cat}|${query}|${runsOn}`, FIRST_PAGE, PAGE);const strip = useFadeEdges<HTMLDivElement>();const stale = q.trim().toLowerCase() !== query;@@ -273,7 +257,7 @@ export function PresetGallery({onClick={more}className="h-9 rounded-full border bg-background px-4 text-[13px] font-medium text-muted-foreground hover:bg-accent hover:text-foreground">- Show more · {list.length - shown} left+ Show more · {left} left</button></div>)}diff --git a/src/components/preset-header.tsx b/src/components/preset-header.tsxnew file mode 100644index 00000000..236153e4--- /dev/null+++ b/src/components/preset-header.tsx@@ -0,0 +1,95 @@+"use client";++import { Cloud, Cpu, Info, X } from "lucide-react";+import { useSyncExternalStore } from "react";+import { PresetPreview } from "@/components/preset-preview";+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";+import type { Preset } from "@/lib/catalog/types";+import { presetHowTo, presetRouteLines, toPresetCard } from "@/lib/preset-cards";+import { cn } from "@/lib/utils";++const REDUCED = "(prefers-reduced-motion: reduce)";+function useReducedMotion() {+ return useSyncExternalStore(+ (cb) => {+ const mq = window.matchMedia(REDUCED);+ mq.addEventListener("change", cb);+ return () => mq.removeEventListener("change", cb);+ },+ () => window.matchMedia(REDUCED).matches,+ () => true,+ );+}++/**+ * The card a studio shows above its composer while a preset (app, camera motion, effect) is active+ * and the feed is still empty: the preview looping, the name, one line on what to do, the models it+ * runs on behind a Details popover, and a way to clear the preset.+ *+ * Hook (studio-page.tsx, empty state, above the composer):+ * {preset && !hasItems && <PresetHeader preset={preset} modelName={(id) => getModel(id)?.name}+ * onClear={config.preset ? undefined : () => setDraft({ presetId: undefined })} />}+ */+export function PresetHeader({+ preset,+ modelName,+ onClear,+ className,+}: {+ preset: Preset;+ /** Display name for a model id (the studio's model lookup). */+ modelName?: (id: string) => string | undefined;+ /** Clear the preset (motions/effects picked in a general studio); omit on a preset's own page. */+ onClear?: () => void;+ className?: string;+}) {+ const card = toPresetCard(preset);+ const reduced = useReducedMotion();+ const routes = presetRouteLines(preset, modelName);+ return (+ <div className={cn("mx-auto flex w-full max-w-[760px] items-center gap-3 rounded-2xl border bg-background p-2 pr-3 text-left shadow-soft", className)}>+ <div className="relative aspect-[4/3] w-24 shrink-0 overflow-hidden rounded-xl bg-muted sm:w-32">+ <PresetPreview preview={card.preview} hue={card.hue} playing={!reduced} />+ </div>+ <div className="min-w-0 flex-1">+ <p className="truncate font-heading text-[19px] leading-snug">{preset.name}</p>+ <p className="line-clamp-2 text-[13px] text-muted-foreground">{presetHowTo(preset)}</p>+ </div>+ <Popover>+ <PopoverTrigger asChild>+ <button+ type="button"+ className="inline-flex h-8 shrink-0 items-center gap-1 rounded-full px-2.5 text-[12px] font-medium text-muted-foreground hover:bg-accent hover:text-foreground"+ aria-label={`About ${preset.name}`}+ >+ <Info className="size-3.5" />+ <span className="hidden sm:inline">Details</span>+ </button>+ </PopoverTrigger>+ <PopoverContent align="end" collisionPadding={12} className="w-[min(92vw,360px)] space-y-2 p-3 text-[13px]">+ <p className="text-muted-foreground">{preset.description}</p>+ <ul className="space-y-1">+ {routes.map((r) => (+ <li key={r.engine} className="flex items-center gap-2">+ {r.engine === "cloud" ? <Cloud className="size-3.5 shrink-0" /> : <Cpu className="size-3.5 shrink-0" />}+ <span className="text-muted-foreground">{r.label}</span>+ <span className={cn("ml-auto truncate font-medium", !r.model && "font-normal text-subtle-foreground")}>{r.model ?? "Not available yet"}</span>+ </li>+ ))}+ </ul>+ {preset.parity && <p className="border-t pt-2 text-[12px] text-muted-foreground">{preset.parity}</p>}+ </PopoverContent>+ </Popover>+ {onClear && (+ <button+ type="button"+ onClick={onClear}+ className="grid size-8 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-accent hover:text-foreground"+ aria-label={`Clear ${preset.name}`}+ >+ <X className="size-4" />+ </button>+ )}+ </div>+ );+}diff --git a/src/components/security-settings.tsx b/src/components/security-settings.tsxindex 3fc68201..7d41c37c 100644--- a/src/components/security-settings.tsx+++ b/src/components/security-settings.tsx@@ -58,10 +58,10 @@ function PasswordForm({ status, onDone }: { status: AuthStatus; onDone: () => vo{status.enabled && (<div className="space-y-1.5"><Label htmlFor={`${id}-current`} className="text-[13px]">Current password</Label>- <Input id={`${id}-current`} type="password" autoComplete="current-password" value={current} onChange={(e) => setCurrent(e.target.value)} className="w-72" />+ <Input id={`${id}-current`} type="password" autoComplete="current-password" value={current} onChange={(e) => setCurrent(e.target.value)} className="w-full max-w-72" /></div>)}- <div className="grid gap-3 sm:grid-cols-2 sm:w-[36rem]">+ <div className="grid grid-cols-[minmax(0,1fr)] gap-3 sm:w-[36rem] sm:max-w-full sm:grid-cols-2"><div className="space-y-1.5"><Label htmlFor={`${id}-new`} className="text-[13px]">{status.enabled ? "New password" : "Password"}</Label><Input id={`${id}-new`} type="password" autoComplete="new-password" placeholder="At least 8 characters" value={next} onChange={(e) => setNext(e.target.value)} />@@ -93,7 +93,7 @@ function McpSnippet({ token, needsToken }: { token: string | null; needsToken: bconst auth = needsToken ? ` --header "Authorization: Bearer ${token ?? "fuobe_…"}"` : "";const cmd = `claude mcp add --transport http fuobe ${origin}/api/mcp${auth}`;return (- <div className="space-y-1.5 sm:w-[36rem]">+ <div className="space-y-1.5 sm:w-[36rem] sm:max-w-full"><p className="text-[12px] font-medium">Connect an agent over MCP</p><div className="flex items-center gap-2 rounded-lg bg-muted px-2.5 py-2"><code className="min-w-0 flex-1 overflow-x-auto font-mono text-[11px] whitespace-nowrap">{cmd}</code>@@ -131,7 +131,7 @@ function Tokens({ status, onChange }: { status: AuthStatus; onChange: () => voidreturn (<div className="space-y-3"><div className="space-y-1">- <Label className="text-[13px]">API tokens</Label>+ <h3 className="text-[13px] font-medium">API tokens</h3><p className="text-[12px] text-muted-foreground">For scripts and agents (the REST API and the MCP endpoint at <code className="font-mono">/api/mcp</code>). Send as <code className="font-mono">Authorization: Bearer fuobe_…</code>. Only needed once a password is set.</p>@@ -155,7 +155,7 @@ function Tokens({ status, onChange }: { status: AuthStatus; onChange: () => void</div>)}{status.tokens.length > 0 && (- <ul className="divide-y rounded-xl border sm:w-[36rem]">+ <ul className="divide-y rounded-xl border sm:w-[36rem] sm:max-w-full">{status.tokens.map((t) => (<li key={t.id} className="flex items-center gap-3 px-3 py-2"><KeyRound className="size-4 text-muted-foreground" />@@ -183,9 +183,15 @@ function Tokens({ status, onChange }: { status: AuthStatus; onChange: () => void</ul>)}<McpSnippet token={fresh} needsToken={status.enabled} />- <div className="flex gap-2 sm:w-[36rem]">- <Input placeholder="Token name, e.g. “Claude Desktop”" value={name} onChange={(e) => setName(e.target.value)} />- <Button size="sm" variant="secondary" className="h-9" disabled={!name.trim()} onClick={() => void create()}>+ <div className="flex gap-2 sm:w-[36rem] sm:max-w-full">+ <Input+ aria-label="Token name"+ placeholder="Token name, e.g. “Claude Desktop”"+ value={name}+ onChange={(e) => setName(e.target.value)}+ onKeyDown={(e) => e.key === "Enter" && name.trim() && void create()}+ />+ <Button size="sm" variant="secondary" className="h-9 shrink-0" disabled={!name.trim()} onClick={() => void create()}>Create token</Button></div>diff --git a/src/components/settings-form.tsx b/src/components/settings-form.tsxindex b93df437..34ad1f6a 100644--- a/src/components/settings-form.tsx+++ b/src/components/settings-form.tsx@@ -2,12 +2,13 @@import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { CheckCircle2, CircleAlert, Cloud, Cpu, ExternalLink, Layers, Loader2 } from "lucide-react";-import { useState } from "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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";+import { Skeleton } from "@/components/ui/skeleton";import { cn } from "@/lib/utils";import { SecuritySettings } from "@/components/security-settings";@@ -41,13 +42,15 @@ function Section({children: React.ReactNode;}) {return (- <section id={id} className="grid scroll-mt-6 gap-6 border-b py-8 first:pt-0 md:grid-cols-[260px_1fr]">- <div>- <h2 className="text-[15px] font-semibold">{title}</h2>+ <section id={id} aria-labelledby={id ? `${id}-title` : undefined} className="grid scroll-mt-6 grid-cols-[minmax(0,1fr)] gap-6 border-b py-8 first:pt-0 md:grid-cols-[260px_minmax(0,1fr)]">+ <div className="min-w-0">+ <h2 id={id ? `${id}-title` : undefined} className="text-[15px] font-semibold">+ {title}+ </h2><p className="mt-1 text-[13px] leading-relaxed text-muted-foreground">{description}</p>{inactive && <p className="mt-2 inline-flex rounded-md bg-muted px-2 py-1 text-[12px] text-muted-foreground">{inactive}</p>}</div>- <div className={cn("space-y-5", inactive && "opacity-55")}>{children}</div>+ <div className={cn("min-w-0 space-y-5", inactive && "opacity-55")}>{children}</div></section>);}@@ -151,12 +154,19 @@ function Field({}) {const [v, setV] = useState("");const [editing, setEditing] = useState(false);+ const id = useId();const shown = editing ? v : setting?.secret ? "" : (setting?.value ?? "");return (<div className="space-y-1.5">- <Label className="text-[13px]">{label}</Label>+ <Label htmlFor={id} className="text-[13px]">+ {label}+ </Label><div className="flex gap-2"><Input+ id={id}+ aria-describedby={`${id}-hint`}+ autoComplete="off"+ spellCheck={false}type={setting?.secret ? "password" : "text"}value={shown}placeholder={setting?.secret && setting.isSet ? setting.value : placeholder}@@ -168,8 +178,9 @@ function Field({/><Buttonsize="sm"- className="h-9"+ className="h-9 shrink-0"disabled={!editing}+ aria-label={`Save ${label}`}onClick={() => {onSave(v);setEditing(false);@@ -179,12 +190,12 @@ function Field({Save</Button>{setting?.isSet && !setting.fromEnv && (- <Button size="sm" variant="ghost" className="h-9" onClick={() => onSave("")}>+ <Button size="sm" variant="ghost" className="h-9 shrink-0" aria-label={`Clear ${label}`} onClick={() => onSave("")}>Clear</Button>)}</div>- <p className="text-[12px] text-muted-foreground">+ <p id={`${id}-hint`} className="text-[12px] text-muted-foreground">{setting?.fromEnv ? "Set from environment variable. " : ""}{hint}</p>@@ -208,7 +219,14 @@ export function SettingsForm() {const get = (n: string) => settings.data?.find((s) => s.name === n);const set = (n: string) => (v: string) => save.mutate({ [n]: v });- if (settings.isLoading) return <Loader2 className="size-5 animate-spin text-muted-foreground" />;+ if (settings.isLoading)+ return (+ <div className="space-y-3" aria-busy="true" aria-label="Loading settings">+ {[0, 1, 2, 3].map((i) => (+ <Skeleton key={i} className="h-24 w-full rounded-xl" />+ ))}+ </div>+ );const mode = get("engineMode")?.value || "both";return (@@ -272,9 +290,11 @@ export function SettingsForm() {/><TestButton provider="higgsfield" /><div className="space-y-1.5">- <Label className="text-[13px]">Preferred provider</Label>+ <Label htmlFor="setting-cloud-provider" className="text-[13px]">+ Preferred provider+ </Label><Select value={get("cloudProvider")?.value || "auto"} onValueChange={set("cloudProvider")}>- <SelectTrigger className="w-72">+ <SelectTrigger id="setting-cloud-provider" className="w-full max-w-80"><SelectValue /></SelectTrigger><SelectContent>@@ -304,9 +324,11 @@ export function SettingsForm() {description="The Enhance toggle rewrites short ideas into rich prompts, and storyboards split stories into frames. Use Claude, a local Ollama model (fully open source), or the built-in offline rewriter. Claude also powers the Assist agent. In Open source only mode, Automatic skips Claude."><div className="space-y-1.5">- <Label className="text-[13px]">Enhancer</Label>+ <Label htmlFor="setting-enhancer" className="text-[13px]">+ Enhancer+ </Label><Select value={get("enhanceProvider")?.value || "auto"} onValueChange={set("enhanceProvider")}>- <SelectTrigger className="w-64">+ <SelectTrigger id="setting-enhancer" className="w-full max-w-72"><SelectValue /></SelectTrigger><SelectContent>@@ -334,7 +356,7 @@ export function SettingsForm() {<Section title="Demo mode" description="Lets you click through everything without keys or a GPU. Demo runs return clearly-labelled placeholder media and cost nothing."><Select value={get("demoMode")?.value || "auto"} onValueChange={set("demoMode")}>- <SelectTrigger className="w-72">+ <SelectTrigger aria-label="Demo mode" className="w-full max-w-80"><SelectValue /></SelectTrigger><SelectContent>diff --git a/src/components/storyboard-view.tsx b/src/components/storyboard-view.tsxindex 7df3bcce..f62fd0b7 100644--- a/src/components/storyboard-view.tsx+++ b/src/components/storyboard-view.tsx@@ -3,33 +3,69 @@import { useMutation, useQueryClient } from "@tanstack/react-query";import { ArrowUp, Clapperboard, Film, ImagePlus, Loader2, Minus, Plus, Sparkles, Trash2, Wand2, X } from "lucide-react";import Link from "next/link";-import { useMemo, useState } from "react";+import { useMemo, useState, useSyncExternalStore } from "react";import { nanoid } from "nanoid";import { toast } from "sonner";import { Button } from "@/components/ui/button";import { SidebarTrigger } from "@/components/ui/sidebar";import { Skeleton } from "@/components/ui/skeleton";+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { EngineSwitch } from "@/components/studio/engine-switch";import { FailedTile, MediaThumb, PendingTile, tileRatio } from "@/components/studio/feed";import { fileToSlot, MediaSlot, type SlotValue } from "@/components/studio/media-slot";import { Viewer } from "@/components/studio/viewer";import { useCreateGeneration, useEngine, useGenerationActions, useGenerations } from "@/lib/api";-import { getModel } from "@/lib/catalog";import { MAX_FRAMES, STORYBOARD_MODELS } from "@/lib/catalog/storyboard";-import type { Generation } from "@/lib/catalog/types";+import type { Engine, Generation } from "@/lib/catalog/types";import { timeAgo } from "@/lib/format";+import { BOARD_TITLES_KEY, boardTitle, filmReady, rememberTitle } from "@/lib/storyboard-board";import { cn } from "@/lib/utils";const ASPECTS = ["16:9", "9:16", "1:1", "4:3", "3:4", "21:9"];+/* The idea each board was made from, remembered in this browser (the server keeps only the scenes). */+const titleListeners = new Set<() => void>();+let titleCache: { raw: string | null; map: Record<string, string> } | null = null;+function readTitles(): Record<string, string> {+ try {+ const raw = localStorage.getItem(BOARD_TITLES_KEY);+ if (titleCache?.raw !== raw) titleCache = { raw, map: raw ? (JSON.parse(raw) as Record<string, string>) : {} };+ return titleCache.map;+ } catch {+ return {};+ }+}+const NO_TITLES: Record<string, string> = {};+function saveTitle(batchId: string, idea: string) {+ try {+ localStorage.setItem(BOARD_TITLES_KEY, JSON.stringify(rememberTitle(readTitles(), batchId, idea)));+ } catch {}+ titleListeners.forEach((l) => l());+}+function useBoardTitles() {+ return useSyncExternalStore(+ (cb) => {+ titleListeners.add(cb);+ return () => titleListeners.delete(cb);+ },+ readTitles,+ () => NO_TITLES,+ );+}++const modelName = (g: Generation, names: Record<string, string>) => (g as Generation & { modelName?: string }).modelName ?? names[g.modelId] ?? g.modelId;+function RatioPill({ value, onChange }: { value: string; onChange: (v: string) => void }) {return (- <div className="flex flex-wrap gap-1 rounded-full bg-muted p-0.5">+ <div role="radiogroup" aria-label="Aspect ratio" className="flex flex-wrap gap-1 rounded-full bg-muted p-0.5">{ASPECTS.map((a) => (<buttonkey={a}+ type="button"+ role="radio"+ aria-checked={value === a}onClick={() => onChange(a)}- className={cn("h-7 rounded-full px-2.5 text-[12px] font-medium text-muted-foreground transition", value === a && "bg-background text-foreground shadow-soft")}+ className={cn("h-7 rounded-full px-2.5 text-[12px] font-medium whitespace-nowrap text-muted-foreground transition", value === a && "bg-background text-foreground shadow-soft")}>{a}</button>@@ -61,7 +97,7 @@ function FilmStrip({ items, ratio, onOpen }: { items: Generation[]; ratio: numbe{shots.map((g) => (<figure key={g.id} className="min-w-0 space-y-1">{tile(g)}- <figcaption className="text-[11px] text-muted-foreground">{g.request.step?.label}</figcaption>+ <figcaption className="truncate text-[11px] text-muted-foreground">{g.request.step?.label}</figcaption></figure>))}</div>@@ -69,12 +105,64 @@ function FilmStrip({ items, ratio, onOpen }: { items: Generation[]; ratio: numbe);}-function Board({ frames, film, onOpen }: { frames: Generation[]; film: Generation[]; onOpen: (g: Generation) => void }) {- const { remove } = useGenerationActions();+function FrameTile({ g, index, ratio, onOpen }: { g: Generation; index: number; ratio: number; onOpen: (g: Generation) => void }) {const create = useCreateGeneration();+ const o = g.outputs[0];+ return (+ <figure className="min-w-0 space-y-1.5">+ <div className="group/tile relative overflow-hidden rounded-xl" style={{ aspectRatio: ratio }}>+ {g.status === "succeeded" && o ? (+ <>+ <button onClick={() => onOpen(g)} className="block size-full cursor-zoom-in bg-muted" aria-label={`Open frame ${index + 1}`}>+ <MediaThumb output={o} />+ </button>+ <span className="pointer-events-none absolute inset-x-0 bottom-0 flex justify-end gap-1 bg-gradient-to-t from-black/60 to-transparent p-2 pt-8 transition-opacity group-focus-within/tile:opacity-100 sm:opacity-0 sm:group-hover/tile:opacity-100">+ <Link+ href={`/video?image=${encodeURIComponent(o.url)}&prompt=${encodeURIComponent(g.request.frame?.scene ?? "")}`}+ className="pointer-events-auto inline-flex h-7 items-center gap-1 rounded-full bg-white/20 px-2.5 text-[12px] font-medium whitespace-nowrap text-white backdrop-blur hover:bg-white/30"+ >+ <Clapperboard className="size-3.5" /> Animate+ </Link>+ <Link+ href={`/edit?image=${encodeURIComponent(o.url)}`}+ className="pointer-events-auto inline-flex h-7 items-center gap-1 rounded-full bg-white/20 px-2.5 text-[12px] font-medium whitespace-nowrap text-white backdrop-blur hover:bg-white/30"+ >+ <Wand2 className="size-3.5" /> Edit+ </Link>+ </span>+ </>+ ) : g.status === "failed" || g.status === "canceled" ? (+ <FailedTile g={g} ratio={ratio} onRetry={() => create.mutate(g.request, { onError: (e) => toast.error((e as Error).message) })} />+ ) : (+ <PendingTile g={g} ratio={ratio} />+ )}+ <span className="pointer-events-none absolute top-2 left-2 grid size-6 place-items-center rounded-full bg-background/90 font-mono text-[11px] font-semibold shadow-soft">+ {index + 1}+ </span>+ </div>+ <figcaption className="line-clamp-2 px-0.5 text-[12px] leading-snug text-muted-foreground">{g.request.frame?.scene}</figcaption>+ </figure>+ );+}++function Board({+ frames,+ film,+ onOpen,+ idea,+ names,+}: {+ frames: Generation[];+ film: Generation[];+ onOpen: (g: Generation) => void;+ idea?: string;+ names: Record<string, string>;+}) {+ const { remove } = useGenerationActions();const qc = useQueryClient();const first = frames[0];const done = frames.filter((f) => f.status === "succeeded").length;+ const ready = filmReady(frames);const ratio = tileRatio(first);const makeFilm = useMutation({mutationFn: async () => {@@ -89,78 +177,56 @@ function Board({ frames, film, onOpen }: { frames: Generation[]; film: Generatio},onError: (e) => toast.error((e as Error).message),});+ const filmButton = (+ <Button variant="secondary" size="sm" disabled={!ready || makeFilm.isPending} onClick={() => makeFilm.mutate()} className="whitespace-nowrap">+ {makeFilm.isPending ? <Loader2 className="animate-spin" /> : <Film />} Make the film+ </Button>+ );return (<section className="animate-fade-up space-y-3">- <header className="flex items-start gap-3">- <div className="min-w-0 flex-1">- <h3 className="line-clamp-1 font-heading text-[19px] leading-snug">{first.request.frame?.scene ?? first.request.prompt}</h3>+ <header className="flex flex-wrap items-start gap-x-3 gap-y-2">+ <div className="min-w-0 flex-1 basis-60">+ <h3 className="line-clamp-2 font-heading text-[19px] leading-snug">{boardTitle(frames, idea)}</h3><p className="text-[12px] text-muted-foreground">- {frames.length} frames · {done === frames.length ? "done" : `${done}/${frames.length} ready`} · {getModel(first.modelId)?.name} · {timeAgo(first.createdAt)}+ {frames.length} frames · {done === frames.length ? "done" : `${done}/${frames.length} ready`} · {modelName(first, names)} · {timeAgo(first.createdAt)}</p></div>- {!film.length && frames.length > 1 && first.batchId && (- <Button variant="secondary" size="sm" disabled={makeFilm.isPending} onClick={() => makeFilm.mutate()}>- {makeFilm.isPending ? <Loader2 className="animate-spin" /> : <Film />} Make the film+ <div className="flex shrink-0 items-center gap-1">+ {!film.length && frames.length > 1 && first.batchId && (+ <Tooltip>+ <TooltipTrigger asChild>+ {/* A disabled button gets no pointer events, so the tooltip hangs on a wrapper. */}+ <span tabIndex={ready ? -1 : 0} className="inline-flex rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring">+ {filmButton}+ </span>+ </TooltipTrigger>+ <TooltipContent>{ready ? "Animate each frame into the next, then join them" : `Ready when all ${frames.length} frames are done`}</TooltipContent>+ </Tooltip>+ )}+ <Button+ variant="ghost"+ size="sm"+ className="text-muted-foreground hover:text-destructive"+ onClick={() => {+ [...frames, ...film].forEach((f) => void remove(f));+ toast("Storyboard deleted");+ }}+ >+ <Trash2 /> <span className="hidden sm:inline">Delete</span></Button>- )}- <Button- variant="ghost"- size="sm"- className="text-muted-foreground hover:text-destructive"- onClick={() => {- [...frames, ...film].forEach((f) => void remove(f));- toast("Storyboard deleted");- }}- >- <Trash2 /> Delete- </Button>+ </div></header>- <div className="scrollbar-none -mx-1 flex gap-3 overflow-x-auto px-1 pb-1">- {frames.map((g, i) => {- const o = g.outputs[0];- return (- <figure key={g.id} className="w-[min(70vw,280px)] shrink-0 space-y-1.5">- <div className="relative overflow-hidden rounded-xl" style={{ aspectRatio: ratio }}>- {g.status === "succeeded" && o ? (- <button onClick={() => onOpen(g)} className="group/tile block size-full cursor-zoom-in bg-muted">- <MediaThumb output={o} />- <span className="absolute inset-x-0 bottom-0 flex justify-end gap-1 bg-gradient-to-t from-black/60 to-transparent p-2 pt-8 opacity-0 transition-opacity group-hover/tile:opacity-100">- <Link- href={`/video?image=${encodeURIComponent(o.url)}&prompt=${encodeURIComponent(g.request.frame?.scene ?? "")}`}- onClick={(e) => e.stopPropagation()}- className="inline-flex h-7 items-center gap-1 rounded-full bg-white/20 px-2.5 text-[12px] font-medium text-white backdrop-blur hover:bg-white/30"- >- <Clapperboard className="size-3.5" /> Animate- </Link>- <Link- href={`/edit?image=${encodeURIComponent(o.url)}`}- onClick={(e) => e.stopPropagation()}- className="inline-flex h-7 items-center gap-1 rounded-full bg-white/20 px-2.5 text-[12px] font-medium text-white backdrop-blur hover:bg-white/30"- >- <Wand2 className="size-3.5" /> Edit- </Link>- </span>- </button>- ) : g.status === "failed" || g.status === "canceled" ? (- <FailedTile g={g} ratio={ratio} onRetry={() => create.mutate(g.request, { onError: (e) => toast.error((e as Error).message) })} />- ) : (- <PendingTile g={g} ratio={ratio} />- )}- <span className="pointer-events-none absolute top-2 left-2 grid size-6 place-items-center rounded-full bg-background/90 font-mono text-[11px] font-semibold shadow-soft">- {i + 1}- </span>- </div>- <figcaption className="line-clamp-2 px-0.5 text-[12px] leading-snug text-muted-foreground">{g.request.frame?.scene}</figcaption>- </figure>- );- })}+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-[repeat(auto-fill,minmax(220px,1fr))]">+ {frames.map((g, i) => (+ <FrameTile key={g.id} g={g} index={i} ratio={ratio} onOpen={onOpen} />+ ))}</div>{film.length > 0 && <FilmStrip items={film} ratio={ratio} onOpen={onOpen} />}</section>);}-export function StoryboardView() {+export function StoryboardView({ modelNames = {} }: { /** Display names of the storyboard models, from the server. */ modelNames?: Record<string, string> }) {const qc = useQueryClient();const [engine, setEngine] = useEngine();const [mode, setMode] = useState<"auto" | "manual">("auto");@@ -172,6 +238,7 @@ export function StoryboardView() {const [refs, setRefs] = useState<SlotValue[]>([]);const [open, setOpen] = useState<Generation | null>(null);const feed = useGenerations({ features: ["storyboard", "storyboard-film"], limit: 240 });+ const titles = useBoardTitles();const films = useMemo(() => {const by = new Map<string, Generation[]>();@@ -193,7 +260,7 @@ export function StoryboardView() {const flat = boards.flatMap((b) => [...b, ...(films.get(b[0].batchId ?? "") ?? [])].filter((g) => g.status === "succeeded" && g.outputs[0]));const pos = open ? flat.findIndex((g) => g.id === open.id) : -1;- const m = STORYBOARD_MODELS[engine];+ const m = STORYBOARD_MODELS[engine as Engine];const submit = useMutation({mutationFn: async () => {const res = await fetch("/api/storyboards", {@@ -209,9 +276,11 @@ export function StoryboardView() {});const body = await res.json();if (!res.ok) throw new Error(body.error);- return body as { scenes: string[] };+ return body as { scenes: string[]; batchId?: string };},onSuccess: (b) => {+ const idea = mode === "auto" ? story : scenes.find((s) => s.trim());+ if (b.batchId && idea?.trim()) saveTitle(b.batchId, idea);toast.success(`${b.scenes.length} frames on the way — each one builds on the last`);void qc.invalidateQueries({ queryKey: ["generations"] });},@@ -224,7 +293,9 @@ export function StoryboardView() {void fileToSlot(f, (v) =>setRefs((rs) => {if (!v) return rs.filter((r) => r.id !== id);- return rs.some((r) => r.id === id) ? rs.map((r) => (r.id === id ? { ...v, id } : r)) : [...rs, { ...v, id }];+ if (rs.some((r) => r.id === id)) return rs.map((r) => (r.id === id ? { ...v, id } : r));+ // A reference removed while it uploaded stays removed.+ return v.uploading ? [...rs, { ...v, id }] : rs;}),);};@@ -233,7 +304,7 @@ export function StoryboardView() {<div className="flex min-h-svh min-w-0 flex-col"><header className="sticky top-0 z-20 flex h-14 items-center gap-2 bg-background/85 px-3 backdrop-blur sm:px-6"><SidebarTrigger className="md:hidden" />- <h1 className="font-heading text-[22px] leading-none">Storyboard</h1>+ <h1 className="min-w-0 truncate font-heading text-[22px] leading-none">Storyboard</h1><div className="ml-auto"><EngineSwitch value={engine} onChange={setEngine} /></div>@@ -242,13 +313,20 @@ export function StoryboardView() {<div className="mx-auto max-w-[820px] pt-6 text-center"><h2 className="font-heading text-display text-balance">Tell it frame by frame</h2><p className="mt-2 text-[13px] text-muted-foreground">- Up to {MAX_FRAMES} consistent frames — each one is made from the previous frame, so faces, wardrobe and light carry through. Runs on{" "}- {getModel(m.next)?.name}.+ Up to {MAX_FRAMES} consistent frames — each one is made from the previous frame, so faces, wardrobe and light carry through.+ {modelNames[m.next] ? ` Runs on ${modelNames[m.next]}.` : ""}</p>- <div className="mt-6 rounded-composer border bg-background p-3 text-left shadow-soft focus-within:border-primary focus-within:ring-4 focus-within:ring-brand-faint">- <div className="mb-2 flex items-center gap-1 rounded-full bg-muted p-0.5 text-[13px] font-medium sm:w-fit">+ <div className="mt-6 rounded-[20px] border bg-background p-3 text-left shadow-soft focus-within:border-primary focus-within:ring-4 focus-within:ring-brand-faint sm:rounded-composer">+ <div role="radiogroup" aria-label="How to write it" className="mb-2 flex items-center gap-1 rounded-full bg-muted p-0.5 text-[13px] font-medium sm:w-fit">{(["auto", "manual"] as const).map((k) => (- <button key={k} onClick={() => setMode(k)} className={cn("h-8 flex-1 rounded-full px-4 text-muted-foreground transition", mode === k && "bg-background text-foreground shadow-soft")}>+ <button+ key={k}+ type="button"+ role="radio"+ aria-checked={mode === k}+ onClick={() => setMode(k)}+ className={cn("h-8 flex-1 rounded-full px-4 whitespace-nowrap text-muted-foreground transition", mode === k && "bg-background text-foreground shadow-soft")}+ >{k === "auto" ? "From one idea" : "Scene by scene"}</button>))}@@ -258,6 +336,7 @@ export function StoryboardView() {value={story}onChange={(e) => setStory(e.target.value)}rows={2}+ aria-label="Your story"placeholder="The whole story in a sentence or two — e.g. “a lighthouse keeper finds a glowing bottle and follows its map into the sea”"className="field-sizing-content max-h-52 min-h-16 w-full resize-none bg-transparent px-2 py-1.5 text-base leading-relaxed outline-none placeholder:text-subtle-foreground"/>@@ -270,10 +349,12 @@ export function StoryboardView() {value={s}onChange={(e) => setScenes((xs) => xs.map((x, j) => (j === i ? e.target.value : x)))}rows={1}+ aria-label={`Frame ${i + 1}`}placeholder={i ? "What happens next?" : "Opening frame — who, where, what"}- className="field-sizing-content max-h-28 min-h-8 flex-1 resize-none bg-transparent py-1 text-[14px] outline-none placeholder:text-subtle-foreground"+ className="field-sizing-content max-h-28 min-h-8 min-w-0 flex-1 resize-none bg-transparent py-1 text-[14px] outline-none placeholder:text-subtle-foreground"/><button+ type="button"onClick={() => setScenes((xs) => (xs.length > 1 ? xs.filter((_, j) => j !== i) : xs))}className="grid size-7 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-accent"aria-label={`Remove frame ${i + 1}`}@@ -283,7 +364,7 @@ export function StoryboardView() {</div>))}{scenes.length < MAX_FRAMES && (- <button onClick={() => setScenes((xs) => [...xs, ""])} className="inline-flex items-center gap-1 px-1 text-[12px] font-medium text-brand-text hover:underline">+ <button type="button" onClick={() => setScenes((xs) => [...xs, ""])} className="inline-flex items-center gap-1 px-1 text-[12px] font-medium text-brand-text hover:underline"><Plus className="size-3" /> Add frame</button>)}@@ -292,6 +373,7 @@ export function StoryboardView() {<inputvalue={style}onChange={(e) => setStyle(e.target.value)}+ aria-label="Look (optional)"placeholder="Look (optional) — e.g. “35mm film, moody teal night, anamorphic”"className="mt-2 h-9 w-full rounded-lg border bg-background px-2.5 text-[13px] outline-none focus:border-primary"/>@@ -301,45 +383,59 @@ export function StoryboardView() {{/* eslint-disable-next-line @next/next/no-img-element */}<img src={r.preview} alt="" className="size-full object-cover" />{r.uploading && <Loader2 className="absolute inset-0 m-auto size-4 animate-spin" />}- <button onClick={() => setRefs((rs) => rs.filter((x) => x.id !== r.id))} className="absolute top-0.5 right-0.5 grid size-4 place-items-center rounded-full bg-foreground/80 text-background" aria-label="Remove reference">+ <button+ type="button"+ onClick={() => setRefs((rs) => rs.filter((x) => x.id !== r.id))}+ className="absolute top-0.5 right-0.5 grid size-4 place-items-center rounded-full bg-foreground/80 text-background"+ aria-label="Remove reference"+ ><X className="size-2.5" /></button></div>))}- {refs.length < 4 && <MediaSlot label="Character / look" kind="image" value={null} onChange={(v) => v && setRefs((rs) => [...rs, { ...v, id: nanoid(6) }])} onFile={addRef} />}+ {refs.length < 4 && <MediaSlot label="Look ref" kind="image" value={null} onChange={(v) => v && setRefs((rs) => [...rs, { ...v, id: nanoid(6) }])} onFile={addRef} />}{mode === "auto" && (<div className="flex items-center gap-1 rounded-full bg-secondary px-1 py-0.5 text-[13px] font-medium">- <button onClick={() => setCount((c) => Math.max(2, c - 1))} className="grid size-7 place-items-center rounded-full hover:bg-accent" aria-label="Fewer frames">+ <button type="button" onClick={() => setCount((c) => Math.max(2, c - 1))} className="grid size-7 place-items-center rounded-full hover:bg-accent" aria-label="Fewer frames"><Minus className="size-3.5" /></button>- <span className="w-16 text-center tabular-nums">{count} frames</span>- <button onClick={() => setCount((c) => Math.min(MAX_FRAMES, c + 1))} className="grid size-7 place-items-center rounded-full hover:bg-accent" aria-label="More frames">+ <span className="w-16 text-center whitespace-nowrap tabular-nums" aria-live="polite">+ {count} frames+ </span>+ <button type="button" onClick={() => setCount((c) => Math.min(MAX_FRAMES, c + 1))} className="grid size-7 place-items-center rounded-full hover:bg-accent" aria-label="More frames"><Plus className="size-3.5" /></button></div>)}<RatioPill value={aspect} onChange={setAspect} />- <Button size="icon" className="ml-auto size-10 rounded-full" disabled={!ready || submit.isPending} onClick={() => submit.mutate()} aria-label="Generate storyboard">+ <Button size="icon" className="ml-auto size-10 shrink-0 rounded-full" disabled={!ready || submit.isPending} onClick={() => submit.mutate()} aria-label="Generate storyboard">{submit.isPending ? <Loader2 className="animate-spin" /> : <ArrowUp />}</Button></div>- <p className="mt-2 flex items-center gap-1.5 text-[11px] text-muted-foreground">- <Sparkles className="size-3" />+ <p className="mt-2 flex items-start gap-1.5 text-[11px] text-muted-foreground">+ <Sparkles className="mt-px size-3 shrink-0" />{mode === "auto" ? "Your story is split into frames by the prompt LLM (Settings → Prompt enhancement), or a shot list when none is set." : "One prompt per frame. References keep the cast consistent."}</p></div></div>{feed.isLoading ? (- <div className="flex gap-3">+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-[repeat(auto-fill,minmax(220px,1fr))]">{[0, 1, 2].map((i) => (- <Skeleton key={i} className="h-40 w-64 rounded-xl" />+ <Skeleton key={i} className="aspect-video rounded-xl" />))}</div>) : boards.length ? (<div className="space-y-10">{boards.map((b) => (- <Board key={b[0].batchId ?? b[0].id} frames={b} film={films.get(b[0].batchId ?? "") ?? []} onOpen={setOpen} />+ <Board+ key={b[0].batchId ?? b[0].id}+ frames={b}+ film={films.get(b[0].batchId ?? "") ?? []}+ onOpen={setOpen}+ idea={b[0].batchId ? titles[b[0].batchId] : undefined}+ names={modelNames}+ />))}</div>) : (diff --git a/src/components/train-dialog.tsx b/src/components/train-dialog.tsxindex 5ac1a869..38fc0dc7 100644--- a/src/components/train-dialog.tsx+++ b/src/components/train-dialog.tsx@@ -9,7 +9,6 @@ import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Progress } from "@/components/ui/progress";-import { getModel } from "@/lib/catalog";import type { StudioElement } from "@/lib/catalog/elements";import { triggerFor, type TrainingTarget } from "@/lib/catalog/training";import { cn } from "@/lib/utils";@@ -108,7 +107,7 @@ export function TrainDialog({ element, open, onOpenChange }: { element: StudioEl{element.loras.map((l) => (<div key={l.modelId} className="flex items-center gap-2 rounded-lg border px-3 py-2 text-[13px]"><Check className="size-4 text-success" />- <span className="font-medium">{getModel(l.modelId)?.name ?? l.modelId}</span>+ <span className="font-medium">{q.data?.targets.find((t) => t.modelIds.includes(l.modelId))?.name ?? l.modelId}</span><span className="truncate text-muted-foreground">{l.referenceId ? "Soul ID" : l.trigger ? `trigger “${l.trigger}”` : l.file}</span><button onClick={() => void remove(l.modelId)} className="ml-auto text-muted-foreground hover:text-destructive" aria-label="Remove"><Trash2 className="size-3.5" />diff --git a/src/components/ui/slider.tsx b/src/components/ui/slider.tsxindex 02314177..4585438d 100644--- a/src/components/ui/slider.tsx+++ b/src/components/ui/slider.tsx@@ -4,14 +4,23 @@ import * as React from "react"import { cn } from "cn"import { Slider as SliderPrimitive } from "radix-ui"+/**+ * shadcn Slider. The accessible name (`aria-label` / `aria-labelledby`) and `aria-valuetext` go to+ * the thumbs, which carry role="slider" (Radix renders the root as a plain span). With several+ * thumbs, `thumbLabels` names each one ("Minimum", "Maximum").+ */function Slider({className,defaultValue,value,min = 0,max = 100,+ "aria-label": ariaLabel,+ "aria-labelledby": ariaLabelledBy,+ "aria-valuetext": ariaValueText,+ thumbLabels,...props-}: React.ComponentProps<typeof SliderPrimitive.Root>) {+}: React.ComponentProps<typeof SliderPrimitive.Root> & { thumbLabels?: string[] }) {const _values = React.useMemo(() =>Array.isArray(value)@@ -48,6 +57,15 @@ function Slider({<SliderPrimitive.Thumbdata-slot="slider-thumb"key={index}+ aria-label={+ thumbLabels?.[index]+ ? ariaLabel+ ? `${ariaLabel}: ${thumbLabels[index]}`+ : thumbLabels[index]+ : ariaLabel+ }+ aria-labelledby={thumbLabels?.[index] ? undefined : ariaLabelledBy}+ aria-valuetext={ariaValueText}className="relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"/>))}diff --git a/src/components/use-progressive.ts b/src/components/use-progressive.tsnew file mode 100644index 00000000..3ca9ef1d--- /dev/null+++ b/src/components/use-progressive.ts@@ -0,0 +1,28 @@+"use client";++import { useCallback, useEffect, useRef, useState } from "react";++/**+ * Render a long list a page at a time: `first` items up front (and in the server HTML), `page` more+ * whenever the sentinel element nears the viewport or is clicked. Starts over when `resetKey` changes+ * (a new search or filter).+ */+export function useProgressive<T extends HTMLElement = HTMLButtonElement>(total: number, resetKey: string, first = 30, page = 40) {+ const [shown, setShown] = useState(first);+ const [lastKey, setLastKey] = useState(resetKey);+ if (lastKey !== resetKey) {+ setLastKey(resetKey);+ setShown(first);+ }+ const more = useCallback(() => setShown((n) => n + page), [page]);+ const sentinel = useRef<T>(null);+ const hasMore = shown < total;+ useEffect(() => {+ const el = sentinel.current;+ if (!el || !hasMore || typeof IntersectionObserver === "undefined") return;+ const io = new IntersectionObserver((es) => es.some((e) => e.isIntersecting) && more(), { rootMargin: "600px 0px" });+ io.observe(el);+ return () => io.disconnect();+ }, [hasMore, more, shown]);+ return { shown, hasMore, more, sentinel, left: Math.max(0, total - shown) };+}diff --git a/src/components/workflows-view.tsx b/src/components/workflows-view.tsxindex 2ff8f90b..eb4bbf5f 100644--- a/src/components/workflows-view.tsx+++ b/src/components/workflows-view.tsx@@ -1,17 +1,31 @@"use client";import { useQuery } from "@tanstack/react-query";-import { CheckCircle2, Circle, CircleAlert, Copy, ExternalLink, Loader2 } from "lucide-react";+import { CheckCircle2, Circle, CircleAlert, Copy, ExternalLink, RotateCcw, Search, Workflow } from "lucide-react";import Link from "next/link";+import { useDeferredValue, useMemo, useState } from "react";import { toast } from "sonner";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";+import { Skeleton } from "@/components/ui/skeleton";import type { ManifestWorkflow } from "@/lib/comfy";-import { MODELS } from "@/lib/catalog";import { cn } from "@/lib/utils";type WF = Omit<ManifestWorkflow, "models"> & { models: (ManifestWorkflow["models"][number] & { present: boolean | null })[] };+interface ComfyStatus {+ reachable: boolean;+ generatedAt: string;+ comfyuiCommit?: string;+ workflows: WF[];+}++/** An open model's ComfyUI route, from the catalog on the server ("video-concat-{n}" style endpoints match by pattern). */+export interface ComfyRoute {+ endpoint: string;+ name: string;+}+function downloadScript(wf: WF): string {const lines = wf.models.filter((m) => m.url && m.present !== true)@@ -20,103 +34,179 @@ function downloadScript(wf: WF): string {return ["COMFYUI=${COMFYUI:-$HOME/ComfyUI}", ...nodes, ...lines].join("\n");}-export function WorkflowsView() {- const q = useQuery({- queryKey: ["comfyui"],- queryFn: async () =>- (await (await fetch("/api/comfyui")).json()) as { reachable: boolean; generatedAt: string; comfyuiCommit?: string; workflows: WF[] },- });- if (q.isLoading) return <Loader2 className="size-5 animate-spin text-muted-foreground" />;- const data = q.data!;- const usedBy = (id: string) => MODELS.filter((m) => m.routes.some((r) => r.provider === "comfyui" && (r.endpoint === id || (r.endpoint.includes("{n}") && new RegExp(`^${r.endpoint.replace("{n}", "\\d")}$`).test(id))))).map((m) => m.name);+export function usedByIndex(routes: ComfyRoute[]) {+ const exact = new Map<string, string[]>();+ const patterns: { re: RegExp; name: string }[] = [];+ for (const r of routes) {+ if (r.endpoint.includes("{n}")) patterns.push({ re: new RegExp(`^${r.endpoint.replace(/[.*+?^$()|[\]\\]/g, "\\$&").replace("{n}", "\\d")}$`), name: r.name });+ else exact.set(r.endpoint, [...(exact.get(r.endpoint) ?? []), r.name]);+ }+ return (id: string) => [...new Set([...(exact.get(id) ?? []), ...patterns.filter((p) => p.re.test(id)).map((p) => p.name)])];+}++async function fetchStatus(): Promise<ComfyStatus> {+ const res = await fetch("/api/comfyui");+ const body = (await res.json().catch(() => ({}))) as Partial<ComfyStatus> & { error?: string };+ if (!res.ok) throw new Error(body.error ?? `Couldn’t load the workflow library (${res.status})`);+ return { reachable: !!body.reachable, generatedAt: body.generatedAt ?? "", comfyuiCommit: body.comfyuiCommit, workflows: body.workflows ?? [] };+}+function WorkflowCard({ wf, usedBy }: { wf: WF; usedBy: string[] }) {+ const missing = wf.models.filter((m) => m.present === false).length;+ const total = wf.models.reduce((a, m) => a + (m.sizeGb ?? 0), 0);+ return (+ <article className="flex min-w-0 flex-col gap-3 rounded-xl border bg-background p-4">+ <div className="flex flex-wrap items-start justify-between gap-2">+ <div className="min-w-0 flex-1 basis-48">+ <h3 className="font-medium break-words">{wf.title}</h3>+ <p className="font-mono text-[11px] break-all text-muted-foreground">{wf.id}</p>+ </div>+ <div className="flex shrink-0 gap-1">+ <Badge variant="secondary" className="rounded-[4px] text-[11px]">+ {wf.capability}+ </Badge>+ <Badge className={cn("rounded-[4px] text-[11px]", wf.validated ? "bg-success/15 text-success" : "bg-warning/15 text-warning")}>+ {wf.validated ? "validated" : "unverified"}+ </Badge>+ </div>+ </div>+ <p className="text-[12px] break-words text-muted-foreground">+ {wf.source}+ {wf.vramGb ? ` · ~${wf.vramGb} GB VRAM` : ""}+ {total ? ` · ${total.toFixed(1)} GB of models` : ""}+ {usedBy.length ? ` · used by ${usedBy.join(", ")}` : ""}+ </p>+ {wf.models.length > 0 && (+ <ul className="space-y-1 text-[12px]">+ {wf.models.map((m) => (+ <li key={m.file} className="flex min-w-0 items-center gap-2">+ {m.present === true ? (+ <CheckCircle2 className="size-3.5 shrink-0 text-success" aria-label="Installed" />+ ) : m.present === false ? (+ <CircleAlert className="size-3.5 shrink-0 text-warning" aria-label="Missing" />+ ) : (+ <Circle className="size-3.5 shrink-0 text-subtle-foreground" aria-label="Unknown" />+ )}+ <span className="min-w-0 truncate font-mono" title={m.file}>+ {m.file}+ </span>+ <span className="hidden shrink-0 text-muted-foreground sm:inline">{m.folder}</span>+ {m.sizeGb ? <span className="ml-auto shrink-0 font-mono text-muted-foreground">{m.sizeGb} GB</span> : null}+ {m.url && (+ <a href={m.url} target="_blank" rel="noreferrer" className={cn("shrink-0 text-muted-foreground hover:text-foreground", !m.sizeGb && "ml-auto")} aria-label={`Download ${m.file}`}>+ <ExternalLink className="size-3.5" />+ </a>+ )}+ </li>+ ))}+ </ul>+ )}+ {wf.customNodes.length > 0 && (+ <p className="text-[12px] break-words text-muted-foreground">+ Custom nodes:{" "}+ {wf.customNodes.map((n, i) => (+ <a key={n.repo} href={n.repo} target="_blank" rel="noreferrer" className="text-brand-text hover:underline">+ {n.name}+ {i < wf.customNodes.length - 1 ? ", " : ""}+ </a>+ ))}+ </p>+ )}+ {wf.notes && <p className="text-[12px] leading-relaxed break-words text-muted-foreground">{wf.notes}</p>}+ <div className="mt-auto flex gap-2 pt-1">+ <Button+ variant="secondary"+ size="sm"+ className="max-w-full"+ onClick={() => {+ void navigator.clipboard.writeText(downloadScript(wf));+ toast("Install commands copied");+ }}+ >+ <Copy /> <span className="truncate">{missing ? `Copy install commands (${missing} missing)` : "Copy install commands"}</span>+ </Button>+ </div>+ </article>+ );+}++export function WorkflowsView({ routes = [] }: { routes?: ComfyRoute[] }) {+ const q = useQuery({ queryKey: ["comfyui"], queryFn: fetchStatus });+ const [search, setSearch] = useState("");+ const term = useDeferredValue(search.trim().toLowerCase());+ const usedBy = useMemo(() => usedByIndex(routes), [routes]);+ const workflows = useMemo(() => q.data?.workflows ?? [], [q.data]);+ const list = useMemo(+ () => (term ? workflows.filter((w) => `${w.id} ${w.title} ${w.capability} ${usedBy(w.id).join(" ")}`.toLowerCase().includes(term)) : workflows),+ [workflows, term, usedBy],+ );++ if (q.isPending)+ return (+ <div className="space-y-6" aria-busy="true" aria-label="Loading workflows">+ <Skeleton className="h-12 w-full rounded-xl" />+ <div className="grid grid-cols-[minmax(0,1fr)] gap-3 lg:grid-cols-2">+ {[0, 1, 2, 3].map((i) => (+ <Skeleton key={i} className="h-48 rounded-xl" />+ ))}+ </div>+ </div>+ );++ if (q.isError)+ return (+ <div className="rounded-xl border border-dashed px-6 py-12 text-center">+ <Workflow className="mx-auto size-6 text-muted-foreground" />+ <p className="mt-3 font-heading text-[22px]">Couldn’t load the workflows</p>+ <p className="mx-auto mt-1 max-w-md text-[13px] text-muted-foreground">{(q.error as Error).message}</p>+ <Button className="mt-5" variant="outline" onClick={() => void q.refetch()}>+ <RotateCcw /> Try again+ </Button>+ </div>+ );++ const data = q.data;+ const validated = workflows.filter((w) => w.validated).length;return (<div className="space-y-6"><div className={cn("flex flex-wrap items-center gap-3 rounded-xl border px-4 py-3 text-[13px]", data.reachable ? "bg-background" : "bg-brand-faint")}>- {data.reachable ? <CheckCircle2 className="size-4 text-success" /> : <CircleAlert className="size-4 text-warning" />}- <span>+ {data.reachable ? <CheckCircle2 className="size-4 shrink-0 text-success" /> : <CircleAlert className="size-4 shrink-0 text-warning" />}+ <span className="min-w-0 flex-1 basis-56">{data.reachable ? "Connected to ComfyUI — model checkmarks below reflect what’s installed." : "ComfyUI is not reachable, so open-source runs fall back to demo output."}</span>- <Link href="/settings" className="ml-auto text-brand-text hover:underline">+ <Link href="/settings#comfyui" className="text-brand-text hover:underline">Server settings</Link></div>- {!data.workflows.length && <p className="text-sm text-muted-foreground">No workflows in workflows/comfyui/manifest.json yet.</p>}- <div className="grid gap-3 lg:grid-cols-2">- {data.workflows.map((wf) => {- const missing = wf.models.filter((m) => m.present === false).length;- const total = wf.models.reduce((a, m) => a + (m.sizeGb ?? 0), 0);- return (- <article key={wf.id} className="flex flex-col gap-3 rounded-xl border bg-background p-4">- <div className="flex items-start justify-between gap-2">- <div>- <h3 className="font-medium">{wf.title}</h3>- <p className="font-mono text-[11px] text-muted-foreground">{wf.id}</p>- </div>- <div className="flex shrink-0 gap-1">- <Badge variant="secondary" className="rounded-[4px] text-[11px]">- {wf.capability}- </Badge>- <Badge className={cn("rounded-[4px] text-[11px]", wf.validated ? "bg-success/15 text-success" : "bg-warning/15 text-warning")}>- {wf.validated ? "validated" : "unverified"}- </Badge>- </div>- </div>- <p className="text-[12px] text-muted-foreground">- {wf.source}- {wf.vramGb ? ` · ~${wf.vramGb} GB VRAM` : ""}- {total ? ` · ${total.toFixed(1)} GB of models` : ""}- {usedBy(wf.id).length ? ` · used by ${usedBy(wf.id).join(", ")}` : ""}- </p>- <ul className="space-y-1 text-[12px]">- {wf.models.map((m) => (- <li key={m.file} className="flex items-center gap-2">- {m.present === true ? (- <CheckCircle2 className="size-3.5 shrink-0 text-success" />- ) : m.present === false ? (- <CircleAlert className="size-3.5 shrink-0 text-warning" />- ) : (- <Circle className="size-3.5 shrink-0 text-subtle-foreground" />- )}- <span className="truncate font-mono">{m.file}</span>- <span className="shrink-0 text-muted-foreground">{m.folder}</span>- {m.sizeGb ? <span className="ml-auto shrink-0 font-mono text-muted-foreground">{m.sizeGb} GB</span> : null}- {m.url && (- <a href={m.url} target="_blank" rel="noreferrer" className="shrink-0 text-muted-foreground hover:text-foreground" aria-label="Download">- <ExternalLink className="size-3.5" />- </a>- )}- </li>- ))}- </ul>- {wf.customNodes.length > 0 && (- <p className="text-[12px] text-muted-foreground">- Custom nodes:{" "}- {wf.customNodes.map((n, i) => (- <a key={n.repo} href={n.repo} target="_blank" rel="noreferrer" className="text-brand-text hover:underline">- {n.name}- {i < wf.customNodes.length - 1 ? ", " : ""}- </a>- ))}- </p>- )}- {wf.notes && <p className="text-[12px] leading-relaxed text-muted-foreground">{wf.notes}</p>}- <div className="mt-auto flex gap-2 pt-1">- <Button- variant="secondary"- size="sm"- onClick={() => {- void navigator.clipboard.writeText(downloadScript(wf));- toast("Install commands copied");- }}- >- <Copy /> {missing ? `Copy install commands (${missing} missing)` : "Copy install commands"}- </Button>- </div>- </article>- );- })}- </div>+ {workflows.length > 0 && (+ <div className="flex flex-col gap-2 sm:flex-row sm:items-center">+ <div className="relative w-full sm:w-80">+ <Search className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />+ <input+ type="search"+ value={search}+ onChange={(e) => setSearch(e.target.value)}+ placeholder="Search workflows, models, capabilities"+ aria-label="Search workflows"+ className="h-9 w-full rounded-full border bg-background pr-3 pl-9 text-[14px] outline-none placeholder:text-subtle-foreground focus:border-primary focus:ring-4 focus:ring-brand-faint"+ />+ </div>+ <span className="text-[12px] text-muted-foreground tabular-nums sm:ml-auto">+ {list.length === workflows.length ? `${workflows.length} workflows` : `${list.length} of ${workflows.length}`} · {validated} validated+ </span>+ </div>+ )}+ {!workflows.length ? (+ <p className="text-sm text-muted-foreground">No workflows in workflows/comfyui/manifest.json yet.</p>+ ) : !list.length ? (+ <p className="py-10 text-center text-sm text-muted-foreground">No workflows match “{search.trim()}”.</p>+ ) : (+ <div className="grid grid-cols-[minmax(0,1fr)] gap-3 lg:grid-cols-2">+ {list.map((wf) => (+ <WorkflowCard key={wf.id} wf={wf} usedBy={usedBy(wf.id)} />+ ))}+ </div>+ )}</div>);}diff --git a/src/lib/model-rows.ts b/src/lib/model-rows.tsnew file mode 100644index 00000000..adc087d7--- /dev/null+++ b/src/lib/model-rows.ts@@ -0,0 +1,49 @@+/** Slim rows for the Models page: what the table shows, computed on the server from the catalog. */+import { formatCost } from "./format";+import { OPERATION_LABELS, type Engine, type MediaKind, type ModelDef } from "./catalog/types";++export interface ModelRow {+ id: string;+ name: string;+ vendor: string;+ tagline: string;+ engine: Engine;+ kind: MediaKind;+ /** Display badges ("New", "Top"…), without the redundant "open". */+ badges: string[];+ /** What it can do, as labels ("Text to image", "Edit"…). */+ ops: string[];+ /** Provider routes ("fal: fal-ai/flux/dev"), shown in the row's details popover. */+ routes: string[];+ price: string;+}++const BADGE_LABEL: Record<string, string> = {+ new: "New",+ top: "Top",+ fast: "Fast",+ audio: "Audio",+ "4k": "4K",+ hd: "1080p",+ pro: "Pro",+ uncensored: "Uncensored",+ beta: "Beta",+};++export function toModelRow(m: ModelDef): ModelRow {+ return {+ id: m.id,+ name: m.name,+ vendor: m.vendor,+ tagline: m.tagline,+ engine: m.engine,+ kind: m.kind,+ badges: (m.badges ?? []).filter((b) => b !== "open").map((b) => BADGE_LABEL[b] ?? b),+ ops: [...new Set(m.routes.map((r) => OPERATION_LABELS[r.op] ?? r.op))],+ routes: [...new Set(m.routes.map((r) => `${r.provider}: ${r.endpoint}`))],+ price: m.engine === "open" ? "Free" : m.pricing ? `${formatCost(m.pricing.usd)} / ${m.pricing.unit}` : "—",+ };+}++/** Lower-cased text the Models search matches against. */+export const modelSearchText = (r: ModelRow) => `${r.name} ${r.vendor} ${r.tagline} ${r.ops.join(" ")} ${r.id}`.toLowerCase();diff --git a/src/lib/preset-cards.ts b/src/lib/preset-cards.tsindex d707e00b..cb6936fa 100644--- a/src/lib/preset-cards.ts+++ b/src/lib/preset-cards.ts@@ -407,6 +407,20 @@ function joinList(items: string[]): string {return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;}+/**+ * Which model each engine runs a preset on, for the preset header's details popover (the studio+ * hero no longer needs to spell out "Cloud: … · Open source: …").+ */+export function presetRouteLines(+ p: Pick<Preset, "cloud" | "open" | "parity">,+ nameOf: (modelId: string) => string | undefined = () => undefined,+): { engine: "cloud" | "open"; label: string; model: string | null }[] {+ return (["cloud", "open"] as const).map((engine) => {+ const route = p[engine];+ return { engine, label: engine === "cloud" ? "Cloud" : "Open source", model: route ? (nameOf(route.modelId) ?? route.modelId) : null };+ });+}+/** One line telling the user what to do with a preset, e.g. "Add a target photo and a face, then Generate." */export function presetHowTo(p: Pick<Preset, "inputs" | "userPrompt" | "type">): string {const needs = p.inputs.filter((i) => i.required).map((i) => article(lowerFirst(i.label)));diff --git a/src/lib/storyboard-board.ts b/src/lib/storyboard-board.tsnew file mode 100644index 00000000..aef400fb--- /dev/null+++ b/src/lib/storyboard-board.ts@@ -0,0 +1,39 @@+/** Storyboard board helpers (pure): the title the user recognises and when a film can be made. */+import type { Generation } from "./catalog/types";++/** Where the browser remembers the idea each board was made from (batchId → idea). */+export const BOARD_TITLES_KEY = "fuobe:storyboard-titles";++/** "establishing wide shot: a lighthouse keeper … — beat 1 of 4" → "a lighthouse keeper …" (offline shot lists). */+export function unwrapScene(scene: string): string {+ const s = scene.trim();+ return /^[^:]{2,40}:\s*(.+?)\s+—\s+beat \d+ of \d+$/.exec(s)?.[1] ?? s;+}++const cap = (s: string) => (s ? s[0].toUpperCase() + s.slice(1) : s);++/**+ * The board's serif title: the idea the user typed (stored on the request by newer servers, or+ * remembered by this browser), else the first scene without the shot-list wrapping.+ */+export function boardTitle(frames: Generation[], remembered?: string | null): string {+ const first = frames[0];+ const own = (first?.request as { title?: string } | undefined)?.title?.trim();+ if (own) return cap(own);+ if (remembered?.trim()) return cap(remembered.trim());+ const scene = first?.request.frame?.scene;+ return cap(scene ? unwrapScene(scene) : (first?.request.prompt ?? "Storyboard"));+}++/** A film needs every frame finished (and at least two of them). */+export function filmReady(frames: Generation[]): boolean {+ return frames.length > 1 && frames.every((f) => f.status === "succeeded" && !!f.outputs[0]);+}++/** Keep the newest `max` remembered titles. */+export function rememberTitle(map: Record<string, string>, batchId: string, idea: string, max = 60): Record<string, string> {+ const next = { ...map, [batchId]: idea.trim().slice(0, 200) };+ const keys = Object.keys(next);+ for (const k of keys.slice(0, Math.max(0, keys.length - max))) delete next[k];+ return next;+}diff --git a/tests/e2e/no-horizontal-scroll.mjs b/tests/e2e/no-horizontal-scroll.mjsnew file mode 100644index 00000000..64932663--- /dev/null+++ b/tests/e2e/no-horizontal-scroll.mjs@@ -0,0 +1,113 @@+// Phone-width layout check: no route may scroll sideways at 390 px.+// Usage: node tests/e2e/no-horizontal-scroll.mjs [appUrl] [--dark] [--routes=/a,/b]+// (app must be running; demo mode is fine). Exits 1 if any page is wider than the screen.+//+// Every page under src/app/(studio) is visited (dynamic segments with a sample id), plus /login and+// an unknown URL (the 404 page). For each route it asserts document.documentElement.scrollWidth ===+// clientWidth after the page settles, and names the widest elements when it isn't.+//+// Playwright: uses the `playwright` (or `playwright-core`) package if it resolves, else the global+// install at /opt/node22/lib/node_modules. Chromium: $CHROMIUM_PATH, else the newest+// /opt/pw-browsers/chromium-*/chrome-linux/chrome, else Playwright's own.+import fs from "node:fs";+import path from "node:path";+import { createRequire } from "node:module";+import { fileURLToPath } from "node:url";++const args = process.argv.slice(2);+const app = (args.find((a) => !a.startsWith("--")) ?? "http://localhost:3000").replace(/\/$/, "");+const dark = args.includes("--dark");+const only = args.find((a) => a.startsWith("--routes="))?.slice(9).split(",").filter(Boolean);++const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");++/** Static routes from the file system, plus samples for the dynamic ones. */+function discoverRoutes() {+ const base = path.join(root, "src/app/(studio)");+ const out = [];+ const walk = (dir, url) => {+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {+ if (!e.isDirectory()) continue;+ const seg = e.name;+ if (seg.startsWith("(")) walk(path.join(dir, seg), url);+ else if (seg.startsWith("[")) continue; // sampled below+ else walk(path.join(dir, seg), `${url}/${seg}`);+ }+ if (fs.existsSync(path.join(dir, "page.tsx"))) out.push(url || "/");+ };+ walk(base, "");+ return [...new Set([...out.sort(), "/apps/app-face-swap", "/apps/app-packshot", "/elements/does-not-exist", "/library?tab=favorites", "/login", "/this-page-does-not-exist"])];+}++function loadPlaywright() {+ for (const from of [path.join(root, "package.json"), "/opt/node22/lib/node_modules/"]) {+ const req = createRequire(from);+ for (const name of ["playwright", "playwright-core"]) {+ try {+ return req(name);+ } catch {}+ }+ }+ throw new Error("Playwright not found: install playwright-core or run where the global install exists");+}++function chromiumPath() {+ if (process.env.CHROMIUM_PATH) return process.env.CHROMIUM_PATH;+ const dir = "/opt/pw-browsers";+ if (!fs.existsSync(dir)) return undefined;+ const newest = fs+ .readdirSync(dir)+ .filter((d) => /^chromium-\d+$/.test(d))+ .sort((a, b) => Number(b.split("-")[1]) - Number(a.split("-")[1]))[0];+ const exe = newest && path.join(dir, newest, "chrome-linux/chrome");+ return exe && fs.existsSync(exe) ? exe : undefined;+}++const { chromium } = loadPlaywright();+const browser = await chromium.launch({ executablePath: chromiumPath() });+const ctx = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true, colorScheme: dark ? "dark" : "light" });+const routes = only ?? discoverRoutes();+const failures = [];+for (const route of routes) {+ const page = await ctx.newPage();+ try {+ await page.goto(app + route, { waitUntil: "networkidle", timeout: 60_000 });+ await page.waitForTimeout(800);+ const r = await page.evaluate(() => {+ const W = document.documentElement.clientWidth;+ const wide = [];+ const describe = (el, b) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}.${String(el.className).split(" ").slice(0, 4).join(".")} (right ${Math.round(b.right)}px)`;+ if (document.documentElement.scrollWidth > W) {+ const sticking = [...document.querySelectorAll("body *")].map((el) => [el, el.getBoundingClientRect()]).filter(([, b]) => b.right > W + 1 && b.width);+ // Prefer elements not inside a scroller that itself fits (those are the real culprits).+ for (const [el, b] of sticking) {+ let contained = false;+ for (let p = el.parentElement; p && p !== document.body; p = p.parentElement) {+ if (["auto", "scroll", "hidden", "clip"].includes(getComputedStyle(p).overflowX) && p.getBoundingClientRect().right <= W + 1) {+ contained = true;+ break;+ }+ }+ if (!contained) wide.push(describe(el, b));+ if (wide.length >= 5) break;+ }+ if (!wide.length) for (const [el, b] of sticking.slice(0, 5)) wide.push(describe(el, b));+ }+ return { scrollWidth: document.documentElement.scrollWidth, clientWidth: W, wide };+ });+ const ok = r.scrollWidth === r.clientWidth;+ console.log(`${ok ? "ok " : "FAIL"} ${route.padEnd(32)} ${r.scrollWidth}/${r.clientWidth}`);+ if (!ok) {+ for (const w of r.wide) console.log(` ${w}`);+ failures.push(route);+ }+ } catch (e) {+ console.log(`FAIL ${route.padEnd(32)} ${e.message.split("\n")[0]}`);+ failures.push(route);+ } finally {+ await page.close();+ }+}+await browser.close();+console.log(failures.length ? `\n${failures.length} of ${routes.length} routes scroll sideways at 390 px: ${failures.join(", ")}` : `\nAll ${routes.length} routes fit 390 px.`);+process.exit(failures.length ? 1 : 0);diff --git a/tests/preset-cards.test.ts b/tests/preset-cards.test.tsindex 8eef90ac..f7e3c2e3 100644--- a/tests/preset-cards.test.ts+++ b/tests/preset-cards.test.ts@@ -12,6 +12,7 @@ import {moveVars,PREVIEW_LAYERS,presetHowTo,+ presetRouteLines,previewFor,searchText,toPresetCard,@@ -246,6 +247,19 @@ describe("slim card DTOs", () => {});});+describe("preset route lines (details popover)", () => {+ it("names each engine's model, or says there is none", () => {+ const names: Record<string, string> = { "nano-banana-pro": "Nano Banana Pro" };+ const lines = presetRouteLines({ cloud: { modelId: "nano-banana-pro", op: "edit" }, open: null }, (id) => names[id]);+ expect(lines).toEqual([+ { engine: "cloud", label: "Cloud", model: "Nano Banana Pro" },+ { engine: "open", label: "Open source", model: null },+ ]);+ // Unknown names fall back to the model id.+ expect(presetRouteLines({ cloud: null, open: { modelId: "oss-x", op: "edit" } })[1].model).toBe("oss-x");+ });+});+describe("preset how-to line", () => {it("names the required inputs", () => {expect(presetHowTo(byName(APPS, "Face Swap"))).toMatch(/^Add .+ and .+, then Generate\.$/);diff --git a/tests/shell-pages.test.ts b/tests/shell-pages.test.tsnew file mode 100644index 00000000..68821a42--- /dev/null+++ b/tests/shell-pages.test.ts@@ -0,0 +1,71 @@+import { describe, expect, it } from "vitest";+import { MODELS } from "@/lib/catalog";+import type { Generation } from "@/lib/catalog/types";+import { modelSearchText, toModelRow } from "@/lib/model-rows";+import { boardTitle, filmReady, rememberTitle, unwrapScene } from "@/lib/storyboard-board";++const frame = (i: number, extra: Partial<Generation> = {}, request: Record<string, unknown> = {}): Generation =>+ ({+ id: `g${i}`,+ feature: "storyboard",+ modelId: "nano-banana-pro",+ status: "succeeded",+ outputs: [{ url: `/api/files/x${i}.png`, kind: "image" }],+ request: { feature: "storyboard", modelId: "nano-banana-pro", prompt: `Frame ${i + 1} of a storyboard: …`, frame: { scene: `establishing wide shot: a lighthouse keeper finds a glowing bottle — beat ${i + 1} of 3`, index: i, of: 3 }, ...request },+ ...extra,+ }) as unknown as Generation;++describe("storyboard boards", () => {+ it("unwraps the offline shot list back to the idea", () => {+ expect(unwrapScene("close-up: a fox in the snow — beat 2 of 4")).toBe("a fox in the snow");+ expect(unwrapScene("A fox looks up at the moon.")).toBe("A fox looks up at the moon.");+ });++ it("titles a board with the user's idea first", () => {+ const frames = [frame(0), frame(1), frame(2)];+ expect(boardTitle(frames, "a lighthouse keeper finds a glowing bottle and follows its map")).toBe("A lighthouse keeper finds a glowing bottle and follows its map");+ // A title stored on the request (newer servers) wins over the browser's memory.+ expect(boardTitle([frame(0, {}, { title: "The keeper's bottle" })], "something else")).toBe("The keeper's bottle");+ // Without either, the first scene without its shot-list wrapping — never the internal frame prompt.+ expect(boardTitle(frames)).toBe("A lighthouse keeper finds a glowing bottle");+ });++ it("is ready for a film only when every frame is done", () => {+ expect(filmReady([frame(0), frame(1)])).toBe(true);+ expect(filmReady([frame(0), frame(1, { status: "running", outputs: [] })])).toBe(false);+ expect(filmReady([frame(0)])).toBe(false);+ });++ it("remembers a bounded number of ideas", () => {+ let map: Record<string, string> = {};+ for (let i = 0; i < 70; i++) map = rememberTitle(map, `b${i}`, `idea ${i}`);+ expect(Object.keys(map)).toHaveLength(60);+ expect(map.b69).toBe("idea 69");+ expect(map.b0).toBeUndefined();+ });+});++describe("model rows", () => {+ it("keeps only what the table shows", () => {+ const m = MODELS.find((x) => x.engine === "cloud" && x.pricing)!;+ const row = toModelRow(m);+ expect(Object.keys(row).sort()).toEqual(["badges", "engine", "id", "kind", "name", "ops", "price", "routes", "tagline", "vendor"]);+ expect(row.routes.every((r) => /^[a-z]+: /.test(r))).toBe(true);+ expect(row.badges).not.toContain("open");+ expect(JSON.stringify(row)).not.toMatch(/"map"|fieldMap|"defaults"/);+ });++ it("prices open models as free and shrinks the payload", () => {+ const open = MODELS.find((x) => x.engine === "open")!;+ expect(toModelRow(open).price).toBe("Free");+ const full = JSON.stringify(MODELS).length;+ const slim = JSON.stringify(MODELS.map(toModelRow)).length;+ expect(slim / full).toBeLessThan(0.5);+ });++ it("searches name, vendor, tagline and what it can do", () => {+ const row = toModelRow(MODELS[0]);+ expect(modelSearchText(row)).toContain(row.name.toLowerCase());+ expect(modelSearchText(row)).toContain(row.ops[0].toLowerCase());+ });+});