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
Home: fixes from the review of the new page
Adarsh78697d6bd11a
diff --git a/public/previews/presets/peak/effect-earth-zoom-out.jpg b/public/previews/presets/peak/effect-earth-zoom-out.jpgdeleted file mode 100644index eac32fb3..00000000Binary files a/public/previews/presets/peak/effect-earth-zoom-out.jpg and /dev/null differdiff --git a/public/previews/presets/peak/thumbs/app-click-to-ad.jpg b/public/previews/presets/peak/thumbs/app-click-to-ad.jpgnew file mode 100644index 00000000..5933f6aeBinary files /dev/null and b/public/previews/presets/peak/thumbs/app-click-to-ad.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-colorize.jpg b/public/previews/presets/peak/thumbs/app-colorize.jpgnew file mode 100644index 00000000..259df0baBinary files /dev/null and b/public/previews/presets/peak/thumbs/app-colorize.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-face-swap.jpg b/public/previews/presets/peak/thumbs/app-face-swap.jpgnew file mode 100644index 00000000..2ce4acafBinary files /dev/null and b/public/previews/presets/peak/thumbs/app-face-swap.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-hairstyle-try-on.jpg b/public/previews/presets/peak/thumbs/app-hairstyle-try-on.jpgnew file mode 100644index 00000000..a80bc1c1Binary files /dev/null and b/public/previews/presets/peak/thumbs/app-hairstyle-try-on.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-outfit-swap.jpg b/public/previews/presets/peak/thumbs/app-outfit-swap.jpgnew file mode 100644index 00000000..8f43e58cBinary files /dev/null and b/public/previews/presets/peak/thumbs/app-outfit-swap.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-product-shot.jpg b/public/previews/presets/peak/thumbs/app-product-shot.jpgnew file mode 100644index 00000000..b7d47971Binary files /dev/null and b/public/previews/presets/peak/thumbs/app-product-shot.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-relight.jpg b/public/previews/presets/peak/thumbs/app-relight.jpgnew file mode 100644index 00000000..9e9b44c9Binary files /dev/null and b/public/previews/presets/peak/thumbs/app-relight.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-sketch-to-real.jpg b/public/previews/presets/peak/thumbs/app-sketch-to-real.jpgnew file mode 100644index 00000000..f9b74478Binary files /dev/null and b/public/previews/presets/peak/thumbs/app-sketch-to-real.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-steal-the-look.jpg b/public/previews/presets/peak/thumbs/app-steal-the-look.jpgnew file mode 100644index 00000000..9706a26eBinary files /dev/null and b/public/previews/presets/peak/thumbs/app-steal-the-look.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-style-transfer.jpg b/public/previews/presets/peak/thumbs/app-style-transfer.jpgnew file mode 100644index 00000000..d2bf2edbBinary files /dev/null and b/public/previews/presets/peak/thumbs/app-style-transfer.jpg differdiff --git a/public/previews/presets/peak/thumbs/app-virtual-try-on.jpg b/public/previews/presets/peak/thumbs/app-virtual-try-on.jpgnew file mode 100644index 00000000..69b754b8Binary files /dev/null and b/public/previews/presets/peak/thumbs/app-virtual-try-on.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-angel-wings.jpg b/public/previews/presets/peak/thumbs/effect-angel-wings.jpgnew file mode 100644index 00000000..c60bd2bbBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-angel-wings.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-aquarium.jpg b/public/previews/presets/peak/thumbs/effect-aquarium.jpgnew file mode 100644index 00000000..9d18a1f0Binary files /dev/null and b/public/previews/presets/peak/thumbs/effect-aquarium.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-building-explosion.jpg b/public/previews/presets/peak/thumbs/effect-building-explosion.jpgnew file mode 100644index 00000000..ef84c498Binary files /dev/null and b/public/previews/presets/peak/thumbs/effect-building-explosion.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-clone-explosion.jpg b/public/previews/presets/peak/thumbs/effect-clone-explosion.jpgnew file mode 100644index 00000000..7cba32adBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-clone-explosion.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-diamond.jpg b/public/previews/presets/peak/thumbs/effect-diamond.jpgnew file mode 100644index 00000000..7cc60b55Binary files /dev/null and b/public/previews/presets/peak/thumbs/effect-diamond.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-fallen-angel.jpg b/public/previews/presets/peak/thumbs/effect-fallen-angel.jpgnew file mode 100644index 00000000..2e9b334fBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-fallen-angel.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-fire-element.jpg b/public/previews/presets/peak/thumbs/effect-fire-element.jpgnew file mode 100644index 00000000..a0bafb6eBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-fire-element.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-flame-on.jpg b/public/previews/presets/peak/thumbs/effect-flame-on.jpgnew file mode 100644index 00000000..b8b8a1ddBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-flame-on.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-jelly-drift.jpg b/public/previews/presets/peak/thumbs/effect-jelly-drift.jpgnew file mode 100644index 00000000..e343b7dfBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-jelly-drift.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-northern-lights.jpg b/public/previews/presets/peak/thumbs/effect-northern-lights.jpgnew file mode 100644index 00000000..2413e1d0Binary files /dev/null and b/public/previews/presets/peak/thumbs/effect-northern-lights.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-outfit-switch.jpg b/public/previews/presets/peak/thumbs/effect-outfit-switch.jpgnew file mode 100644index 00000000..d34ddeebBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-outfit-switch.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-portal.jpg b/public/previews/presets/peak/thumbs/effect-portal.jpgnew file mode 100644index 00000000..860872b7Binary files /dev/null and b/public/previews/presets/peak/thumbs/effect-portal.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-powder-explosion.jpg b/public/previews/presets/peak/thumbs/effect-powder-explosion.jpgnew file mode 100644index 00000000..3eb775cdBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-powder-explosion.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-raven-transition.jpg b/public/previews/presets/peak/thumbs/effect-raven-transition.jpgnew file mode 100644index 00000000..83e55efaBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-raven-transition.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-scrapbook-collage.jpg b/public/previews/presets/peak/thumbs/effect-scrapbook-collage.jpgnew file mode 100644index 00000000..ba0e5fffBinary files /dev/null and b/public/previews/presets/peak/thumbs/effect-scrapbook-collage.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-thunder-god.jpg b/public/previews/presets/peak/thumbs/effect-thunder-god.jpgnew file mode 100644index 00000000..70eb91a8Binary files /dev/null and b/public/previews/presets/peak/thumbs/effect-thunder-god.jpg differdiff --git a/public/previews/presets/peak/thumbs/effect-water-splash.jpg b/public/previews/presets/peak/thumbs/effect-water-splash.jpgnew file mode 100644index 00000000..9f377551Binary files /dev/null and b/public/previews/presets/peak/thumbs/effect-water-splash.jpg differdiff --git a/scripts/gen-preset-peaks.mjs b/scripts/gen-preset-peaks.mjsindex b994b02e..28d57d56 100644--- a/scripts/gen-preset-peaks.mjs+++ b/scripts/gen-preset-peaks.mjs@@ -1,17 +1,23 @@#!/usr/bin/env node/*** Cuts each named preset's peak frame from its published clip: the frame where the effect is at its height,- * just before the clip's closing crossfade back into its first frame. Home's cards rest on it, and their clip- * starts from that same frame (PresetPreview's `rest`), so nothing jumps when it plays.+ * just before the clip's closing crossfade back into its first frame. Home's cards and the preset header rest on it,+ * and their clip starts from that same frame (PresetPreview's `rest`), so nothing jumps when it plays.+ *+ * The clips open on a still subject for about a second before the change starts. A card that plays by itself loops+ * back to just before the change starts (`from`), not to that still opening, and a hover starts there: the frame+ * whose mean difference from the first is past CHANGE, LEAD frames earlier.** Output:- * public/previews/presets/peak/<id>.jpg 512x384, with the same settings as the covers' posters- * src/lib/preset-peaks.generated.ts { "<id>": { at: <seconds> } }, the time inside that frame+ * public/previews/presets/peak/<id>.jpg 512x384, with the same settings as the covers' posters+ * public/previews/presets/peak/thumbs/<id>.jpg its 320 px copy, with the same settings as the posters' thumbs+ * src/lib/preset-peaks.generated.ts { "<id>": { at: <seconds>, from: <seconds> } }** The frame is (duration − 0.45 s) × fps, rounded; `<id>@<frame>` picks another one by eye. Entries already in- * the file stay, so the next run adds to it. Nothing is rendered: it reads the clips under public/ only.+ * the file stay, so the next run adds to it; `-<id>` takes one out, with its files. Nothing is rendered: it reads+ * the clips under public/ only.*- * Run: node scripts/gen-preset-peaks.mjs effect-flame-on app-relight effect-clone-explosion@84 …+ * Run: node scripts/gen-preset-peaks.mjs effect-flame-on app-relight effect-clone-explosion@84 -effect-earth-zoom-out …*/import { spawnSync } from "node:child_process";import fs from "node:fs";@@ -21,12 +27,19 @@ import { fileURLToPath } from "node:url";const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");const PRESETS = path.join(ROOT, "public", "previews", "presets");const OUT_DIR = path.join(PRESETS, "peak");+const THUMB_DIR = path.join(OUT_DIR, "thumbs");const OUT_TS = path.join(ROOT, "src", "lib", "preset-peaks.generated.ts");/** How long before the end the peak sits: the clips close with a crossfade back into their first frame. */const BEFORE_END = 0.45;+/** The thumbs' width, as the covers' own (scripts/eval/lib/covers.mjs). */+const THUMB_PX = 320;+/** The change has started once a frame's mean difference from the first passes this (of 255, on a 64x48 grey copy). */+const CHANGE = 3;+/** The loop comes back this many frames before that, while the frame still looks like the first. */+const LEAD = 3;-const tool = (name, args) => {- const r = spawnSync(process.env[name === "ffmpeg" ? "FUOBE_FFMPEG" : "FUOBE_FFPROBE"] ?? name, args, { encoding: "utf8" });+const tool = (name, args, encoding = "utf8") => {+ const r = spawnSync(process.env[name === "ffmpeg" ? "FUOBE_FFMPEG" : "FUOBE_FFPROBE"] ?? name, args, { encoding, maxBuffer: 64 << 20 });if (r.error?.code === "ENOENT") throw new Error(`gen-preset-peaks needs ${name} on PATH`);if (r.status !== 0) throw new Error(`${name} failed: ${String(r.stderr).trim().split("\n").at(-1)}`);return r.stdout;@@ -41,6 +54,19 @@ function probe(file) {return { fps: num / (den || 1), frames: Number(frames) };}+/** The first frame whose mean difference from the clip's first frame passes CHANGE (0 if none does). */+function changeStarts(file) {+ const [w, h] = [64, 48];+ const n = w * h;+ const raw = tool("ffmpeg", ["-v", "error", "-i", file, "-vf", `scale=${w}:${h},format=gray`, "-f", "rawvideo", "-"], "buffer");+ for (let f = 1; (f + 1) * n <= raw.length; f++) {+ let sum = 0;+ for (let i = 0; i < n; i++) sum += Math.abs(raw[f * n + i] - raw[i]);+ if (sum / n > CHANGE) return f;+ }+ return 0;+}+const read = () => {if (!fs.existsSync(OUT_TS)) return {};const text = fs.readFileSync(OUT_TS, "utf8");@@ -48,35 +74,48 @@ const read = () => {return JSON.parse(json);};+/** Half a frame in, so a seek lands inside that frame. */+const timeOf = (frame, fps) => Math.round(((frame + 0.5) / fps) * 1e4) / 1e4;+const args = process.argv.slice(2);if (!args.length) {- console.error("usage: node scripts/gen-preset-peaks.mjs <id>[@frame] …");+ console.error("usage: node scripts/gen-preset-peaks.mjs <id>[@frame] … -<id> …");process.exit(1);}-fs.mkdirSync(OUT_DIR, { recursive: true });+fs.mkdirSync(THUMB_DIR, { recursive: true });const peaks = read();for (const arg of args) {+ if (arg.startsWith("-")) {+ const id = arg.slice(1);+ delete peaks[id];+ for (const f of [path.join(OUT_DIR, `${id}.jpg`), path.join(THUMB_DIR, `${id}.jpg`)]) fs.rmSync(f, { force: true });+ console.log(`${id}: taken out`);+ continue;+ }const [id, pick] = arg.split("@");const clip = path.join(PRESETS, `${id}.mp4`);if (!fs.existsSync(clip)) throw new Error(`${id} has no clip in public/previews/presets`);const { fps, frames } = probe(clip);const n = pick ? Number(pick) : Math.round((frames / fps - BEFORE_END) * fps);if (!(n >= 0 && n < frames)) throw new Error(`${id}: frame ${n} is outside its ${frames} frames`);- tool("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y", "-i", clip, "-vf", `select=eq(n\\,${n}),format=yuvj420p`, "-frames:v", "1", "-q:v", "4", path.join(OUT_DIR, `${id}.jpg`)]);- // Half a frame in, so a seek lands inside the frame the card rests on.- peaks[id] = { at: Math.round(((n + 0.5) / fps) * 1e4) / 1e4 };- console.log(`${id}: frame ${n} of ${frames}, at ${peaks[id].at}s`);+ const still = path.join(OUT_DIR, `${id}.jpg`);+ tool("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y", "-i", clip, "-vf", `select=eq(n\\,${n}),format=yuvj420p`, "-frames:v", "1", "-q:v", "4", still]);+ tool("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y", "-i", still, "-vf", `scale='min(${THUMB_PX},iw)':-2,format=yuvj420p`, "-frames:v", "1", "-q:v", "5", path.join(THUMB_DIR, `${id}.jpg`)]);+ const from = Math.min(n, Math.max(0, changeStarts(clip) - LEAD));+ peaks[id] = { at: timeOf(n, fps), from: timeOf(from, fps) };+ console.log(`${id}: frame ${n} of ${frames}, at ${peaks[id].at}s; loops from frame ${from}, ${peaks[id].from}s`);}const sorted = Object.entries(peaks).sort(([a], [b]) => a.localeCompare(b));fs.writeFileSync(OUT_TS,`/**- * Peak frames of preset clips: public/previews/presets/peak/<id>.jpg, and the time inside that frame where the clip- * starts when a card resting on it plays. Generated by scripts/gen-preset-peaks.mjs: run it again rather than editing.+ * Peak frames of preset clips: public/previews/presets/peak/<id>.jpg (and its 320 px copy in thumbs/), the time inside+ * that frame where the clip starts when a card resting on it plays (\`at\`), and where its loop comes back to, just+ * before the change starts (\`from\`). Generated by scripts/gen-preset-peaks.mjs: run it again rather than editing.*/-export const PRESET_PEAKS: Record<string, { at: number }> = {-${sorted.map(([id, p]) => ` ${JSON.stringify(id)}: ${JSON.stringify(p).replace(/:/g, ": ").replace(/^\{|\}$/g, (b) => (b === "{" ? "{ " : " }"))}`).join(",\n")}+export const PRESET_PEAKS: Record<string, { at: number; from: number }> = {+${sorted.map(([id, p]) => ` ${JSON.stringify(id)}: { "at": ${p.at}, "from": ${p.from} }`).join(",\n")}};`,);diff --git a/src/app/globals.css b/src/app/globals.cssindex de43d614..58bf5969 100644--- a/src/app/globals.css+++ b/src/app/globals.css@@ -340,6 +340,19 @@.fade-x[data-fade-start] { --fade-l: 32px; }.fade-x[data-fade-end] { --fade-r: 32px; }+/*+ * Home's sections under the fold (home-sections.tsx): the first paint doesn't wait for their layout. Until the page+ * is idle (home-view.tsx then marks them data-laid-out, one at a time) each one is laid out only once it comes near+ * the screen, and is --cv high until then: its measured height at that width, so nothing moves when it's drawn.+ */+.home-cv {+ content-visibility: auto;+ contain-intrinsic-size: auto var(--cv, 700px);+}+.home-cv[data-laid-out] {+ content-visibility: visible;+}+/* Sidebar groups that remember being collapsed (app-sidebar.tsx). In icon mode every item shows. */[data-nav-group][data-open="false"] [data-nav-items] { display: none; }/* A collapsed group still shows the page you're on (only that item), so something is always lit. */diff --git a/src/components/home-view.tsx b/src/components/home-view.tsxindex a750f9e7..92f36ba1 100644--- a/src/components/home-view.tsx+++ b/src/components/home-view.tsx@@ -12,7 +12,7 @@ import { HadItemsScript, useHadItems } from "@/components/use-had-items";import { IntentLink } from "@/components/intent-link";import { useFadeEdges } from "@/components/preset-gallery";import { MediaThumb } from "@/components/studio/result-media";-import { CONNECT_GPU_EVENT, signInHref, useEngine, useGenerations, useHydrated, useStatus } from "@/lib/api";+import { CONNECT_GPU_EVENT, signInHref, useEngine, useGenerations, useHydrated, useIsOwner, useStatus } from "@/lib/api";import { EngineSwitch } from "@/components/studio/engine-switch";import type { Generation } from "@/lib/catalog/types";import { issueStartToken, START_PARAM } from "@/lib/composer";@@ -144,7 +144,7 @@ export function HomeView({/** "130+": the open models a visitor runs on their own GPU (About & licences' count, rounded down). */openModels: string;chips: readonly TryChip[];- /** The Try chip that opens Assist with a job typed in. */+ /** The chip that opens Assist with a job typed in: the owner's, in place of the last Try chip. */assist: { label: string; href: string };wall: React.ReactNode;children: React.ReactNode;@@ -177,6 +177,11 @@ export function HomeView({const guide = !status || firstRun;// A guest or an account (public sign-up) runs open-source models on its own GPU, whatever the install's engines.const visitor = status?.viewer;+ // Only the studio's owner can use Assist: its chip takes the last Try chip's place once the owner is known.+ const owner = useIsOwner();+ // A Try chip's prompt fills two lines on a phone and scrolls past that, so the chips and the wall under the+ // composer stay where the thumb is; typing lets it grow again.+ const [chipFilled, setChipFilled] = useState(false);useEffect(() => {if (!status) return;try {@@ -184,6 +189,20 @@ export function HomeView({} catch {}document.documentElement.setAttribute("data-first-run", firstRun ? "1" : "0");}, [status, firstRun]);+ // The sections under the fold skip layout for the first paint only (.home-cv in globals.css). Once the page is+ // idle they're laid out one at a time, each when the page is idle again, so no one task holds the page up, and a+ // jump to one, or a picture of the whole page, finds every one of them drawn.+ useEffect(() => {+ const left = [...document.querySelectorAll<HTMLElement>(".home-cv:not([data-laid-out])")];+ const ric = typeof requestIdleCallback === "function";+ let id = 0;+ const next = () => {+ left.shift()?.setAttribute("data-laid-out", "");+ if (left.length) id = ric ? requestIdleCallback(next, { timeout: 4000 }) : window.setTimeout(next, 300);+ };+ id = ric ? requestIdleCallback(next, { timeout: 4000 }) : window.setTimeout(next, 1500);+ return () => (ric ? cancelIdleCallback(id) : clearTimeout(id));+ }, []);// With a prompt, the studio starts the run itself, or points at the photo it still needs. `go`// carries a one-time token from this tab, so only this button can start a run that way.@@ -203,9 +222,16 @@ export function HomeView({const tryChip = (c: TryChip) => {setMode(MODES.find((m) => m.id === c.mode) ?? MODES[0]);setPrompt(c.prompt);+ setChipFilled(true);setFlash((n) => n + 1);box.current?.focus();- requestAnimationFrame(() => box.current?.setSelectionRange(c.prompt.length, c.prompt.length));+ requestAnimationFrame(() => {+ const el = box.current;+ if (!el) return;+ el.setSelectionRange(c.prompt.length, c.prompt.length);+ // A phone shows its last lines, where the caret is.+ el.scrollTop = el.scrollHeight;+ });};return (@@ -245,7 +271,10 @@ export function HomeView({{flash > 0 && <span key={flash} aria-hidden className="pointer-events-none absolute -inset-px animate-ring-flash rounded-[inherit] ring-4 ring-primary/30 motion-reduce:hidden" />}<textareavalue={prompt}- onChange={(e) => setPrompt(e.target.value)}+ onChange={(e) => {+ setPrompt(e.target.value);+ setChipFilled(false);+ }}onKeyDown={(e) => {if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {e.preventDefault();@@ -257,7 +286,12 @@ export function HomeView({autoFocusaria-label="Describe what to create"placeholder={mode.placeholder}- className="field-sizing-content max-h-48 min-h-14 w-full resize-none bg-transparent px-2.5 py-1.5 text-base outline-none placeholder:text-subtle-foreground"+ className={cn(+ // Two lines high from the first paint, so a two-line prompt doesn't move what's under it.+ "field-sizing-content max-h-48 min-h-[60px] w-full resize-none bg-transparent px-2.5 py-1.5 text-base outline-none placeholder:text-subtle-foreground",+ // The lines above fade out under the top edge, so the field reads as one that scrolls.+ chipFilled && "max-sm:max-h-[60px] max-sm:overflow-y-auto max-sm:[mask-image:linear-gradient(to_bottom,transparent,#000_14px)]",+ )}/><div className="flex items-center gap-1.5"><div role="radiogroup" aria-label="What to make" className="flex min-w-0 items-center gap-1">@@ -325,7 +359,7 @@ export function HomeView({className="fade-x scrollbar-none mt-6 flex items-center gap-1.5 max-sm:-mx-4 max-sm:h-8 max-sm:w-[calc(100%+2rem)] max-sm:overflow-x-auto max-sm:px-4 sm:flex-wrap sm:justify-center sm:[mask-image:none]"><span className="mr-0.5 hidden shrink-0 text-[12px] text-muted-foreground sm:block">Try</span>- {chips.map((c) => {+ {(owner ? chips.slice(0, -1) : chips).map((c) => {const Icon = MODES.find((m) => m.id === c.mode)?.icon ?? ImageIcon;return (<button@@ -339,13 +373,15 @@ export function HomeView({</button>);})}- <IntentLink- href={assist.href}- className="inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full border border-transparent bg-brand-faint px-3 text-[13px] whitespace-nowrap text-brand-text transition-colors hover:bg-brand-faint-hover"- >- <MessageCircle className="size-3.5" />- {assist.label}- </IntentLink>+ {owner && (+ <IntentLink+ href={assist.href}+ className="inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full border border-transparent bg-brand-faint px-3 text-[13px] whitespace-nowrap text-brand-text transition-colors hover:bg-brand-faint-hover"+ >+ <MessageCircle className="size-3.5" />+ {assist.label}+ </IntentLink>+ )}</div>{guide ? (<>diff --git a/src/components/home/before-after.tsx b/src/components/home/before-after.tsxindex 7a317130..ad06d3b7 100644--- a/src/components/home/before-after.tsx+++ b/src/components/home/before-after.tsx@@ -22,11 +22,17 @@ const easeInOut = (t: number) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 //** The one-time peek: where the handle goes, and how long it takes, once the picture is mostly in view. */const PEEK = [50, 80, 20, 50];const PEEK_MS = 1400;+/** How far (px) a finger moves sideways before it drags the handle; up or down first, it's scrolling the page. */+const DRAG_SLOP = 6;+const TAG = "pointer-events-none absolute top-2.5 rounded bg-black/60 px-1.5 text-[11px] leading-5 text-white";/*** An app's before and after, to drag between, with a tab per app. The first time it's mostly in view (and both- * pictures are in), the handle sweeps once to show it moves; any touch or key stops that, and with reduced motion it- * never moves by itself. Stills only: it plays no clip.+ * pictures are in), the handle sweeps once to show it moves; any drag, tap or key stops that, and with reduced motion+ * it never moves by itself. A mouse moves the handle as it's pressed; a finger moves it once it goes sideways, or where+ * it taps, so a scroll that starts on the picture leaves the handle where it was. Stills only: it plays no clip.+ *+ * From lg to xl (beside the sidebar) the tabs stand in a column next to the picture, in the room it leaves.*/export function BeforeAfter({ pairs }: { pairs: BeforeAfterPair[] }) {const [tab, setTab] = useState(0);@@ -36,6 +42,8 @@ export function BeforeAfter({ pairs }: { pairs: BeforeAfterPair[] }) {const [inView, setInView] = useState(false);const box = useRef<HTMLDivElement>(null);const dragging = useRef(false);+ /** Where a finger came down, until it moves sideways (then it drags) or lifts (a tap). */+ const touch = useRef<{ x: number; y: number } | null>(null);/** Set once the peek ran, or the viewer moved the handle first. */const peeked = useRef(false);const frame = useRef(0);@@ -82,6 +90,10 @@ export function BeforeAfter({ pairs }: { pairs: BeforeAfterPair[] }) {const r = box.current!.getBoundingClientRect();return clamp(((clientX - r.left) / r.width) * 100);};+ const moveTo = (clientX: number) => {+ take();+ setPos(at(clientX));+ };const pick = (i: number) => {if (i === tab) return;take();@@ -94,23 +106,41 @@ export function BeforeAfter({ pairs }: { pairs: BeforeAfterPair[] }) {const value = Math.round(pos);return (- <div className="w-full max-w-[512px] xl:max-w-[460px]">+ <div className="w-full max-w-[512px] lg:max-xl:flex lg:max-xl:max-w-none lg:max-xl:items-start lg:max-xl:gap-4 xl:max-w-[460px]"><divref={box}id={`${id}-panel`}role="tabpanel"aria-label={`${pair.name}: ${beforeTag} and ${afterTag}`}- className="relative isolate aspect-[4/3] cursor-ew-resize touch-pan-y overflow-hidden rounded-xl bg-muted select-none"+ className="relative isolate aspect-[4/3] cursor-ew-resize touch-pan-y overflow-hidden rounded-xl bg-muted select-none lg:max-xl:w-[512px] lg:max-xl:shrink-0"onPointerDown={(e) => {if (e.button !== 0) return;- take();dragging.current = true;e.currentTarget.setPointerCapture(e.pointerId);- setPos(at(e.clientX));+ if (e.pointerType === "mouse") moveTo(e.clientX);+ else touch.current = { x: e.clientX, y: e.clientY };+ }}+ onPointerMove={(e) => {+ if (!dragging.current) return;+ const t = touch.current;+ if (t) {+ const dx = Math.abs(e.clientX - t.x);+ if (dx < DRAG_SLOP || dx < Math.abs(e.clientY - t.y)) return;+ touch.current = null;+ }+ moveTo(e.clientX);+ }}+ onPointerUp={(e) => {+ // A tap moves the handle there.+ if (dragging.current && touch.current) moveTo(e.clientX);+ dragging.current = false;+ touch.current = null;+ }}+ onPointerCancel={() => {+ // The page took the touch to scroll: the handle stays where it was.+ dragging.current = false;+ touch.current = null;}}- onPointerMove={(e) => dragging.current && setPos(at(e.clientX))}- onPointerUp={() => (dragging.current = false)}- onPointerCancel={() => (dragging.current = false)}><div key={pair.id} className="absolute inset-0 motion-safe:animate-in motion-safe:fade-in motion-safe:duration-150">{/* Both enlarged alike (pair.zoom), so an edge in the source never shows; the after is cut at the handle. */}@@ -143,8 +173,8 @@ export function BeforeAfter({ pairs }: { pairs: BeforeAfterPair[] }) {/></div></div>- <span className="pointer-events-none absolute top-2.5 left-2.5 rounded bg-black/45 px-1.5 text-[11px] leading-5 text-white">{beforeTag}</span>- <span className="pointer-events-none absolute top-2.5 right-2.5 rounded bg-black/45 px-1.5 text-[11px] leading-5 text-white">{afterTag}</span>+ <span className={cn(TAG, "left-2.5")}>{beforeTag}</span>+ <span className={cn(TAG, "right-2.5")}>{afterTag}</span><span aria-hidden className="pointer-events-none absolute inset-y-0 -ml-px w-0.5 bg-white shadow-[0_0_6px_rgb(0_0_0/35%)]" style={{ left: `${pos}%` }} /><spanrole="slider"@@ -171,45 +201,52 @@ export function BeforeAfter({ pairs }: { pairs: BeforeAfterPair[] }) {</svg></span></div>- <div- role="tablist"- aria-label="Apps to compare"- className="mt-2 flex gap-1.5"- onKeyDown={(e) => {- if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return;- e.preventDefault();- const next = (tab + (e.key === "ArrowRight" ? 1 : pairs.length - 1)) % pairs.length;- pick(next);- (e.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]')[next] as HTMLElement | undefined)?.focus();- }}- >- {pairs.map((p, i) => (- <button- key={p.id}- type="button"- role="tab"- aria-selected={i === tab}- aria-controls={`${id}-panel`}- tabIndex={i === tab ? 0 : -1}- onClick={() => pick(i)}- onPointerEnter={() => preload(p)}- onFocus={() => preload(p)}- className={cn(- "flex min-w-0 flex-1 items-center gap-1.5 rounded-lg p-1 pr-1.5 text-left sm:gap-2 sm:pr-2 text-[12px] font-medium text-muted-foreground transition-colors outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",- i === tab && "bg-muted text-foreground",- )}- >- {/* eslint-disable-next-line @next/next/no-img-element */}- <img src={`/previews/presets/thumbs/${p.id}.jpg`} alt="" width={56} height={42} loading="lazy" decoding="async" className="h-6 w-8 shrink-0 rounded object-cover sm:h-[42px] sm:w-14 sm:rounded-md" />- <span className="line-clamp-2 leading-tight">{p.name}</span>- </button>- ))}- </div>- <div className="mt-2 flex items-center justify-between gap-3 text-[12px] text-muted-foreground">- <span>Drag to compare</span>- <IntentLink href={pair.href} className="inline-flex items-center gap-1 font-medium text-brand-text hover:underline underline-offset-2">- Try {pair.name} <ArrowRight className="size-3.5" />- </IntentLink>+ <div className="min-w-0 lg:max-xl:flex-1">+ <div+ role="tablist"+ aria-label="Apps to compare"+ className="mt-2 flex gap-1.5 lg:max-xl:mt-0 lg:max-xl:flex-col"+ onKeyDown={(e) => {+ const keys = ["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp"];+ if (!keys.includes(e.key)) return;+ e.preventDefault();+ const next = (tab + (e.key === "ArrowRight" || e.key === "ArrowDown" ? 1 : pairs.length - 1)) % pairs.length;+ pick(next);+ (e.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]')[next] as HTMLElement | undefined)?.focus();+ }}+ >+ {pairs.map((p, i) => (+ <button+ key={p.id}+ type="button"+ role="tab"+ aria-selected={i === tab}+ aria-controls={`${id}-panel`}+ tabIndex={i === tab ? 0 : -1}+ onClick={() => pick(i)}+ onPointerEnter={() => preload(p)}+ onFocus={() => preload(p)}+ className={cn(+ "flex min-w-0 flex-1 items-center justify-center gap-2 rounded-lg p-1 text-[12px] font-medium text-muted-foreground transition-colors outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring max-sm:h-9 sm:justify-start sm:pr-2 xl:flex-col xl:items-stretch xl:gap-1 xl:pr-1 xl:pb-1.5",+ i === tab && "bg-muted text-foreground",+ )}+ >+ {/* A phone's tabs are words alone, and from xl (a narrower picture) the thumb stands over the name, so each+ name fits whole. The sketch's paper edge is cropped as in the picture. */}+ <span className="hidden shrink-0 overflow-hidden rounded-md sm:block sm:h-[42px] sm:w-14 xl:h-10 xl:w-full">+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img src={`/previews/presets/thumbs/${p.id}.jpg`} alt="" width={56} height={42} loading="lazy" decoding="async" className="size-full object-cover" style={{ scale: p.zoom }} />+ </span>+ <span className="truncate leading-tight xl:text-center">{p.name}</span>+ </button>+ ))}+ </div>+ <div className="mt-2 flex items-center justify-between gap-3 text-[12px] text-muted-foreground lg:max-xl:mt-4 lg:max-xl:flex-col lg:max-xl:items-start lg:max-xl:gap-1.5 lg:max-xl:px-1">+ <span>Drag to compare</span>+ <IntentLink href={pair.href} className="inline-flex items-center gap-1 font-medium text-brand-text hover:underline underline-offset-2">+ Try {pair.name} <ArrowRight className="size-3.5" />+ </IntentLink>+ </div></div></div>);diff --git a/src/components/home/home-islands.tsx b/src/components/home/home-islands.tsxindex cca2c45d..cbd6a024 100644--- a/src/components/home/home-islands.tsx+++ b/src/components/home/home-islands.tsx@@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from "react";import { CardPending, IntentLink } from "@/components/intent-link";import { useFadeEdges } from "@/components/preset-gallery";import { PresetPreview, setPreviewsPaused, usePreviewPlayback, usePreviewsPaused } from "@/components/preset-preview";-import { CONNECT_GPU_EVENT, signInHref, useHydrated, useStatus } from "@/lib/api";+import { CONNECT_GPU_EVENT, signInHref, useHydrated, useIsOwner, useStatus } from "@/lib/api";import { copyWithToast } from "@/lib/clipboard";import type { PresetCardData } from "@/lib/preset-cards";import { cn } from "@/lib/utils";@@ -25,7 +25,7 @@ export function HomeRail({ className, children }: { className?: string; childrenreturn <FadeRow className={cn("flex snap-x snap-mandatory scroll-px-4 sm:grid sm:[mask-image:none]", className)}>{children}</FadeRow>;}-/** Stops every preview playing by itself, on every page, and remembers it; a hover still plays one. */+/** Stops every preview playing by itself, on every page, for this visit; a hover still plays one. */export function PausePreviews() {const paused = usePreviewsPaused();const Icon = paused ? Play : Pause;@@ -68,14 +68,31 @@ export function CopyCommand({ text }: { text: string }) {/*** A studio's card. It plays where nothing can hover, like the cards above it; with a mouse it waits for one, so the- * clips higher on the page keep the screen's few players. `zoom`: a still that slowly closes in on hover instead.+ * clips higher on the page keep the screen's few players. A hover on a card resting on its peak starts where the+ * change starts (PresetPreview's `asked`). `zoom`: a still that slowly closes in on hover instead.*/-export function StudioCard({ href, label, line, card, zoom }: { href: string; label: string; line: string; card: PresetCardData; zoom?: boolean }) {- const { ref, playing, handlers } = usePreviewPlayback<HTMLAnchorElement>(card.id, card.preview, { auto: "touch" });+export function StudioCard({+ href,+ label,+ line,+ card,+ zoom,+ delay,+ sizes,+}: {+ href: string;+ label: string;+ line: string;+ card: PresetCardData;+ zoom?: boolean;+ delay?: number;+ sizes?: string;+}) {+ const { ref, playing, asked, handlers } = usePreviewPlayback<HTMLAnchorElement>(card.id, card.preview, { auto: "touch" });return (<IntentLink ref={ref} href={href} {...handlers} className="group/studio flex min-w-0 flex-col gap-2 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring"><StudioPicture zoom={zoom}>- <PresetPreview preview={card.preview} hue={card.hue} playing={playing} />+ <PresetPreview preview={card.preview} hue={card.hue} playing={playing} asked={asked} delay={delay} sizes={sizes} /></StudioPicture><StudioName label={label} line={line} /></IntentLink>@@ -98,18 +115,96 @@ export function StudioPicture({ zoom, className, children }: { zoom?: boolean; c);}+/** A studio card's name, the arrow following its last word wherever the name wraps, and its line. */export function StudioName({ label, line }: { label: string; line: string }) {+ const cut = label.lastIndexOf(" ") + 1;return (<div className="min-w-0 px-0.5">- <p className="flex items-center gap-1.5 text-[14px] font-medium">- {label}- <ArrowRight className="size-3.5 text-muted-foreground transition-transform duration-150 group-hover/studio:translate-x-0.5 group-hover/studio:text-foreground" />+ <p className="text-[14px] font-medium">+ {label.slice(0, cut)}+ <span className="whitespace-nowrap">+ {label.slice(cut)}+ <ArrowRight+ aria-hidden+ className="ml-1.5 inline-block size-3.5 align-[-2px] text-muted-foreground transition-transform duration-150 group-hover/studio:translate-x-0.5 group-hover/studio:text-foreground"+ />+ </span></p><p className="mt-0.5 text-[12px] leading-snug text-muted-foreground">{line}</p></div>);}+/** Over Assist's heading, for everyone but the studio's owner: here, Assist is the owner's (AssistSection). */+export function AssistTag() {+ if (useIsOwner()) return null;+ return <p className="mb-2 inline-flex h-6 items-center rounded-full bg-brand-faint px-2.5 text-[12px] font-medium text-brand-text">On your own install</p>;+}++const ASSIST_ACTION =+ "group mt-5 inline-flex h-9 items-center gap-1.5 rounded-full bg-primary px-4 text-[13px] font-medium text-primary-foreground transition hover:opacity-90";++/** The owner opens Assist; anyone else is shown how to run Fuobe themselves (the self-host card, StartSection). */+export function AssistAction() {+ const arrow = <ArrowRight className="size-3.5 transition-transform duration-150 group-hover:translate-x-0.5" />;+ return useIsOwner() ? (+ <IntentLink href="/assist" className={ASSIST_ACTION}>+ Open Assist {arrow}+ </IntentLink>+ ) : (+ <a href="#home-start" className={ASSIST_ACTION}>+ Run Fuobe yourself {arrow}+ </a>+ );+}++/**+ * What to ask Assist, and the skills it starts from: for the owner, each opens Assist with it typed in (nothing is+ * sent); for anyone else, examples of what it does. Both keep the same size, so nothing moves when the viewer is known.+ */+export function AssistExamples({ prompts, skills }: { prompts: string[]; skills: { name: string; title: string }[] }) {+ const owner = useIsOwner();+ const row = "flex items-center justify-between gap-3 rounded-xl bg-muted/60 px-4 py-2.5 text-[13px]";+ const chip = "inline-flex h-8 items-center rounded-full border px-3 text-[13px]";+ return (+ <div className="min-w-0">+ <h3 className="mb-2 font-sans text-[12px] text-muted-foreground">{owner ? "Try asking" : "Ask it things like"}</h3>+ <ul className="space-y-1.5">+ {prompts.map((s) => (+ <li key={s}>+ {owner ? (+ <IntentLink href={`/assist?prompt=${encodeURIComponent(s)}`} className={cn(row, "group transition-colors hover:bg-muted")}>+ <span className="min-w-0">{s}</span>+ <ArrowRight className="size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-hover:translate-x-[3px] group-hover:text-foreground" />+ </IntentLink>+ ) : (+ <p className={row}>+ <span className="min-w-0">“{s}”</span>+ </p>+ )}+ </li>+ ))}+ </ul>+ <h3 className="mt-5 mb-2 font-sans text-[12px] text-muted-foreground">{owner ? "Or start with a skill" : "Skills it starts from"}</h3>+ <FadeRow>+ <ul className="flex gap-1.5 max-sm:w-max sm:flex-wrap">+ {skills.map((s) => (+ <li key={s.name}>+ {owner ? (+ <IntentLink href={`/assist?skill=${s.name}`} className={cn(chip, "transition-colors hover:bg-accent")}>+ {s.title}+ </IntentLink>+ ) : (+ <span className={cn(chip, "border-transparent bg-muted/60")}>{s.title}</span>+ )}+ </li>+ ))}+ </ul>+ </FadeRow>+ </div>+ );+}+/*** The three steps to start, for who's looking: a guest signs up, an account connects its GPU, the owner of their own* install connects ComfyUI or adds a key. Until the status comes, a guest's (as the composer's line); every stepdiff --git a/src/components/home/home-sections.tsx b/src/components/home/home-sections.tsxindex ed176a13..6fc2cffa 100644--- a/src/components/home/home-sections.tsx+++ b/src/components/home/home-sections.tsx@@ -1,8 +1,21 @@import Link from "next/link";+import { Fragment } from "react";import { ArrowRight, AudioLines, Box, CalendarClock, ImageIcon, ListChecks, Plug, ScanEye, Sparkles, Video, type LucideIcon } from "lucide-react";import { GitHubMark } from "@/components/github-mark";import { BeforeAfter } from "@/components/home/before-after";-import { CopyCommand, FadeRow, HomeRail, PausePreviews, StartSteps, StudioCard, StudioName, StudioPicture } from "@/components/home/home-islands";+import {+ AssistAction,+ AssistExamples,+ AssistTag,+ CopyCommand,+ FadeRow,+ HomeRail,+ PausePreviews,+ StartSteps,+ StudioCard,+ StudioName,+ StudioPicture,+} from "@/components/home/home-islands";import { ShowcaseTile } from "@/components/home/showcase-tile";import { IntentLink } from "@/components/intent-link";import { NAV } from "@/components/nav-items";@@ -10,19 +23,28 @@ import { PresetCard } from "@/components/preset-gallery";import { ASSIST_SUGGESTIONS } from "@/lib/assist";import { FUOBE_REPO } from "@/lib/connections";import { presetHref, type HomeShowcase } from "@/lib/home-showcase";-import type { PresetCardData } from "@/lib/preset-cards";+import { staggered } from "@/lib/preview-playback";import { cn } from "@/lib/utils";/** Home's sections under the wall. Server components: their words, numbers and links ship as HTML, and only the- * cards, the before/after, the Copy button and the start steps hydrate (home-islands.tsx, before-after.tsx).+ * cards, the before/after, the Copy button, Assist's actions and the start steps hydrate (home-islands.tsx,+ * before-after.tsx).*//** A card in a HomeRail: two-thirds of a phone's width (the next one peeks in), a grid cell from sm up. */const RAIL_ITEM = "w-[64%] shrink-0 snap-start sm:w-auto";-const SECTION = "mt-10 sm:mt-14";+/**+ * A section under the fold is laid out only once it comes near the screen (content-visibility), sized until then+ * by its height at that width (`cv`, measured; the browser keeps the real one after). Its box reaches 16 px past+ * the column and 8 px above and below it, so the rails, the cards' hover and focus rings aren't cut at its edge.+ */+const SECTION = "home-cv -mx-4 mt-8 -mb-2 px-4 py-2 sm:mt-12";const H2 = "font-heading text-[24px] leading-tight sm:text-[28px]";const LINE = "mt-1 text-[15px] text-pretty text-muted-foreground";+/** How wide a row's picture shows: two-thirds of a phone, then a third, a quarter, a sixth of the screen. */+const CARD_SIZES = "(min-width: 1280px) 16vw, (min-width: 1024px) 25vw, (min-width: 640px) 33vw, 64vw";+const STUDIO_SIZES = "(min-width: 1024px) 25vw, (min-width: 640px) 50vw, 64vw";const navIcon = (href: string) => NAV.flatMap((g) => g.items).find((i) => i.href === href)?.icon;@@ -33,7 +55,10 @@ function SectionHead({ id, title, count, all, line }: { id: string; title: strin<h2 id={id} className={H2}>{title}{count !== undefined && (- <span className="ml-2 inline-block rounded-full bg-muted px-2 align-[0.3em] font-sans text-[13px] leading-6 tracking-normal text-muted-foreground tabular-nums">+ <span+ aria-hidden+ className="ml-2 inline-block rounded-full bg-muted px-2 align-[0.3em] font-sans text-[13px] leading-6 tracking-normal text-muted-foreground tabular-nums"+ >{count}</span>)}@@ -41,6 +66,7 @@ function SectionHead({ id, title, count, all, line }: { id: string; title: strin{all && (<IntentLinkhref={all}+ aria-label={`See all ${count} ${title.toLowerCase()}`}className="group inline-flex shrink-0 items-center gap-1 text-[13px] text-muted-foreground transition-colors hover:text-foreground">See all {count} <ArrowRight className="size-3.5 transition-transform duration-150 group-hover:translate-x-0.5" />@@ -52,13 +78,17 @@ function SectionHead({ id, title, count, all, line }: { id: string; title: strin);}-/** Preset cards: all of them in a phone's rail; from sm up, the first `wide` (a rail costs no height, a grid does). */-function Cards({ cards, className, wide = cards.length }: { cards: PresetCardData[]; className: string; wide?: number }) {+/**+ * Preset cards with a short line each: all of them in a phone's rail; from sm up, the first `wide`, and from lg to+ * xl the first `lg` (a rail costs no height, a grid does). The cards' own padding hangs outside the column, so each+ * picture lines up with the heading and the wall, 12 px from the next.+ */+function Cards({ items, className, wide = items.length, lg = wide }: { items: HomeShowcase["effects"]; className: string; wide?: number; lg?: number }) {return (- <HomeRail className={cn("gap-1", className)}>- {cards.map((c, i) => (- <div key={c.id} className={cn(RAIL_ITEM, i >= wide && "sm:hidden")}>- <PresetCard preset={c} href={presetHref(c.id)} bare />+ <HomeRail className={cn("gap-0 scroll-px-2.5 max-sm:px-2.5 sm:-mx-1.5", className)}>+ {items.map(({ card, caption }, i) => (+ <div key={card.id} className={cn(RAIL_ITEM, i >= wide && "sm:hidden", i >= lg && "lg:max-xl:hidden")}>+ <PresetCard preset={card} href={presetHref(card.id)} caption={caption} delay={staggered(i)} sizes={CARD_SIZES} bare /></div>))}</HomeRail>@@ -69,7 +99,7 @@ function Cards({ cards, className, wide = cards.length }: { cards: PresetCardDatexport function ShowcaseWall({ wall }: { wall: HomeShowcase["wall"] }) {return (<section aria-label="What Fuobe makes" className="mt-6 sm:mt-8">- <div className="grid grid-cols-2 gap-2 sm:grid-cols-4 md:max-lg:grid-cols-2">+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-4 md:max-lg:grid-cols-2">{wall.map((t, i) => (<ShowcaseTile key={t.id} card={t.card} kind={t.kind} caption={t.caption} href={t.href} index={i} />))}@@ -87,7 +117,7 @@ export function ShowcaseWall({ wall }: { wall: HomeShowcase["wall"] }) {export function EffectsSection({ facts, effects }: Pick<HomeShowcase, "facts" | "effects">) {return (- <section aria-labelledby="home-effects" className={SECTION}>+ <section aria-labelledby="home-effects" className={cn(SECTION, "[--cv:336px] sm:[--cv:946px] md:[--cv:846px] lg:[--cv:691px] xl:[--cv:490px]")}><SectionHeadid="home-effects"title="Effects"@@ -95,14 +125,14 @@ export function EffectsSection({ facts, effects }: Pick<HomeShowcase, "facts" |all="/effects"line="Add one photo and get the shot: fire, wings, floods, explosions."/>- <Cards cards={effects} className="sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6" />+ <Cards items={effects} className="sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6" /></section>);}export function MotionsSection({ facts, motions }: Pick<HomeShowcase, "facts" | "motions">) {return (- <section aria-labelledby="home-motions" className={SECTION}>+ <section aria-labelledby="home-motions" className={cn(SECTION, "[--cv:336px] sm:[--cv:528px] md:[--cv:492px] lg:[--cv:293px] xl:[--cv:290px]")}><SectionHeadid="home-motions"title="Camera motions"@@ -110,20 +140,20 @@ export function MotionsSection({ facts, motions }: Pick<HomeShowcase, "facts" |all="/motions"line="Moves a film crew would make: orbits, drone dives, crash zooms. Mix any two."/>- <Cards cards={motions} wide={6} className="sm:grid-cols-3 xl:grid-cols-6" />+ <Cards items={motions} wide={6} lg={4} className="sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6" /></section>);}export function AppsSection({ facts, beforeAfter, reveals }: Pick<HomeShowcase, "facts" | "beforeAfter" | "reveals">) {return (- <section aria-labelledby="home-apps" className={SECTION}>+ <section aria-labelledby="home-apps" className={cn(SECTION, "[--cv:676px] sm:[--cv:1004px] md:[--cv:943px] lg:[--cv:957px] xl:[--cv:525px]")}><SectionHead id="home-apps" title="Apps" count={facts.apps} all="/apps" line="One click changes one thing and keeps the rest." /><div className="grid grid-cols-1 gap-6 xl:grid-cols-12 xl:gap-4"><div className="min-w-0 xl:col-span-5 xl:pt-1.5"><BeforeAfter pairs={beforeAfter} /></div>- <Cards cards={reveals} className="self-start sm:grid-cols-3 xl:col-span-7" />+ <Cards items={reveals} className="self-start sm:grid-cols-3 xl:col-span-7" /></div></section>);@@ -133,12 +163,18 @@ export function AppsSection({ facts, beforeAfter, reveals }: Pick<HomeShowcase,const WAVE = [0.3, 0.45, 0.7, 0.5, 0.85, 1, 0.75, 0.55, 0.4, 0.6, 0.9, 0.7, 0.45, 0.3, 0.5, 0.8, 0.95, 0.65, 0.4, 0.55, 0.75, 0.5, 0.35, 0.6, 0.8, 0.55, 0.35, 0.25,];+/** How many of the Audio card's tools it names where its card is narrowest (lg to xl, four cards a row beside the sidebar). */+const AUDIO_NARROW = 3;-/** Audio has no cover: its card shows a waveform that ripples on hover, and the studio's tools by name. */+/**+ * Audio has no cover: its card shows a waveform that ripples on hover, and the studio's tools by name (each whole on+ * its line; fewer where the card is narrow). The link reads as its name and line, like its neighbours.+ */function AudioCard({ href, label, line, tools }: { href: string; label: string; line: string; tools: HomeShowcase["audioTools"] }) {+ const total = tools.named.length + tools.more;return (<IntentLink href={href} className="group/studio flex min-w-0 flex-col gap-2 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring">- <StudioPicture className="bg-media">+ <StudioPicture className="bg-media ring-1 ring-white/10"><div className="absolute inset-0 flex flex-col justify-center gap-[9%] px-[9%]"><div aria-hidden className="flex h-[38%] items-center gap-[2.5%]">{WAVE.map((h, i) => (@@ -149,9 +185,14 @@ function AudioCard({ href, label, line, tools }: { href: string; label: string;/>))}</div>- <p className="text-[12px] leading-snug text-white/70">- {tools.named.join(" · ")}- {tools.more > 0 && ` · ${tools.more} more`}+ <p aria-hidden className="text-[12px] leading-snug text-white/70">+ {tools.named.map((t, i) => (+ <Fragment key={t}>+ <span className={cn("whitespace-nowrap", i >= AUDIO_NARROW && "lg:max-xl:hidden")}>{t} ·</span>{" "}+ </Fragment>+ ))}+ <span className="whitespace-nowrap lg:max-xl:hidden">{tools.more} more</span>+ <span className="hidden whitespace-nowrap lg:max-xl:inline">{total - AUDIO_NARROW} more</span></p></div></StudioPicture>@@ -162,7 +203,7 @@ function AudioCard({ href, label, line, tools }: { href: string; label: string;export function StudiosSection({ facts, studios, audioTools, pills }: Pick<HomeShowcase, "facts" | "studios" | "audioTools" | "pills">) {return (- <section aria-labelledby="home-studios" className={SECTION}>+ <section aria-labelledby="home-studios" className={cn(SECTION, "[--cv:529px] sm:[--cv:1597px] md:[--cv:1482px] lg:[--cv:770px] xl:[--cv:795px]")}><SectionHeadid="home-studios"title="Studios and tools"@@ -170,10 +211,10 @@ export function StudiosSection({ facts, studios, audioTools, pills }: Pick<HomeSline="Whole productions, start to finish: films, ads, shoots and series. Open any of them to look around, no account needed."/><HomeRail className="gap-3 sm:grid-cols-2 sm:gap-x-3 sm:gap-y-4 lg:grid-cols-4">- {studios.map((s) => (+ {studios.map((s, i) => (<div key={s.href} className={RAIL_ITEM}>{s.card ? (- <StudioCard href={s.href} label={s.label} line={s.line} card={s.card} zoom={!s.card.preview.video} />+ <StudioCard href={s.href} label={s.label} line={s.line} card={s.card} zoom={!s.card.preview.video} delay={staggered(i)} sizes={STUDIO_SIZES} />) : (<AudioCard href={s.href} label={s.label} line={s.line} tools={audioTools} />)}@@ -204,6 +245,11 @@ export function StudiosSection({ facts, studios, audioTools, pills }: Pick<HomeS);}+/**+ * Assist plans with the install's own AI, so only the studio's owner can use it (src/lib/guest-access.ts): everyone+ * else reads it as what they get on their own install, with the way to run one (AssistTag, AssistAction,+ * AssistExamples). Until the viewer is known, that's what shows.+ */export function AssistSection({ facts, runsOn, skills }: Pick<HomeShowcase, "facts" | "runsOn" | "skills">) {const points: [LucideIcon, string][] = [[ListChecks, "Plans every step and prices it first"],@@ -213,9 +259,10 @@ export function AssistSection({ facts, runsOn, skills }: Pick<HomeShowcase, "fac[Plug, "MCP connectors, a CLI and its own MCP server"],];return (- <section aria-labelledby="home-assist" className={SECTION}>+ <section aria-labelledby="home-assist" className={cn(SECTION, "[--cv:912px] sm:[--cv:831px] md:[--cv:911px] lg:[--cv:562px] xl:[--cv:480px]")}><div className="grid gap-8 rounded-2xl border bg-card p-5 sm:p-7 lg:grid-cols-2"><div className="min-w-0">+ <AssistTag /><h2 id="home-assist" className={H2}>Assist runs the whole job</h2>@@ -234,44 +281,9 @@ export function AssistSection({ facts, runsOn, skills }: Pick<HomeShowcase, "facPlans with the LLM you pick: {runsOn.named.join(", ")}{runsOn.more > 0 && `, and ${runsOn.more} more`}, a local LLM ({runsOn.local.join(", ")}), or an offline planner with no LLM at all.</p>- <IntentLink- href="/assist"- className="group mt-5 inline-flex h-9 items-center gap-1.5 rounded-full bg-primary px-4 text-[13px] font-medium text-primary-foreground transition hover:opacity-90"- >- Open Assist <ArrowRight className="size-3.5 transition-transform duration-150 group-hover:translate-x-0.5" />- </IntentLink>- </div>- <div className="min-w-0">- <h3 className="mb-2 font-sans text-[12px] text-muted-foreground">Try asking</h3>- <ul className="space-y-1.5">- {ASSIST_SUGGESTIONS.map((s) => (- <li key={s}>- <IntentLink- href={`/assist?prompt=${encodeURIComponent(s)}`}- className="group flex items-center justify-between gap-3 rounded-xl bg-muted/60 px-4 py-2.5 text-[13px] transition-colors hover:bg-muted"- >- <span className="min-w-0">{s}</span>- <ArrowRight className="size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-hover:translate-x-[3px] group-hover:text-foreground" />- </IntentLink>- </li>- ))}- </ul>- <h3 className="mt-5 mb-2 font-sans text-[12px] text-muted-foreground">Or start with a skill</h3>- <FadeRow>- <ul className="flex gap-1.5 max-sm:w-max sm:flex-wrap">- {skills.map((s) => (- <li key={s.name}>- <IntentLink- href={`/assist?skill=${s.name}`}- className="inline-flex h-8 items-center rounded-full border px-3 text-[13px] transition-colors hover:bg-accent"- >- {s.title}- </IntentLink>- </li>- ))}- </ul>- </FadeRow>+ <AssistAction /></div>+ <AssistExamples prompts={[...ASSIST_SUGGESTIONS]} skills={skills} /></div></section>);@@ -288,7 +300,7 @@ export function OpenSourceSection({ facts, newModels }: Pick<HomeShowcase, "fact{ value: facts.partners, label: "partner models through your own fal.ai or Replicate key", href: "/models" },];return (- <section aria-labelledby="home-open" className={SECTION}>+ <section aria-labelledby="home-open" className={cn(SECTION, "[--cv:528px] sm:[--cv:494px] md:[--cv:571px] lg:[--cv:494px] xl:[--cv:363px]")}><h2 id="home-open" className={H2}>Open source, all the way down</h2>@@ -339,7 +351,7 @@ const COMMANDS = ["git clone https://github.com/workingprototype/fuobe.git && cdexport function StartSection() {return (- <section aria-labelledby="home-start" className={SECTION}>+ <section aria-labelledby="home-start" className={cn(SECTION, "[--cv:843px] sm:[--cv:726px] md:[--cv:748px] lg:[--cv:430px] xl:[--cv:427px]")}><h2 id="home-start" className={H2}>Your GPU. Your models. Your files.</h2>@@ -358,7 +370,13 @@ export function StartSection() {<span className="text-[12px] text-white/55">Terminal</span><CopyCommand text={COMMANDS} /></div>- <pre className="overflow-x-auto px-4 pb-4 font-mono text-[13px] leading-relaxed text-white/90">+ {/* A phone wraps the lines, so the whole command shows; wider, a line too long scrolls, and a keyboard can reach it. */}+ <pre+ tabIndex={0}+ role="region"+ aria-label="Commands to run Fuobe"+ className="overflow-x-auto px-4 pb-4 font-mono text-[13px] leading-relaxed text-white/90 outline-none focus-visible:ring-2 focus-visible:ring-white/40 focus-visible:ring-inset max-sm:break-all max-sm:whitespace-pre-wrap"+ ><code>{COMMANDS}</code></pre></div>diff --git a/src/components/home/showcase-tile.tsx b/src/components/home/showcase-tile.tsxindex ee6e674f..618ac745 100644--- a/src/components/home/showcase-tile.tsx+++ b/src/components/home/showcase-tile.tsx@@ -1,37 +1,62 @@"use client";import { ArrowRight } from "lucide-react";+import { preload } from "react-dom";import { CardPending, IntentLink } from "@/components/intent-link";import { PresetPreview, usePreviewPlayback } from "@/components/preset-preview";-import type { PresetCardData } from "@/lib/preset-cards";+import { thumbOf, type PresetCardData } from "@/lib/preset-cards";+import { staggered } from "@/lib/preview-playback";import { cn } from "@/lib/utils";+/** How wide a tile shows: half a phone, a quarter from sm, half again beside the sidebar from md, a quarter from lg. */+const SIZES = "(min-width: 1024px) 25vw, (min-width: 768px) 50vw, (min-width: 640px) 25vw, 50vw";+/** Where tiles 5 to 8 show (the wall has four columns): a tablet held upright, and a desktop. */+const FOUR_UP = "(min-width: 640px) and (max-width: 767px), (min-width: 1024px)";+/*** A tile of Home's wall: a real cover that plays in view, its name, and what it does. On a desktop the line and a* "Try it" pill come in on hover or focus; on touch the line always shows. The first tile is the page's largest- * picture, fetched first; tiles 5 to 8 are hidden (and never fetched) where the wall has two columns.+ * picture, fetched first. Tiles 5 to 8 are hidden (and never fetched) where the wall has two columns; where it has+ * four, they're on the first screen, so they're asked for with the page, not after its layout as a lazy image is.*/export function ShowcaseTile({ card, kind, caption, href, index }: { card: PresetCardData; kind: string; caption: string; href: string; index: number }) {- const { ref, playing, handlers } = usePreviewPlayback<HTMLAnchorElement>(card.id, card.preview);+ const { ref, playing, asked, handlers } = usePreviewPlayback<HTMLAnchorElement>(card.id, card.preview);+ const still = card.preview.rest?.src ?? card.preview.poster;+ if (index >= 4) preload(still, { as: "image", imageSrcSet: `${thumbOf(still)} 320w, ${still} 512w`, imageSizes: SIZES, media: FOUR_UP });return (<IntentLinkref={ref}href={href}{...handlers}- aria-label={`${card.name}, ${kind.split(" ·")[0].toLowerCase()}: ${caption.charAt(0).toLowerCase()}${caption.slice(1)}. Try it`}+ // In the order it shows: the kind (from xl), the name, the line.+ aria-label={`${kind}: ${card.name}, ${caption}. Try it`}className={cn("group/tile relative isolate block overflow-hidden rounded-xl bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",index >= 4 && "max-sm:hidden md:max-lg:hidden",)}><div className="relative aspect-[4/3] ease-out motion-safe:transition-transform motion-safe:duration-[400ms] motion-safe:group-hover/tile:scale-[1.03]">- <PresetPreview preview={card.preview} hue={card.hue} playing={playing} loading={index < 4 ? "eager" : "lazy"} fetchPriority={index === 0 ? "high" : undefined} />+ <PresetPreview+ preview={card.preview}+ hue={card.hue}+ playing={playing}+ asked={asked}+ delay={staggered(index)}+ sizes={SIZES}+ loading={index < 4 ? "eager" : "lazy"}+ fetchPriority={index === 0 ? "high" : undefined}+ /></div>- <span aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 h-[45%] bg-gradient-to-t from-black/65 to-transparent" />+ {/* A small tile (a phone's, or four across a tablet) is short: a taller, darker shade keeps its white words readable over a bright picture. */}+ <span+ aria-hidden+ className="pointer-events-none absolute inset-x-0 bottom-0 h-[45%] bg-gradient-to-t from-black/65 to-transparent max-md:h-[70%] max-md:via-black/40 max-md:from-black/75"+ /><span aria-hidden className="pointer-events-none absolute inset-x-3 bottom-2.5 flex min-w-0 flex-col text-left text-white [text-shadow:0_1px_2px_rgb(0_0_0/30%)]"><span className="hidden text-[11px] tracking-wide text-white/75 uppercase xl:block">{kind}</span><span className="truncate text-[14px] leading-snug font-medium">{card.name}</span>- <span className="truncate text-[12px] text-white/80 transition-opacity duration-150 group-hover/tile:opacity-100 group-focus-visible/tile:opacity-100 [@media(hover:hover)]:opacity-0">+ {/* Whole, on a second line where a tile is narrow. */}+ <span className="line-clamp-2 text-[12px] leading-snug text-white/80 transition-opacity duration-150 group-hover/tile:opacity-100 group-focus-visible/tile:opacity-100 [@media(hover:hover)]:opacity-0">{caption}</span></span>diff --git a/src/components/preset-gallery.tsx b/src/components/preset-gallery.tsxindex 328e9f32..924880eb 100644--- a/src/components/preset-gallery.tsx+++ b/src/components/preset-gallery.tsx@@ -36,6 +36,9 @@ export const PresetCard = memo(function PresetCard({href,compact,bare,+ caption,+ delay,+ sizes,engine,gpu,gpuName,@@ -45,6 +48,12 @@ export const PresetCard = memo(function PresetCard({compact?: boolean;/** The picture, the name and the description only: no category icon or engine chips (Home's rows). */bare?: boolean;+ /** A short line in place of the description (Home's rows); the description stays the tooltip. */+ caption?: string;+ /** How long (ms) its clip waits on the still before it plays by itself (PresetPreview). */+ delay?: number;+ /** How wide its picture shows (PresetPreview). */+ sizes?: string;/** Settings → Engine mode: with one engine locked in, the other's chip would suggest a route the user turned off. */engine?: "cloud" | "open";/** Its state on the viewer's GPU (a badge as one string, badgeKey), or none. */@@ -53,7 +62,7 @@ export const PresetCard = memo(function PresetCard({}) {const badge = engine !== "cloud" ? parseBadgeKey(gpu) : null;const Icon = PRESET_ICONS[preset.icon] ?? Sparkles;- const { ref, playing, handlers } = usePreviewPlayback<HTMLAnchorElement>(preset.id, preset.preview);+ const { ref, playing, asked, handlers } = usePreviewPlayback<HTMLAnchorElement>(preset.id, preset.preview);return (// Prefetched on hover or touch, not on sight: a gallery shows hundreds of these.<IntentLink@@ -63,7 +72,7 @@ export const PresetCard = memo(function PresetCard({className="group/card flex min-w-0 flex-col gap-2 rounded-xl p-1.5 transition-colors outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"><div className="relative aspect-[4/3] overflow-hidden rounded-lg bg-muted">- <PresetPreview preview={preset.preview} hue={preset.hue} playing={playing} flip={previewFlip(preset)} />+ <PresetPreview preview={preset.preview} hue={preset.hue} playing={playing} asked={asked} delay={delay} sizes={sizes} flip={previewFlip(preset)} />{!bare && (<><span className="pointer-events-none absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-black/40 to-transparent" />@@ -92,7 +101,7 @@ export const PresetCard = memo(function PresetCard({// Two lines hold the card's place in the grid and stay inside the card on hover (a panel over the next// row read as broken); the full text is the tooltip and the preset's own page.<p title={preset.description} className="line-clamp-2 text-[12px] leading-snug text-muted-foreground">- {preset.description}+ {caption ?? preset.description}</p>)}</div>diff --git a/src/components/preset-header.tsx b/src/components/preset-header.tsxindex 845d6133..9e29e81a 100644--- a/src/components/preset-header.tsx+++ b/src/components/preset-header.tsx@@ -9,7 +9,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popoverimport type { Preset } from "@/lib/catalog/types";// The covers manifest comes with toPresetCard: this component is loaded on its own (next/dynamic in studio-page.tsx).import { toPresetCard } from "@/lib/preset-card-data";-import { presetHowTo, presetRouteLines, previewFlip } from "@/lib/preset-cards";+import { onPeak, presetHowTo, presetRouteLines, previewFlip } from "@/lib/preset-cards";import { cn } from "@/lib/utils";/**@@ -35,8 +35,9 @@ export function PresetHeader({onClear?: () => void;className?: string;}) {- const card = toPresetCard(preset);- const { ref, playing, handlers, onTap } = usePreviewPlayback<HTMLDivElement>(card.id, card.preview, { always: true });+ // On its clip's peak frame when it has one, as Home's card the visitor came from (onPeak).+ const card = onPeak(toPresetCard(preset));+ const { ref, playing, asked, handlers, onTap } = usePreviewPlayback<HTMLDivElement>(card.id, card.preview, { always: true });const routes = presetRouteLines(preset, modelName);// Its state on the viewer's GPU (open engine only): a pill that opens the guided fix.const badges = useGpuBadges().data;@@ -51,7 +52,7 @@ export function PresetHeader({onPointerUp={onTap}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={playing} flip={previewFlip(card)} />+ <PresetPreview preview={card.preview} hue={card.hue} playing={playing} asked={asked} flip={previewFlip(card)} /></div><div className="min-w-0 flex-1"><p className="truncate font-heading text-[19px] leading-snug">{preset.name}</p>diff --git a/src/components/preset-preview.tsx b/src/components/preset-preview.tsxindex 3105eb73..0d3cac28 100644--- a/src/components/preset-preview.tsx+++ b/src/components/preset-preview.tsx@@ -10,6 +10,7 @@ import {PREVIEW_LAYERS,sceneLayer,scenePoster,+ thumbOf,type MoveSpec,type PresetPreview as Preview,type PreviewLayer,@@ -23,10 +24,13 @@ import { cn } from "@/lib/utils";/** Which previews play, shared by every card and the preset header (rules in lib/preview-playback.ts). */const store = createPlaybackStore(browserPlaybackEnv);-/** Home's "Pause previews", remembered in this browser: it holds on every page. */+/**+ * Home's "Pause previews", kept for this visit (the tab's session): it holds on every page, and a new visit plays+ * again, so a pause tapped by mistake doesn't keep every gallery still in that browser.+ */const PAUSE_KEY = "fuobe:previews";try {- if (typeof window !== "undefined" && localStorage.getItem(PAUSE_KEY) === "paused") store.setPaused(true);+ if (typeof window !== "undefined" && sessionStorage.getItem(PAUSE_KEY) === "paused") store.setPaused(true);} catch {}/** Whether the viewer paused previews (false until hydrated, as on the server). */@@ -35,17 +39,17 @@ export const usePreviewsPaused = () => useSyncExternalStore(store.subscribe, stoexport function setPreviewsPaused(paused: boolean) {store.setPaused(paused);try {- if (paused) localStorage.setItem(PAUSE_KEY, "paused");- else localStorage.removeItem(PAUSE_KEY);+ if (paused) sessionStorage.setItem(PAUSE_KEY, "paused");+ else sessionStorage.removeItem(PAUSE_KEY);} catch {}}/**- * Wire a card element to the playback store. Returns whether its preview should play, the handlers- * to spread on the card (hover and keyboard focus, after a short rest) and `onTap`, which plays or- * stops it from a touch (for an element a tap doesn't otherwise use). A clip plays by itself while- * the card is in view (with `auto: "touch"`, only where nothing can hover); with `always`, any- * preview that moves does (the preset header).+ * Wire a card element to the playback store. Returns whether its preview should play (and whether the+ * viewer asked for it: a hover, focus or tap), the handlers to spread on the card (hover and keyboard+ * focus, after a short rest) and `onTap`, which plays or stops it from a touch (for an element a tap+ * doesn't otherwise use). A clip plays by itself while the card is in view (with `auto: "touch"`, only+ * where nothing can hover); with `always`, any preview that moves does (the preset header).*/export function usePreviewPlayback<T extends HTMLElement>(id: string,@@ -53,11 +57,13 @@ export function usePreviewPlayback<T extends HTMLElement>({ always = false, auto = "always" }: { always?: boolean; auto?: AutoPlay } = {},) {const ref = useRef<T | null>(null);- const playing = useSyncExternalStore(+ // 0: at rest, 1: playing by itself, 2: playing because the viewer asked.+ const state = useSyncExternalStore(store.subscribe,- () => store.isPlaying(id),- () => false,+ () => (store.isPlaying(id) ? (store.isAsked(id) ? 2 : 1) : 0),+ () => 0,);+ const playing = state > 0;const kind = previewKind(preview);useEffect(() => {const el = ref.current;@@ -70,6 +76,7 @@ export function usePreviewPlayback<T extends HTMLElement>(return {ref,playing,+ asked: state === 2,handlers: {onPointerEnter: (e: React.PointerEvent) => e.pointerType === "mouse" && on(),onPointerLeave: (e: React.PointerEvent) => e.pointerType === "mouse" && off(),@@ -275,35 +282,59 @@ function Fx({ fx, scene }: { fx: NonNullable<Preview["fx"]>; scene: PreviewScene/*** A real cover's clip, mounted only while it plays (a browser allows a page only so many live* players, a phone fewer), over the poster until its first frame is ready. The poster is that- * frame, so starting and stopping never flashes. With `startAt` (a card resting on the clip's peak- * frame) it starts from that frame instead, and shows once the seek there is done, with a short fade.+ * frame, so starting and stopping never flashes.+ *+ * A card resting on the clip's peak frame (`rest`) starts from that frame when it plays by itself,+ * and shows once the seek there is done, with a short fade. Its loop comes back to just before the+ * change starts (`rest.from`), not to the clip's still opening, and a hover or tap (`asked`) starts+ * there, so the change builds up at once. `delay` (ms) holds a clip that plays by itself on the still+ * for a moment first, so the clips of a row don't all loop in step.*/-function Clip({ src, startAt }: { src: string; startAt?: number }) {+function Clip({ src, rest, asked, delay = 0 }: { src: string; rest?: Preview["rest"]; asked: boolean; delay?: number }) {const ref = useRef<HTMLVideoElement>(null);const [ready, setReady] = useState(false);+ const [due, setDue] = useState(!delay);+ // Where it starts, fixed when it does: asked for, at once; by itself, once its delay is over.+ const [start, setStart] = useState<number>();+ if (start === undefined && (asked || due)) setStart(rest ? (asked ? rest.from : rest.at) : 0);+ useEffect(() => {+ if (due) return;+ const t = setTimeout(() => setDue(true), delay);+ return () => clearTimeout(t);+ }, [due, delay]);+ const started = start !== undefined;// A layout effect: a page kept hidden after navigating away (Activity) keeps its elements, and a// video only stops when told to. The source is set here too, so a page shown again plays again.useLayoutEffect(() => {const v = ref.current;- if (!v) return;+ if (!v || !started) return;v.src = src;void v.play().catch(() => {});return () => {releaseVideo(v);setReady(false);};- }, [src]);+ }, [src, started]);+ const seeks = !!start;return (<videoref={ref}muted- loop+ loop={!rest}playsInlinepreload="auto"- onLoadedMetadata={startAt ? (e) => void (e.currentTarget.currentTime = startAt) : undefined}- onLoadedData={startAt ? undefined : () => setReady(true)}- onSeeked={startAt ? () => setReady(true) : undefined}- className={cn("absolute inset-0 size-full object-cover", startAt && "transition-opacity duration-150", !ready && "opacity-0")}+ onLoadedMetadata={seeks ? (e) => void (e.currentTarget.currentTime = start) : undefined}+ onLoadedData={seeks ? undefined : () => setReady(true)}+ onSeeked={seeks ? () => setReady(true) : undefined}+ onEnded={+ rest+ ? (e) => {+ e.currentTarget.currentTime = rest.from;+ void e.currentTarget.play().catch(() => {});+ }+ : undefined+ }+ className={cn("absolute inset-0 size-full object-cover", rest && "transition-opacity duration-150", !ready && "opacity-0")}aria-hidden/>);@@ -319,31 +350,43 @@ export const PresetPreview = memo(function PresetPreview({preview,hue,playing,+ asked = false,+ delay,flip,loading = "lazy",fetchPriority,+ sizes,}: {preview: Preview;hue: number;playing: boolean;+ /** It plays because the viewer asked (usePreviewPlayback's `asked`): a clip resting on its peak starts where the change starts. */+ asked?: boolean;+ /** How long (ms) a clip that plays by itself waits on its still first (Clip). */+ delay?: number;/** Mirror the still (see previewFlip). */flip?: boolean;/** A real cover's still: "eager" above the fold (Home's wall), lazy everywhere else. */loading?: "eager" | "lazy";/** "high" for the page's largest picture (Next's image guide: instead of preloading it). */fetchPriority?: "high";+ /** How wide a real cover's still shows (the img's `sizes`): with it, a small screen gets the 320 px copy (thumbOf). */+ sizes?: string;}) {const [armed, setArmed] = useState(false);if (playing && !armed) setArmed(true);// A real cover: the card's image as rendered, without the procedural preview's tint, bleed or// mirroring (and no move glyph: the picture shows the preset itself), with its clip over it while it plays.- if (preview.video || isCover(preview))+ if (preview.video || isCover(preview)) {+ const still = preview.rest?.src ?? preview.poster;return (<>{/* eslint-disable-next-line @next/next/no-img-element */}<img- src={preview.rest?.src ?? preview.poster}+ src={still}+ srcSet={sizes ? `${thumbOf(still)} 320w, ${still} 512w` : undefined}+ sizes={sizes}alt=""width={512}height={384}@@ -354,9 +397,10 @@ export const PresetPreview = memo(function PresetPreview({className="absolute inset-0 size-full object-cover"aria-hidden/>- {preview.video && playing && <Clip src={preview.video} startAt={preview.rest?.at} />}+ {preview.video && playing && <Clip src={preview.video} rest={preview.rest} asked={asked} delay={delay} />}</>);+ }const spec: MoveSpec | undefined = preview.move ? CAMERA_MOVES[preview.move] : undefined;const glyph = preview.move ? glyphFor(preview.move) : undefined;diff --git a/src/lib/home-showcase.ts b/src/lib/home-showcase.tsindex 7340a11c..838f9694 100644--- a/src/lib/home-showcase.ts+++ b/src/lib/home-showcase.ts@@ -16,51 +16,58 @@ import type { Manifest } from "@/lib/comfy";import { HUB_MODES } from "@/lib/hubs";import { buildLicenceList } from "@/lib/licences";import { modelHref } from "@/lib/palette-index";+import { cacheLife } from "next/cache";import { toPresetCard } from "@/lib/preset-card-data";-import type { PresetCardData } from "@/lib/preset-cards";-import { PRESET_PEAKS } from "@/lib/preset-peaks.generated";+import { onPeak, type PresetCardData } from "@/lib/preset-cards";-/** The wall under the composer: the first pictures a visitor sees, each with what it does. */+/**+ * The wall under the composer: the first pictures a visitor sees, each with what it does, in a line that fits a+ * phone's tile (HOME_CAPTION_MAX.wall).+ */export const HOME_WALL = [- { id: "effect-flame-on", kind: "Effect", caption: "Bursts into living flame" },- { id: "effect-powder-explosion", kind: "Effect", caption: "A burst of colored powder around them" },+ { id: "effect-flame-on", kind: "Effect", caption: "Bursts into flame" },+ { id: "effect-powder-explosion", kind: "Effect", caption: "Colored powder bursts" },{ id: "app-virtual-try-on", kind: "App · before → after", caption: "Any garment, on anyone" },- { id: "motion-fpv-drone", kind: "Camera motion", caption: "A drone dive over the cove" },- { id: "motion-low-shutter", kind: "Camera motion", caption: "Silk trails at slow shutter" },- { id: "effect-clone-explosion", kind: "Effect", caption: "Clones burst out in every direction" },- { id: "effect-angel-wings", kind: "Effect", caption: "Wings unfold from their back" },- { id: "motion-glam", kind: "Camera motion", caption: "A slow-motion arc in gold" },+ { id: "motion-fpv-drone", kind: "Camera motion", caption: "Diving over the cove" },+ { id: "motion-low-shutter", kind: "Camera motion", caption: "Dreamy light trails" },+ { id: "effect-clone-explosion", kind: "Effect", caption: "Clones burst outward" },+ { id: "effect-angel-wings", kind: "Effect", caption: "Great wings unfold" },+ { id: "motion-glam", kind: "Camera motion", caption: "A slow arc in gold" },] as const;+/** The longest caption a wall tile (a phone's, 136 px at 360) and a row's card (two lines) hold whole. */+export const HOME_CAPTION_MAX = { wall: 22, card: 40 };++/** Each card says in a few words what it does (the catalog's description stays its tooltip). */export const HOME_EFFECTS = [- "effect-aquarium",- "effect-portal",- "effect-building-explosion",- "effect-diamond",- "effect-thunder-god",- "effect-jelly-drift",- "effect-earth-zoom-out",- "effect-fallen-angel",- "effect-fire-element",- "effect-water-splash",- "effect-raven-transition",- "effect-northern-lights",+ { id: "effect-aquarium", caption: "The room floods into an aquarium" },+ { id: "effect-portal", caption: "A glowing portal pulls them in" },+ { id: "effect-building-explosion", caption: "The building behind them explodes" },+ { id: "effect-diamond", caption: "Their body turns to diamond" },+ { id: "effect-thunder-god", caption: "Lightning crackles around them" },+ { id: "effect-jelly-drift", caption: "Glowing jellyfish drift around them" },+ { id: "effect-earth-zoom-out", caption: "Zooms out from them to space" },+ { id: "effect-fallen-angel", caption: "Dark wings burst as they land" },+ { id: "effect-fire-element", caption: "Fire spirals up from their hands" },+ { id: "effect-water-splash", caption: "A huge wave crashes over them" },+ { id: "effect-raven-transition", caption: "Ravens burst out, then remake them" },+ { id: "effect-northern-lights", caption: "An aurora ripples across the sky" },];-/** A phone's rail shows all twelve; a wider screen shows the first six, one row (home-sections.tsx). */+/** A phone's rail shows all twelve; a wider screen shows the first six (four from lg to xl), one row (home-sections.tsx). */export const HOME_MOTIONS = [- "motion-bullet-time",- "motion-mouth-in",- "motion-car-chasing",- "motion-360-orbit",- "motion-flying",- "motion-crash-zoom-in",- "motion-catwalk",- "motion-crane-up",- "motion-super-dolly-in",- "motion-action-run",- "motion-through-object-in",- "motion-lazy-susan",+ { id: "motion-bullet-time", caption: "Time freezes as the camera sweeps" },+ { id: "motion-mouth-in", caption: "A fast push in to the lips" },+ { id: "motion-car-chasing", caption: "Chasing the car at speed" },+ { id: "motion-360-orbit", caption: "A full circle around them" },+ { id: "motion-flying", caption: "Flying alongside through the air" },+ { id: "motion-crash-zoom-in", caption: "A crash zoom into the face" },+ { id: "motion-catwalk", caption: "Tracks them down the runway" },+ { id: "motion-crane-up", caption: "Rises above to reveal the scene" },+ { id: "motion-super-dolly-in", caption: "From a wide shot to a close-up, fast" },+ { id: "motion-action-run", caption: "Running backward as they sprint" },+ { id: "motion-through-object-in", caption: "Flies through the opening to them" },+ { id: "motion-lazy-susan", caption: "They turn as if on a turntable" },];/**@@ -74,7 +81,14 @@ export const HOME_BEFORE_AFTER = [] as const;/** Apps whose clip wipes from before to after: at rest they show the after. */-export const HOME_REVEALS = ["app-face-swap", "app-outfit-swap", "app-hairstyle-try-on", "app-relight", "app-product-shot", "app-steal-the-look"];+export const HOME_REVEALS = [+ { id: "app-face-swap", caption: "A new face, same pose and light" },+ { id: "app-outfit-swap", caption: "Wear the outfit from any photo" },+ { id: "app-hairstyle-try-on", caption: "Try a new haircut or color" },+ { id: "app-relight", caption: "Change the light of any photo" },+ { id: "app-product-shot", caption: "Your product, relit in a new scene" },+ { id: "app-steal-the-look", caption: "Copy the style of a reference" },+];/** Studio cards: a real cover (a clip, or Image to 3D's still) and one line each; Audio shows its tools instead of a picture. */export const HOME_STUDIOS: { href: string; id?: string; line: (f: HomeFacts) => string }[] = [@@ -84,7 +98,7 @@ export const HOME_STUDIOS: { href: string; id?: string; line: (f: HomeFacts) =>{ href: "/marketing", id: "app-click-to-ad", line: (f) => `From a product link to a finished ad. ${f.adTemplates} ad templates.` },{ href: "/mixed-media", id: "effect-scrapbook-collage", line: (f) => `Redraw a clip as collage, paper or paint, in ${f.mixedLooks} looks.` },{ href: "/motion-control", id: "motion-moonwalk-left", line: () => "Give anyone the moves from any clip." },- { href: "/audio", line: () => "Voices, music and sound effects. Split any soundtrack into voice, music and effects." },+ { href: "/audio", line: () => "Voices, music and sound for any clip, made or split apart." },{ href: "/image-to-3d", id: "app-3d-rotation", line: () => "A photo or a sentence to a 3D model you can spin." },];@@ -116,8 +130,9 @@ export const HOME_NEW_OPEN = [];/**- * The chips under the composer. Each fills it with a prompt that looks like a cover on this page (Glam and FPV- * Drone on the wall, Relight under Apps); nothing runs until Start.+ * The chips under the composer. Each fills it with a prompt that looks like a cover on this page (Glam, FPV Drone+ * and Angel Wings on the wall, Relight under Apps); nothing runs until Start. The studio's owner gets Assist's chip in+ * place of the last (home-view.tsx): only the owner can use Assist.*/export const HOME_TRY = [{@@ -131,6 +146,11 @@ export const HOME_TRY = [prompt: "FPV drone dives off a limestone cliff and skims a turquoise cove past a white yacht, bright morning sun",},{ mode: "edit", label: "Make it golden hour", prompt: "Make it golden hour: warm low sun, long soft shadows and a glowing sky" },+ {+ mode: "image",+ label: "Wings above the clouds",+ prompt: "Fashion portrait of a model in an ivory silk suit with vast white feathered wings, on a cliff above a sea of clouds at sunrise",+ },] as const;export interface HomeFacts {@@ -158,13 +178,11 @@ export const roundedDown = (n: number) => `${Math.floor(n / 10) * 10}+`;const isOpen = (m: ModelDef) => m.engine === "open" || !!m.engines?.includes("open");-/** A preset's card, resting on its peak frame when it has one. */+/** A preset's card, resting on its peak frame when it has one (onPeak). */export function homeCard(id: string): PresetCardData {const p = getPreset(id);if (!p) throw new Error(`Home names ${id}, which isn't in the catalog`);- const card = toPresetCard(p);- const peak = PRESET_PEAKS[id];- return peak ? { ...card, preview: { ...card.preview, rest: { src: `/previews/presets/peak/${id}.jpg`, at: peak.at } } } : card;+ return onPeak(toPresetCard(p));}/** Where a preset's card opens: an app's own page, else the Video studio with it picked. */@@ -231,9 +249,16 @@ async function readSkills() {return { count: has.filter(Boolean).length, starters: titles.flatMap((t) => (t.title ? [{ name: t.name, title: t.title }] : [])) };}-/** Everything Home shows below the composer, computed once per build (the page stays prerendered). */+/** A row's card with its short line. */+const captioned = ({ id, caption }: { id: string; caption: string }) => ({ card: homeCard(id), caption });++/**+ * Everything Home shows below the composer, computed once per build (the page stays prerendered): all of it changes+ * only with a deploy, so it's kept for as long as Next keeps anything ("max").+ */export async function homeShowcase() {"use cache";+ cacheLife("max");const [manifest, skills] = await Promise.all([readJson<Manifest>(fs.readFile(path.join(process.cwd(), "workflows", "comfyui", "manifest.json"), "utf8")),readSkills(),@@ -263,9 +288,9 @@ export async function homeShowcase() {return {facts,wall: HOME_WALL.map((t) => ({ ...t, card: homeCard(t.id), href: presetHref(t.id) })),- effects: HOME_EFFECTS.map(homeCard),- motions: HOME_MOTIONS.map(homeCard),- reveals: HOME_REVEALS.map(homeCard),+ effects: HOME_EFFECTS.map(captioned),+ motions: HOME_MOTIONS.map(captioned),+ reveals: HOME_REVEALS.map(captioned),beforeAfter: HOME_BEFORE_AFTER.map(({ id, tags, zoom }) => {const card = homeCard(id);return { id, name: card.name, before: card.preview.poster, after: card.preview.rest?.src ?? card.preview.poster, tags: [...tags], zoom, href: presetHref(id) };diff --git a/src/lib/preset-cards.ts b/src/lib/preset-cards.tsindex dfcdf47b..b3e59a7f 100644--- a/src/lib/preset-cards.ts+++ b/src/lib/preset-cards.ts@@ -11,6 +11,7 @@* components import this module, and would carry the whole manifest into every chunk they are in.*/import type { Preset } from "./catalog/types";+import { PRESET_PEAKS } from "./preset-peaks.generated";/** Bundled sample stills (public/samples/previews, see scripts/gen-preview-scenes.mjs). */export type PreviewScene = "landscape" | "portrait" | "city" | "product";@@ -180,10 +181,11 @@ export interface PresetPreview {/** A real cover's clip (preset-previews.generated.ts), played instead of the procedural preview. */video?: string;/**- * Shown at rest instead of the poster: the clip's peak frame (preset-peaks.generated.ts), where the clip starts- * (`at`, in seconds) when it plays, so nothing jumps. Home's cards only; the galleries keep their posters.+ * Shown at rest instead of the poster: the clip's peak frame (preset-peaks.generated.ts, onPeak), where the clip+ * starts (`at`, in seconds) when it plays by itself, so nothing jumps. Its loop comes back to `from`, just before+ * the change starts, and a hover starts there. Home's cards and the preset header; the galleries keep their posters.*/- rest?: { src: string; at: number };+ rest?: { src: string; at: number; from: number };scene: PreviewScene;move?: CameraMove;fx?: PreviewFx;@@ -403,6 +405,15 @@ export function proceduralPreview(p: Pick<Preset, "id" | "type" | "name" | "cate*/export const isCover = (p: Pick<PresetPreview, "move" | "fx">) => !p.move && !p.fx;+/** A poster's 320 px copy: thumbs/ next to it (pnpm eval:covers makes the covers' own, gen-preset-peaks the peaks'). */+export const thumbOf = (poster: string) => poster.replace(/\/([^/]+)$/, "/thumbs/$1");++/** The card resting on its clip's peak frame (preset-peaks.generated.ts) when it has one, else as it is. */+export function onPeak(card: PresetCardData): PresetCardData {+ const peak = PRESET_PEAKS[card.id];+ return peak ? { ...card, preview: { ...card.preview, rest: { src: `/previews/presets/peak/${card.id}.jpg`, ...peak } } } : card;+}+/*** Whether a card shows its still mirrored, so neighbouring treatments on the same still differ.* Never for camera moves (a pan left must still go left), nor for a real cover (shown as rendered).diff --git a/src/lib/preset-covers.ts b/src/lib/preset-covers.tsindex 36c3624c..a4d49630 100644--- a/src/lib/preset-covers.ts+++ b/src/lib/preset-covers.ts@@ -5,8 +5,12 @@* Keep it to the pickers' own chunks all the same: tests/preset-covers.test.ts checks the importers.*/import type { CameraMove } from "./catalog/cinema";+import { thumbOf } from "./preset-cards";import { PRESET_COVERS } from "./preset-covers.generated";+/** Where pnpm eval:covers puts a poster's small copy (scripts/eval/lib/covers.mjs, thumbOf). */+export { thumbOf };+export interface PresetCover {/** The still (a clip's first frame), as the gallery card shows it. */poster: string;@@ -16,9 +20,6 @@ export interface PresetCover {video?: string;}-/** Where pnpm eval:covers puts a poster's small copy: thumbs/ next to it (scripts/eval/lib/covers.mjs, thumbOf). */-export const thumbOf = (poster: string) => poster.replace(/\/([^/]+)$/, "/thumbs/$1");-/*** Presets without a cover of their own that show another one, of the same shot: the 3D Rotation motion spins the* subject in place like a product on a turntable, which is the 3D Rotation app's cover.diff --git a/src/lib/preset-peaks.generated.ts b/src/lib/preset-peaks.generated.tsindex 58562ba8..9929ea27 100644--- a/src/lib/preset-peaks.generated.ts+++ b/src/lib/preset-peaks.generated.ts@@ -1,35 +1,35 @@/**- * Peak frames of preset clips: public/previews/presets/peak/<id>.jpg, and the time inside that frame where the clip- * starts when a card resting on it plays. Generated by scripts/gen-preset-peaks.mjs: run it again rather than editing.+ * Peak frames of preset clips: public/previews/presets/peak/<id>.jpg (and its 320 px copy in thumbs/), the time inside+ * that frame where the clip starts when a card resting on it plays (`at`), and where its loop comes back to, just+ * before the change starts (`from`). Generated by scripts/gen-preset-peaks.mjs: run it again rather than editing.*/-export const PRESET_PEAKS: Record<string, { at: number }> = {- "app-click-to-ad": { "at": 2.8958 },- "app-colorize": { "at": 2.8958 },- "app-face-swap": { "at": 2.8958 },- "app-hairstyle-try-on": { "at": 2.8958 },- "app-outfit-swap": { "at": 2.8958 },- "app-product-shot": { "at": 2.8958 },- "app-relight": { "at": 2.8958 },- "app-sketch-to-real": { "at": 2.8958 },- "app-steal-the-look": { "at": 2.8958 },- "app-style-transfer": { "at": 2.8958 },- "app-virtual-try-on": { "at": 2.8958 },- "effect-angel-wings": { "at": 3.5625 },- "effect-aquarium": { "at": 3.5625 },- "effect-building-explosion": { "at": 3.5625 },- "effect-clone-explosion": { "at": 3.7292 },- "effect-diamond": { "at": 3.5625 },- "effect-earth-zoom-out": { "at": 3.5625 },- "effect-fallen-angel": { "at": 3.5625 },- "effect-fire-element": { "at": 3.5625 },- "effect-flame-on": { "at": 3.5625 },- "effect-jelly-drift": { "at": 3.5625 },- "effect-northern-lights": { "at": 3.5625 },- "effect-outfit-switch": { "at": 3.5625 },- "effect-portal": { "at": 3.5625 },- "effect-powder-explosion": { "at": 3.5625 },- "effect-raven-transition": { "at": 3.5625 },- "effect-scrapbook-collage": { "at": 3.5625 },- "effect-thunder-god": { "at": 3.5625 },- "effect-water-splash": { "at": 3.5625 }+export const PRESET_PEAKS: Record<string, { at: number; from: number }> = {+ "app-click-to-ad": { "at": 2.8958, "from": 0.6458 },+ "app-colorize": { "at": 2.8958, "from": 0.5625 },+ "app-face-swap": { "at": 2.8958, "from": 0.5625 },+ "app-hairstyle-try-on": { "at": 2.8958, "from": 0.3542 },+ "app-outfit-swap": { "at": 2.8958, "from": 0.4792 },+ "app-product-shot": { "at": 2.8958, "from": 0.6042 },+ "app-relight": { "at": 2.8958, "from": 0.6875 },+ "app-sketch-to-real": { "at": 2.8958, "from": 0.5625 },+ "app-steal-the-look": { "at": 2.8958, "from": 0.3125 },+ "app-style-transfer": { "at": 2.8958, "from": 0.4792 },+ "app-virtual-try-on": { "at": 2.8958, "from": 0.5625 },+ "effect-angel-wings": { "at": 3.5625, "from": 0.6042 },+ "effect-aquarium": { "at": 3.5625, "from": 0.1042 },+ "effect-building-explosion": { "at": 3.5625, "from": 0.0208 },+ "effect-clone-explosion": { "at": 3.7292, "from": 0.3958 },+ "effect-diamond": { "at": 3.5625, "from": 1.1458 },+ "effect-fallen-angel": { "at": 3.5625, "from": 0.6458 },+ "effect-fire-element": { "at": 3.5625, "from": 0.6042 },+ "effect-flame-on": { "at": 3.5625, "from": 0.6458 },+ "effect-jelly-drift": { "at": 3.5625, "from": 0.2292 },+ "effect-northern-lights": { "at": 3.5625, "from": 0.1875 },+ "effect-outfit-switch": { "at": 3.5625, "from": 0.0625 },+ "effect-portal": { "at": 3.5625, "from": 0.6875 },+ "effect-powder-explosion": { "at": 3.5625, "from": 0.6042 },+ "effect-raven-transition": { "at": 3.5625, "from": 0.4375 },+ "effect-scrapbook-collage": { "at": 3.5625, "from": 0.0208 },+ "effect-thunder-god": { "at": 3.5625, "from": 1.1875 },+ "effect-water-splash": { "at": 3.5625, "from": 0.1042 }};diff --git a/src/lib/preview-playback.ts b/src/lib/preview-playback.tsindex 6238dcf9..8f6d96b1 100644--- a/src/lib/preview-playback.ts+++ b/src/lib/preview-playback.ts@@ -52,6 +52,13 @@ export const NARROW = 640;export const maxPlaying = (viewportWidth: number) => (viewportWidth < NARROW ? MAX_PLAYING.narrow : MAX_PLAYING.wide);+/**+ * How long (ms) the clip of a row's `i`th card waits on its still before it plays by itself (Home's wall and rows):+ * the clips picked together start apart, so they never loop in step (every effect clip is 4 s long) and some card+ * is always at its height.+ */+export const staggered = (i: number) => (i % 8) * 350;+/** What a preview shows: a real cover's clip, a procedural animation, or a still. */export type PreviewKind = "clip" | "procedural" | "still";@@ -200,6 +207,8 @@ export function createPlaybackStore(env: PlaybackEnv) {};},isPlaying,+ /** Playing because the viewer asked (a hover, focus or tap), not by itself. */+ isAsked: (id: string) => !env.hidden() && hovered === id,/** Every card playing now, by id (for tests). */playing: () => [...new Set([...auto, ...(hovered ? [hovered] : [])])].filter(isPlaying).sort(),canHover: () => env.matches("(hover: hover) and (pointer: fine)"),diff --git a/tests/home-showcase.test.ts b/tests/home-showcase.test.tsindex 47bbb9f0..2d554232 100644--- a/tests/home-showcase.test.ts+++ b/tests/home-showcase.test.ts@@ -1,6 +1,6 @@import fs from "node:fs";import path from "node:path";-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import { NAV } from "@/components/nav-items";import { APPS, EFFECTS, MODELS, MOTIONS, getPreset } from "@/lib/catalog";import { CAMERA_MOVES } from "@/lib/catalog/cinema";@@ -11,6 +11,7 @@ import { HUB_MODES } from "@/lib/hubs";import { buildLicenceList, type LicenceWorkflowInput } from "@/lib/licences";import {HOME_BEFORE_AFTER,+ HOME_CAPTION_MAX,HOME_EFFECTS,HOME_MOTIONS,HOME_NEW_OPEN,@@ -25,9 +26,13 @@ import {presetHref,roundedDown,} from "@/lib/home-showcase";+import { onPeak, thumbOf } from "@/lib/preset-cards";import { PRESET_PEAKS } from "@/lib/preset-peaks.generated";import { PRESET_PREVIEWS } from "@/lib/preset-previews.generated";+// homeShowcase() is kept with "use cache" and cacheLife, which only a Next render reads.+vi.mock("next/cache", () => ({ cacheLife: () => {} }));+/** Home's showcase (src/lib/home-showcase.ts) against the catalog and the files in public/: every preset it names is* real, has its cover (and its clip where the slot plays one), shows once, and every number it quotes is the@@ -44,7 +49,10 @@ const WHITE_BARS = ["app-dance", "app-simlife", "app-game-dump", "app-japanese-sconst STILLS = ["app-3d-rotation"];const studioIds = HOME_STUDIOS.flatMap((s) => (s.id ? [s.id] : []));-const homeIds = [...HOME_WALL.map((t) => t.id), ...HOME_EFFECTS, ...HOME_MOTIONS, ...HOME_BEFORE_AFTER.map((p) => p.id), ...HOME_REVEALS, ...studioIds];+const rows = [...HOME_EFFECTS, ...HOME_MOTIONS, ...HOME_REVEALS];+const homeIds = [...HOME_WALL.map((t) => t.id), ...rows.map((r) => r.id), ...HOME_BEFORE_AFTER.map((p) => p.id), ...studioIds];+/** Effects whose first frame is the strong one, so their card rests on the poster as the camera motions' do. */+const ON_POSTER = ["effect-earth-zoom-out"];describe("Home's showcase", () => {it("names real presets, each with its cover and, where the slot plays one, its clip", () => {@@ -69,17 +77,23 @@ describe("Home's showcase", () => {it("rests effects and apps on their peak frame, cut and listed; camera motions on their poster", async () => {const home = await homeShowcase();- const cards = [...home.wall.map((t) => t.card), ...home.effects, ...home.motions, ...home.reveals, ...home.studios.flatMap((s) => (s.card ? [s.card] : []))];+ const rowCards = [...home.effects, ...home.motions, ...home.reveals].map((r) => r.card);+ const cards = [...home.wall.map((t) => t.card), ...rowCards, ...home.studios.flatMap((s) => (s.card ? [s.card] : []))];for (const c of cards) {const peaked = !!PRESET_PEAKS[c.id];expect(!!c.preview.rest, c.id).toBe(peaked);if (c.preview.rest) {- expect(c.preview.rest).toEqual({ src: `/previews/presets/peak/${c.id}.jpg`, at: PRESET_PEAKS[c.id].at });+ expect(c.preview.rest).toEqual({ src: `/previews/presets/peak/${c.id}.jpg`, ...PRESET_PEAKS[c.id] });expect(exists(c.preview.rest.src), c.preview.rest.src).toBe(true);+ // Its 320 px copy, for a small screen (PresetPreview's sizes).+ expect(exists(thumbOf(c.preview.rest.src)), thumbOf(c.preview.rest.src)).toBe(true);}+ expect(exists(thumbOf(c.preview.poster)), thumbOf(c.preview.poster)).toBe(true);if (c.id.startsWith("motion-")) expect(c.preview.rest, c.id).toBeUndefined();}- for (const id of [...HOME_EFFECTS, ...HOME_REVEALS, ...HOME_WALL.filter((t) => !t.id.startsWith("motion-")).map((t) => t.id)]) expect(PRESET_PEAKS[id], id).toBeDefined();+ const peakedIds = [...HOME_EFFECTS, ...HOME_REVEALS, ...HOME_WALL.filter((t) => !t.id.startsWith("motion-"))].map((t) => t.id).filter((id) => !ON_POSTER.includes(id));+ for (const id of peakedIds) expect(PRESET_PEAKS[id], id).toBeDefined();+ for (const id of ON_POSTER) expect(PRESET_PEAKS[id], id).toBeUndefined();// The before/after: the poster, then the peak.for (const p of home.beforeAfter) {expect(p.before).toBe(PRESET_PREVIEWS[p.id].poster);@@ -87,13 +101,30 @@ describe("Home's showcase", () => {expect(p.tags).toHaveLength(2);}// Every peak in the list has its file, and every file is in the list; a peak starts inside its clip's last second.- const files = fs.readdirSync(path.join(root, "public", "previews", "presets", "peak")).map((f) => f.replace(/\.jpg$/, ""));- expect(files.sort()).toEqual(Object.keys(PRESET_PEAKS).sort());- for (const [id, { at }] of Object.entries(PRESET_PEAKS)) {+ const peakDir = path.join(root, "public", "previews", "presets", "peak");+ const files = (dir: string) => fs.readdirSync(dir).filter((f) => f.endsWith(".jpg")).map((f) => f.replace(/\.jpg$/, "")).sort();+ expect(files(peakDir)).toEqual(Object.keys(PRESET_PEAKS).sort());+ expect(files(path.join(peakDir, "thumbs"))).toEqual(Object.keys(PRESET_PEAKS).sort());+ // A peak sits in its clip's last second; its loop comes back to within the clip's first one and a half.+ for (const [id, { at, from }] of Object.entries(PRESET_PEAKS)) {expect(PRESET_PREVIEWS[id]?.video, id).toBeDefined();expect(at, id).toBeGreaterThan(2.5);expect(at, id).toBeLessThan(4);+ expect(from, id).toBeGreaterThan(0);+ expect(from, id).toBeLessThan(1.5);}+ // The preset header rests on the same frame (onPeak), and a preset without one keeps its poster.+ const flame = home.wall.find((t) => t.id === "effect-flame-on")!.card;+ expect(onPeak({ ...flame, preview: { ...flame.preview, rest: undefined } }).preview.rest).toEqual(flame.preview.rest);+ const glam = home.wall.find((t) => t.id === "motion-glam")!.card;+ expect(onPeak(glam)).toBe(glam);+ });++ it("gives every card a short line that fits whole: a phone's wall tile, two lines of a row's card", async () => {+ for (const t of HOME_WALL) expect(t.caption.length, t.id).toBeLessThanOrEqual(HOME_CAPTION_MAX.wall);+ for (const r of rows) expect(r.caption.length, r.id).toBeLessThanOrEqual(HOME_CAPTION_MAX.card);+ const home = await homeShowcase();+ expect(home.effects.map((r) => [r.card.id, r.caption])).toEqual(HOME_EFFECTS.map((r) => [r.id, r.caption]));});it("links effects and motions to the Video studio with the preset picked, apps to their own page", async () => {@@ -191,7 +222,8 @@ describe("Home's showcase", () => {expect(["image", "video", "edit"]).toContain(c.mode);expect(c.prompt.length).toBeGreaterThan(c.label.length);}- expect(new Set(HOME_TRY.map((c) => c.mode)).size).toBe(HOME_TRY.length);+ // The owner's three (Assist's chip takes the last one's place) show one of each.+ expect(new Set(HOME_TRY.slice(0, -1).map((c) => c.mode)).size).toBe(3);});});diff --git a/tests/preset-covers.test.ts b/tests/preset-covers.test.tsindex c4e75758..b841e146 100644--- a/tests/preset-covers.test.ts+++ b/tests/preset-covers.test.ts@@ -40,9 +40,9 @@ describe("the preset covers manifest", () => {}});- it("leaves no cover file in public/previews that no entry names (with its poster's small copy for the pickers, and its clip's peak frame for Home)", () => {+ it("leaves no cover file in public/previews that no entry names (with its poster's small copy for the pickers, and its clip's peak frame and its small copy for Home)", () => {const named = new Set(entries.flatMap(([, e]) => [e.poster, thumbOf(e.poster), e.video].filter(Boolean)));- for (const id of Object.keys(PRESET_PEAKS)) named.add(`/previews/presets/peak/${id}.jpg`);+ for (const id of Object.keys(PRESET_PEAKS)) for (const f of [`/previews/presets/peak/${id}.jpg`, thumbOf(`/previews/presets/peak/${id}.jpg`)]) named.add(f);const dir = path.join(root, "public", "previews");const files = fs.existsSync(dir) ? fs.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((f) => /\.(jpg|mp4)$/.test(f)) : [];const orphans = files.map((f) => `/previews/${f.replaceAll("\\", "/")}`).filter((u) => !named.has(u));diff --git a/tests/shell-logic.test.ts b/tests/shell-logic.test.tsindex d428b3b3..84d5368e 100644--- a/tests/shell-logic.test.ts+++ b/tests/shell-logic.test.ts@@ -30,6 +30,7 @@ import {playsWhenAsked,previewKind,SCROLL_SETTLE,+ staggered,type PlaybackEnv,type PlaybackStore,} from "@/lib/preview-playback";@@ -471,6 +472,28 @@ describe("preview playback store", () => {expect(store.playing()).toEqual(["r0c0", "r0c1", "r0c2"]);});+ it("tells a card playing because the viewer asked (a hover, focus or tap) from one playing by itself", () => {+ const fake = fakeEnv({ hover: true, width: 1280, height: 800 });+ const store = createPlaybackStore(fake.env);+ store.subscribe(() => {});+ watchGrid(store, fake, 1, 3);+ fake.advance(SCROLL_SETTLE);+ expect([store.isPlaying("r0c0"), store.isAsked("r0c0")]).toEqual([true, false]);+ store.play("r0c0");+ fake.advance(HOVER_INTENT);+ expect([store.isPlaying("r0c0"), store.isAsked("r0c0")]).toEqual([true, true]);+ // The pointer leaves: it goes on playing by itself.+ store.stop("r0c0");+ expect([store.isPlaying("r0c0"), store.isAsked("r0c0")]).toEqual([true, false]);+ });++ it("starts the clips of a row apart (Home), each within three seconds", () => {+ const waits = Array.from({ length: 8 }, (_, i) => staggered(i));+ expect(waits[0]).toBe(0);+ expect(new Set(waits).size).toBe(8);+ expect(Math.max(...waits)).toBeLessThan(3000);+ });+it("with reduced motion a hover or tap plays a clip, but a procedural preview keeps its poster", () => {expect([false, true].map((reduced) => playsWhenAsked("clip", reduced))).toEqual([true, true]);expect([false, true].map((reduced) => playsWhenAsked("procedural", reduced))).toEqual([true, false]);