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
Canvas: what a canvas is, and ready boards that run as they come
Adarsh65dd7f9dffa9
diff --git a/docs/public-signup.md b/docs/public-signup.mdindex e8cb6076..d063bef8 100644--- a/docs/public-signup.md+++ b/docs/public-signup.md@@ -69,6 +69,8 @@ An account is signed in, but it sees the owner's studio as a guest does:So does Split soundtrack's **Export mix** (`POST /api/audio-tools/export`), which saves into theowner's Library, with or without a GPU. Accounts have their own uploads and runs (below), but noprojects yet.+ Canvas shows its ready boards to guests and accounts as read-only pages (`/canvas/start/<id>`):+ what goes in, the steps and what comes out. Only the owner makes boards.- **Settings, keys and tokens are the owner's.** Changing settings or model switches, the password,API tokens, Public sign-up, LoRA downloads, Assist connectors and the MCP endpoint answer 403 foran account.diff --git a/src/app/(studio)/canvas/page.tsx b/src/app/(studio)/canvas/page.tsxindex 7f7eb328..e52279b9 100644--- a/src/app/(studio)/canvas/page.tsx+++ b/src/app/(studio)/canvas/page.tsx@@ -1,43 +1,9 @@import type { Metadata } from "next";-import { CanvasList, type TemplateCardData } from "@/components/canvas/canvas-list";-import { getModel } from "@/lib/catalog";-import { CANVAS_TEMPLATES, isGenerator, outline, type CanvasTemplate } from "@/lib/catalog/canvas";-import type { Engine } from "@/lib/catalog/types";+import { CanvasList } from "@/components/canvas/canvas-list";+import { canvasIntro, templateCards } from "@/lib/canvas-template-cards";export const metadata: Metadata = { title: "Canvas" };-/**- * One template's board outline and model names on an engine, with the name a node falls back to when its model is- * switched off in Models & licences (the card swaps it in the browser, as the board the server makes does).- */-function forEngine(t: CanvasTemplate, engine: Engine): TemplateCardData["byEngine"][Engine] {- const graph = t.build(engine);- const nameOf = (id?: string) => getModel(id ?? "")?.name;- const names = graph.nodes.filter(isGenerator).map((n) => nameOf(n.data.modelId));- const without = t.build(engine, () => false).nodes;- const ifOff: NonNullable<TemplateCardData["byEngine"][Engine]["ifOff"]> = [];- for (const n of graph.nodes) {- const id = n.data.modelId;- const name = nameOf(id);- const instead = nameOf(without.find((x) => x.id === n.id)?.data.modelId);- if (id && name && instead && instead !== name && !ifOff.some((x) => x.id === id)) ifOff.push({ id, name, instead });- }- return { outline: outline(graph), models: [...new Set(names.filter((m): m is string => !!m))], ...(ifOff.length && { ifOff }) };-}--/** Template cards built here, so the browser never loads the model catalog for /canvas (nor for the pages that prefetch it). */-function templateCards(): TemplateCardData[] {- return CANVAS_TEMPLATES.map((t) => ({- id: t.id,- name: t.name,- description: t.description,- icon: t.icon,- hue: t.hue,- ...(t.group && { group: t.group }),- byEngine: { cloud: forEngine(t, "cloud"), open: forEngine(t, "open") },- }));-}-export default function Page() {- return <CanvasList templates={templateCards()} />;+ return <CanvasList templates={templateCards()} intro={canvasIntro()} />;}diff --git a/src/app/(studio)/canvas/start/[id]/page.tsx b/src/app/(studio)/canvas/start/[id]/page.tsxnew file mode 100644index 00000000..85c842de--- /dev/null+++ b/src/app/(studio)/canvas/start/[id]/page.tsx@@ -0,0 +1,35 @@+import type { Metadata } from "next";+import { notFound } from "next/navigation";+import { Suspense } from "react";+import { TemplatePage } from "@/components/canvas/template-page";+import { shownTo } from "@/lib/canvas-sections";+import { templateDetail, templateIds } from "@/lib/canvas-template-cards";+import { templateCover } from "@/lib/template-covers";++export function generateStaticParams() {+ return templateIds().map((id) => ({ id }));+}++export async function generateMetadata({ params }: PageProps<"/canvas/start/[id]">): Promise<Metadata> {+ const { id } = await params;+ const t = templateDetail(id);+ if (!t) return { title: "Not found" };+ // A board visitors don't see yet (no real cover): its page is the owner's, kept out of search.+ const hidden = !shownTo(t, { visitor: true, hasCover: (x) => !!templateCover("canvas", x) });+ return { title: `${t.name} · Canvas`, description: t.description, ...(hidden && { robots: { index: false, follow: false } }) };+}++async function Template({ params }: { params: PageProps<"/canvas/start/[id]">["params"] }) {+ const { id } = await params;+ const t = templateDetail(id);+ if (!t) notFound();+ return <TemplatePage t={t} />;+}++export default function Page({ params }: PageProps<"/canvas/start/[id]">) {+ return (+ <Suspense fallback={null}>+ <Template params={params} />+ </Suspense>+ );+}diff --git a/src/components/canvas/canvas-context.tsx b/src/components/canvas/canvas-context.tsxindex 40cc8b40..f2a58a3c 100644--- a/src/components/canvas/canvas-context.tsx+++ b/src/components/canvas/canvas-context.tsx@@ -1,41 +1,5 @@"use client";-import {- AtSign,- AudioLines,- AudioWaveform,- Building2,- Castle,- Clapperboard,- Columns3,- Combine,- Dog,- Eraser,- Feather,- Film,- Fish,- Frame,- GalleryHorizontal,- Gem,- ImageIcon,- Languages,- MessageSquareText,- Mic2,- MonitorPlay,- Package,- Palette,- Sparkles,- Star,- StickyNote,- Swords,- Table,- Type,- UserRound,- Waves,- ZoomIn,- type LucideIcon,- Box,-} from "lucide-react";import { createContext, useContext, useMemo, useSyncExternalStore } from "react";import {describeNode,@@ -55,49 +19,7 @@ import {import type { Engine, Generation, GenerationStatus, ModelDef, Operation, OutputFile } from "@/lib/catalog/types";import type { EngineMode } from "@/lib/api";-export const ICONS: Record<string, LucideIcon> = {- Type,- ImageIcon,- Film,- AudioLines,- AtSign,- Sparkles,- Combine,- Frame,- ZoomIn,- Eraser,- Mic2,- MonitorPlay,- StickyNote,- Clapperboard,- MessageSquareText,- Package,- GalleryHorizontal,- Columns3,- AudioWaveform,- UserRound,- Languages,- Table,- // Blockout to film- Box,- // Effects 2.0 chains (src/lib/catalog/canvas.ts EFFECT_CHAINS)- Swords,- Feather,- Gem,- Palette,- Castle,- Waves,- Star,- Building2,- Fish,- Dog,-};--/** A node type's or template's icon, by lucide name. */-export function NodeIcon({ name, className }: { name: string; className?: string }) {- const Icon: LucideIcon = ICONS[name] ?? Sparkles;- return <Icon className={className} />;-}+export { ICONS, NodeIcon } from "./node-icon";/** Edge and handle colours per port type (the app's chart tokens, so both themes work). */export const PORT_COLOR: Record<PortType, string> = {diff --git a/src/components/canvas/canvas-list.tsx b/src/components/canvas/canvas-list.tsxindex be4a3eeb..0a84070a 100644--- a/src/components/canvas/canvas-list.tsx+++ b/src/components/canvas/canvas-list.tsx@@ -1,84 +1,31 @@"use client";-import { Cloud, Copy, Cpu, Loader2, MoreHorizontal, Pencil, Plus, Search, Trash2, Workflow } from "lucide-react";+import { ArrowRight, Play, Copy, Loader2, MoreHorizontal, Pencil, Plus, Search, Trash2 } from "lucide-react";import Link from "next/link";import { useRouter, useSearchParams } from "next/navigation";-import { Suspense, useState } from "react";+import { Suspense, useEffect, useRef, useState } from "react";import { toast } from "sonner";import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";-import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";import { Input } from "@/components/ui/input";import { Skeleton } from "@/components/ui/skeleton";import { EngineSwitch } from "@/components/studio/engine-switch";import { PageShell } from "@/components/page-shell";-import { SelfHostNote } from "@/components/self-host-note";import { CoverArt, CoverImg, useCoverPlayback } from "@/components/template-cover";-import { useEngine, useIsVisitor, useModelAccess } from "@/lib/api";+import { useEngine, useHydrated, useIsOwner, useLikelyVisitor, useModelAccess } from "@/lib/api";// Types only: the catalog (models, templates) stays on the server; the page passes slim template cards.-import type { CanvasNodeType, CanvasSummary, Outline } from "@/lib/catalog/canvas";-import type { Engine } from "@/lib/catalog/types";-import { offered, type AccessSummary } from "@/lib/model-access";+import type { CanvasSummary } from "@/lib/catalog/canvas";+import { firstTemplates, moreTemplates, templateSections, type CanvasIntro, type TemplateCardData, type Viewing } from "@/lib/canvas-sections";import { timeAgo } from "@/lib/format";import { templateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";import { toastError } from "@/lib/refusals";-import { NodeIcon } from "./canvas-context";+import { Schematic, TemplateCard } from "./template-card";import { useCanvasActions, useCanvases } from "./use-canvas";-const BOX = { w: 280, h: 150 };--const BOX_COLOR: Partial<Record<CanvasNodeType, string>> = {- prompt: "var(--chart-2)",- table: "var(--chart-2)",- "image-input": "var(--chart-5)",- "video-input": "var(--chart-4)",- "audio-input": "var(--chart-3)",- element: "var(--chart-1)",- output: "var(--muted-foreground)",-};--/** The board in miniature, for cards without a result to show. */-function Schematic({ outline: o, className }: { outline: Outline; className?: string }) {- if (!o.boxes.length) {- return (- <div className={cn("grid size-full place-items-center text-subtle-foreground", className)}>- <Workflow className="size-8" />- </div>- );- }- const xs = o.boxes.map((b) => b.x);- const ys = o.boxes.map((b) => b.y);- const pad = 80;- const minX = Math.min(...xs) - pad;- const minY = Math.min(...ys) - pad;- const w = Math.max(...xs) + BOX.w + pad - minX;- const h = Math.max(...ys) + BOX.h + pad - minY;- return (- <svg viewBox={`${minX} ${minY} ${w} ${h}`} preserveAspectRatio="xMidYMid meet" className={cn("size-full", className)} aria-hidden>- {o.links.map(([a, b], i) => {- const s = o.boxes[a];- const t = o.boxes[b];- const x1 = s.x + BOX.w;- const y1 = s.y + BOX.h / 2;- const x2 = t.x;- const y2 = t.y + BOX.h / 2;- const mx = (x1 + x2) / 2;- return <path key={i} d={`M${x1},${y1} C${mx},${y1} ${mx},${y2} ${x2},${y2}`} fill="none" stroke="var(--border-strong)" strokeWidth={8} />;- })}- {o.boxes.map((b, i) => (- <g key={i}>- <rect x={b.x} y={b.y} width={BOX.w} height={BOX.h} rx={22} fill="var(--card)" stroke="var(--border-strong)" strokeWidth={4} />- <rect x={b.x + 24} y={b.y + 28} width={44} height={44} rx={10} fill={BOX_COLOR[b.type] ?? "var(--primary)"} opacity={0.85} />- <rect x={b.x + 84} y={b.y + 36} width={150} height={14} rx={7} fill="var(--muted-foreground)" opacity={0.35} />- <rect x={b.x + 24} y={b.y + 94} width={220} height={12} rx={6} fill="var(--muted-foreground)" opacity={0.18} />- </g>- ))}- </svg>- );-}+export type { TemplateCardData } from "@/lib/canvas-sections";function CanvasCard({ c, onRename, onDelete }: { c: CanvasSummary; onRename: () => void; onDelete: () => void }) {const router = useRouter();@@ -137,91 +84,91 @@ function CanvasCard({ c, onRename, onDelete }: { c: CanvasSummary; onRename: ());}-/** A template as the list shows it, built on the server (app/(studio)/canvas/page.tsx): its board outline and model names per engine. */-export interface TemplateCardData {- id: string;- name: string;- description: string;- icon: string;- hue: number;- /** The picker's section (Effects 2.0 chains); none: the workflows. */- group?: string;- /** ifOff: a model's name and the one its node falls back to when the model is off on this install. */- byEngine: Record<Engine, { outline: Outline; models: string[]; ifOff?: { id: string; name: string; instead: string }[] }>;+/** "What's a canvas?": two plain sentences, then one real effect film as three tiles, the photo, the scene, the shot. */+function WhatsACanvas({ intro }: { intro?: CanvasIntro }) {+ const { ref, playing, asked, handlers } = useCoverPlayback<HTMLLIElement>("canvas-intro", intro?.film);+ const tile = "relative aspect-[4/3] overflow-hidden rounded-lg border bg-muted";+ const caption = "mt-1 text-center text-[12px] font-medium text-muted-foreground sm:text-[13px]";+ const arrow = <ArrowRight className="mt-[calc(12%-8px)] size-4 shrink-0 self-start text-subtle-foreground" aria-hidden />;+ const sizes = "(max-width: 1024px) 30vw, 240px";+ return (+ <section aria-labelledby="whats-a-canvas" className="mt-4 grid gap-3 rounded-2xl border bg-card p-4 sm:p-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] lg:items-center lg:gap-8">+ <div>+ <h2 id="whats-a-canvas" className="font-heading text-[22px] leading-tight">+ What's a canvas?+ </h2>+ <p className="mt-1 text-[15px] text-pretty text-muted-foreground">+ A board of connected steps: a photo goes in, an edit sets the scene, and the last step turns it into a moving shot. Change any step and run it again.+ </p>+ </div>+ {intro && (+ <ol className="flex items-start gap-1.5 sm:gap-3" aria-label="One canvas, step by step">+ <li className="min-w-0 flex-1">+ <div className={tile}>+ <CoverImg frame={intro.photo} sizes={sizes} />+ </div>+ <p className={caption}>Your photo</p>+ </li>+ {arrow}+ <li className="min-w-0 flex-1">+ <div className={tile}>+ <CoverImg frame={intro.film.frames[0]} sizes={sizes} />+ </div>+ <p className={caption}>A new scene</p>+ </li>+ {arrow}+ <li ref={ref} {...handlers} className="min-w-0 flex-1">+ <div className={tile}>+ <CoverArt cover={intro.film} sizes={sizes} playing={playing} asked={asked} />+ <Play className="pointer-events-none absolute right-1.5 bottom-1.5 size-5 rounded-full bg-background/85 p-1 text-foreground shadow-soft" aria-hidden />+ </div>+ <p className={caption}>A moving shot</p>+ </li>+ </ol>+ )}+ </section>+ );}-/** The model names a card shows as this install offers them: a model that is off shows the one its node falls back to. */-function offeredNames({ models, ifOff }: TemplateCardData["byEngine"][Engine], access: AccessSummary | undefined, engine: Engine): string[] {- if (!ifOff || !access) return models;- return [...new Set(models.map((m) => ifOff.find((x) => x.name === m && !offered(access, x.id, engine))?.instead ?? m))];+/** The owner's boards while they load. */+function MineSkeleton({ className }: { className?: string }) {+ return (+ <div className={cn("mt-6 grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", className)}>+ {Array.from({ length: 4 }, (_, i) => (+ <div key={i}>+ <Skeleton className="aspect-[16/10] rounded-xl" />+ <Skeleton className="mt-2 h-4 w-2/3" />+ </div>+ ))}+ </div>+ );}-/** What each template section is, under its heading (a guest or an account runs a canvas on a self-hosted Fuobe only). */-const GROUP_NOTES: Record<string, (visitor: boolean) => string> = {- "Effects 2.0 chains": (visitor) =>- `A photo, an image edit that sets the scene, then Fuobe DoP animates it with the effect${visitor ? "." : ", free on your GPU."}`,-};--/** onUse: none for a guest or an account (a canvas is saved to the owner's library: the page says so once). */-export function TemplateCard({ t, engine, onUse, busy, access }: { t: TemplateCardData; engine: Engine; onUse?: () => void; busy: boolean; access?: AccessSummary }) {- const { outline } = t.byEngine[engine];- const models = offeredNames(t.byEngine[engine], access, engine);- // Its real cover when it has one (what it makes: a still, a clip, or its frames side by side), with the board in- // miniature over a corner; else the board alone.- const cover = templateCover("canvas", t.id);- const { ref, playing, asked, handlers } = useCoverPlayback<HTMLElement>(`canvas/${t.id}`, cover);+/** A grid of template cards; `row`: one short row, a snap scroller on a phone. */+function CardGrid({ items, row, card }: { items: TemplateCardData[]; row?: boolean; card: (t: TemplateCardData) => React.ReactNode }) {return (- <article ref={ref} {...handlers} className="flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card">- {cover ? (- <div className="relative aspect-[16/9] overflow-hidden bg-muted">- {cover.frames.length > 1 ? (- <div className="absolute inset-0 grid auto-cols-fr grid-flow-col gap-0.5">- {cover.frames.map((f) => (- <CoverImg key={f.src} frame={f} sizes="(max-width: 640px) 34vw, 125px" />- ))}- </div>- ) : (- <CoverArt cover={cover} sizes="(max-width: 640px) 100vw, 370px" playing={playing} asked={asked} />- )}- <span className="pointer-events-none absolute right-2.5 bottom-2.5 h-[36%] w-[32%] overflow-hidden rounded-lg bg-background/80 shadow-soft backdrop-blur">- <Schematic outline={outline} className="p-1.5" />- </span>- <span className="absolute top-3 left-3 grid size-8 place-items-center rounded-lg bg-background/90 text-foreground shadow-soft">- <NodeIcon name={t.icon} className="size-4" />- </span>- </div>- ) : (- <div className="relative aspect-[16/9] bg-muted/50" style={{ background: `linear-gradient(135deg, oklch(0.62 0.12 ${t.hue} / 0.14), transparent 70%)` }}>- <Schematic outline={outline} className="p-4" />- <span className="absolute top-3 left-3 grid size-8 place-items-center rounded-lg bg-background/90 text-foreground shadow-soft">- <NodeIcon name={t.icon} className="size-4" />- </span>- </div>+ <div+ className={cn(+ "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",+ row && "-mx-4 flex snap-x snap-mandatory overflow-x-auto px-4 pb-1 sm:mx-0 sm:grid sm:overflow-visible sm:px-0 sm:pb-0 [&>*]:w-[78%] [&>*]:shrink-0 [&>*]:snap-start sm:[&>*]:w-auto",)}- <div className="flex flex-1 flex-col gap-2 p-3.5">- <div>- <h3 className="text-[14px] font-medium">{t.name}</h3>- <p className="text-[13px] text-muted-foreground">{t.description}</p>- </div>- <p className="flex items-start gap-1.5 text-[12px] text-muted-foreground">- {engine === "open" ? <Cpu className="mt-px size-3.5 shrink-0" /> : <Cloud className="mt-px size-3.5 shrink-0" />}- <span className="line-clamp-2">{models.join(" · ")}</span>- </p>- {onUse && (- <Button size="sm" className="mt-auto w-fit rounded-full" onClick={onUse} disabled={busy}>- {busy ? <Loader2 className="animate-spin" /> : <Plus />} Use template- </Button>- )}- </div>- </article>+ >+ {items.map(card)}+ </div>);}-function ListInner({ templates }: { templates: TemplateCardData[] }) {+function ListInner({ templates, intro }: { templates: TemplateCardData[]; intro?: CanvasIntro }) {const router = useRouter();const params = useSearchParams();- const tab = params.get("tab") === "templates" ? "templates" : "mine";- const canvases = useCanvases();+ const askedTemplates = params.get("tab") === "templates";+ // A canvas is saved to the studio's library, which is its owner's: a guest or an account can look, not start one.+ // Until the viewer is known to be the owner, the page is a visitor's: only ready boards with their real cover show.+ const owner = useIsOwner();+ // In a browser the owner used last, their boards are on the way: a skeleton until they come, not the visitor's page.+ const likelyOwner = !useLikelyVisitor();+ const hydrated = useHydrated();+ const canvases = useCanvases({ enabled: owner });const { create, rename, remove } = useCanvasActions();const [engine, setEngine] = useEngine();const [q, setQ] = useState("");@@ -229,12 +176,22 @@ function ListInner({ templates }: { templates: TemplateCardData[] }) {const [renaming, setRenaming] = useState<CanvasSummary | null>(null);const [draft, setDraft] = useState("");const [deleting, setDeleting] = useState<CanvasSummary | null>(null);- // A canvas is saved to the studio's library, which is its owner's: a guest or an account can look, not start one.- const visitor = useIsVisitor();+ const [seeAll, setSeeAll] = useState(false);+ const allTemplates = seeAll || askedTemplates;+ const gallery = useRef<HTMLElement>(null);const access = useModelAccess();+ const viewing: Viewing = { visitor: !owner, hasCover: (id) => !!templateCover("canvas", id) };- const items = (canvases.data ?? []).filter((c) => !q || c.name.toLowerCase().includes(q.toLowerCase()));- const setTab = (t: "mine" | "templates") => router.replace(t === "templates" ? "/canvas?tab=templates" : "/canvas", { scroll: false });+ const mine = owner ? (canvases.data ?? []) : [];+ const loadingMine = likelyOwner && (!owner || canvases.isPending);+ const hasBoards = mine.length > 0;+ const items = mine.filter((c) => !q || c.name.toLowerCase().includes(q.toLowerCase()));++ // ?tab=templates (a board's "Browse templates"): the full gallery, scrolled to.+ useEffect(() => {+ if (!askedTemplates) return;+ gallery.current?.scrollIntoView({ block: "start" });+ }, [askedTemplates, hasBoards]);const start = async (key: string, body: Parameters<typeof create>[0]) => {setCreating(key);@@ -247,119 +204,135 @@ function ListInner({ templates }: { templates: TemplateCardData[] }) {}};+ const card = (t: TemplateCardData) => (+ <TemplateCard key={t.id} t={t} engine={engine} access={access} owner={owner} busy={creating === t.id} onUse={owner ? () => void start(t.id, { templateId: t.id, engine }) : undefined} />+ );+ const sections = templateSections(templates, viewing);+ const more = moreTemplates(templates, viewing);++ const fullGallery = (+ <div className="space-y-10">+ {sections.map((s) => (+ <section key={s.key || "films"} aria-labelledby={`tpl-${s.key || "films"}`}>+ <div className="mb-3">+ <h3 id={`tpl-${s.key || "films"}`} className="font-heading text-[20px] leading-tight">+ {s.title}+ </h3>+ <p className="mt-0.5 text-[13px] text-muted-foreground">{s.note}</p>+ </div>+ <CardGrid items={s.items} card={card} />+ </section>+ ))}+ {owner && (+ <section aria-labelledby="tpl-more">+ <div className="mb-3">+ <h3 id="tpl-more" className="font-heading text-[20px] leading-tight">+ More templates+ </h3>+ <p className="mt-0.5 text-[13px] text-muted-foreground">Boards to build on, and a blank one.</p>+ </div>+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">+ {more.map(card)}+ <button+ onClick={() => void start("new", {})}+ disabled={!!creating}+ className="flex min-h-40 flex-col items-center justify-center gap-2 rounded-xl border border-dashed text-[14px] font-medium text-muted-foreground transition-colors hover:border-border-strong hover:text-foreground"+ >+ {creating === "new" ? <Loader2 className="size-5 animate-spin" /> : <Plus className="size-5" />} Start blank+ </button>+ </div>+ </section>+ )}+ </div>+ );++ const galleryHeading = (title: string, note?: string) => (+ <div className="mb-4 flex flex-wrap items-end gap-3">+ <div className="min-w-0 flex-1">+ <h2 id="templates-title" className="font-heading text-[26px] leading-tight">+ {title}+ </h2>+ {note && <p className="mt-0.5 text-[14px] text-muted-foreground">{note}</p>}+ </div>+ {owner && <EngineSwitch value={engine} onChange={setEngine} size="sm" />}+ </div>+ );+return (<PageShell wide><div className="flex flex-col gap-4 sm:flex-row sm:items-end"><div className="min-w-0 flex-1"><h1 className="font-heading text-[34px] leading-tight">Canvas</h1>- <p className="mt-1 max-w-xl text-[15px] text-muted-foreground">Make images, videos and ideas in one place: wire prompts, files and models together, then run them in order or side by side.</p>+ {hasBoards && <p className="mt-1 max-w-xl text-[15px] text-muted-foreground">Make images, videos and ideas in one place: wire prompts, files and models together, then run them in order or side by side.</p>}</div>- {visitor ? (- <SelfHostNote className="max-w-xs sm:text-right">Canvas editing isn't available here.</SelfHostNote>- ) : (+ {owner ? (<Button className="w-fit rounded-full" onClick={() => void start("new", {})} disabled={!!creating}>{creating === "new" ? <Loader2 className="animate-spin" /> : <Plus />} New canvas</Button>- )}- </div>-- <div className="mt-6 flex flex-wrap items-center gap-3">- <div className="inline-grid h-9 grid-cols-2 rounded-full bg-muted p-0.5 text-[13px] font-medium" role="tablist" aria-label="Canvases or templates">- {(- [- ["mine", "Your canvases"],- ["templates", "Templates"],- ] as const- ).map(([k, label]) => (- <button key={k} role="tab" aria-selected={tab === k} onClick={() => setTab(k)} className={cn("rounded-full px-3.5 transition-colors", tab === k ? "bg-background text-foreground shadow-soft" : "text-muted-foreground hover:text-foreground")}>- {label}- </button>- ))}- </div>- {tab === "mine" ? (- <div className="relative ml-auto w-full sm:w-64">- <Search className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />- <Input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Search canvases" aria-label="Search canvases" className="h-9 rounded-full pl-9" />- </div>- ) : (- <div className="ml-auto flex items-center gap-2 text-[13px] text-muted-foreground">- <span className="hidden sm:inline">Variant</span>- <EngineSwitch value={engine} onChange={setEngine} size="sm" />- </div>- )}+ ) : null}</div>- {tab === "mine" ? (- canvases.isLoading ? (- <div className="mt-6 grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">- {Array.from({ length: 4 }, (_, i) => (- <div key={i}>- <Skeleton className="aspect-[16/10] rounded-xl" />- <Skeleton className="mt-2 h-4 w-2/3" />+ {loadingMine ? (+ <MineSkeleton />+ ) : hasBoards ? (+ <>+ <section aria-labelledby="mine-title" className="mt-6">+ <div className="flex flex-wrap items-center gap-3">+ <h2 id="mine-title" className="font-heading text-[22px] leading-tight">+ Your canvases+ </h2>+ <div className="relative ml-auto w-full sm:w-64">+ <Search className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />+ <Input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Search canvases" aria-label="Search canvases" className="h-9 rounded-full pl-9" /></div>- ))}- </div>- ) : items.length ? (- <div className="mt-6 grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">- {items.map((c) => (- <CanvasCard- key={c.id}- c={c}- onRename={() => {- setDraft(c.name);- setRenaming(c);- }}- onDelete={() => setDeleting(c)}- />- ))}- </div>- ) : q ? (- <p className="py-16 text-center text-[15px] text-muted-foreground">No canvas called “{q}”.</p>- ) : (- <Empty className="mt-6 border">- <EmptyHeader>- <EmptyMedia variant="icon">- <Workflow />- </EmptyMedia>- <EmptyTitle className="text-[22px]">No canvases yet</EmptyTitle>- <EmptyDescription>Build a workflow once — prompt → image → video, three models side by side — and run it again whenever you like.</EmptyDescription>- </EmptyHeader>- <EmptyContent className="flex-row justify-center">- {!visitor && (- <Button className="rounded-full" onClick={() => void start("new", {})} disabled={!!creating}>- <Plus /> New canvas+ </div>+ {items.length ? (+ <div className="mt-4 grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">+ {items.map((c) => (+ <CanvasCard+ key={c.id}+ c={c}+ onRename={() => {+ setDraft(c.name);+ setRenaming(c);+ }}+ onDelete={() => setDeleting(c)}+ />+ ))}+ </div>+ ) : (+ <p className="py-16 text-center text-[15px] text-muted-foreground">No canvas called “{q}”.</p>+ )}+ </section>+ <section id="templates" ref={gallery} aria-labelledby="templates-title" className="mt-12 scroll-mt-20">+ {galleryHeading("Start from a template")}+ {allTemplates ? (+ fullGallery+ ) : (+ <>+ <CardGrid items={firstTemplates(templates, viewing)} row card={card} />+ <Button variant="secondary" className="mt-4 rounded-full" onClick={() => setSeeAll(true)}>+ See all templates</Button>- )}- <Button variant="secondary" className="rounded-full" onClick={() => setTab("templates")}>- Browse templates- </Button>- </EmptyContent>- </Empty>- )+ </>+ )}+ </section>+ </>) : (- <div className="mt-6 space-y-10">- {[...new Set(templates.map((t) => t.group ?? ""))].map((group) => (- <section key={group || "workflows"} aria-labelledby={group ? `tpl-${group.replace(/\W+/g, "-")}` : undefined}>- {group && (- <div className="mb-3">- <h2 id={`tpl-${group.replace(/\W+/g, "-")}`} className="font-heading text-[22px] leading-tight">- {group}- </h2>- {GROUP_NOTES[group] && <p className="mt-0.5 text-[13px] text-muted-foreground">{GROUP_NOTES[group](visitor)}</p>}- </div>+ <>+ {/* Before hydration, a browser the owner used last shows the skeleton (html[data-viewer]), not the visitor's page. */}+ {!hydrated && <MineSkeleton className="hidden [html[data-viewer='owner']_&]:grid" />}+ <div className={cn(!hydrated && "[html[data-viewer='owner']_&]:hidden")}>+ <WhatsACanvas intro={intro} />+ <section id="templates" ref={gallery} aria-labelledby="templates-title" className="mt-8 scroll-mt-20">+ {galleryHeading(+ "Start from a ready board",+ owner ? "Every step, word and file is already in place. Press Run all, or change anything first." : "See how each one is built, then make it in Video with your own photo.",)}- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">- {templates- .filter((t) => (t.group ?? "") === group)- // Templates with a real cover lead their section; the rest keep their order after them.- .sort((a, b) => Number(!templateCover("canvas", a.id)) - Number(!templateCover("canvas", b.id)))- .map((t) => (- <TemplateCard key={t.id} t={t} engine={engine} access={access} busy={creating === t.id} onUse={visitor ? undefined : () => void start(t.id, { templateId: t.id, engine })} />- ))}- </div>+ {fullGallery}</section>- ))}- </div>+ </div>+ </>)}<Dialog open={!!renaming} onOpenChange={(o) => !o && setRenaming(null)}>@@ -415,10 +388,10 @@ function ListInner({ templates }: { templates: TemplateCardData[] }) {);}-export function CanvasList({ templates }: { templates: TemplateCardData[] }) {+export function CanvasList({ templates, intro }: { templates: TemplateCardData[]; intro?: CanvasIntro }) {return (<Suspense fallback={null}>- <ListInner templates={templates} />+ <ListInner templates={templates} intro={intro} /></Suspense>);}diff --git a/src/components/canvas/node-icon.tsx b/src/components/canvas/node-icon.tsxnew file mode 100644index 00000000..988df2dc--- /dev/null+++ b/src/components/canvas/node-icon.tsx@@ -0,0 +1,84 @@+"use client";++// The icons of node types and templates, by lucide name. Its own file: the template cards and pages show them without+// loading the canvas editor's context (and through it the model catalog).+import {+ AtSign,+ AudioLines,+ AudioWaveform,+ Building2,+ Castle,+ Clapperboard,+ Columns3,+ Combine,+ Dog,+ Eraser,+ Feather,+ Film,+ Fish,+ Frame,+ GalleryHorizontal,+ Gem,+ ImageIcon,+ Languages,+ MessageSquareText,+ Mic2,+ MonitorPlay,+ Package,+ Palette,+ Sparkles,+ Star,+ StickyNote,+ Swords,+ Table,+ Type,+ UserRound,+ Waves,+ ZoomIn,+ type LucideIcon,+ Box,+} from "lucide-react";++export const ICONS: Record<string, LucideIcon> = {+ Type,+ ImageIcon,+ Film,+ AudioLines,+ AtSign,+ Sparkles,+ Combine,+ Frame,+ ZoomIn,+ Eraser,+ Mic2,+ MonitorPlay,+ StickyNote,+ Clapperboard,+ MessageSquareText,+ Package,+ GalleryHorizontal,+ Columns3,+ AudioWaveform,+ UserRound,+ Languages,+ Table,+ // Blockout to film+ Box,+ // Effects 2.0 chains (src/lib/catalog/canvas.ts EFFECT_CHAINS)+ Swords,+ Feather,+ Gem,+ Palette,+ Castle,+ Waves,+ Star,+ Building2,+ Fish,+ Dog,+};++/** A node type's or template's icon, by lucide name. */+export function NodeIcon({ name, className }: { name: string; className?: string }) {+ const Icon: LucideIcon = ICONS[name] ?? Sparkles;+ return <Icon className={className} />;+}diff --git a/src/components/canvas/template-card.tsx b/src/components/canvas/template-card.tsxnew file mode 100644index 00000000..bd9036c2--- /dev/null+++ b/src/components/canvas/template-card.tsx@@ -0,0 +1,143 @@+"use client";++import { ArrowRight, ChevronRight, Cloud, Cpu, Loader2, Plus, Workflow } from "lucide-react";+import { Fragment } from "react";+import { Button } from "@/components/ui/button";+import { StarterCard } from "@/components/starters/starter-card";+// Types only: the catalog (models, templates) stays on the server; the pages pass slim template cards.+import type { CanvasNodeType, Outline } from "@/lib/catalog/canvas";+import type { Engine } from "@/lib/catalog/types";+import type { TemplateCardData } from "@/lib/canvas-sections";+import { offered, type AccessSummary } from "@/lib/model-access";+import { templateCover } from "@/lib/template-covers";+import { cn } from "@/lib/utils";+import { NodeIcon } from "./node-icon";++const BOX = { w: 280, h: 150 };++const BOX_COLOR: Partial<Record<CanvasNodeType, string>> = {+ prompt: "var(--chart-2)",+ table: "var(--chart-2)",+ "image-input": "var(--chart-5)",+ "video-input": "var(--chart-4)",+ "audio-input": "var(--chart-3)",+ element: "var(--chart-1)",+ output: "var(--muted-foreground)",+};++/** The board in miniature, for cards without a result to show; `labeled`: each box names its step. */+export function Schematic({ outline: o, className, labeled = false }: { outline: Outline; className?: string; labeled?: boolean }) {+ if (!o.boxes.length) {+ return (+ <div className={cn("grid size-full place-items-center text-subtle-foreground", className)}>+ <Workflow className="size-8" />+ </div>+ );+ }+ const xs = o.boxes.map((b) => b.x);+ const ys = o.boxes.map((b) => b.y);+ const pad = 80;+ const minX = Math.min(...xs) - pad;+ const minY = Math.min(...ys) - pad;+ const w = Math.max(...xs) + BOX.w + pad - minX;+ const h = Math.max(...ys) + BOX.h + pad - minY;+ return (+ <svg viewBox={`${minX} ${minY} ${w} ${h}`} preserveAspectRatio="xMidYMid meet" className={cn("size-full", className)} aria-hidden>+ {o.links.map(([a, b], i) => {+ const s = o.boxes[a];+ const t = o.boxes[b];+ const x1 = s.x + BOX.w;+ const y1 = s.y + BOX.h / 2;+ const x2 = t.x;+ const y2 = t.y + BOX.h / 2;+ const mx = (x1 + x2) / 2;+ return <path key={i} d={`M${x1},${y1} C${mx},${y1} ${mx},${y2} ${x2},${y2}`} fill="none" stroke="var(--border-strong)" strokeWidth={8} />;+ })}+ {o.boxes.map((b, i) => (+ <g key={i}>+ <rect x={b.x} y={b.y} width={BOX.w} height={BOX.h} rx={22} fill="var(--card)" stroke="var(--border-strong)" strokeWidth={4} />+ <rect x={b.x + 24} y={b.y + 28} width={44} height={44} rx={10} fill={BOX_COLOR[b.type] ?? "var(--primary)"} opacity={0.85} />+ {labeled && b.label ? (+ <text x={b.x + 24} y={b.y + 122} fontSize={34} fontWeight={500} fill="var(--foreground)">+ {b.label.length > 14 ? `${b.label.slice(0, 13)}…` : b.label}+ </text>+ ) : (+ <>+ <rect x={b.x + 84} y={b.y + 36} width={150} height={14} rx={7} fill="var(--muted-foreground)" opacity={0.35} />+ <rect x={b.x + 24} y={b.y + 94} width={220} height={12} rx={6} fill="var(--muted-foreground)" opacity={0.18} />+ </>+ )}+ </g>+ ))}+ </svg>+ );+}++/** A starter's steps as a few words on dark glass ("Photo › Scene › Film"), over its cover's corner. */+export function StepFlow({ steps, className }: { steps: string[]; className?: string }) {+ return (+ <span className={cn("pointer-events-none inline-flex items-center gap-0.5 rounded-full bg-black/60 px-2 py-0.5 text-[11px] leading-5 font-medium text-white backdrop-blur-sm", className)} aria-hidden>+ {steps.map((s, i) => (+ <Fragment key={s}>+ {i > 0 && <ChevronRight className="size-3 opacity-70" />}+ {s}+ </Fragment>+ ))}+ </span>+ );+}++/** The model names a card shows as this install offers them: a model that is off shows the one its node falls back to. */+export function offeredNames({ models, ifOff }: TemplateCardData["byEngine"][Engine], access: AccessSummary | undefined, engine: Engine): string[] {+ if (!ifOff || !access) return models;+ return [...new Set(models.map((m) => ifOff.find((x) => x.name === m && !offered(access, x.id, engine))?.instead ?? m))];+}++/** The owner's line under a card or a template's steps: the models it runs on, and free on the owner's GPU. */+export function ModelLine({ t, engine, access, className }: { t: TemplateCardData; engine: Engine; access?: AccessSummary; className?: string }) {+ const models = offeredNames(t.byEngine[engine], access, engine);+ return (+ <p className={cn("flex items-start gap-1.5 text-[12px] text-muted-foreground", className)}>+ {engine === "open" ? <Cpu className="mt-px size-3.5 shrink-0" /> : <Cloud className="mt-px size-3.5 shrink-0" />}+ <span className="line-clamp-2">+ {models.join(" · ")}+ {engine === "open" && " · free on your GPU"}+ </span>+ </p>+ );+}++/**+ * A Canvas template as a starter card. Everyone opens its page from the card; the owner makes the board from it in+ * one tap (onUse) and sees what it runs on, and "No cover yet" on a card that visitors don't get to see.+ */+export function TemplateCard({ t, engine, onUse, busy, access, owner = false }: { t: TemplateCardData; engine: Engine; onUse?: () => void; busy: boolean; access?: AccessSummary; owner?: boolean }) {+ const cover = templateCover("canvas", t.id);+ const { outline } = t.byEngine[engine];+ return (+ <StarterCard+ coverKey={`canvas/${t.id}`}+ cover={cover}+ hue={t.hue}+ flow={<StepFlow steps={t.flow} />}+ overlay={<Schematic outline={outline} className="p-4" />}+ icon={<NodeIcon name={t.icon} className="size-4" />}+ title={t.name}+ description={t.description}+ href={`/canvas/start/${t.id}`}+ meta={owner ? <ModelLine t={t} engine={engine} access={access} /> : undefined}+ badge={owner && !cover ? "No cover yet" : undefined}+ action={+ onUse ? (+ <Button size="sm" className="w-fit rounded-full" onClick={onUse} disabled={busy}>+ {busy ? <Loader2 className="animate-spin" /> : <Plus />} Use template+ </Button>+ ) : (+ <span className="inline-flex items-center gap-1 text-[13px] font-medium text-foreground">+ See how it works <ArrowRight className="size-3.5 transition-transform group-hover/starter:translate-x-0.5" />+ </span>+ )+ }+ />+ );+}diff --git a/src/components/canvas/template-page.tsx b/src/components/canvas/template-page.tsxnew file mode 100644index 00000000..e19fa4ba--- /dev/null+++ b/src/components/canvas/template-page.tsx@@ -0,0 +1,214 @@+"use client";++import { ArrowLeft, ArrowRight, Loader2, Plus } from "lucide-react";+import Link from "next/link";+import { useRouter } from "next/navigation";+import { useState } from "react";+import { Button } from "@/components/ui/button";+import { PageShell } from "@/components/page-shell";+import { SelfHostNote } from "@/components/self-host-note";+import { EngineSwitch } from "@/components/studio/engine-switch";+import { CoverArt, CoverImg, useCoverPlayback } from "@/components/template-cover";+import { useEngine, useIsOwner, useIsVisitor, useModelAccess } from "@/lib/api";+import { shownTo, type TemplateDetail, type TemplateInput } from "@/lib/canvas-sections";+import { templateCover } from "@/lib/template-covers";+import { toastError } from "@/lib/refusals";+import { NodeIcon } from "./node-icon";+import { ModelLine, Schematic } from "./template-card";+import { useCanvasActions } from "./use-canvas";++function Input({ input }: { input: TemplateInput }) {+ const thumb = input.sample?.thumb;+ return (+ <li className="rounded-xl border bg-card p-3.5">+ <div className="flex items-start gap-3">+ {thumb && (+ // eslint-disable-next-line @next/next/no-img-element+ <img src={thumb} alt="" loading="lazy" decoding="async" className="size-14 shrink-0 rounded-lg border object-cover" />+ )}+ <div className="min-w-0">+ <p className="text-[14px] font-medium">{input.label}</p>+ {input.hint && <p className="text-[13px] text-muted-foreground">{input.hint}</p>}+ </div>+ </div>+ {input.text && <p className="mt-2 rounded-lg bg-muted/60 px-3 py-2 text-[13px] whitespace-pre-line">{input.text}</p>}+ {input.table && (+ <div className="mt-2 overflow-x-auto">+ <table className="w-full text-left text-[13px]">+ <thead className="text-muted-foreground">+ <tr>+ {input.table.columns.map((c) => (+ <th key={c} className="py-1 pr-3 font-medium">+ {c}+ </th>+ ))}+ </tr>+ </thead>+ <tbody>+ {input.table.rows.map((r, i) => (+ <tr key={i} className="border-t">+ {r.map((cell, j) => (+ <td key={j} className="py-1 pr-3 align-top">+ {cell}+ </td>+ ))}+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ )}+ </li>+ );+}++/**+ * A Canvas template's page (/canvas/start/<id>): what it makes, what goes in, the steps and what comes out, for+ * everyone. The owner makes the board from here; a guest or an account (who can't save a board here) gets, for an+ * effect film, the Video effect that makes the same in one step with its example loaded, else the studios they can use.+ */+export function TemplatePage({ t }: { t: TemplateDetail }) {+ const router = useRouter();+ const owner = useIsOwner();+ const visitor = useIsVisitor();+ const access = useModelAccess();+ const [engine, setEngine] = useEngine();+ const { create } = useCanvasActions();+ const [busy, setBusy] = useState(false);+ const cover = templateCover("canvas", t.id);+ const { ref, playing, asked, handlers } = useCoverPlayback<HTMLDivElement>(`canvas-start/${t.id}`, cover);+ // A board visitors don't get to see yet (no real cover, or no ready board of its own): the owner's only.+ const ownerOnly = !shownTo(t, { visitor: true, hasCover: (id) => !!templateCover("canvas", id) });++ if (ownerOnly && !owner) {+ return (+ <PageShell>+ {visitor && (+ <div className="py-16 text-center">+ <p className="text-[15px] text-muted-foreground">This board isn't here.</p>+ <Link href="/canvas" className="mt-3 inline-flex text-[14px] font-medium underline underline-offset-4">+ See the ready boards+ </Link>+ </div>+ )}+ </PageShell>+ );+ }++ const use = async () => {+ setBusy(true);+ try {+ const c = await create({ templateId: t.id, engine });+ router.push(`/canvas/${c.id}`);+ } catch (e) {+ toastError(e);+ setBusy(false);+ }+ };++ const heading = "text-[13px] font-semibold tracking-wide text-muted-foreground uppercase";++ return (+ <PageShell wide>+ <Link href="/canvas" className="inline-flex items-center gap-1.5 text-[13px] text-muted-foreground hover:text-foreground">+ <ArrowLeft className="size-3.5" /> Canvas+ </Link>+ <div className="mt-3 grid gap-6 lg:grid-cols-[minmax(0,3fr)_minmax(0,2fr)] lg:gap-10">+ <div className="min-w-0">+ <div ref={ref} {...handlers} className="relative aspect-[16/9] overflow-hidden rounded-2xl border bg-muted">+ {cover ? (+ cover.frames.length > 1 ? (+ <div className="absolute inset-0 grid auto-cols-fr grid-flow-col gap-0.5">+ {cover.frames.map((f) => (+ <CoverImg key={f.src} frame={f} sizes="(max-width: 1024px) 34vw, 280px" />+ ))}+ </div>+ ) : (+ <CoverArt cover={cover} sizes="(max-width: 1024px) 100vw, 820px" playing={playing} asked={asked} />+ )+ ) : (+ <div className="absolute inset-0" style={{ background: `linear-gradient(135deg, oklch(0.62 0.12 ${t.hue} / 0.14), transparent 70%)` }}>+ <Schematic outline={t.byEngine[engine].outline} className="p-6" />+ </div>+ )}+ {owner && !cover && <span className="absolute top-3 right-3 rounded-full bg-background/90 px-2 py-0.5 text-[11px] font-medium text-muted-foreground shadow-soft">No cover yet</span>}+ </div>+ {cover && (+ <div className="relative mt-3 hidden h-28 overflow-hidden rounded-xl border bg-card p-2 sm:block">+ <span className="absolute top-2 left-3 text-[12px] text-muted-foreground">The board</span>+ <Schematic outline={t.byEngine[engine].outline} labeled />+ </div>+ )}+ </div>++ <div className="min-w-0">+ <div className="flex items-center gap-3">+ <span className="grid size-9 shrink-0 place-items-center rounded-lg border bg-card">+ <NodeIcon name={t.icon} className="size-4" />+ </span>+ <h1 className="font-heading text-[30px] leading-tight">{t.name}</h1>+ </div>+ <p className="mt-2 text-[15px] text-pretty text-muted-foreground">{t.description}</p>++ <div className="mt-4 flex flex-wrap items-center gap-3">+ {owner ? (+ <>+ <Button className="rounded-full" onClick={() => void use()} disabled={busy}>+ {busy ? <Loader2 className="animate-spin" /> : <Plus />} Use template+ </Button>+ <EngineSwitch value={engine} onChange={setEngine} size="sm" />+ </>+ ) : (+ t.oneStep && (+ <Button asChild className="rounded-full">+ <Link href={t.oneStep.href}>+ {t.oneStep.label} <ArrowRight />+ </Link>+ </Button>+ )+ )}+ </div>+ {!owner &&+ (t.oneStep ? (+ <p className="mt-2 text-[13px] text-pretty text-muted-foreground [html[data-viewer='owner']_&]:hidden">One tap opens it with a photo ready. Change anything, then make your own.</p>+ ) : (+ <SelfHostNote className="mt-2" />+ ))}++ <section aria-labelledby="goes-in" className="mt-8">+ <h2 id="goes-in" className={heading}>+ What goes in+ </h2>+ <ul className="mt-2 space-y-2">+ {t.inputs.map((i) => (+ <Input key={i.id} input={i} />+ ))}+ </ul>+ </section>++ <section aria-labelledby="the-steps" className="mt-8">+ <h2 id="the-steps" className={heading}>+ The steps+ </h2>+ <ol className="mt-2 space-y-2">+ {t.steps.map((s, i) => (+ <li key={i} className="flex gap-3 text-[14px]">+ <span className="grid size-6 shrink-0 place-items-center rounded-full bg-muted text-[12px] font-medium">{i + 1}</span>+ <span className="min-w-0 pt-0.5 text-pretty">{s}</span>+ </li>+ ))}+ </ol>+ {owner && <ModelLine t={t} engine={engine} access={access} className="mt-3" />}+ </section>++ <section aria-labelledby="comes-out" className="mt-8">+ <h2 id="comes-out" className={heading}>+ What comes out+ </h2>+ <p className="mt-2 text-[14px] text-pretty">{t.makes}</p>+ </section>+ </div>+ </div>+ </PageShell>+ );+}diff --git a/src/components/canvas/use-canvas.ts b/src/components/canvas/use-canvas.tsindex 4651ab15..bbd4983d 100644--- a/src/components/canvas/use-canvas.ts+++ b/src/components/canvas/use-canvas.ts@@ -25,9 +25,11 @@ export interface CanvasView {const active = (g: Generation) => g.status === "queued" || g.status === "running";-export function useCanvases() {+/** The owner's canvases; `enabled: false` (a visitor, who has none) asks for nothing. */+export function useCanvases({ enabled = true }: { enabled?: boolean } = {}) {return useQuery({queryKey: ["canvases"],+ enabled,queryFn: async () => (await json<{ items: CanvasSummary[] }>(await fetch("/api/canvases"))).items,});}diff --git a/src/components/starters/starter-card.tsx b/src/components/starters/starter-card.tsxnew file mode 100644index 00000000..93771291--- /dev/null+++ b/src/components/starters/starter-card.tsx@@ -0,0 +1,87 @@+"use client";++import Link from "next/link";+import type { ReactNode } from "react";+import { CoverArt, CoverImg, useCoverPlayback } from "@/components/template-cover";+import type { TemplateCover } from "@/lib/template-covers";+import { cn } from "@/lib/utils";++export interface StarterCardProps {+ /** The cover's playback key (one clip plays at a time on a phone). */+ coverKey: string;+ /** What the starter makes: a still, a clip, or its frames side by side. None: the overlay fills the card (owner only). */+ cover?: TemplateCover;+ /** The tint behind a card without a cover. */+ hue: number;+ /** The steps in a few words, over the cover's bottom-right corner. */+ flow?: ReactNode;+ /** The steps in miniature, filling a card that has no cover yet. */+ overlay: ReactNode;+ icon: ReactNode;+ title: string;+ description: string;+ /** The starter's page: the whole card opens it. */+ href: string;+ /** A line under the description (the owner's: the models it runs on). */+ meta?: ReactNode;+ /** A small chip on the cover (the owner's: "No cover yet"). */+ badge?: string;+ /** The card's one action, at its foot: a button over the card's link, or words that belong to it. */+ action?: ReactNode;+ className?: string;+}++/**+ * A ready-made starter as a card: its cover with its steps in a few words over a corner, an icon badge, a title, one+ * line of description and one action. The cards of a row line up: the description takes two lines at most and the+ * action sits at the foot.+ */+export function StarterCard({ coverKey, cover, hue, flow, overlay, icon, title, description, href, meta, badge, action, className }: StarterCardProps) {+ const { ref, playing, asked, handlers } = useCoverPlayback<HTMLElement>(coverKey, cover);+ const iconBadge = <span className="absolute top-3 left-3 grid size-8 place-items-center rounded-lg bg-background/90 text-foreground shadow-soft">{icon}</span>;+ return (+ <article+ ref={ref}+ {...handlers}+ className={cn(+ "group/starter relative flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card transition-shadow focus-within:ring-4 focus-within:ring-brand-faint hover:shadow-normal",+ className,+ )}+ >+ {cover ? (+ <div className="relative aspect-[16/9] overflow-hidden bg-muted">+ {cover.frames.length > 1 ? (+ <div className="absolute inset-0 grid auto-cols-fr grid-flow-col gap-0.5">+ {cover.frames.map((f) => (+ <CoverImg key={f.src} frame={f} sizes="(max-width: 640px) 34vw, (max-width: 1024px) 17vw, 150px" />+ ))}+ </div>+ ) : (+ <CoverArt cover={cover} sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 440px" playing={playing} asked={asked} />+ )}+ {flow && <span className="pointer-events-none absolute right-2.5 bottom-2.5">{flow}</span>}+ {iconBadge}+ </div>+ ) : (+ <div className="relative aspect-[16/9] bg-muted/50" style={{ background: `linear-gradient(135deg, oklch(0.62 0.12 ${hue} / 0.14), transparent 70%)` }}>+ <div className="absolute inset-0">{overlay}</div>+ {iconBadge}+ </div>+ )}+ {badge && <span className="pointer-events-none absolute top-3 right-3 rounded-full bg-background/90 px-2 py-0.5 text-[11px] font-medium text-muted-foreground shadow-soft">{badge}</span>}+ <div className="flex flex-1 flex-col gap-2 p-3.5">+ <div>+ <h3 className="text-[14px] font-medium">+ {/* The whole card opens the starter's page; the action sits above this link. */}+ <Link href={href} className="outline-none after:absolute after:inset-0 after:content-['']">+ {title}+ </Link>+ </h3>+ <p className="line-clamp-2 text-[13px] text-muted-foreground">{description}</p>+ </div>+ {meta}+ {action && <div className="relative z-10 mt-auto pt-1 [&:has(>span)]:pointer-events-none">{action}</div>}+ </div>+ </article>+ );+}diff --git a/src/lib/canvas-sections.ts b/src/lib/canvas-sections.tsnew file mode 100644index 00000000..17e8d6df--- /dev/null+++ b/src/lib/canvas-sections.ts@@ -0,0 +1,98 @@+/**+ * Canvas's template sections and who sees which card (client-safe: no catalog). The template cards themselves are+ * built on the server (src/lib/canvas-template-cards.ts) and passed to the page as props.+ */+import type { CanvasNodeType, Outline } from "@/lib/catalog/canvas";+import type { Engine } from "@/lib/catalog/types";+import type { CoverFrame, TemplateCover } from "@/lib/template-covers";++/** The sections in order, with the words visitors read (a template's `group` is the key). */+export const TEMPLATE_SECTIONS = [+ { key: "", title: "Films and campaigns", note: "Ready boards that make a finished piece. Each one runs as it is." },+ { key: "effect-films", title: "Effect films", note: "Your photo, a new scene, then a moving shot." },+] as const;++export type TemplateSectionKey = Exclude<(typeof TEMPLATE_SECTIONS)[number]["key"], "">;++/** A template as the list shows it: its board outline and model names per engine (the model names are the owner's). */+export interface TemplateCardData {+ id: string;+ name: string;+ description: string;+ icon: string;+ hue: number;+ section: TemplateSectionKey | "";+ rank: number;+ /** The steps as a word or two each: the small flow over the card's cover. */+ flow: string[];+ /** false: no ready board of its own: the owner's "More templates" only. */+ starter?: false;+ /** ifOff: a model's name and the one its node falls back to when the model is off on this install. */+ byEngine: Record<Engine, { outline: Outline; models: string[]; ifOff?: { id: string; name: string; instead: string }[] }>;+}++/** An input of a template's board, as its page shows it. */+export interface TemplateInput {+ id: string;+ type: CanvasNodeType;+ label: string;+ hint?: string;+ /** A prompt's or a script's words. */+ text?: string;+ table?: { columns: string[]; rows: string[][] };+ /** The file the board starts with here (its sample): a picture's small copy, or what kind of file it is. */+ sample?: { kind: "image" | "video" | "audio"; thumb?: string; name: string };+}++/** A template's page (/canvas/start/<id>). */+export interface TemplateDetail extends TemplateCardData {+ makes: string;+ steps: string[];+ inputs: TemplateInput[];+ oneStep?: { href: string; label: string };+}++/** "What's a canvas?": one effect film as the photo that went in, then its cover (the scene, then the moving shot). */+export interface CanvasIntro {+ templateId: string;+ photo: CoverFrame;+ film: TemplateCover;+}++export interface Viewing {+ /** A guest or an account (or not known yet): they see ready boards with a real cover only. */+ visitor: boolean;+ hasCover: (id: string) => boolean;+}++/** Whether a template's card shows: to a visitor only a ready board with its real cover, to the owner every one. */+export const shownTo = (t: TemplateCardData, { visitor, hasCover }: Viewing) => !visitor || (t.starter !== false && hasCover(t.id));++/** Covered cards first, then by rank. */+const order = (hasCover: Viewing["hasCover"]) => (a: TemplateCardData, b: TemplateCardData) => Number(!hasCover(a.id)) - Number(!hasCover(b.id)) || a.rank - b.rank;++export interface TemplateSection {+ key: TemplateSectionKey | "";+ title: string;+ note: string;+ items: TemplateCardData[];+}++/** The ready boards by section, as the viewer sees them; a section with nothing to show is left out. */+export function templateSections(templates: TemplateCardData[], v: Viewing): TemplateSection[] {+ return TEMPLATE_SECTIONS.map((s) => ({+ key: s.key,+ title: s.title,+ note: s.note,+ items: templates.filter((t) => t.section === s.key && t.starter !== false && shownTo(t, v)).sort(order(v.hasCover)),+ })).filter((s) => s.items.length > 0);+}++/** The owner's other templates (no ready board of their own); none for a visitor. */+export const moreTemplates = (templates: TemplateCardData[], v: Viewing) => (v.visitor ? [] : templates.filter((t) => t.starter === false));++/** The short row under a person's own boards: the first few ready boards, covered first, sections in order. */+export function firstTemplates(templates: TemplateCardData[], v: Viewing, n = 3): TemplateCardData[] {+ const covered = templateSections(templates, v).flatMap((s) => s.items);+ return [...covered.filter((t) => v.hasCover(t.id)), ...covered.filter((t) => !v.hasCover(t.id))].slice(0, n);+}diff --git a/src/lib/canvas-template-cards.ts b/src/lib/canvas-template-cards.tsnew file mode 100644index 00000000..9c5d34d1--- /dev/null+++ b/src/lib/canvas-template-cards.ts@@ -0,0 +1,109 @@+import "server-only";+import { getModel } from "@/lib/catalog";+import { CANVAS_TEMPLATES, getTemplate, isGenerator, outline, type CanvasNodeType, type CanvasTemplate } from "@/lib/catalog/canvas";+import type { Engine } from "@/lib/catalog/types";+import { EXAMPLE_MEDIA } from "@/lib/examples/media.generated";+import plan from "@/lib/examples/plan.json";+import { presetCover } from "@/lib/preset-covers";+import { templateCover } from "@/lib/template-covers";+import type { CanvasIntro, TemplateCardData, TemplateDetail, TemplateInput } from "@/lib/canvas-sections";++/**+ * One template's board outline and model names on an engine, with the name a node falls back to when its model is+ * switched off in Models & licences (the card swaps it in the browser, as the board the server makes does).+ */+function forEngine(t: CanvasTemplate, engine: Engine): TemplateCardData["byEngine"][Engine] {+ const graph = t.build(engine);+ const nameOf = (id?: string) => getModel(id ?? "")?.name;+ const names = graph.nodes.filter(isGenerator).map((n) => nameOf(n.data.modelId));+ const without = t.build(engine, () => false).nodes;+ const ifOff: NonNullable<TemplateCardData["byEngine"][Engine]["ifOff"]> = [];+ for (const n of graph.nodes) {+ const id = n.data.modelId;+ const name = nameOf(id);+ const instead = nameOf(without.find((x) => x.id === n.id)?.data.modelId);+ if (id && name && instead && instead !== name && !ifOff.some((x) => x.id === id)) ifOff.push({ id, name, instead });+ }+ return { outline: outline(graph), models: [...new Set(names.filter((m): m is string => !!m))], ...(ifOff.length && { ifOff }) };+}++function card(t: CanvasTemplate): TemplateCardData {+ return {+ id: t.id,+ name: t.name,+ description: t.description,+ icon: t.icon,+ hue: t.hue,+ section: t.group ?? "",+ rank: t.rank,+ flow: t.flow,+ ...(t.starter === false && { starter: false as const }),+ byEngine: { cloud: forEngine(t, "cloud"), open: forEngine(t, "open") },+ };+}++/** Template cards built here, so the browser never loads the model catalog for /canvas (nor for the pages that prefetch it). */+export function templateCards(): TemplateCardData[] {+ return CANVAS_TEMPLATES.map(card);+}++/** What a kind of input is, in plain words, where the template doesn't say. */+const INPUT_HINT: Partial<Record<CanvasNodeType, string>> = {+ "image-input": "A photo you add.",+ "video-input": "A clip you add.",+ "audio-input": "A recording you add.",+ "clone-voice": "A short recording of the voice to copy.",+ element: "One of your saved elements.",+};+const INPUT_TYPES = new Set<CanvasNodeType>(["prompt", "table", "image-input", "video-input", "audio-input", "clone-voice", "element"]);++/** The example ids the pages have (src/lib/examples/plan.json): "effect-pearl-earring.1". */+const EXAMPLE_IDS = new Set((plan as { id: string }[]).map((r) => r.id));++/** The Video effect a template's "Try this effect in Video" opens, with the effect's own example loaded when it has one. */+function oneStepHref(href: string): string {+ const preset = new URL(href, "http://x").searchParams.get("preset");+ return preset && EXAMPLE_IDS.has(`${preset}.1`) ? `${href}&example=${preset}.1` : href;+}++/** What a sample is, as a template's page shows it: a picture's small copy (a published example's inset), else its kind. */+function sampleOf(t: CanvasTemplate, nodeId: string, type: CanvasNodeType): TemplateInput["sample"] {+ const s = t.samples?.[nodeId];+ if (!s) return undefined;+ const kind = type === "image-input" ? "image" : type === "video-input" ? "video" : "audio";+ return { kind, name: s.name, ...(kind === "image" && { thumb: EXAMPLE_MEDIA[s.src]?.thumb ?? s.src }) };+}++/** A template's page (/canvas/start/<id>): its card, what goes in, the steps and what comes out, in plain words. */+export function templateDetail(id: string): TemplateDetail | undefined {+ const t = getTemplate(id);+ if (!t) return undefined;+ // The words a board starts with are the same on both engines: read them from one.+ const graph = t.build("open");+ const inputs: TemplateInput[] = graph.nodes+ .filter((n) => INPUT_TYPES.has(n.type))+ .map((n) => ({+ id: n.id,+ type: n.type,+ label: n.data.label ?? (n.type === "prompt" ? "Prompt" : "Input"),+ ...((t.inputs?.[n.id] ?? INPUT_HINT[n.type]) && { hint: t.inputs?.[n.id] ?? INPUT_HINT[n.type] }),+ ...(n.type === "prompt" && n.data.text && { text: n.data.text }),+ ...(n.type === "table" && n.data.columns && n.data.rows && { table: { columns: n.data.columns, rows: n.data.rows } }),+ ...(t.samples?.[n.id] && { sample: sampleOf(t, n.id, n.type) }),+ }));+ return { ...card(t), makes: t.makes, steps: t.steps, inputs, ...(t.oneStep && { oneStep: { ...t.oneStep, href: oneStepHref(t.oneStep.href) } }) };+}++/** Every template's page, prerendered. */+export const templateIds = () => CANVAS_TEMPLATES.map((t) => t.id);++/**+ * "What's a canvas?": one real effect film in three tiles, the photo that went in, the scene it became and the moving+ * shot. The photo is the clip's first frame (the effect's own cover), the scene its peak (the template's cover).+ */+export function canvasIntro(templateId = "effect-chain-pearl-earring"): CanvasIntro | undefined {+ const film = templateCover("canvas", templateId);+ const photo = presetCover(templateId.replace(/^effect-chain-/, "effect-"));+ if (!film?.video || !photo) return undefined;+ return { templateId, photo: { src: photo.poster, thumb: photo.thumb }, film };+}diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 8f72cfd3..980ddc16 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -10,6 +10,7 @@import type { CanvasComment, CanvasGroup, CanvasPage, CanvasShape } from "./canvas-board";import { EXAMPLE_SCENE, EXAMPLE_WORDS, beatsFrom, blockoutFramePrompt, compileBlockoutPrompt, type BlockoutRef } from "@/lib/blockout";import { QMA_MODEL } from "@/lib/qma";+import type { TemplateSectionKey } from "@/lib/canvas-sections";import { getModel, getPreset, MODELS, supportsOp } from "./index";import { dualEngine, onEngine, runsOn } from "./engines";import { chainedWaitMessage, keyframeChain } from "./keyframes";@@ -178,6 +179,8 @@ export interface OutlineBox {x: number;y: number;type: CanvasNodeType;+ /** The node's own label, short (a template page's diagram names its steps). */+ label?: string;}/** The board in miniature: node boxes and the edges between them (as indexes into `boxes`). */@@ -1750,7 +1753,7 @@ export function outline(graph: CanvasGraph): Outline {const nodes = graph.nodes.filter((n) => n.type !== "note").slice(0, 40);const index = new Map(nodes.map((n, i) => [n.id, i]));return {- boxes: nodes.map((n) => ({ x: Math.round(n.position.x), y: Math.round(n.position.y), type: n.type })),+ boxes: nodes.map((n) => ({ x: Math.round(n.position.x), y: Math.round(n.position.y), type: n.type, ...(n.data.label && { label: n.data.label.slice(0, 24) }) })),links: graph.edges.flatMap((e) => (index.has(e.source) && index.has(e.target) ? [[index.get(e.source)!, index.get(e.target)!] as [number, number]] : [])),};}@@ -1772,8 +1775,27 @@ export interface CanvasTemplate {/** lucide icon name. */icon: string;hue: number;- /** The picker's section ("Effects 2.0 chains"); none: the workflows. */- group?: string;+ /** The section's key (TEMPLATE_SECTIONS: "effect-films"); none: the films and campaigns. */+ group?: TemplateSectionKey;+ /** Its place in its section, ascending: the most premium first. */+ rank: number;+ /** false: no ready board of its own (Blockout → film): only the owner sees it, under "More templates". */+ starter?: false;+ /** What the board makes, in plain words (its page's "What comes out"): no model names. */+ makes: string;+ /** The steps in order, in plain words (its page's "The steps"): no model names. */+ steps: string[];+ /** Plain words for an input node, by node id (its page's "What goes in"), where its label alone doesn't say it. */+ inputs?: Record<string, string>;+ /** The studio that makes the same in one step: an effect film's Video effect. */+ oneStep?: { href: string; label: string };+ /** The steps as a word or two each, for the small flow over a card's cover ("Photo", "Scene", "Film"). */+ flow: string[];+ /**+ * Files the board starts with, by input node id: a public file Fuobe ships (a published example input, a sample),+ * copied into the owner's storage when the board is made (src/server/canvas-samples.ts), so the board runs as it is.+ */+ samples?: Record<string, { src: string; name: string }>;/** `offered`: whether the install offers a model (Settings → Models & licences); a node falls back when it doesn't. */build: (engine: Engine, offered?: (id: string) => boolean) => CanvasGraph;}@@ -1898,11 +1920,15 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [description: "Write a prompt, make a still, bring it to life",icon: "Clapperboard",hue: 282,+ rank: 5,+ makes: "A 5-second film of the still, in 16:9.",+ flow: ["Words", "Still", "Film"],+ steps: ["Your prompt says what the picture shows.", "An image model makes a still from it.", "A video model brings the still to life as a 5-second shot."],build: tpl([- { id: "prompt", type: "prompt", x: 0, y: 80, data: { label: "Prompt", text: "A lighthouse on a sea cliff at golden hour, waves crashing below, cinematic wide shot" } },+ { id: "prompt", type: "prompt", x: 0, y: 80, data: { label: "Prompt", text: "A fashion model in a long crimson silk gown on an Icelandic black-sand beach, the silk train lifting in the sea wind, basalt sea stacks behind her, soft overcast light, cinematic wide shot" } },{ id: "still", type: "model", x: COL, y: 40, data: { mediaKind: "image", label: "Still", params: { aspectRatio: "16:9" } }, models: { cloud: "nano-banana-pro", open: "oss-qwen-image-21" } },- { id: "animate", type: "model", x: COL * 2, y: 40, data: { mediaKind: "video", label: "Animate", op: "i2v", prompt: "Slow push-in as the waves roll and the beam sweeps across the sea", params: { aspectRatio: "16:9", duration: 5 } }, models: { cloud: "minimax-h3", open: "oss-minimax-h3" } },+ { id: "animate", type: "model", x: COL * 2, y: 40, data: { mediaKind: "video", label: "Animate", op: "i2v", prompt: "Slow push-in as the silk train lifts in the sea wind and she turns her face towards the light", params: { aspectRatio: "16:9", duration: 5 } }, models: { cloud: "minimax-h3", open: "oss-minimax-h3" } },{ id: "out", type: "output", x: COL * 3, y: 60, data: { label: "Film" } },],[@@ -1918,6 +1944,12 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [description: "One product photo, three studio angles, one ad clip",icon: "Package",hue: 30,+ rank: 1,+ makes: "Three studio angles of the product and a 5-second ad clip.",+ steps: ["Your product photo goes in.", "Three edits show it from the front, from the side and from above, on a clean studio background.", "A video model turns the three angles into a 5-second ad clip with a slow orbit."],+ inputs: { product: "A photo of your product on its own." },+ flow: ["Product", "3 angles", "Ad"],+ samples: { product: { src: "/examples/app-product-360/1/in-image.jpg", name: "Red patent heel.jpg" } },build: tpl([{ id: "product", type: "image-input", x: 0, y: ROW, data: { label: "Product photo" } },@@ -1944,12 +1976,16 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [{id: "script-film",name: "Script → storyboard → film",- description: "A text model breaks a short script into three shots: three frames, three clips, one film",+ description: "A short script becomes three frames, three clips and one film",icon: "GalleryHorizontal",hue: 200,+ rank: 6,+ makes: "Three frames, three clips and one film.",+ flow: ["Script", "Frames", "Film"],+ steps: ["Your script goes in.", "A writing model splits it into three shots: the opening, the turning point and the ending.", "Each shot becomes a still frame, all in one look.", "Each frame becomes a 5-second clip.", "The three clips are joined into one film."],build: tpl([- { id: "script", type: "prompt", x: 0, y: FILM_ROW, data: { label: "Script", text: "A paper boat sails down a rain-soaked city gutter, rides a little waterfall into a storm drain and comes out on a sunny canal." } },+ { id: "script", type: "prompt", x: 0, y: FILM_ROW, data: { label: "Script", text: "On a candlelit night, a woman in an emerald silk ball gown walks down the grand marble staircase of a palace. At the bottom she turns, and her face catches the candlelight. Then she pushes open tall gilded doors onto a moonlit garden." } },// The script reaches every shot through a text model: edit the script and all three shots follow....[0, 1, 2].map((i) => ({id: `beat${i + 1}`,@@ -2009,11 +2045,15 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [description: "One prompt, three models, side by side",icon: "Columns3",hue: 150,+ rank: 7,+ makes: "Three pictures of the same prompt, side by side.",+ flow: ["Prompt", "3 pictures"],+ steps: ["Your prompt goes in.", "Three image models each make a picture from it.", "The three pictures sit side by side, so you can keep the best."],build: (engine) => {const models = engine === "open" ? ["oss-ideogram-4", "oss-qwen-image-21", "oss-krea2-realism"] : ["nano-banana-pro", "seedream-5-pro", "flux-3"];return tpl([- { id: "prompt", type: "prompt", x: 0, y: ROW - 60, data: { label: "Prompt", text: "Portrait of an elderly fisherman mending a net at dawn, soft window light, film grain" } },+ { id: "prompt", type: "prompt", x: 0, y: ROW - 60, data: { label: "Prompt", text: "Editorial beauty portrait of a Senegalese fashion model in a gold silk headwrap and gold earrings, warm studio light, film grain" } },...models.map((m, i) => ({ id: `m${i + 1}`, type: "model" as const, x: COL, y: i * (ROW - 60), data: { mediaKind: "image" as const, modelId: m, params: { aspectRatio: "3:4" } } })),{ id: "out", type: "output", x: COL * 2, y: ROW - 120, data: { label: "Compare" }, width: 560 },],@@ -2027,13 +2067,19 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [description: "A photo, a short voice sample and a script make a talking clip",icon: "Mic2",hue: 340,+ rank: 8,+ makes: "A talking clip of the portrait in the cloned voice.",+ steps: ["A portrait, a short voice sample and a script go in.", "The script is read in the cloned voice.", "The portrait speaks the lines, with natural head movement."],+ inputs: { portrait: "A photo of a face, looking at the camera.", sample: "10 to 30 seconds of the voice to copy." },+ flow: ["Portrait", "Voice", "Talk"],+ samples: { portrait: { src: "/examples/effect-pearl-earring/1/in-image.jpg", name: "Portrait.jpg" }, sample: { src: "/samples/clean-voice/clean.m4a", name: "Voice sample.m4a" } },build: tpl([{ id: "portrait", type: "image-input", x: 0, y: 0, data: { label: "Portrait" } },{ id: "sample", type: "clone-voice", x: 0, y: 340, data: { label: "Your voice (10–30 s sample)" } },- { id: "script", type: "prompt", x: 0, y: 540, data: { label: "Script", text: "Hi! This whole clip was made on a Fuobe canvas from one photo and a few seconds of my voice." } },+ { id: "script", type: "prompt", x: 0, y: 540, data: { label: "Script", text: "Welcome to the new collection. Every piece is cut by hand in our Milan atelier, and made to last a lifetime." } },{ id: "voice", type: "tts", x: COL, y: 400, data: { label: "Cloned voice" }, models: { cloud: "chatterbox-cloud", open: "oss-chatterbox" } },- { id: "avatar", type: "model", x: COL * 2, y: 80, data: { mediaKind: "video", label: "Talking avatar", op: "avatar", prompt: "A friendly presenter talking to the camera, natural head movement" }, models: { cloud: "kling-avatar-2", open: "oss-infinitetalk" } },+ { id: "avatar", type: "model", x: COL * 2, y: 80, data: { mediaKind: "video", label: "Talking avatar", op: "avatar", prompt: "A model talking warmly to the camera, natural head movement" }, models: { cloud: "kling-avatar-2", open: "oss-infinitetalk" } },{ id: "out", type: "output", x: COL * 3, y: 100, data: { label: "Clip" } },],[@@ -2048,14 +2094,18 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [{id: "table-film",name: "Table → shots → film",- description: "One row per shot: each row makes a still and animates it, then every row is joined into one film",+ description: "Each row is a shot: a still, then a clip, all joined into one film",icon: "Table",hue: 160,+ rank: 3,+ makes: "One film with a shot for every row.",+ flow: ["Table", "Stills", "Film"],+ steps: ["Each row of the table is one shot.", "Every row becomes a still.", "Every still becomes a 5-second clip.", "The clips are joined into one film."],build: tpl([- { id: "cast", type: "table", x: 0, y: 40, data: { label: "Shots", columns: ["Animal", "Place"], rows: [["red fox", "a snowy pine forest"], ["barn owl", "an old wooden barn at dusk"], ["sea otter", "a kelp forest at sunrise"]] } },- { id: "still", type: "model", x: COL + 140, y: 0, data: { mediaKind: "image", label: "Still", prompt: "A {Animal} in {Place}, wildlife photography, soft natural light", params: { aspectRatio: "16:9" } }, models: { cloud: "nano-banana-pro", open: "oss-qwen-image-21" } },- { id: "animate", type: "model", x: COL * 2 + 140, y: 0, data: { mediaKind: "video", label: "Animate", op: "i2v", prompt: "Slow push-in, the animal turns its head", params: { aspectRatio: "16:9", duration: 5 } }, models: { cloud: "minimax-h3", open: "oss-minimax-h3" } },+ { id: "cast", type: "table", x: 0, y: 40, data: { label: "Shots", columns: ["Shot", "Scene"], rows: [["Opening", "a fashion model in a white linen dress at the bow of a classic wooden yacht off Capri, morning sun"], ["Middle", "the model on the teak deck in a navy silk scarf, the cliffs of the Amalfi coast behind her"], ["Ending", "the model at the stern at golden hour, the sea glittering behind her"]] } },+ { id: "still", type: "model", x: COL + 140, y: 0, data: { mediaKind: "image", label: "Still", prompt: "{Scene}, a luxury yacht campaign, cinematic light", params: { aspectRatio: "16:9" } }, models: { cloud: "nano-banana-pro", open: "oss-qwen-image-21" } },+ { id: "animate", type: "model", x: COL * 2 + 140, y: 0, data: { mediaKind: "video", label: "Animate", op: "i2v", prompt: "Slow cinematic camera move, the sea glittering, fabric moving in the wind", params: { aspectRatio: "16:9", duration: 5 } }, models: { cloud: "minimax-h3", open: "oss-minimax-h3" } },{ id: "film", type: "concat", x: COL * 3 + 140, y: 0, data: { label: "Film", params: { aspectRatio: "16:9" } }, models: { cloud: CONCAT_MODELS.cloud, open: CONCAT_MODELS.open } },],[@@ -2071,6 +2121,11 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [description: "A grey-box blockout sets the camera and timing; reference stills and timed beats say what it becomes",icon: "Box",hue: 210,+ rank: 99,+ starter: false,+ makes: "A film that follows the blockout's camera and timing.",+ flow: ["Blockout", "Film"],+ steps: ["A grey-box blockout sets the camera and timing.", "Reference stills and timed beats say what it becomes.", "A video model renders the film."],build: (engine) => (engine === "cloud" ? BLOCKOUT_CLOUD(engine) : BLOCKOUT_OPEN(engine)),},{@@ -2079,6 +2134,11 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [description: "Trim, mute and join clips into one film, at 30 fps",icon: "Film",hue: 250,+ rank: 9,+ makes: "One film made of the three clips.",+ flow: ["Clips", "Film"],+ samples: Object.fromEntries(["pearl-earring", "superstar", "blue-depth"].map((e, i) => [`clip${i + 1}`, { src: `/previews/presets/effect-${e}.mp4`, name: `Clip ${i + 1}.mp4` }])),+ steps: ["Three clips go in.", "Each one is trimmed, muted and set to 30 frames a second.", "They are joined into one film."],build: tpl([...[0, 1, 2].map((i) => ({ id: `clip${i + 1}`, type: "video-input" as const, x: 0, y: i * 320, data: { label: `Clip ${i + 1}` } })),@@ -2102,23 +2162,25 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [// Qwen-Image 2.1 Turbo on your GPU (Qwen-Image-Edit 2511 hosted on fal) and Fuobe DoP (Wan 2.2 14B on your GPU, or hosted on fal).// The edit prompts are Fuobe's own words; the motion is the effect's own prompt from the effects catalog.-export const EFFECT_CHAIN_GROUP = "Effects 2.0 chains";+/** The effect films' section (TEMPLATE_SECTIONS). */+export const EFFECT_CHAIN_GROUP = "effect-films" satisfies TemplateSectionKey;/** Image edit, then image to video: the models per engine (Fuobe DoP is an Original, run on the template's engine). */export const EFFECT_CHAIN_MODELS = { edit: { cloud: "qwen-image-edit-2511-cloud", open: "oss-qwen-image-21-turbo" }, video: "fuobe-dop" } as const;/** The researched Effects 2.0 chains with a scene to set first: the effect (its name in the effects catalog) and the edit. */-export const EFFECT_CHAINS: { effect: string; edit: string; icon: string; hue: number }[] = [- { effect: "Agamemnon", icon: "Swords", hue: 35, edit: "Dress the person as an ancient Greek warrior king in polished bronze armour and a red cape, a sword in hand, a vast army on a dusty battlefield behind them at golden hour. Keep their face and pose." },- { effect: "Fallen Angel", icon: "Feather", hue: 270, edit: "Give the person large dark ragged wings and put them on a storm-lit rooftop at night, black feathers drifting in the air. Keep their face, clothes and pose." },- { effect: "Pearl Earring", icon: "Gem", hue: 220, edit: "Repaint the picture as a Dutch Golden Age oil portrait: a blue and gold head wrap, a pearl earring, a dark background and soft window light. Keep the person's face." },- { effect: "Monet Muse", icon: "Palette", hue: 150, edit: "Repaint the scene as an impressionist oil painting of a garden pond with water lilies, soft dabs of light and colour. Keep the person and their pose." },- { effect: "Fairytale Castle", icon: "Castle", hue: 300, edit: "Put a magical fairytale castle on a hill far behind the person under a twilight sky with the first fireworks. Keep the person exactly as they are." },- { effect: "Blue Depth", icon: "Waves", hue: 210, edit: "Place the person underwater in deep blue ocean light, rays shimmering down from the surface, hair and clothes floating. Keep their face." },- { effect: "Superstar", icon: "Star", hue: 50, edit: "Put the person on a glittering concert stage under bright spotlights, a cheering crowd in silhouette and confetti in the air. Keep their face and outfit." },- { effect: "Street Colossus", icon: "Building2", hue: 15, edit: "Make the person a giant standing in the middle of a city street, as tall as the buildings, with tiny cars and people around their feet. Keep their face and clothes." },- { effect: "Dolphin Ride", icon: "Fish", hue: 190, edit: "Put the person on the back of a dolphin leaping over sparkling ocean waves in bright sunshine. Keep their face." },- { effect: "Skatedog", icon: "Dog", hue: 95, edit: "Add a happy dog riding a skateboard next to the person on a sunny street. Keep the person exactly as they are." },+/** `line`: what it does for you, in one short line (cards and pages). `photo`: another effect's example photo, where its own has none yet. */+export const EFFECT_CHAINS: { effect: string; line: string; edit: string; icon: string; hue: number; rank: number; photo?: string }[] = [+ { effect: "Agamemnon", line: "You become a bronze-armoured king before a vast army at golden hour.", rank: 6, icon: "Swords", hue: 35, edit: "Dress the person as an ancient Greek warrior king in polished bronze armour and a red cape, a sword in hand, a vast army on a dusty battlefield behind them at golden hour. Keep their face and pose." },+ { effect: "Fallen Angel", photo: "superstar", line: "You get dark wings on a storm-lit rooftop, feathers in the air.", rank: 10, icon: "Feather", hue: 270, edit: "Give the person large dark ragged wings and put them on a storm-lit rooftop at night, black feathers drifting in the air. Keep their face, clothes and pose." },+ { effect: "Pearl Earring", line: "You become a Dutch Golden Age portrait with a pearl earring.", rank: 1, icon: "Gem", hue: 220, edit: "Repaint the picture as a Dutch Golden Age oil portrait: a blue and gold head wrap, a pearl earring, a dark background and soft window light. Keep the person's face." },+ { effect: "Monet Muse", line: "You step into an impressionist painting of a water-lily pond.", rank: 2, icon: "Palette", hue: 150, edit: "Repaint the scene as an impressionist oil painting of a garden pond with water lilies, soft dabs of light and colour. Keep the person and their pose." },+ { effect: "Fairytale Castle", line: "A fairytale castle rises behind you under a twilight sky.", rank: 4, icon: "Castle", hue: 300, edit: "Put a magical fairytale castle on a hill far behind the person under a twilight sky with the first fireworks. Keep the person exactly as they are." },+ { effect: "Blue Depth", line: "You drift in deep blue water, light rays falling from above.", rank: 5, icon: "Waves", hue: 210, edit: "Place the person underwater in deep blue ocean light, rays shimmering down from the surface, hair and clothes floating. Keep their face." },+ { effect: "Superstar", line: "You take the stage under bright spotlights as confetti falls.", rank: 3, icon: "Star", hue: 50, edit: "Put the person on a glittering concert stage under bright spotlights, a cheering crowd in silhouette and confetti in the air. Keep their face and outfit." },+ { effect: "Street Colossus", photo: "blue-depth", line: "You stand as tall as the buildings in a busy city street.", rank: 9, icon: "Building2", hue: 15, edit: "Make the person a giant standing in the middle of a city street, as tall as the buildings, with tiny cars and people around their feet. Keep their face and clothes." },+ { effect: "Dolphin Ride", line: "You ride a dolphin over sparkling waves in bright sunshine.", rank: 7, icon: "Fish", hue: 190, edit: "Put the person on the back of a dolphin leaping over sparkling ocean waves in bright sunshine. Keep their face." },+ { effect: "Skatedog", line: "A dog on a skateboard rolls along right beside you.", rank: 8, icon: "Dog", hue: 95, edit: "Add a happy dog riding a skateboard next to the person on a sunny street. Keep the person exactly as they are." },];const slugOf = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");@@ -2134,11 +2196,19 @@ function effectChainTemplate(c: (typeof EFFECT_CHAINS)[number]): CanvasTemplatereturn {id: `effect-chain-${slugOf(c.effect)}`,name: c.effect,- // What the effect does, in the catalog's words (the section's note says how the chain works).- description: getPreset(`effect-${slugOf(c.effect)}`)?.description ?? "A photo, its scene set by an image edit, then animated with the effect",+ description: c.line,icon: c.icon,hue: c.hue,group: EFFECT_CHAIN_GROUP,+ rank: c.rank,+ makes: `A 5-second moving shot of you in the ${c.effect} scene.`,+ flow: ["Photo", "Scene", "Film"],+ // The photo its Video effect's own example starts from (a published example input: example-files.ts).+ samples: { photo: { src: `/examples/effect-${c.photo ?? slugOf(c.effect)}/1/in-image.jpg`, name: "Your photo.jpg" } },+ steps: ["Your photo goes in.", `An edit sets the scene: ${c.edit}`, `The ${c.effect} effect brings it to life as a 5-second moving shot.`],+ inputs: { photo: "A photo of a person, facing the camera." },+ // canvas-template-cards.ts adds the effect's own example, when it has one.+ oneStep: { href: `/video?preset=effect-${slugOf(c.effect)}`, label: "Try this effect in Video" },build: (engine) => {const graph = tpl([@@ -2151,7 +2221,7 @@ function effectChainTemplate(c: (typeof EFFECT_CHAINS)[number]): CanvasTemplatey: 0,data: { mediaKind: "video", label: c.effect, op: "i2v", modelId: EFFECT_CHAIN_MODELS.video, engine, prompt: words, params: { aspectRatio: "auto", duration: 5 } },},- { id: "out", type: "output", x: COL * 3, y: 40, data: { label: c.effect } },+ { id: "out", type: "output", x: COL * 3, y: 40, data: { label: "Your film" } },],[["photo", "scene", "images"],diff --git a/src/server/canvas-samples.ts b/src/server/canvas-samples.tsnew file mode 100644index 00000000..45018d85--- /dev/null+++ b/src/server/canvas-samples.ts@@ -0,0 +1,58 @@+import "server-only";+import crypto from "node:crypto";+import fs from "node:fs";+import path from "node:path";+import type { CanvasGraph, CanvasTemplate } from "@/lib/catalog/canvas";+import { db } from "./db";+import { exampleStat } from "./example-files";+import { absolutePath, contentTypeFor, getAsset, saveFile } from "./storage";++/**+ * A ready board's starting files (a template's `samples`): Fuobe's own public files, copied into the owner's storage+ * when the board is made, so its inputs hold a picture, a clip or a voice and "Run all" runs as it is. A canvas input+ * only takes a stored file (/api/files/…), so the copy is what the node names. Each file is stored once, as a file the+ * Library lists don't show ("derived"), and reused by the next board while it is still there.+ */++const PUBLIC_DIR = path.join(/*turbopackIgnore: true*/ process.cwd(), "public");++/** Where a template's sample may come from: Fuobe's published example inputs, its samples and its preview covers. */+const FOLDERS = ["/examples/", "/samples/", "/previews/presets/"];++/** The file on disk a sample names, or null: a plain path under one of FOLDERS, never one that steps out of public/. */+export function sampleFile(src: string): string | null {+ if (!FOLDERS.some((f) => src.startsWith(f)) || /[?#\\\0%]/.test(src) || src.split("/").some((p) => p === "..")) return null;+ // A published example input is read only when its bytes are the ones listed (example-files.ts).+ if (src.startsWith("/examples/")) return exampleStat(src)?.abs ?? null;+ const abs = path.resolve(PUBLIC_DIR, `.${src}`);+ return abs.startsWith(PUBLIC_DIR + path.sep) && fs.existsSync(abs) ? abs : null;+}++/** The stored copy of a sample: the one made before while its file is there, else a new one. Its name carries the content hash. */+function storedSample(abs: string): string {+ const data = fs.readFileSync(abs);+ const ext = path.extname(abs).toLowerCase();+ const key = `starter-${crypto.createHash("sha256").update(data).digest("hex").slice(0, 16)}${ext}`;+ const row = db().prepare("SELECT id FROM assets WHERE source = 'derived' AND name = ? AND account_id IS NULL ORDER BY created_at DESC LIMIT 1").get(key) as { id: string } | undefined;+ const known = row && getAsset(row.id);+ if (known && fs.existsSync(absolutePath(known.relPath))) return known.url;+ return saveFile({ data, contentType: contentTypeFor(abs), name: key, source: "derived" }).url;+}++/**+ * The board with its starting files in place: each input node a sample names gets the stored copy and a plain name. A+ * sample whose file isn't there leaves its input empty (the board still opens, and asks for that one file).+ */+export function fillSamples(graph: CanvasGraph, samples: CanvasTemplate["samples"]): CanvasGraph {+ if (!samples) return graph;+ return {+ ...graph,+ nodes: graph.nodes.map((n) => {+ const s = samples[n.id];+ if (!s || n.data.url) return n;+ const abs = sampleFile(s.src);+ if (!abs) return n;+ return { ...n, data: { ...n.data, url: storedSample(abs), name: s.name } };+ }),+ };+}diff --git a/src/server/canvas.ts b/src/server/canvas.tsindex 1149de72..65607eec 100644--- a/src/server/canvas.ts+++ b/src/server/canvas.ts@@ -52,6 +52,7 @@ import { createGenerations, getGeneration } from "./generations";import { silentWav } from "./marketing";import { engineMode } from "./settings";import { absolutePath, saveFile } from "./storage";+import { fillSamples } from "./canvas-samples";/*** Canvas boards (Higgsfield Canvas): the pages the user edits (each a graph, with its groups, comments and@@ -378,7 +379,8 @@ export function createCanvas(input: CreateCanvasInput = {}): Canvas {// A locked install only ever gets the variant it can run.const mode = engineMode();const engine: Engine = mode === "both" ? (input.engine ?? "cloud") : mode;- const graph = template ? template.build(engine, (id) => isOffered(id, engine)) : (input.graph ?? EMPTY_GRAPH);+ // A ready board starts with its sample files in place, so it runs as it is.+ const graph = template ? fillSamples(template.build(engine, (id) => isOffered(id, engine)), template.samples) : (input.graph ?? EMPTY_GRAPH);const pages = !template && input.pages?.length ? input.pages : [{ id: FIRST_PAGE_ID, name: pageName(0), graph: cleanGraph(graph) }];const now = Date.now();const row: Row = {diff --git a/tests/canvas-starter-create.test.ts b/tests/canvas-starter-create.test.tsnew file mode 100644index 00000000..91d0c30a--- /dev/null+++ b/tests/canvas-starter-create.test.ts@@ -0,0 +1,71 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterAll, describe, expect, it, vi } from "vitest";+import type { Canvas } from "@/lib/catalog/canvas";++// A ready board made by the owner starts with its sample files in place: each input node names a stored copy of the+// template's sample, the copy is made once and reused, the Library lists don't show it, and the board plans as it is.++vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));++const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-starter-"));+process.env.FUOBE_DATA_DIR = dir;+process.env.COMFYUI_URL = "http://127.0.0.1:9";++const { CANVAS_TEMPLATES, planCanvas } = await import("@/lib/catalog/canvas");+const { absolutePath, filesRel, listAssets } = await import("@/server/storage");+const { sampleFile } = await import("@/server/canvas-samples");+const list = await import("@/app/api/canvases/route");++afterAll(() => {+ try {+ fs.rmSync(dir, { recursive: true, force: true });+ } catch {}+});++const create = async (templateId: string, engine: "open" | "cloud") =>+ (await (await list.POST(new Request("http://localhost/api/canvases", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ templateId, engine }) }))).json()) as Canvas;++const starters = CANVAS_TEMPLATES.filter((t) => t.starter !== false);++describe("A ready board's sample files", () => {+ it("every sample a template names is a file Fuobe ships", () => {+ for (const t of starters) for (const [node, s] of Object.entries(t.samples ?? {})) expect(sampleFile(s.src), `${t.id} ${node} ${s.src}`).toBeTruthy();+ });++ it("every board that takes a picture, a clip or a voice names a sample for each", () => {+ const MEDIA = new Set(["image-input", "video-input", "audio-input", "clone-voice"]);+ for (const t of starters) for (const n of t.build("open").nodes.filter((x) => MEDIA.has(x.type))) expect(t.samples?.[n.id], `${t.id} ${n.id}`).toBeTruthy();+ });++ it("a sample path that steps out of its folders names nothing", () => {+ for (const bad of ["/examples/../../package.json", "/previews/presets/%2e%2e/x.mp4", "/etc/passwd", "/samples/clean-voice/nope.m4a", "/examples/effect-pearl-earring/1/in-image.jpg?x=1"]) expect(sampleFile(bad), bad).toBeNull();+ });+});++describe("Making a ready board", () => {+ it("fills each input with a stored copy of its sample, and the board plans as it is", async () => {+ for (const t of starters)+ for (const engine of ["open", "cloud"] as const) {+ const c = await create(t.id, engine);+ const graph = c.pages[0].graph;+ for (const [node, s] of Object.entries(t.samples ?? {})) {+ const n = graph.nodes.find((x) => x.id === node)!;+ expect(n.data.url, `${t.id} ${node}`).toMatch(/^\/api\/files\//);+ expect(n.data.name).toBe(s.name);+ const stored = fs.readFileSync(absolutePath(filesRel(n.data.url!)!));+ expect(stored.equals(fs.readFileSync(sampleFile(s.src)!)), `${t.id} ${node}`).toBe(true);+ }+ expect(planCanvas(graph, { engineMode: engine }).errors, `${t.id} ${engine}`).toEqual([]);+ }+ });++ it("stores each sample once and keeps it out of the Library", async () => {+ const a = await create("effect-chain-pearl-earring", "open");+ const b = await create("effect-chain-pearl-earring", "open");+ const url = (c: Canvas) => c.pages[0].graph.nodes.find((n) => n.id === "photo")!.data.url;+ expect(url(a)).toBe(url(b));+ expect(listAssets({}).length).toBe(0);+ });+});diff --git a/tests/canvas-starters.test.ts b/tests/canvas-starters.test.tsnew file mode 100644index 00000000..3d615c17--- /dev/null+++ b/tests/canvas-starters.test.ts@@ -0,0 +1,180 @@+import { createElement, type FC } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it } from "vitest";+import { getModel, getPreset } from "@/lib/catalog";+import { CANVAS_TEMPLATES, isGenerator, planCanvas } from "@/lib/catalog/canvas";+import { firstTemplates, moreTemplates, TEMPLATE_SECTIONS, templateSections, type Viewing } from "@/lib/canvas-sections";+import { canvasIntro, templateCards, templateDetail, templateIds } from "@/lib/canvas-template-cards";+import { guestRead, isLibraryChange } from "@/lib/guest-access";+import { templateCover } from "@/lib/template-covers";++// Canvas's first screen: what a canvas is, then ready boards (its templates) by section, each with a page of its own.+// Visitors see a board only once its real cover exists, and never the model names or the engine words.++const { TemplateCard } = await import("@/components/canvas/template-card");+const html = (props: Record<string, unknown>) => renderToStaticMarkup(createElement(TemplateCard as FC<Record<string, unknown>>, props));++const cards = templateCards();+const hasCover = (id: string) => !!templateCover("canvas", id);+const visitor: Viewing = { visitor: true, hasCover };+const owner: Viewing = { visitor: false, hasCover };++/** Words visitors never read on a card or a template's page. */+const ENGINE_WORDS = /Fuobe DoP|Effects 2\.0|\bGPU\b|Variant|\bComfyUI\b|\bfal\b|Replicate/;++describe("Canvas templates as ready boards", () => {+ it("each sits in a known section with a rank of its own, its steps and what it makes", () => {+ const keys = TEMPLATE_SECTIONS.map((s) => s.key as string);+ for (const t of CANVAS_TEMPLATES) {+ expect(keys, t.id).toContain(t.group ?? "");+ expect(t.steps.length, t.id).toBeGreaterThanOrEqual(2);+ expect(t.makes.length, t.id).toBeGreaterThan(10);+ }+ for (const s of TEMPLATE_SECTIONS) {+ const ranks = CANVAS_TEMPLATES.filter((t) => (t.group ?? "") === s.key).map((t) => t.rank);+ expect(new Set(ranks).size, s.title).toBe(ranks.length);+ }+ expect(CANVAS_TEMPLATES.filter((t) => t.starter === false).map((t) => t.id)).toEqual(["blockout-film"]);+ });++ it("say what they are in plain words: no model names, no engine words", () => {+ for (const t of CANVAS_TEMPLATES.filter((x) => x.starter !== false)) {+ const names = new Set<string>();+ for (const engine of ["cloud", "open"] as const)+ for (const n of t.build(engine).nodes.filter(isGenerator)) {+ const name = getModel(n.data.modelId ?? "")?.name;+ if (name && name.length > 4) names.add(name);+ }+ const words = [t.name, t.description, t.makes, ...t.steps, ...Object.values(t.inputs ?? {})].join("\n");+ expect(words, t.id).not.toMatch(ENGINE_WORDS);+ for (const name of names) expect(words, `${t.id}: ${name}`).not.toContain(name);+ }+ for (const s of TEMPLATE_SECTIONS) expect(`${s.title} ${s.note}`).not.toMatch(ENGINE_WORDS);+ });++ it("a card's line is short and speaks to the visitor, and its flow names each step in a word or two", () => {+ for (const t of CANVAS_TEMPLATES.filter((x) => x.starter !== false)) {+ expect(t.description.length, t.id).toBeLessThanOrEqual(90);+ expect(t.description, t.id).not.toMatch(/the subject/i);+ expect(t.flow.length, t.id).toBeGreaterThanOrEqual(2);+ for (const w of t.flow) expect(w.length, `${t.id} ${w}`).toBeLessThanOrEqual(10);+ }+ for (const t of CANVAS_TEMPLATES.filter((x) => x.group === "effect-films")) expect(t.description.length, t.id).toBeLessThanOrEqual(70);+ });++ it("the words a board starts with describe only what is wanted, with people as fashion models", () => {+ for (const t of CANVAS_TEMPLATES.filter((x) => x.starter !== false)) {+ const words = t+ .build("open")+ .nodes.map((n) => [n.data.text, n.data.prompt, ...(n.data.rows ?? []).flat()].filter(Boolean).join(" "))+ .join(" ");+ expect(words, t.id).not.toMatch(/\b(lighthouse|fisherman|fox|owl|otter|paper boat)\b/i);+ }+ });++ it("an effect film's board plans as it is once a photo is in", () => {+ for (const t of CANVAS_TEMPLATES.filter((x) => x.group === "effect-films"))+ for (const engine of ["cloud", "open"] as const) {+ const g = t.build(engine);+ g.nodes.find((n) => n.id === "photo")!.data.url = "/api/files/u/me.png";+ expect(planCanvas(g, { engineMode: engine }).errors, `${t.id} ${engine}`).toEqual([]);+ }+ });+});++describe("Who sees which ready board", () => {+ it("a visitor: only the boards with a real cover, the effect films in rank order, nothing else", () => {+ const sections = templateSections(cards, visitor);+ for (const s of sections) for (const t of s.items) expect(hasCover(t.id), t.id).toBe(true);+ const films = sections.find((s) => s.key === "effect-films")!;+ expect(films.items.map((t) => t.id)).toEqual(+ ["pearl-earring", "superstar", "fairytale-castle", "blue-depth", "agamemnon", "dolphin-ride", "skatedog"].filter((id) => hasCover(`effect-chain-${id}`)).map((id) => `effect-chain-${id}`),+ );+ // A section with nothing to show is left out; the owner's other templates aren't a visitor's.+ expect(sections.every((s) => s.items.length > 0)).toBe(true);+ expect(moreTemplates(cards, visitor)).toEqual([]);+ expect(sections.flatMap((s) => s.items).some((t) => t.id === "blockout-film")).toBe(false);+ });++ it("the owner: every ready board, covered first then by rank, and Blockout under More templates", () => {+ const sections = templateSections(cards, owner);+ expect(sections.map((s) => s.title)).toEqual(["Films and campaigns", "Effect films"]);+ const all = sections.flatMap((s) => s.items);+ expect(all).toHaveLength(CANVAS_TEMPLATES.length - 1);+ for (const s of sections) {+ const covered = s.items.map((t) => hasCover(t.id));+ expect(covered, s.title).toEqual([...covered].sort((a, b) => Number(b) - Number(a)));+ }+ expect(sections[0].items[0].id).toBe(hasCover("product-angles") ? "product-angles" : sections[0].items.find((t) => hasCover(t.id))?.id ?? "product-angles");+ expect(moreTemplates(cards, owner).map((t) => t.id)).toEqual(["blockout-film"]);+ });++ it("with boards of one's own, one short row: the first three covered boards", () => {+ const row = firstTemplates(cards, owner);+ expect(row).toHaveLength(3);+ expect(row.every((t) => hasCover(t.id))).toBe(true);+ expect(row[0].id).toBe("effect-chain-pearl-earring");+ });+});++describe("A template's card", () => {+ const t = cards.find((c) => c.id === "effect-chain-pearl-earring")!;+ const blank = cards.find((c) => c.id === "script-film")!;++ it("for a visitor: the cover, a link to its page and plain words, no models", () => {+ const h = html({ t, engine: "open", busy: false });+ expect(h).toContain('href="/canvas/start/effect-chain-pearl-earring"');+ expect(h).toContain("See how it works");+ expect(h).toContain("/previews/presets/peak/effect-pearl-earring.jpg?v=");+ expect(h).not.toContain("Use template");+ expect(h).not.toMatch(ENGINE_WORDS);+ for (const m of t.byEngine.open.models) expect(h).not.toContain(m);+ });++ it("for the owner: Use template, the models it runs on, and No cover yet where visitors see nothing", () => {+ const h = html({ t, engine: "open", busy: false, owner: true, onUse: () => {} });+ expect(h).toContain("Use template");+ expect(h).toContain(t.byEngine.open.models[0]);+ expect(h).toContain("free on your GPU");+ expect(h).not.toContain("No cover yet");+ expect(html({ t: blank, engine: "open", busy: false, owner: true, onUse: () => {} })).toContain(hasCover("script-film") ? "Use template" : "No cover yet");+ });+});++describe("A template's page and the first screen's strip", () => {+ it("every template has a prerendered page; an unknown one has none", () => {+ expect(templateIds()).toEqual(CANVAS_TEMPLATES.map((t) => t.id));+ expect(templateDetail("no-such-board")).toBeUndefined();+ });++ it("an effect film says what goes in, its steps, what comes out, and links to its Video effect", () => {+ const d = templateDetail("effect-chain-pearl-earring")!;+ expect(d.inputs).toMatchObject([{ id: "photo", type: "image-input", label: "Your photo", hint: "A photo of a person, facing the camera." }]);+ expect(d.steps).toHaveLength(3);+ expect(d.steps[1]).toMatch(/^An edit sets the scene: Repaint the picture as a Dutch Golden Age oil portrait/);+ expect(d.makes).toMatch(/moving shot/);+ // One tap gives a filled, ready shot: the effect's own example is loaded.+ expect(d.oneStep).toEqual({ href: "/video?preset=effect-pearl-earring&example=effect-pearl-earring.1", label: "Try this effect in Video" });+ expect(d.inputs[0].sample).toMatchObject({ kind: "image", thumb: expect.stringMatching(/^\/examples\/effect-pearl-earring\/1\/in-image\.384\.webp\?v=/) });+ for (const c of CANVAS_TEMPLATES.filter((x) => x.oneStep)) expect(getPreset(c.oneStep!.href.split("preset=")[1]), c.id).toBeTruthy();+ });++ it("a board's words show as they start: a prompt's text, a table's rows", () => {+ expect(templateDetail("image-animate")!.inputs[0]).toMatchObject({ type: "prompt", text: expect.any(String) });+ const table = templateDetail("table-film")!.inputs.find((i) => i.type === "table")!;+ expect(table.table!.rows.length).toBeGreaterThan(0);+ });++ it("the strip is one real effect film: its first frame, its peak and its clip, each at a versioned URL", () => {+ const intro = canvasIntro()!;+ expect(intro.photo.src).toMatch(/^\/previews\/presets\/effect-pearl-earring\.jpg\?v=[0-9a-f]{8}$/);+ expect(intro.film.poster).toMatch(/\?v=[0-9a-f]{8}$/);+ expect(intro.film.video).toMatch(/\.mp4\?v=[0-9a-f]{8}$/);+ expect(canvasIntro("script-film")).toBeUndefined();+ });++ it("is open to guests (a page), while making a board stays the owner's", () => {+ expect(guestRead("/canvas/start/effect-chain-pearl-earring")).toEqual({ kind: "pass" });+ expect(isLibraryChange("POST", "/api/canvases")).toBe(true);+ });+});diff --git a/tests/canvas.test.ts b/tests/canvas.test.tsindex 2c4e02b1..1155cf74 100644--- a/tests/canvas.test.ts+++ b/tests/canvas.test.ts@@ -337,7 +337,7 @@ describe("canvas graph → plan", () => {const plan = planCanvas(g);expect(plan.errors).toEqual([]);expect(plan.steps).toHaveLength(3);- expect(plan.steps.every((s) => s.deps.length === 0 && s.request.prompt?.startsWith("Portrait of an elderly fisherman"))).toBe(true);+ expect(plan.steps.every((s) => s.deps.length === 0 && s.request.prompt?.startsWith("Editorial beauty portrait"))).toBe(true);expect(new Set(plan.steps.map((s) => s.request.modelId)).size).toBe(3);});});@@ -394,19 +394,19 @@ describe("canvas templates", () => {// The shot text is written from the script…expect(step(`beat${i}`).request).toMatchObject({ modelId: llm, op: "write" });expect(step(`beat${i}`).request.prompt).toContain(`shot ${i} of 3`);- expect(step(`beat${i}`).request.prompt).toContain("A paper boat sails down");+ expect(step(`beat${i}`).request.prompt).toContain("emerald silk ball gown");// …and becomes the frame's prompt and the shot's prompt (with the frame as its start).expect(step(`frame${i}`)).toMatchObject({ deps: [`beat${i}`], request: { chain: [{ slot: "prompt" }] } });expect(step(`frame${i}`).request.prompt).toContain("{text}");expect(step(`shot${i}`).deps).toEqual([`beat${i}`, `frame${i}`]);expect(step(`shot${i}`).request.chain).toEqual([{ slot: "prompt" }, { slot: "images", position: "first" }]);}- // A new script changes what every shot is written from: no paper boat left anywhere.+ // A new script changes what every shot is written from: no gown left anywhere.g.nodes.find((n) => n.id === "script")!.data.text = "An astronaut plants a flower on Mars";const again = planCanvas(g, { engineMode: engine });const prompts = again.steps.map((s) => s.request.prompt ?? "").join("\n");expect(prompts).toContain("An astronaut plants a flower on Mars");- expect(prompts).not.toMatch(/boat/i);+ expect(prompts).not.toMatch(/gown/i);});it("disables palette entries with no model on an install's only engine", () => {diff --git a/tests/e2e/canvas-starters.mjs b/tests/e2e/canvas-starters.mjsnew file mode 100644index 00000000..75593204--- /dev/null+++ b/tests/e2e/canvas-starters.mjs@@ -0,0 +1,187 @@+// Canvas's first screen, as a guest, a fresh account and the owner, at 390 and 1440 px: "What's a canvas?" and the ready+// boards come first while the viewer has no boards of their own; visitors see only boards with a real cover and no+// model or engine words; a card opens the board's page, an effect film's page links to its Video effect with the+// effect's example loaded; the owner's "Use template" makes the board, which runs as it is ("Run all" in demo mode,+// nothing left to add), after which their boards lead and one template row sits below.+//+// node tests/e2e/canvas-starters.mjs <app address> <owner password> [screenshot folder]+// Against `next start` with a fresh data dir, FUOBE_PUBLIC_SIGNUP=1 and demo mode on (FUOBE_DEMO_MODE=on): the+// boards run on demo outputs, never on a model.+import fs from "node:fs";+import path from "node:path";+import { launch, PHONE, DESKTOP } from "./_browser.mjs";++const [app, password, shots] = process.argv.slice(2);+if (!app || !password) throw new Error("usage: node tests/e2e/canvas-starters.mjs <app address> <owner password> [screenshot folder]");+if (shots) fs.mkdirSync(shots, { recursive: true });++const ENGINE_WORDS = /Fuobe DoP|Effects 2\.0|\bGPU\b|Variant|Qwen|MiniMax|Nano Banana|Seedance|Wan VACE|Kling|Chatterbox|InfiniteTalk/;+const failures = [];+const check = (name, ok, detail = "") => {+ console.log(`${ok ? "ok " : "FAIL"} ${name}${detail ? ` (${detail})` : ""}`);+ if (!ok) failures.push(name);+};++async function signIn(ctx, persona) {+ if (persona === "owner") {+ const r = await ctx.request.post(`${app}/api/auth/login`, { data: { password } });+ if (!r.ok()) throw new Error(`owner login ${r.status()}`);+ } else if (persona === "account") {+ const email = `canvas-starters-${Date.now()}-${Math.random().toString(36).slice(2, 6)}@example.com`;+ const r = await ctx.request.post(`${app}/api/auth/signup`, { data: { email, password: "canvas-starters-pw-123" } });+ if (!r.ok()) throw new Error(`signup ${r.status()}`);+ }+}++const browser = await launch();+try {+ for (const persona of ["guest", "account", "owner"]) {+ for (const [size, device] of [+ ["390", PHONE],+ ["1440", DESKTOP],+ ]) {+ const tag = `${persona} ${size}`;+ const ctx = await browser.newContext({ ...device, colorScheme: "light" });+ await signIn(ctx, persona);+ const page = await ctx.newPage();+ page.setDefaultTimeout(30_000);+ const errors = [];+ page.on("pageerror", (e) => errors.push(`${page.url()} :: ${String(e).slice(0, 200)}`));+ const shot = async (name) => shots && page.screenshot({ path: path.join(shots, `${name}--${persona}--${size}.png`), fullPage: false });+ const fullShot = async (name) => shots && page.screenshot({ path: path.join(shots, `${name}--${persona}--${size}--full.png`), fullPage: true });+ const sideways = () => page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth);+ const text = () => page.locator("main, body").first().innerText();++ // ---- The first screen, with no boards of one's own+ await page.goto(`${app}/canvas`, { waitUntil: "load", timeout: 180_000 });+ const intro = page.getByRole("heading", { name: "What's a canvas?" });+ await intro.waitFor();+ if (persona === "owner") await page.getByRole("button", { name: "Use template" }).first().waitFor();+ else await page.waitForTimeout(1500);+ const order = await page.evaluate(() => [...document.querySelectorAll("h2")].map((h) => h.textContent?.trim()));+ check(`${tag}: "What's a canvas?" leads, then the ready boards`, order[0] === "What's a canvas?" && order[1] === "Start from a ready board", order.join(" | "));+ check(`${tag}: the strip shows a photo, a scene and a moving shot`, (await page.getByText("Your photo", { exact: true }).count()) > 0 && (await page.getByText("A moving shot", { exact: true }).count()) > 0);+ const cards = page.locator("#templates article");+ const n = await cards.count();+ const covered = await cards.evaluateAll((els) => els.filter((e) => e.querySelector("img")).length);+ const t = await text();+ if (persona === "owner") {+ check(`${tag}: the owner sees every ready board and More templates`, n >= 18 && /More templates/.test(t), `${n} cards`);+ check(`${tag}: a board without a cover is marked for the owner`, (await page.getByText("No cover yet").count()) > 0);+ check(`${tag}: the owner sees what a board runs on`, /Fuobe DoP/.test(t));+ } else {+ check(`${tag}: a visitor sees only boards with a real cover`, n > 0 && covered === n, `${covered}/${n}`);+ check(`${tag}: no model or engine words for a visitor`, !ENGINE_WORDS.test(t), (t.match(ENGINE_WORDS) ?? [""])[0]);+ check(`${tag}: no "No cover yet" or More templates for a visitor`, !/No cover yet|More templates|Use template/.test(t));+ check(`${tag}: the visitor's action is to see how it works`, (await page.getByText("See how it works").count()) === n);+ check(`${tag}: no "isn't available here" note for a visitor`, !/isn.t available here/.test(t));+ const firstCard = await cards.first().evaluate((e) => e.getBoundingClientRect().top);+ const vh = await page.evaluate(() => window.innerHeight);+ check(`${tag}: the first card starts on the first screen`, firstCard < vh - 120, `${Math.round(firstCard)} of ${vh} px`);+ }+ check(`${tag}: no sideways scroll on /canvas`, (await sideways()) <= 1, `${await sideways()} px`);+ await shot("canvas-first");+ await fullShot("canvas-first");++ // ---- A ready board's page+ await page.locator("#templates article", { hasText: "Pearl Earring" }).getByRole("link", { name: "Pearl Earring" }).click();+ await page.waitForURL(/\/canvas\/start\/effect-chain-pearl-earring$/);+ await page.getByRole("heading", { name: "What goes in" }).waitFor();+ const pt = await text();+ check(`${tag}: the page says what goes in, the steps and what comes out`, /The steps/i.test(pt) && /What comes out/i.test(pt) && /An edit sets the scene/.test(pt));+ check(`${tag}: no sideways scroll on the board's page`, (await sideways()) <= 1, `${await sideways()} px`);+ await shot("canvas-start-pearl-earring");+ if (persona === "owner") {+ check(`${tag}: the owner can use the board from its page`, (await page.getByRole("button", { name: "Use template" }).count()) === 1);+ } else {+ check(`${tag}: no model or engine words on the board's page`, !ENGINE_WORDS.test(pt), (pt.match(ENGINE_WORDS) ?? [""])[0]);+ check(`${tag}: the page has no "isn't available here" note, one quiet line instead`, !/isn.t available here/.test(pt) && /One tap opens it with a photo ready/.test(pt));+ await page.getByRole("link", { name: "Try this effect in Video" }).click();+ await page.waitForURL(/\/video\?preset=effect-pearl-earring&example=effect-pearl-earring\.1/);+ await page.getByText("Pearl Earring").first().waitFor({ timeout: 60_000 }).catch(() => {});+ await page.waitForTimeout(2500);+ const vt = await text();+ check(`${tag}: the Video effect opens with the effect and its example loaded`, /Pearl Earring/i.test(vt) && /In the composer/.test(vt));+ await shot("video-from-canvas");+ // A board that visitors don't get to see yet.+ await page.goto(`${app}/canvas/start/script-film`, { waitUntil: "load" });+ await page.getByText("This board isn't here.").waitFor({ timeout: 30_000 }).catch(() => {});+ check(`${tag}: a board without its cover isn't shown to a visitor`, /This board isn.t here/.test(await text()) && !/The steps/i.test(await text()));+ }+ // An unknown board.+ // (Its status is 404 once the route is warm; the first render streams the not-found page under a 200.)+ const missing = await page.goto(`${app}/canvas/start/no-such-board`, { waitUntil: "load" });+ await page.getByText("This page isn’t here").first().waitFor({ timeout: 30_000 }).catch(() => {});+ check(`${tag}: an unknown board is not found`, /This page isn’t here/.test(await text()), String(missing?.status()));++ // ---- The owner makes a board; then their boards lead+ if (persona === "owner" && size === "1440") {+ await page.goto(`${app}/canvas`, { waitUntil: "load" });+ await page.locator("#templates article", { hasText: "Pearl Earring" }).getByRole("button", { name: "Use template" }).click();+ await page.waitForURL(/\/canvas\/(?!start)[^/?]+$/, { timeout: 60_000 });+ await page.getByText("Set the scene").first().waitFor({ timeout: 60_000 }).catch(() => {});+ check(`${tag}: Use template opens the board with its steps`, /Set the scene/.test(await text()));+ await shot("canvas-board-from-template");+ await page.goto(`${app}/canvas`, { waitUntil: "load" });+ await page.getByRole("heading", { name: "Your canvases" }).waitFor();+ const h2 = await page.evaluate(() => [...document.querySelectorAll("h2")].map((h) => h.textContent?.trim()));+ check(`${tag}: with a board, their boards lead and one template row sits below`, h2[0] === "Your canvases" && h2[1] === "Start from a template" && !h2.includes("What's a canvas?"), h2.join(" | "));+ check(`${tag}: the row has three cards and See all templates`, (await page.locator("#templates article").count()) === 3 && (await page.getByRole("button", { name: "See all templates" }).count()) === 1);+ await shot("canvas-with-boards");+ await page.getByRole("button", { name: "See all templates" }).click();+ check(`${tag}: See all templates opens the sections`, (await page.getByRole("heading", { name: "Effect films" }).count()) === 1);+ await page.goto(`${app}/canvas?tab=templates`, { waitUntil: "load" });+ await page.getByRole("heading", { name: "Effect films" }).waitFor();+ const top = await page.evaluate(() => document.getElementById("templates")?.getBoundingClientRect().top ?? 9999);+ check(`${tag}: ?tab=templates opens the templates, scrolled to`, top < 200, `${Math.round(top)} px`);+ await shot("canvas-tab-templates");+ }+ // ---- Every ready board runs as it is: Use template, then Run all (demo mode), and nothing needs attention+ if (persona === "owner" && size === "1440") {+ await page.goto(`${app}/canvas?tab=templates`, { waitUntil: "load" });+ await page.getByRole("heading", { name: "Effect films" }).waitFor();+ const ids = await page+ .locator("#templates section:not(:has(#tpl-more)) article a[href^='/canvas/start/']")+ .evaluateAll((as) => [...new Set(as.map((a) => a.getAttribute("href").split("/").pop()))]);+ check(`${tag}: every ready board is listed for the owner`, ids.length >= 17, `${ids.length}`);+ for (const id of ids) {+ await page.goto(`${app}/canvas/start/${id}`, { waitUntil: "load" });+ await page.getByRole("button", { name: "Use template" }).click();+ await page.waitForURL(/\/canvas\/(?!start)[^/?]+$/, { timeout: 60_000 });+ const run = page.getByRole("button", { name: /^Run all$/ }).first();+ await run.waitFor();+ await page.waitForTimeout(1500);+ const before = await text();+ const enabled = await run.isEnabled();+ if (enabled) {+ await run.click();+ const t0 = Date.now();+ await page.waitForTimeout(4000);+ while (Date.now() - t0 < 180_000 && (await page.getByText(/^\d+ running$/).count())) await page.waitForTimeout(2000);+ }+ await page.waitForTimeout(1500);+ const after = await text();+ const problem = (before + "\n" + after).match(/[^\n]*(need(s)? attention|Add an? [a-z]+ to|failed|couldn.t)[^\n]*/i)?.[0];+ check(`${tag}: ${id} runs as it is`, enabled && !problem, problem ?? (enabled ? "" : "Run all is off"));+ await shot(`board-run-${id}`);+ }+ }+ if (persona === "owner" && size === "390") {+ await page.goto(`${app}/canvas/start/script-film`, { waitUntil: "load" });+ await page.getByRole("heading", { name: "The steps" }).waitFor();+ check(`${tag}: the owner sees a board without a cover, marked`, (await page.getByText("No cover yet").count()) > 0);+ await shot("canvas-start-script-film");+ }+ check(`${tag}: no page errors`, errors.length === 0, errors[0]);+ await ctx.close();+ }+ }+} finally {+ await browser.close();+}++if (failures.length) {+ console.log(`\n${failures.length} check(s) failed`);+ process.exit(1);+}+console.log("\nall checks passed");diff --git a/tests/e2e/popcorn-evolution.mjs b/tests/e2e/popcorn-evolution.mjsindex 1f880989..5d55b52e 100644--- a/tests/e2e/popcorn-evolution.mjs+++ b/tests/e2e/popcorn-evolution.mjs@@ -5,7 +5,7 @@// hosted on fal (Wan 2.2 Fun VACE, no LTX-2.3), 480p / 580p / 720p, and says in one line what stays on the GPU; the open// engine says "on your GPU". Storyboard: the cloud board runs on Fuobe's open recipe with Nano Banana Pro a partner choice, the look chip// starts at "No look", a look is picked, the board's price is shown, a board in that look is made. Canvas: the-// Effects 2.0 chains have their own section and one opens as a canvas with the edit and the effect. Nothing scrolls+// effect films have their own section and one opens as a canvas with the edit and the effect. Nothing scrolls// sideways. Usage: node tests/e2e/popcorn-evolution.mjs [appUrl] [--shots <dir>]. Exits 1 on a failed check.import fs from "node:fs";import path from "node:path";@@ -158,12 +158,12 @@ try {check(`${tag}: a board in the look is made (demo)`, board && /Fuobe Soul/.test(await text()));check(`${tag}: no sideways scroll (Storyboard with a board)`, (await sideways()) <= 1, `${await sideways()} px`);- // ---- Canvas: Effects 2.0 chains+ // ---- Canvas: effect filmsawait page.goto(`${app}/canvas?tab=templates`, { waitUntil: "load", timeout: 180_000 });- const section = page.getByRole("heading", { name: "Effects 2.0 chains" });+ const section = page.getByRole("heading", { name: "Effect films" });await section.waitFor({ timeout: 120_000 });const cards = await page.locator("section", { has: section }).getByRole("button", { name: "Use template" }).count();- check(`${tag}: the Effects 2.0 chains have their own section`, cards >= 10, `${cards} cards`);+ check(`${tag}: the effect films have their own section`, cards >= 10, `${cards} cards`);check(`${tag}: the chain cards name their models`, /Qwen-Image-Edit 2511 \(hosted\) · Fuobe DoP/.test(await text()));check(`${tag}: no sideways scroll (templates)`, (await sideways()) <= 1, `${await sideways()} px`);await shot("canvas-templates");diff --git a/tests/preset-covers.test.ts b/tests/preset-covers.test.tsindex 644dc491..66ee2935 100644--- a/tests/preset-covers.test.ts+++ b/tests/preset-covers.test.ts@@ -182,6 +182,7 @@ describe("the preset covers manifest", () => {"components/cinema/move-list.tsx","components/preset-header.tsx","components/studio/preset-chips.tsx",+ "lib/canvas-template-cards.ts","lib/nav-covers.ts","lib/palette-index.ts",]);diff --git a/tests/template-cover-tiles.test.ts b/tests/template-cover-tiles.test.tsindex 36bc8a83..0199fe1d 100644--- a/tests/template-cover-tiles.test.ts+++ b/tests/template-cover-tiles.test.ts@@ -49,7 +49,7 @@ const { StyleTile } = await import("@/components/marketing/click-to-ad");const { TemplatePreview: FashionPreview } = await import("@/components/fashion/template-preview");const { PackCover } = await import("@/components/photodump/covers");const { LookCard } = await import("@/components/shorts/preset-card");-const { TemplateCard: CanvasCard } = await import("@/components/canvas/canvas-list");+const { TemplateCard: CanvasCard } = await import("@/components/canvas/template-card");const { PresetTile } = await import("@/components/content-factory/parts");const { StyleArt } = await import("@/components/faceless/style-art");const { AD_STYLES, TEMPLATES } = await import("@/lib/catalog/marketing");@@ -184,13 +184,14 @@ describe("Canvas templates", () => {const card = (id: string) => {const t = by(CANVAS_TEMPLATES, id);const engine = { outline: outline(t.build("cloud")), models: [] };- return html(CanvasCard, { t: { id: t.id, name: t.name, description: t.description, icon: t.icon, hue: t.hue, byEngine: { cloud: engine, open: engine } }, engine: "cloud", busy: false });+ return html(CanvasCard, { t: { id: t.id, name: t.name, description: t.description, icon: t.icon, hue: t.hue, section: t.group ?? "", rank: t.rank, flow: t.flow, byEngine: { cloud: engine, open: engine } }, engine: "cloud", busy: false });};- it("show the cover's frames side by side with the board in a corner, or its still and clip, else the board", () => {+ it("show the cover's frames side by side with its steps in a corner, or its still and clip, else the board", () => {const angles = card("product-angles");for (const f of ["product-angles.jpg?v=e7f8091a", "product-angles-2.jpg?v=f8091a2b", "product-angles-3.jpg?v=091a2b3c"]) expect(angles).toContain(`src="/previews/templates/canvas/${f}"`);- expect(angles).toContain("<svg viewBox=");+ expect(angles).toContain("3 angles");+ expect(angles).not.toContain("<svg viewBox=");const chain = card("effect-chain-fallen-angel");expect(chain).toContain('src="/previews/presets/effect-fallen-angel.jpg?v=1a2b3c4e"');expect(chain).not.toContain("<video");