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
Starters: only finished ones reach visitors, narrated starters run as they are
Adarsh682107e14eb4
diff --git a/src/app/api/starters/route.ts b/src/app/api/starters/route.tsnew file mode 100644index 00000000..1b69a29b--- /dev/null+++ b/src/app/api/starters/route.ts@@ -0,0 +1,13 @@+import { STARTER_SURFACES, type StarterSurface } from "@/lib/starters/types";+import { startersForOwner } from "@/server/starters";++/**+ * Every ready-made starter of a studio, with the ones that have no cover yet, for the owner: a studio's page carries+ * only the covered ones (the same prerendered page for everyone), and the owner's view adds the rest from here. A guest+ * gets 401 and an account 403 before this runs (the owner's library: guestRead "closed").+ */+export async function GET(request: Request) {+ const surface = new URL(request.url).searchParams.get("surface") ?? "";+ if (!Object.hasOwn(STARTER_SURFACES, surface)) return Response.json({ error: "Name a studio" }, { status: 400 });+ return Response.json(startersForOwner(surface as StarterSurface), { headers: { "Cache-Control": "no-store" } });+}diff --git a/src/components/ads/ads-home.tsx b/src/components/ads/ads-home.tsxindex 48817938..801a4448 100644--- a/src/components/ads/ads-home.tsx+++ b/src/components/ads/ads-home.tsx@@ -10,7 +10,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTriggeimport { Skeleton } from "@/components/ui/skeleton";import { BrandStart } from "@/components/brand/brand-dialog";import { SelfHostNote } from "@/components/self-host-note";-import { StarterSection } from "@/components/starters/starter-section";+import { StarterSection, useStarters } from "@/components/starters/starter-section";import { ExampleRow } from "@/components/studio/example-row";import { useIsOwner, useIsVisitor } from "@/lib/api";import { ResearchLabel } from "@/components/brand/research-progress";@@ -104,7 +104,8 @@ function DeleteBrand({ brand, onClose }: { brand: BrandKit | null; onClose: () =* examples: "More to try" (exampleRow(), from the page), while there are no brands of one's own.* starters: the ready brand kits (src/lib/starters/catalog.ts), first while there are no brands, one row under them after.*/-export function AdsHome({ examples, starters = [] }: { examples?: ExampleRowData | null; starters?: StarterCardData[] }) {+export function AdsHome({ examples, starters: given = [] }: { examples?: ExampleRowData | null; starters?: StarterCardData[] }) {+ const { starters } = useStarters("ads", given);const router = useRouter();const { engine, setEngine } = useMarketingEngine();const brands = useBrands();@@ -133,7 +134,7 @@ export function AdsHome({ examples, starters = [] }: { examples?: ExampleRowData</div></section>- {!brands.isLoading && !hasBrands && <StarterSection starters={starters} className="mt-12" />}+ {!brands.isLoading && !hasBrands && <StarterSection surface="ads" starters={given} className="mt-12" />}{!!moreToTry?.cards.length && (visitor || (brands.isSuccess && !brands.data.length)) && <ExampleRow row={moreToTry} className="mt-12" />}@@ -167,7 +168,7 @@ export function AdsHome({ examples, starters = [] }: { examples?: ExampleRowData</section>)}- {hasBrands && <StarterSection starters={starters} row className="mt-12" />}+ {hasBrands && <StarterSection surface="ads" starters={given} row className="mt-12" />}<section className="mt-12 grid gap-4 md:grid-cols-2"><Link href="/ads/multiplier" className={cn("group flex items-center gap-4 rounded-2xl border bg-background p-4 transition-shadow hover:shadow-soft")}>diff --git a/src/components/content-factory/home.tsx b/src/components/content-factory/home.tsxindex 85deeeb6..bf2291da 100644--- a/src/components/content-factory/home.tsx+++ b/src/components/content-factory/home.tsx@@ -17,7 +17,7 @@ import { NarratorChip } from "@/components/faceless/narrator";import { StyleArt } from "@/components/faceless/style-art";import { SelfHostNote } from "@/components/self-host-note";import { StarterParam } from "@/components/starters/starter-param";-import { StarterSection } from "@/components/starters/starter-section";+import { StarterSection, useStarters } from "@/components/starters/starter-section";import { useEdgeFade } from "@/components/studio/use-edge-fade";import { uploadFile, useEngine, useHydrated, useIsOwner, useLikelyVisitor } from "@/lib/api";import {@@ -71,7 +71,8 @@ function chipTrigger(className?: string) {* starters: the ready series (src/lib/starters/catalog.ts), right under the composer while you have none, one row under* yours after; fills: what each one puts in the composer.*/-export function ContentFactoryHome({ voices, starters = [], fills = {} }: { voices: PickerData["voices"]; starters?: StarterCardData[]; fills?: Record<string, StarterFill> }) {+export function ContentFactoryHome({ voices, starters: given = [], fills: givenFills = {} }: { voices: PickerData["voices"]; starters?: StarterCardData[]; fills?: Record<string, StarterFill> }) {+ const { starters, fills } = useStarters("content-factory", given, givenFills);const router = useRouter();const [engine, setEngine] = useEngine();const [mode, setMode] = useState<"here" | "claude">("here");@@ -121,6 +122,7 @@ export function ContentFactoryHome({ voices, starters = [], fills = {} }: { voic}, [gone]);const view = seriesId ? series.data : undefined;+ const briefFolded = !view && !hasSeries;const preset = getPreset(view?.reference?.presetId ?? presetId);const brief = view ? view.brief : (preset?.brief ?? null);const reading = view?.analysis?.status === "reading";@@ -196,16 +198,19 @@ export function ContentFactoryHome({ voices, starters = [], fills = {} }: { voic/** A ready series in the composer: its trending style, its idea, its length; the style brings its own look. */const fill = (id: string) => {const f = fills[id];- if (f?.kind !== "content-factory") return;+ if (f?.kind !== "content-factory") return false;choosePreset(f.presetId);setPrompt(f.prompt);setLength(f.length);setEpisodes(f.episodes);+ // Open source narration clones a voice: the starter's own narrator, while it has one.+ if (engine === "open" && f.voiceSample) setVoice({ kind: "sample", url: f.voiceSample, name: "Narrator" });setMode("here");requestAnimationFrame(() => {promptRef.current?.scrollIntoView({ block: "center", behavior: "smooth" });promptRef.current?.focus({ preventScroll: true });});+ return true;};const blocker = !prompt.trim() ? "Say what the video is about" : reading ? "The reference is still being read — a moment" : !brief ? "Add a reference or pick a preset" : null;@@ -488,6 +493,9 @@ export function ContentFactoryHome({ voices, starters = [], fills = {} }: { voic{brief && !reading && (<BriefCard+ // A preset's brief, before there are any series, is one line: the ready series sit right under the composer.+ key={briefFolded ? "folded" : "open"}+ folded={briefFolded}className="mt-4"brief={brief}note={view?.analysis?.note}@@ -505,7 +513,7 @@ export function ContentFactoryHome({ voices, starters = [], fills = {} }: { voic)}</div>- {!list.isLoading && !hasSeries && <StarterSection starters={starters} onFill={fill} />}+ {!list.isLoading && !hasSeries && <StarterSection surface="content-factory" starters={given} onFill={fill} />}<section id="presets" aria-labelledby="presets-title" className="scroll-mt-16 space-y-4"><div>@@ -546,7 +554,7 @@ export function ContentFactoryHome({ voices, starters = [], fills = {} }: { voic</section>)}- {hasSeries && <StarterSection starters={starters} onFill={fill} row />}+ {hasSeries && <StarterSection surface="content-factory" starters={given} onFill={fill} row />}<section aria-label="How it works" className="grid gap-3 sm:grid-cols-3">{STEPS.map((s, i) => (diff --git a/src/components/content-factory/parts.tsx b/src/components/content-factory/parts.tsxindex ca5a4aa1..15d7ca20 100644--- a/src/components/content-factory/parts.tsx+++ b/src/components/content-factory/parts.tsx@@ -1,6 +1,6 @@"use client";-import { AlertTriangle, Check, Copy, Film, Info, Loader2, Pencil, RotateCcw, Sparkles, Terminal, X } from "lucide-react";+import { AlertTriangle, Check, ChevronDown, Copy, Film, Info, Loader2, Pencil, RotateCcw, Sparkles, Terminal, X } from "lucide-react";import Link from "next/link";import { useQuery } from "@tanstack/react-query";import { useId, useState } from "react";@@ -135,24 +135,39 @@ const EDITABLE: { key: EditableKey; label: string }[] = [];/** What every episode follows: format, hook, pacing, shots, narrator, music and captions — with the reading's note, and an editor. */-export function BriefCard({ brief, note, onSave, saving, className }: { brief: StyleBrief; note?: string; onSave?: (b: StyleBrief) => void; saving?: boolean; className?: string }) {+/**+ * The style brief every episode follows, with Edit. `folded`: it starts as one line that opens on a tap (Content+ * Factory's home while there are no series yet, so its ready series stay near the composer).+ */+export function BriefCard({ brief, note, onSave, saving, className, folded = false }: { brief: StyleBrief; note?: string; onSave?: (b: StyleBrief) => void; saving?: boolean; className?: string; folded?: boolean }) {const [draft, setDraft] = useState<StyleBrief | null>(null);+ const [open, setOpen] = useState(!folded);const id = useId();+ const shut = !open && !draft;return (- <section aria-labelledby={`${id}-t`} className={cn("rounded-2xl border bg-background p-4 text-left", className)}>+ <section aria-labelledby={`${id}-t`} className={cn("rounded-2xl border bg-background text-left", shut ? "px-4 py-2.5" : "p-4", className)}><div className="flex items-center gap-2"><Sparkles className="size-4 shrink-0 text-brand-text" /><h3 id={`${id}-t`} className="text-[14px] font-medium">Style brief</h3>- <span className="text-[12px] text-muted-foreground">every episode follows it</span>- {onSave && !draft && (- <Button variant="ghost" size="sm" className="ml-auto h-7 rounded-full" onClick={() => setDraft(brief)}>- <Pencil /> Edit- </Button>+ <span className="min-w-0 truncate text-[12px] text-muted-foreground">every episode follows it</span>+ {!draft && (+ <div className="ml-auto flex shrink-0 items-center gap-1">+ {onSave && !shut && (+ <Button variant="ghost" size="sm" className="h-7 rounded-full" onClick={() => setDraft(brief)}>+ <Pencil /> Edit+ </Button>+ )}+ {folded && (+ <Button variant="ghost" size="sm" className="h-7 rounded-full" aria-expanded={open} aria-controls={`${id}-b`} onClick={() => setOpen((v) => !v)}>+ {open ? "Hide" : "Show"} <ChevronDown className={cn("transition-transform", open && "rotate-180")} />+ </Button>+ )}+ </div>)}</div>- {note && (+ {note && !shut && (<p className="mt-2 flex items-start gap-1.5 rounded-lg bg-warning/10 px-2.5 py-2 text-[12px] text-foreground"><Info className="mt-0.5 size-3.5 shrink-0 text-warning" /><span className="min-w-0">{note}</span>@@ -207,7 +222,7 @@ export function BriefCard({ brief, note, onSave, saving, className }: { brief: S</div></form>) : (- <ul className="mt-3 grid gap-x-6 gap-y-1.5 text-[13px] leading-snug sm:grid-cols-2">+ <ul id={`${id}-b`} hidden={shut} className="mt-3 grid gap-x-6 gap-y-1.5 text-[13px] leading-snug sm:grid-cols-2">{[...briefLines(brief), `Look: ${brief.look}`].map((l) => {const [k, ...v] = l.split(": ");return (diff --git a/src/components/explainer/explainer-studio.tsx b/src/components/explainer/explainer-studio.tsxindex ec92ebd3..545f2cb8 100644--- a/src/components/explainer/explainer-studio.tsx+++ b/src/components/explainer/explainer-studio.tsx@@ -17,7 +17,7 @@ import { OldFootageOffer } from "@/components/restore/old-footage";import { fileToSlot } from "@/components/studio/media-slot";import { SelfHostNote } from "@/components/self-host-note";import { StarterParam } from "@/components/starters/starter-param";-import { StarterSection } from "@/components/starters/starter-section";+import { StarterSection, useStarters } from "@/components/starters/starter-section";import { useEngine, useIsOwner, useLikelyVisitor } from "@/lib/api";import {ANIMATION_MODES,@@ -35,6 +35,7 @@ import {MUSIC_HINT,type EpisodeSettings,type ExplainerSource,+ type NarratorVoice,type PickerData,} from "@/lib/catalog/faceless";import { starterShown, type StarterCardData, type StarterFill } from "@/lib/starters/types";@@ -153,7 +154,8 @@ function LinkPopover({ engine, disabled, onAdd }: { engine: EpisodeSettings["eng* starters: the ready explainers (src/lib/starters/catalog.ts), where the history is while it's empty, one row under it* after; fills: what each one puts in the form.*/-export function ExplainerStudio({ picker, starters = [], fills = {} }: { picker: PickerData; starters?: StarterCardData[]; fills?: Record<string, StarterFill> }) {+export function ExplainerStudio({ picker, starters: given = [], fills: givenFills = {} }: { picker: PickerData; starters?: StarterCardData[]; fills?: Record<string, StarterFill> }) {+ const { starters, fills } = useStarters("explainer", given, givenFills);const router = useRouter();const [engine, setEngine] = useEngine();// An explainer doesn't run on an account's own GPU yet (only the studios' generations do): said here, not after Generate.@@ -185,9 +187,11 @@ export function ExplainerStudio({ picker, starters = [], fills = {} }: { picker:/** A ready explainer in the form: its topic, style, length, shape and narrator. */const fill = (id: string) => {const f = fills[id];- if (f?.kind !== "explainer") return;+ if (f?.kind !== "explainer") return false;setPrompt(f.prompt);- set({ styleId: f.styleId, aspect: f.aspect, ...(f.voice && { voice: { kind: "preset" as const, id: f.voice } }) });+ // Open source narration clones a voice: the starter's own narrator sample, while it has one; else its preset voice.+ const voice: NarratorVoice | undefined = engine === "open" && f.voiceSample ? { kind: "sample", url: f.voiceSample, name: "Narrator" } : f.voice ? { kind: "preset", id: f.voice } : undefined;+ set({ styleId: f.styleId, aspect: f.aspect, ...(voice && { voice }) });if (f.duration === "auto" || EXPLAINER_DURATIONS.some((d) => d.value === f.duration)) setDuration(String(f.duration));else {setDuration("manual");@@ -197,6 +201,7 @@ export function ExplainerStudio({ picker, starters = [], fills = {} }: { picker:promptRef.current?.scrollIntoView({ block: "center", behavior: "smooth" });promptRef.current?.focus({ preventScroll: true });});+ return true;};const manualSecs = Math.round(Number(manual));@@ -471,25 +476,29 @@ export function ExplainerStudio({ picker, starters = [], fills = {} }: { picker:</ol></section>- {/* While there is no history yet, the ready explainers stand in its place, without its tabs and search. */}+ {/* While there is no history yet, the ready explainers stand in its place; its tabs and search wait for a first one. */}<section aria-labelledby={noHistory && readyShown ? "starters-title" : "history-title"} className="min-w-0 space-y-4"><div className={cn("flex flex-wrap items-center gap-2", noHistory && readyShown && "hidden")}><h2 id="history-title" className="mr-auto font-heading text-[24px]">History</h2>- <Segmented- label="Show"- value={tab}- options={[- { value: "all", label: "Show all" },- { value: "liked", label: "Liked" },- ]}- onChange={setTab}- />- <div className="flex h-8 w-full items-center gap-1.5 rounded-full bg-secondary px-3 sm:w-52">- <Search className="size-3.5 shrink-0 text-muted-foreground" />- <input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Search" aria-label="Search your explainers" className="h-full min-w-0 flex-1 bg-transparent text-[13px] outline-none placeholder:text-subtle-foreground" />- </div>+ {!noHistory && (+ <>+ <Segmented+ label="Show"+ value={tab}+ options={[+ { value: "all", label: "Show all" },+ { value: "liked", label: "Liked" },+ ]}+ onChange={setTab}+ />+ <div className="flex h-8 w-full items-center gap-1.5 rounded-full bg-secondary px-3 sm:w-52">+ <Search className="size-3.5 shrink-0 text-muted-foreground" />+ <input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Search" aria-label="Search your explainers" className="h-full min-w-0 flex-1 bg-transparent text-[13px] outline-none placeholder:text-subtle-foreground" />+ </div>+ </>+ )}</div>{history.isLoading ? (<div className="grid grid-cols-2 gap-4 xl:grid-cols-3">@@ -504,7 +513,7 @@ export function ExplainerStudio({ picker, starters = [], fills = {} }: { picker:))}</div>) : noHistory && readyShown ? (- <StarterSection starters={starters} onFill={fill} narrow />+ <StarterSection surface="explainer" starters={given} onFill={fill} narrow />) : (<div className="flex flex-col items-center rounded-2xl border border-dashed px-6 py-12 text-center"><div className="grid size-12 place-items-center rounded-2xl bg-brand-faint text-brand-text">{tab === "liked" ? <ImageIcon className="size-5" /> : <Sparkles className="size-5" />}</div>@@ -512,7 +521,7 @@ export function ExplainerStudio({ picker, starters = [], fills = {} }: { picker:<p className="mt-1 max-w-sm text-[13px] text-muted-foreground">{tab === "liked" ? "Like an explainer to keep it here." : "Pick a style, say what to explain, and press Generate."}</p></div>)}- {!!history.data?.length && tab === "all" && !q && <StarterSection starters={starters} onFill={fill} headingLevel="h3" narrow row className="pt-6" />}+ {!!history.data?.length && tab === "all" && !q && <StarterSection surface="explainer" starters={given} onFill={fill} headingLevel="h3" narrow row className="pt-6" />}</section></div>diff --git a/src/components/faceless/faceless-home.tsx b/src/components/faceless/faceless-home.tsxindex f608ce9b..f5ba97d2 100644--- a/src/components/faceless/faceless-home.tsx+++ b/src/components/faceless/faceless-home.tsx@@ -11,7 +11,7 @@ import { EngineSwitch } from "@/components/studio/engine-switch";import { radioKeys, radioTab } from "@/components/studio/radio-keys";import { SelfHostNote } from "@/components/self-host-note";import { useEdgeFade } from "@/components/studio/use-edge-fade";-import { StarterSection } from "@/components/starters/starter-section";+import { StarterSection, useStarters } from "@/components/starters/starter-section";import { useEngine, useIsOwner, useLikelyVisitor } from "@/lib/api";import { GENRE_IDEAS, GENRES, MAX_IDEA, MAX_SCRIPT, wordCount, youtubeKind, YOUTUBE_ERROR, type FacelessGenre } from "@/lib/catalog/faceless";import { starterShown, type StarterCardData } from "@/lib/starters/types";@@ -30,7 +30,8 @@ const STEPS = [];/** starters: the ready channels (src/lib/starters/catalog.ts): first while you have no channels, one row under yours after. */-export function FacelessHome({ starters = [] }: { starters?: StarterCardData[] }) {+export function FacelessHome({ starters: given = [] }: { starters?: StarterCardData[] }) {+ const { starters } = useStarters("faceless", given);const router = useRouter();const [engine, setEngine] = useEngine();const [genre, setGenre] = useState<FacelessGenre>("education");@@ -202,7 +203,7 @@ export function FacelessHome({ starters = [] }: { starters?: StarterCardData[] }</div></div>- {!channels.isLoading && !hasChannels && <StarterSection starters={starters} />}+ {!channels.isLoading && !hasChannels && <StarterSection surface="faceless" starters={given} />}{(channels.isLoading || hasChannels || !readyShown) && (<section aria-labelledby="channels-title" className="space-y-4">@@ -230,7 +231,7 @@ export function FacelessHome({ starters = [] }: { starters?: StarterCardData[] }</section>)}- {hasChannels && <StarterSection starters={starters} row />}+ {hasChannels && <StarterSection surface="faceless" starters={given} row />}<section aria-label="How it works" className="grid gap-3 sm:grid-cols-3">{STEPS.map((s, i) => (diff --git a/src/components/marketing/click-to-ad.tsx b/src/components/marketing/click-to-ad.tsxindex 81bee42b..0f60d427 100644--- a/src/components/marketing/click-to-ad.tsx+++ b/src/components/marketing/click-to-ad.tsx@@ -327,7 +327,7 @@ export function ClickToAd({ models, starters = [] }: { models: Record<string, Mo<Suspense fallback={null}><ProductParam products={products.data} onProduct={choose} /></Suspense>- {products.isSuccess && !products.data.length && <StarterSection starters={starters} className="pb-3" />}+ {products.isSuccess && !products.data.length && <StarterSection surface="click-to-ad" starters={starters} className="pb-3" />}<Step n={1} title="Your product" hint="Paste the product's own page, or pick one you saved." done={!!product}><AddFromLink limit={1} withBrand placeholder="https://yourshop.com/products/…" onAdded={(ps, extra) => ps[0] && choose(ps[0], extra.brand)} disabled={visitor} />@@ -530,7 +530,7 @@ export function ClickToAd({ models, starters = [] }: { models: Record<string, Mo/></div>- {!!products.data?.length && <StarterSection starters={starters} row className="pt-8" />}+ {!!products.data?.length && <StarterSection surface="click-to-ad" starters={starters} row className="pt-8" />}</div></div>);diff --git a/src/components/marketing/marketing-studio.tsx b/src/components/marketing/marketing-studio.tsxindex ec54680c..89a7fee7 100644--- a/src/components/marketing/marketing-studio.tsx+++ b/src/components/marketing/marketing-studio.tsx@@ -340,6 +340,7 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<striconst brands = useBrands();const brandId = savedBrand && brands.data?.some((b) => b.id === savedBrand) ? savedBrand : null;const products = useProducts();+ const noProducts = products.isSuccess && !products.data.length;const pickTemplate = (t: MarketingTemplate) => {setDraft((d) => withTemplate(d, t));@@ -430,14 +431,16 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri<ProductParam products={products.data} onProduct={(p) => set({ product: productChoice(p) })} /></Suspense><div className="mx-auto w-full min-w-0 max-w-[1240px] flex-1 px-4 pb-10 sm:px-6">- <div className="pt-6 pb-2 text-center sm:pt-10">+ {/* With no products yet, the ready shoots come first: a lower hero keeps them above the docked composer. */}+ <div className={cn("pt-6 pb-2 text-center", noProducts ? "sm:pt-6" : "sm:pt-10")}><h2 className="font-heading text-display text-balance">Turn a product into ready-to-post content</h2><p className="mx-auto mt-2 max-w-xl text-[15px] text-muted-foreground">Product shots, motion, UGC presenters, ads, posters and listings — from Fuobe's templates, on {engine === "open" ? (visitor ? "open-source models" : "your own GPU, free") : "Fuobe Marketing Image or partner models in the cloud"}.</p>- {visitor && <SelfHostNote className="mx-auto mt-3 max-w-xl">Marketing Studio isn't available here.</SelfHostNote>}</div>- {products.isSuccess && !products.data.length && <StarterSection starters={starters} className="mt-6 mb-4" />}+ {noProducts && <StarterSection surface="marketing" starters={starters} center compact className="mt-6 mb-4" />}+ {/* Under the ready shoots, so it doesn't read as an answer to them. */}+ {visitor && <SelfHostNote className="mx-auto mt-3 max-w-xl text-center">Marketing Studio isn't available here.</SelfHostNote>}<div role="tablist" aria-label="View" className="mx-auto mt-4 flex w-fit rounded-full bg-muted p-0.5">{(["templates", "generations"] as const).map((t) => (<button key={t} role="tab" aria-selected={tab === t} onClick={() => setTab(t)} className={cn("h-8 rounded-full px-4 text-[13px] font-medium text-muted-foreground", tab === t && "bg-background text-foreground shadow-soft")}>@@ -447,17 +450,21 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri</div><div className="mt-6">{tab === "templates" ? (- <TemplateGallery- category={category}- onCategory={setCategory}- media={media}- onMedia={(m) => {- setMedia(m);- if (m !== "all" && m !== kind) setDraft((d) => withTemplate(d, null, m === "image" ? "product-standalone" : "motion-hyper"));- }}- selected={draft.templateId ?? undefined}- onPick={pickTemplate}- />+ <>+ {/* Once there are products of your own, the ready shoots are one row above the templates. */}+ {!!products.data?.length && <StarterSection surface="marketing" starters={starters} row center className="mb-12" />}+ <TemplateGallery+ category={category}+ onCategory={setCategory}+ media={media}+ onMedia={(m) => {+ setMedia(m);+ if (m !== "all" && m !== kind) setDraft((d) => withTemplate(d, null, m === "image" ? "product-standalone" : "motion-hyper"));+ }}+ selected={draft.templateId ?? undefined}+ onPick={pickTemplate}+ />+ </>) : (<RunsListfeature="marketing"@@ -474,7 +481,6 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri/>)}</div>- {tab === "templates" && !!products.data?.length && <StarterSection starters={starters} row className="mt-12" />}</div>{/* Docked composer */}diff --git a/src/components/starters/starter-card.tsx b/src/components/starters/starter-card.tsxindex 93771291..f61af1ef 100644--- a/src/components/starters/starter-card.tsx+++ b/src/components/starters/starter-card.tsx@@ -28,6 +28,10 @@ export interface StarterCardProps {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;+ /** Two cards side by side: a wider, lower cover (2:1) from the small breakpoint up. */+ wide?: boolean;+ /** On a phone, the cover as a thumbnail on the left and the words beside it (a row that must fit above a docked composer). */+ compact?: boolean;className?: string;}@@ -36,8 +40,10 @@ export interface StarterCardProps {* 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) {+export function StarterCard({ coverKey, cover, hue, flow, overlay, icon, title, description, href, meta, badge, action, wide, compact, className }: StarterCardProps) {const { ref, playing, asked, handlers } = useCoverPlayback<HTMLElement>(coverKey, cover);+ // A phone's compact card: a thumbnail as tall as the words beside it.+ const shape = cn(wide ? "aspect-[16/9] sm:aspect-[2/1]" : "aspect-[16/9]", compact && "max-sm:aspect-auto max-sm:min-h-28 max-sm:w-28 max-sm:shrink-0");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@@ -45,11 +51,12 @@ export function StarterCard({ coverKey, cover, hue, flow, overlay, icon, title,{...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",+ compact && "max-sm:flex-row",className,)}>{cover ? (- <div className="relative aspect-[16/9] overflow-hidden bg-muted">+ <div className={cn("relative overflow-hidden bg-muted", shape)}>{cover.frames.length > 1 ? (<div className="absolute inset-0 grid auto-cols-fr grid-flow-col gap-0.5">{cover.frames.map((f) => (@@ -57,19 +64,19 @@ export function StarterCard({ coverKey, cover, hue, flow, overlay, icon, title,))}</div>) : (- <CoverArt cover={cover} sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 440px" playing={playing} asked={asked} />+ <CoverArt cover={cover} sizes={`(max-width: 640px) ${compact ? "112px" : "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>}+ {flow && <span className={cn("pointer-events-none absolute right-2.5 bottom-2.5", compact && "max-sm:hidden")}>{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={cn("relative bg-muted/50", shape)} 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">+ {badge && <span className={cn("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", compact && "max-sm:top-auto max-sm:right-auto max-sm:bottom-2 max-sm:left-2")}>{badge}</span>}+ <div className="flex min-w-0 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. */}diff --git a/src/components/starters/starter-param.tsx b/src/components/starters/starter-param.tsxindex 9130c380..b3a1c4b7 100644--- a/src/components/starters/starter-param.tsx+++ b/src/components/starters/starter-param.tsx@@ -5,16 +5,16 @@ import { useEffect, useRef } from "react";/*** A ready starter opened from its page (`?starter=<id>`): handed to the studio's composer once per id (Content Factory,- * Explainer). Render it inside a Suspense boundary (it reads the search params).+ * Explainer). `onStarter` answers whether it filled it: one the page doesn't know yet (the owner's starters still+ * loading) is tried again when it changes. Render it inside a Suspense boundary (it reads the search params).*/-export function StarterParam({ onStarter }: { onStarter: (id: string) => void }) {+export function StarterParam({ onStarter }: { onStarter: (id: string) => boolean }) {const q = useSearchParams();const last = useRef<string | null>(null);const id = q.get("starter");useEffect(() => {if (!id || last.current === id) return;- last.current = id;- onStarter(id);+ if (onStarter(id)) last.current = id;}, [id, onStarter]);return null;}diff --git a/src/components/starters/starter-section.tsx b/src/components/starters/starter-section.tsxindex 360ac5e9..35f409fd 100644--- a/src/components/starters/starter-section.tsx+++ b/src/components/starters/starter-section.tsx@@ -1,19 +1,40 @@"use client";import { ArrowRight, Loader2, Plus } from "lucide-react";-import { useQueryClient } from "@tanstack/react-query";+import { useQuery, useQueryClient } from "@tanstack/react-query";import { useRouter } from "next/navigation";import { useState, useTransition } from "react";import { Button } from "@/components/ui/button";import { StepFlow } from "@/components/canvas/template-card";import { useEngine, useIsOwner } from "@/lib/api";import { responseError, toastError } from "@/lib/refusals";-import { STARTER_SURFACES, starterHref, starterShown, type StarterCardData } from "@/lib/starters/types";+import { STARTER_SURFACES, starterHref, starterShown, type OwnerStarters, type StarterCardData, type StarterFill, type StarterSurface } from "@/lib/starters/types";import { cn } from "@/lib/utils";import { StarterCard } from "./starter-card";import { StarterIcon } from "./starter-icon";import { StepsGlyph } from "./steps-glyph";+/**+ * A studio's starters for the viewer: the covered ones its page was given (everyone's), and for the owner every one,+ * loaded once from GET /api/starters (a starter with no cover yet never reaches a visitor's page). `fills`: what each+ * one puts in its composer (Content Factory, Explainer), the owner's with the starter's narrator sample.+ */+export function useStarters(surface: StarterSurface, starters: StarterCardData[], fills: Record<string, StarterFill> = {}) {+ const owner = useIsOwner();+ const q = useQuery({+ queryKey: ["starters", surface],+ queryFn: async (): Promise<OwnerStarters> => {+ const res = await fetch(`/api/starters?surface=${encodeURIComponent(surface)}`);+ if (!res.ok) throw new Error("Starters didn't load");+ return (await res.json()) as OwnerStarters;+ },+ enabled: owner,+ staleTime: 5 * 60_000,+ });+ const mine = owner ? q.data : undefined;+ return { owner, starters: mine?.starters ?? starters, fills: mine ? { ...fills, ...mine.fills } : fills };+}+/*** The owner's "Use template": a starter made on the server (POST /api/starters/<id>) opens where it answers; one that* fills a composer fills it here (`onFill`, on its own studio's page) or opens its studio with `?starter=`.@@ -52,9 +73,11 @@ export function useStarterUse(onFill?: (id: string) => void) {}/** One starter as a card: the whole card opens its page; the owner's action makes or fills it. */-export function StarterTile({ s, owner, busy, onUse }: { s: StarterCardData; owner: boolean; busy: boolean; onUse: () => void }) {+export function StarterTile({ s, owner, busy, onUse, wide, compact }: { s: StarterCardData; owner: boolean; busy: boolean; onUse: () => void; wide?: boolean; compact?: boolean }) {return (<StarterCard+ wide={wide}+ compact={compact}coverKey={s.coverKey}cover={s.cover}hue={s.hue}@@ -86,13 +109,18 @@ export function StarterTile({ s, owner, busy, onUse }: { s: StarterCardData; own* `row`: one short row (the first three, "See all" for the rest), under the person's own work; a snap scroller on a phone.*/export function StarterSection({- starters,+ surface: surfaceId,+ starters: given,row = false,onFill,className,headingLevel = "h2",narrow = false,+ center = false,+ compact = false,}: {+ surface: StarterSurface;+ /** The covered starters the page was given; the owner's view adds the rest (useStarters). */starters: StarterCardData[];row?: boolean;onFill?: (id: string) => void;@@ -100,20 +128,26 @@ export function StarterSection({headingLevel?: "h2" | "h3";/** In a narrow column (Explainer's history): two cards a row at most. */narrow?: boolean;+ /** Under a centred hero: the section centred, at the width of its cards. */+ center?: boolean;+ /** On a phone, each card as a thumbnail beside its words (Marketing Studio's, above its docked composer). */+ compact?: boolean;}) {// Until the viewer is known to be the owner, the page is a visitor's: only starters with their real cover show.- const owner = useIsOwner();+ const { owner, starters } = useStarters(surfaceId, given);const { use, busy } = useStarterUse(onFill);const [all, setAll] = useState(false);const shown = starters.filter((s) => starterShown(s, !owner));if (!shown.length) return null;- const surface = STARTER_SURFACES[shown[0].surface];+ const surface = STARTER_SURFACES[surfaceId];const items = row && !all ? shown.slice(0, 3) : shown;- // Two cards or fewer: two columns at most, so no column stands empty beside them.+ // Two cards or fewer: two columns at most, so no column stands empty beside them, with wider, lower covers.const few = items.length <= 2;const H = headingLevel;+ // A snap row on a phone reaches the screen's edges: it steps out of the page's 16 px gutter and snaps back inside it.+ const snap = row && !all && items.length > 1;return (- <section id="starters" aria-labelledby="starters-title" className={cn("scroll-mt-20", className)}>+ <section id="starters" aria-labelledby="starters-title" className={cn("scroll-mt-20", center && few && !narrow && "mx-auto w-full lg:max-w-[880px]", className)}><div className="mb-3 flex flex-wrap items-end gap-x-3 gap-y-1"><div className="min-w-0 flex-1"><H id="starters-title" className="font-heading text-[24px] leading-tight">@@ -132,11 +166,11 @@ export function StarterSection({"grid grid-cols-1 gap-4 sm:grid-cols-2",!narrow && !few && "lg:grid-cols-3",!narrow && few && "lg:max-w-[880px]",- row && !all && "-mx-3 flex snap-x snap-mandatory overflow-x-auto px-3 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",+ snap && "-mx-4 flex scroll-px-4 snap-x snap-mandatory overflow-x-auto px-4 pb-1 sm:mx-0 sm:grid sm:scroll-px-0 sm:overflow-visible sm:px-0 sm:pb-0 [&>*]:w-[78%] [&>*]:shrink-0 [&>*]:snap-start sm:[&>*]:w-auto",)}>{items.map((s) => (- <StarterTile key={s.id} s={s} owner={owner} busy={busy === s.id} onUse={() => void use(s)} />+ <StarterTile key={s.id} s={s} owner={owner} busy={busy === s.id} onUse={() => void use(s)} wide={few && !narrow} compact={compact} />))}</div></section>diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 89413ca6..8e8f8066 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -2336,21 +2336,24 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [{id: "music-video",name: "Music video",- description: "Three song scenes as moving shots, joined into one film, and a song in the same mood",+ description: "One singer photo, three song scenes as moving shots, and a song laid under the film",icon: "Music",hue: 315,rank: 4,- makes: "A film of the three scenes and a 30-second song to go with it.",- flow: ["Lyrics", "Scenes", "Film"],+ makes: "A 15-second music video of the three scenes, with its song.",+ flow: ["Singer", "Scenes", "Film"],steps: [+ "A photo of the singer goes in, so she looks the same in every scene.","Each row of the table is one scene: a line of the song and what the picture shows.",- "Every scene becomes a still.",- "Every still becomes a 5-second moving shot.",- "The shots are joined into one film.",- "A 30-second song is made in the same mood.",+ "Every scene becomes a still of her, then a 5-second moving shot.",+ "The shots are joined into one film, and a song is made in the same mood.",+ "The song is laid under the film and cut to its 15 seconds.",],+ inputs: { singer: "A clear photo of the singer's face and hair." },+ samples: { singer: { src: "/examples/app-hairstyle-try-on/1/in-image.jpg", name: "Singer photo.jpg" } },build: tpl([+ { id: "singer", type: "image-input", x: 0, y: FILM_ROW - 80, data: { label: "Singer photo" } },{id: "scenes",type: "table",@@ -2361,24 +2364,30 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [label: "Scenes",columns: ["Lyric", "Scene"],rows: [- ["Midnight, the city is ours", "a fashion model in a silver sequin gown dancing on a Tokyo rooftop at night, neon signs glowing behind her"],- ["I keep the lights on for you", "the same model in the silver gown driving a red vintage convertible on a coast road at night, city lights below"],- ["Till the sun comes up", "the model laughing on a Malibu beach at sunrise, the silver gown catching the pink light"],+ ["Midnight, the city is ours", "she dances in a silver sequin gown on a Tokyo rooftop at night, neon signs glowing behind her"],+ ["I keep the lights on for you", "she drives a red vintage convertible on a coast road at night in the silver sequin gown, city lights below"],+ ["Till the sun comes up", "she laughs on a Malibu beach at sunrise, the silver sequin gown catching the pink light"],],},},- { id: "still", type: "model", x: COL + 180, y: 0, data: { mediaKind: "image", label: "Still", prompt: "{Scene}, a music video still, glossy cinematic light, fashion film look", params: { aspectRatio: "16:9" } }, models: { cloud: "nano-banana-pro", open: "oss-qwen-image-21" } },+ { id: "still", type: "model", x: COL + 180, y: 0, data: { mediaKind: "image", label: "Still", op: "edit", prompt: "The same woman from the photo, her face and long dark hair unchanged: {Scene}. A music video still, glossy cinematic light, fashion film look", params: { aspectRatio: "16:9" } }, models: { cloud: "nano-banana-pro", open: "oss-qwen-image-21" } },{ id: "animate", type: "model", x: COL * 2 + 180, y: 0, data: { mediaKind: "video", label: "Moving shot", op: "i2v", prompt: "She moves to the music, her sequin gown shimmering, the camera gliding slowly around her, lights glowing", params: { aspectRatio: "16:9", duration: 5 } }, models: { cloud: "minimax-h3", open: "oss-minimax-h3" } },{ id: "film", type: "concat", x: COL * 3 + 180, y: 0, data: { label: "Film", params: { aspectRatio: "16:9" } }, models: { cloud: CONCAT_MODELS.cloud, open: CONCAT_MODELS.open } },{ id: "song", type: "model", x: COL * 3 + 180, y: FILM_ROW, data: { mediaKind: "audio", label: "Song", op: "music", prompt: "Dreamy synth-pop, 104 bpm, a female vocal, glossy and cinematic, a warm night-drive mood", params: { duration: 30 } }, models: { cloud: "elevenlabs-music", open: "oss-ace-step" } },- { id: "out", type: "output", x: COL * 4 + 220, y: FILM_ROW / 2, data: { label: "Film and song" } },+ // The song under the film, then the whole cut to the film's 15 seconds (three 5-second shots).+ { id: "score", type: "model", x: COL * 4 + 220, y: FILM_ROW / 2, data: { mediaKind: "video", label: "Song under the film", op: "mux" }, models: { cloud: CONCAT_TOOLS.cloud.mux, open: "oss-mux" } },+ { id: "cut", type: "model", x: COL * 5 + 220, y: FILM_ROW / 2, data: { mediaKind: "video", label: "Cut to the film", op: "trim", params: { startTime: 0, endTime: 15 } }, models: { cloud: CONCAT_TOOLS.cloud.trim, open: "oss-trim" } },+ { id: "out", type: "output", x: COL * 6 + 220, y: FILM_ROW / 2, data: { label: "Music video" } },],[+ ["singer", "still", "images"],["scenes", "still", "prompt"],["still", "animate", "images"],["animate", "film", "videos"],- ["film", "out"],- ["song", "out"],+ ["film", "score", "video"],+ ["song", "score", "audio"],+ ["score", "cut", "video"],+ ["cut", "out"],],),},diff --git a/src/lib/record-pages.ts b/src/lib/record-pages.tsindex 04a7fdd5..8ad972f9 100644--- a/src/lib/record-pages.ts+++ b/src/lib/record-pages.ts@@ -7,7 +7,7 @@* Pure, so the route table is tested without a server.*/import { HUB_MODES, type HubKind } from "./hubs";-import { STARTER_IDS } from "./starters/ids";+import { STARTER_IDS, starterCovered } from "./starters/ids";import type { StarterSurface } from "./starters/types";export type RecordKind = "cinema" | "canvas" | "assist-project" | "layers" | "shorts" | "brand" | "element" | "channel" | "episode" | "explainer" | "series" | "swap-project";@@ -69,6 +69,17 @@ export function unknownStarterPage(pathname: string): boolean {return !!m && !STARTER_IDS[STARTER_BASE[m[1]]].includes(decode(m[2]));}+/**+ * A starter page whose starter has no real cover yet: the owner's alone until its cover is made. The proxy answers+ * anyone else a real 404, so its words never reach a visitor (the page itself is prerendered for the owner).+ */+export function hiddenStarterPage(pathname: string): boolean {+ const m = STARTER_PAGE.exec(pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname);+ if (!m) return false;+ const id = decode(m[2]);+ return STARTER_IDS[STARTER_BASE[m[1]]].includes(id) && !starterCovered(id);+}+/** /audio/<mode>, /video-tools/<mode> and /upscale/<mode> with a mode the hub doesn't have. */export function unknownHubMode(pathname: string): boolean {const m = /^\/(audio|video-tools|upscale)\/([^/]+)\/?$/.exec(pathname);diff --git a/src/lib/starters/catalog.ts b/src/lib/starters/catalog.tsindex b91abbf3..239e6b74 100644--- a/src/lib/starters/catalog.ts+++ b/src/lib/starters/catalog.ts@@ -95,7 +95,7 @@ export function assertStarters(list: Starter[] = STARTERS): void {if (!EXAMPLE_MEDIA[seed.kit.product.image.src]) throw new Error(`Starter ${s.id}: ${seed.kit.product.image.src} isn't a published example file`);if (seed.open.to === "marketing" && !TEMPLATE_INDEX.get(seed.open.template)) throw new Error(`Starter ${s.id}: no Marketing template ${seed.open.template}`);}- if (s.coverFrom && !presetCover(s.coverFrom)) throw new Error(`Starter ${s.id}: no preset cover ${s.coverFrom}`);+ if (s.coverFrom && (!presetCover(s.coverFrom) || !PRESET_PEAKS[s.coverFrom])) throw new Error(`Starter ${s.id}: no preset cover with a finished frame ${s.coverFrom}`);if (s.tryIn) {if (!getPreset(s.tryIn.app)) throw new Error(`Starter ${s.id}: no app ${s.tryIn.app}`);if (exampleSurfaceOf(s.tryIn.example) !== `app:${s.tryIn.app}`) throw new Error(`Starter ${s.id}: ${s.tryIn.example} isn't an example of ${s.tryIn.app}`);@@ -110,14 +110,17 @@ assertStarters();export const getStarter = (id: string): Starter | undefined => STARTERS.find((s) => s.id === id);-/** A preset's cover as a starter's, resting on its peak frame (the finished shot) where it has one. */+/**+ * A preset's cover as a starter's: its peak frame alone (the finished shot), never its clip. The clip is the app's+ * before → after reveal, which opens on the plain photo and wipes across it: a starter shows what it makes.+ */function presetAsCover(id: string): TemplateCover | undefined {const c = presetCover(id);- if (!c) return undefined;const peak = PRESET_PEAKS[id];- const poster = peak && c.video ? `/previews/presets/peak/${id}.jpg?v=${peak.v}` : c.poster;- const thumb = peak && c.video ? thumbOf(poster) : c.thumb;- return { poster, thumb, ...(c.video && { video: c.video }), ...(peak && c.video && { at: peak.at }), frames: [{ src: poster, thumb }] };+ if (!c || !peak) return undefined;+ const poster = `/previews/presets/peak/${id}.jpg?v=${peak.v}`;+ const thumb = thumbOf(poster);+ return { poster, thumb, frames: [{ src: poster, thumb }] };}/** A starter's real cover: its own (starters/<id>), else the preset cover that shows the same thing. */@@ -156,16 +159,32 @@ export function starterCard(s: Starter): StarterCardData {};}-/** A surface's starters as cards, covered first, then by rank (a visitor's list drops the ones with no cover). */-export function starterCards(surface: StarterSurface): StarterCardData[] {+/**+ * A surface's starters as cards, covered first, then by rank. A page's props (prerendered, the same for everyone) get+ * only the covered ones: a starter with no cover yet is the owner's, who loads the rest from GET /api/starters, so its+ * words never reach a visitor's page. `all`: every one (that route's answer).+ */+export function starterCards(surface: StarterSurface, { all = false }: { all?: boolean } = {}): StarterCardData[] {return STARTERS.filter((s) => s.surface === surface).map(starterCard)+ .filter((c) => all || !!c.cover).sort((a, b) => Number(!a.cover) - Number(!b.cover) || a.rank - b.rank);}-/** The composers' fills of a surface, by starter id (small: the page gets them all). */-export function starterFills(surface: "content-factory" | "explainer"): Record<string, StarterFill> {- return Object.fromEntries(STARTERS.flatMap((s) => (s.surface === surface && s.seed.kind === "fill" ? [[s.id, s.seed.fill] as const] : [])));+/** The composers' fills of a surface, by starter id (small: the page gets them all), the covered ones unless `all`. */+export function starterFills(surface: "content-factory" | "explainer", { all = false }: { all?: boolean } = {}): Record<string, StarterFill> {+ return Object.fromEntries(STARTERS.flatMap((s) => (s.surface === surface && s.seed.kind === "fill" && (all || starterCover(s)) ? [[s.id, s.seed.fill] as const] : [])));+}++/** Studios whose starters speak through a narrator (Faceless, Content Factory, Explainer). */+const NARRATED: ReadonlySet<StarterSurface> = new Set(["faceless", "content-factory", "explainer"]);++/**+ * A narrated starter's narrator sample: a short neutral read, published at /starters/<id>/<v>/voice.m4a once it is made+ * (the open engine's narrator clones a voice, and a starter must run as it is). Until the file is there, nothing.+ */+export function starterVoice(s: Pick<Starter, "id" | "surface">): StarterSample | undefined {+ return NARRATED.has(s.surface) ? { src: `/starters/${s.id}/1/voice.m4a`, name: "Narrator" } : undefined;}/** Every starter page of a surface, prerendered. */diff --git a/src/lib/starters/ids.ts b/src/lib/starters/ids.tsindex 0e57e31a..2b922304 100644--- a/src/lib/starters/ids.ts+++ b/src/lib/starters/ids.ts@@ -1,7 +1,9 @@/*** Every starter's id by studio, client-safe and tiny, for the proxy: a starter page whose id isn't here gets a real 404- * (src/lib/record-pages.ts unknownStarterPage). tests/starters-catalog.test.ts checks it matches the catalog.+ * (src/lib/record-pages.ts unknownStarterPage), and so does one with no real cover yet for anyone but the owner+ * (hiddenStarterPage). tests/starters-catalog.test.ts checks both match the catalog.*/+import { templateCover } from "@/lib/template-covers";import type { StarterSurface } from "./types";export const STARTER_IDS: Record<StarterSurface, readonly string[]> = {@@ -12,3 +14,9 @@ export const STARTER_IDS: Record<StarterSurface, readonly string[]> = {"click-to-ad": ["c2a.eau-de-verre", "c2a.marlow-bag"],marketing: ["mk.perfume-moss", "mk.bag-packshot"],};++/** The starters shown with another cover until their own is made (Starter.coverFrom in the catalog). */+const BORROWED_COVER: ReadonlySet<string> = new Set(["mk.perfume-moss", "mk.bag-packshot"]);++/** Whether a starter has a real cover, so visitors see it: its own (starters/<id>), or one it borrows. */+export const starterCovered = (id: string): boolean => BORROWED_COVER.has(id) || !!templateCover("starters", id);diff --git a/src/lib/starters/types.ts b/src/lib/starters/types.tsindex 3bfb2ce1..301059dd 100644--- a/src/lib/starters/types.ts+++ b/src/lib/starters/types.ts@@ -57,9 +57,19 @@ export interface StarterCardData {* The composer a "fill" starter loads (Content Factory, Explainer): small enough to pass to the page, read when the* page opens with `?starter=<id>` or when the owner taps "Use template" on its card.*/-export type StarterFill =+export type StarterFill = (| { kind: "content-factory"; presetId: string; prompt: string; length: number; episodes: number }- | { kind: "explainer"; prompt: string; styleId: string; duration: "auto" | number; aspect: "9:16" | "16:9"; voice?: string };+ | { kind: "explainer"; prompt: string; styleId: string; duration: "auto" | number; aspect: "9:16" | "16:9"; voice?: string }+) & {+ /** The starter's narrator sample, stored for the owner (/api/files/…): the open engine's narrator clones a voice. */+ voiceSample?: string;+};++/** GET /api/starters?surface=: every starter of a surface, for the owner (a page's props carry only covered ones). */+export interface OwnerStarters {+ starters: StarterCardData[];+ fills: Record<string, StarterFill>;+}/** The starter's page (`<base>/start/<id>`). */export const starterHref = (s: Pick<StarterCardData, "id" | "surface">) => `${STARTER_SURFACES[s.surface].base}/start/${s.id}`;diff --git a/src/proxy.ts b/src/proxy.tsindex a556ac8d..c9dcf9ab 100644--- a/src/proxy.ts+++ b/src/proxy.ts@@ -1,7 +1,7 @@import { NextResponse, type NextRequest } from "next/server";import { APPS } from "@/lib/catalog/apps";import { modeHref, type HubKind } from "@/lib/hubs";-import { recordForPath, unknownHubMode, unknownStarterPage } from "@/lib/record-pages";+import { hiddenStarterPage, recordForPath, unknownHubMode, unknownStarterPage } from "@/lib/record-pages";import { countsAsView, SHARE_VIEW_HEADER, shareRoute } from "@/lib/share";import {ACCOUNT_LIBRARY_MESSAGE,@@ -365,6 +365,8 @@ export function proxy(request: NextRequest) {const open = publicSignup(request.headers.get("host") ?? request.nextUrl.host);const viewer = viewerOf(request, open);if (viewer?.kind === "owner") return pass(request);+ // A starter with no real cover yet is the owner's: anyone else gets a real 404, not its words.+ if ((viewer || open) && read && hiddenStarterPage(pathname)) return notFound(request);if (viewer?.kind === "account") return account(request, viewer.account);if (open) return guest(request);if (pathname.startsWith("/api/")) {diff --git a/src/server/canvas-samples.ts b/src/server/canvas-samples.tsindex ecdec386..a41470ee 100644--- a/src/server/canvas-samples.ts+++ b/src/server/canvas-samples.ts@@ -16,8 +16,8 @@ import { absolutePath, contentTypeFor, getAsset, saveFile } from "./storage";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/"];+/** Where a sample may come from: Fuobe's published example inputs, its samples, its preview covers and its starters' files. */+const FOLDERS = ["/examples/", "/samples/", "/previews/presets/", "/starters/"];/** 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 {diff --git a/src/server/starters.ts b/src/server/starters.tsindex 00a1c6c5..d92ad22c 100644--- a/src/server/starters.ts+++ b/src/server/starters.ts@@ -1,9 +1,11 @@import "server-only";import type { Engine } from "@/lib/catalog/types";-import { getStarter, type StarterProduct } from "@/lib/starters/catalog";+import type { NarratorVoice } from "@/lib/catalog/faceless";+import { getStarter, starterCards, starterFills, starterVoice, type Starter, type StarterProduct } from "@/lib/starters/catalog";+import type { OwnerStarters, StarterFill, StarterSurface } from "@/lib/starters/types";import { createManualBrand, createProduct, listBrands, listProducts, updateProduct } from "./brand";import { adoptSample } from "./canvas-samples";-import { createChannel } from "./faceless";+import { createChannel, listChannels, updateChannel } from "./faceless";/*** The owner's "Use template" on a starter that is made here (POST /api/starters/<id>): a Faceless channel set up for@@ -43,6 +45,33 @@ async function brandAndProduct(kit: StarterProduct): Promise<{ brandId: string;return { brandId: brand.id, productId: product.id };}+/** The narrator a starter speaks with until its own sample is published: Fuobe's clean voice sample, a calm 8 s read. */+const NARRATOR_FALLBACK = "/samples/clean-voice/clean.m4a";++/**+ * The starter's narrator sample as a stored file (made once): its own once published, else Fuobe's clean voice sample,+ * so a narrated starter runs on the open engine as it is. Undefined for a starter with no narrator.+ */+function narrator(s: Pick<Starter, "id" | "surface">): (NarratorVoice & { kind: "sample" }) | undefined {+ const v = starterVoice(s);+ if (!v) return undefined;+ const url = adoptSample(v.src) ?? adoptSample(NARRATOR_FALLBACK);+ return url ? { kind: "sample", url, name: v.name } : undefined;+}++/** Every starter of a surface for the owner (GET /api/starters?surface=), the fills with their narrator sample. */+export function startersForOwner(surface: StarterSurface): OwnerStarters {+ const starters = starterCards(surface, { all: true });+ const fills: Record<string, StarterFill> = {};+ if (surface === "content-factory" || surface === "explainer") {+ for (const [id, f] of Object.entries(starterFills(surface, { all: true }))) {+ const voice = narrator({ id, surface });+ fills[id] = voice ? { ...f, voiceSample: voice.url } : f;+ }+ }+ return { starters, fills };+}+/** Make the starter and say where it opens. */export async function createFromStarter(id: string, engine: Engine): Promise<{ href: string }> {const s = getStarter(id);@@ -50,13 +79,21 @@ export async function createFromStarter(id: string, engine: Engine): Promise<{ hconst seed = s.seed;if (seed.kind === "fill") throw new StarterError("That starter opens in its studio: nothing to make here");if (seed.kind === "faceless") {- const channel = await createChannel({- idea: seed.channel.idea,- genre: seed.channel.genre,- engine,- name: seed.channel.name,- settings: { styleId: seed.episode.styleId, length: seed.episode.length },- });+ // On the open engine the narrator clones a voice: the starter's own sample, while it is published.+ const voice = engine === "open" ? narrator(s) : undefined;+ // The channel made before from this starter (same name and idea) opens again, rather than a second one.+ const known = listChannels().find((c) => c.name === seed.channel.name && c.idea === seed.channel.idea);+ const channel = known+ ? voice && known.settings.voice?.kind !== "sample"+ ? await updateChannel(known.id, { settings: { voice } })+ : known+ : await createChannel({+ idea: seed.channel.idea,+ genre: seed.channel.genre,+ engine,+ name: seed.channel.name,+ settings: { styleId: seed.episode.styleId, length: seed.episode.length, ...(voice && { voice }) },+ });return { href: `/faceless/${channel.id}/new?starter=${encodeURIComponent(s.id)}` };}const { brandId, productId } = await brandAndProduct(seed.kit);diff --git a/tests/canvas-models.test.ts b/tests/canvas-models.test.tsindex e8d82400..f0adb174 100644--- a/tests/canvas-models.test.ts+++ b/tests/canvas-models.test.ts@@ -67,7 +67,7 @@ describe("Canvas templates' models", () => {it("every template plans on the open engine with these models, for free", () => {for (const t of CANVAS_TEMPLATES) {const plan = planCanvas(t.build("open"), { engineMode: "open" });- for (const e of plan.errors) expect(e.message, t.id).toMatch(/^(Add (an image|an audio clip|a video|a voice sample) to|Waiting on)/);+ for (const e of plan.errors) expect(e.message, t.id).toMatch(/^(Row \d+: )?(Add (an image|an audio clip|a video|a voice sample) to|Waiting on)/);expect(plan.costUsd, t.id).toBe(0);}});diff --git a/tests/canvas.test.ts b/tests/canvas.test.tsindex 1155cf74..17fd6e95 100644--- a/tests/canvas.test.ts+++ b/tests/canvas.test.ts@@ -355,7 +355,7 @@ describe("canvas templates", () => {expect(graphEngine(g)).toBe(engine);const plan = planCanvas(g, { engineMode: engine });// Only the empty upload nodes need the user.- for (const e of plan.errors) expect(e.message).toMatch(/^(Add (an image|an audio clip|a video|a voice sample) to|Waiting on)/);+ for (const e of plan.errors) expect(e.message).toMatch(/^(Row \d+: )?(Add (an image|an audio clip|a video|a voice sample) to|Waiting on)/);if (!plan.errors.length) expect(plan.steps.length).toBe(g.nodes.filter(isGenerator).length);if (engine === "open") expect(plan.costUsd).toBe(0);});diff --git a/tests/e2e/starters-b.mjs b/tests/e2e/starters-b.mjsindex 1e3eb46f..76e43cf7 100644--- a/tests/e2e/starters-b.mjs+++ b/tests/e2e/starters-b.mjs@@ -24,12 +24,13 @@ const check = (name, ok, detail = "") => {/** Each studio, the heading of its starters, how many it has, and whether visitors see them yet (a real cover). */const SURFACES = [- { path: "/faceless", heading: "Start from a ready channel", n: 3, covered: false, first: "faceless.boat-hotels" },- { path: "/content-factory", heading: "Start from a ready series", n: 3, covered: false, first: "cf.underwater-fashion-week" },- { path: "/explainer", heading: "Start from a ready explainer", n: 3, covered: false, first: "ex.couture-400-hours" },+ // words: a cover-less starter's name and composer words, which a visitor's page must not carry.+ { path: "/faceless", heading: "Start from a ready channel", n: 3, covered: false, first: "faceless.boat-hotels", words: ["Hotels you reach by boat", "Only by Boat"] },+ { path: "/content-factory", heading: "Start from a ready series", n: 3, covered: false, first: "cf.underwater-fashion-week", words: ["Fashion week, underwater", "Paris fashion week was held underwater"] },+ { path: "/explainer", heading: "Start from a ready explainer", n: 3, covered: false, first: "ex.couture-400-hours", words: ["A couture gown in 400 hours", "takes 400 hours to make"] },// An ad and a video ad wait for their own covers (a plain product shot isn't what they make).- { path: "/ads", heading: "Start from a ready brand", n: 2, covered: false, first: "ads.maison-verre" },- { path: "/marketing/click-to-ad", heading: "Start from a ready product", n: 2, covered: false, first: "c2a.eau-de-verre" },+ { path: "/ads", heading: "Start from a ready brand", n: 2, covered: false, first: "ads.maison-verre", words: ["Maison Verre perfume", "Studio Marlow leather"] },+ { path: "/marketing/click-to-ad", heading: "Start from a ready product", n: 2, covered: false, first: "c2a.eau-de-verre", words: ["Perfume video ad", "Handbag video ad"] },{ path: "/marketing", heading: "Start from a ready shoot", n: 2, covered: true, first: "mk.perfume-moss", tryIn: "/apps/app-product-shot?example=app-product-shot.1" },];@@ -86,8 +87,25 @@ try {check(`${tag}: ${s.path} visitor cards say See how it works`, (await section.getByText("See how it works").count()) === s.n && !/Use template|No cover yet/.test(await section.innerText()));const firstCard = await cards.first().evaluate((e) => e.getBoundingClientRect().top + window.scrollY);check(`${tag}: ${s.path} starters sit near the top`, firstCard < (size === "390" ? 2200 : 1400), `${Math.round(firstCard)} px`);+ // The first card's title is clear of the docked composer (nothing lies over it).+ const hidden = await cards+ .first()+ .locator("h3")+ .first()+ .evaluate((h) => {+ h.scrollIntoView({ block: "nearest" });+ const r = h.getBoundingClientRect();+ const at = document.elementFromPoint(r.left + Math.min(r.width / 2, 40), r.top + r.height / 2);+ return !at || !h.closest("article")?.contains(at);+ })+ .catch(() => true);+ check(`${tag}: ${s.path} first starter card is clear of the composer`, !hidden);} else {check(`${tag}: ${s.path} shows a visitor no starter without its cover`, n === 0 && !/No cover yet|Use template/.test(t) && !t.includes(s.heading));+ // Nor in the page's data: a cover-less starter's words never reach a visitor.+ const html = await (await ctx.request.get(`${app}${s.path}`)).text();+ const leak = s.words.find((w) => html.includes(w));+ check(`${tag}: ${s.path} sends a visitor none of a cover-less starter's words`, !leak, leak);}if (!owner) check(`${tag}: no model or engine words on ${s.path}`, !ENGINE_WORDS.test(n ? await section.innerText() : ""), (t.match(ENGINE_WORDS) ?? [""])[0]);check(`${tag}: no sideways scroll on ${s.path}`, (await sideways()) <= 1, `${await sideways()} px`);@@ -124,9 +142,12 @@ try {}check(`${tag}: no sideways scroll on ${s.first}'s page`, (await sideways()) <= 1, `${await sideways()} px`);} else {- await page.getByText("This starter isn't here.").waitFor({ timeout: 30_000 }).catch(() => {});- const pt = await text();- check(`${tag}: ${s.first} (no cover yet) isn't shown to a visitor`, /This starter isn.t here/.test(pt) && !/The steps/i.test(pt));+ // A real 404, with none of its words in what is sent.+ const r = await ctx.request.get(`${app}${s.path}/start/${s.first}`);+ const html = await r.text();+ const leak = s.words.find((w) => html.includes(w));+ check(`${tag}: ${s.first} (no cover yet) is a 404 for a visitor, with none of its words`, r.status() === 404 && !leak, `${r.status()} ${leak ?? ""}`);+ check(`${tag}: ${s.first}'s page shows a visitor no steps`, !/The steps/i.test(await text()));}await shot(`${name}-start`);}diff --git a/tests/starters-catalog.test.ts b/tests/starters-catalog.test.tsindex 1c103611..05a82e25 100644--- a/tests/starters-catalog.test.ts+++ b/tests/starters-catalog.test.ts@@ -3,9 +3,9 @@ import { renderToStaticMarkup } from "react-dom/server";import { describe, expect, it } from "vitest";import { MODELS } from "@/lib/catalog/models";import { guestRead, isLibraryChange } from "@/lib/guest-access";-import { recordForPath, unknownStarterPage } from "@/lib/record-pages";-import { assertStarters, STARTERS, starterCards, starterFills, starterIds, starterOn, type Starter } from "@/lib/starters/catalog";-import { STARTER_IDS } from "@/lib/starters/ids";+import { hiddenStarterPage, recordForPath, unknownStarterPage } from "@/lib/record-pages";+import { assertStarters, STARTERS, starterCards, starterCover, starterFills, starterIds, starterOn, starterVoice, type Starter } from "@/lib/starters/catalog";+import { STARTER_IDS, starterCovered } from "@/lib/starters/ids";import { STARTER_SURFACES, starterHref, starterShown, type StarterSurface } from "@/lib/starters/types";import { sampleFile } from "@/server/canvas-samples";import { exampleStat } from "@/server/example-files";@@ -84,9 +84,10 @@ describe("the starters catalog", () => {if (s.surface === "ads" || s.surface === "click-to-ad") expect(s.coverFrom, s.id).toBeUndefined();if (s.surface === "marketing") {expect(card.cover, s.id).toBeTruthy();- // It rests on the finished shot, and plays the clip.+ // The finished shot alone: never the app's before → after clip, which opens on the plain photo.expect(card.cover!.poster, s.id).toMatch(/^\/previews\/presets\/peak\/app-[a-z-]+\.jpg\?v=[0-9a-f]{8}$/);- expect(card.cover!.video, s.id).toMatch(/\?v=[0-9a-f]{8}$/);+ expect(card.cover!.video, s.id).toBeUndefined();+ expect(card.cover!.at, s.id).toBeUndefined();}// A product's photo shows on its page; words show as words; a visitor goes on to the app that makes the same.if (s.seed.kind === "product") {@@ -98,9 +99,12 @@ describe("the starters catalog", () => {}});- it("lists a surface's cards covered first, then by rank; a visitor sees only covered ones", () => {+ it("gives a page only the covered starters; the owner's list (all) has every one, covered first, then by rank", () => {for (const surface of SURFACES) {- const cards = starterCards(surface);+ // The prerendered page's props: no starter without its real cover, so its words never reach a visitor.+ expect(starterCards(surface).every((c) => !!c.cover), surface).toBe(true);+ expect(starterCards(surface).map((c) => c.id)).toEqual(starterCards(surface, { all: true }).filter((c) => c.cover).map((c) => c.id));+ const cards = starterCards(surface, { all: true });expect(cards.map((c) => c.id).sort()).toEqual(starterIds(surface).sort());const covered = cards.map((c) => !!c.cover);expect(covered, surface).toEqual([...covered].sort((a, b) => Number(b) - Number(a)));@@ -114,13 +118,26 @@ describe("the starters catalog", () => {});it("fills Content Factory and Explainer from the address, and makes the others on the server", () => {- for (const c of [...starterCards("content-factory"), ...starterCards("explainer")]) {+ for (const c of [...starterCards("content-factory", { all: true }), ...starterCards("explainer", { all: true })]) {expect(c.use.kind, c.id).toBe("fill");if (c.use.kind === "fill") expect(c.use.href).toBe(`${STARTER_SURFACES[c.surface].base}?starter=${encodeURIComponent(c.id)}`);}- for (const surface of ["faceless", "ads", "click-to-ad", "marketing"] as const) for (const c of starterCards(surface)) expect(c.use.kind, c.id).toBe("create");- expect(Object.keys(starterFills("content-factory")).sort()).toEqual(starterIds("content-factory").sort());- expect(Object.keys(starterFills("explainer")).sort()).toEqual(starterIds("explainer").sort());+ for (const surface of ["faceless", "ads", "click-to-ad", "marketing"] as const) for (const c of starterCards(surface, { all: true })) expect(c.use.kind, c.id).toBe("create");+ for (const surface of ["content-factory", "explainer"] as const) {+ expect(Object.keys(starterFills(surface, { all: true })).sort()).toEqual(starterIds(surface).sort());+ // A page's fills, like its cards, are the covered starters' only.+ expect(Object.keys(starterFills(surface)).sort()).toEqual(starterCards(surface).map((c) => c.id).sort());+ }+ });++ it("gives every narrated starter its own narrator sample's place, versioned, and none to the others", () => {+ for (const s of STARTERS) {+ const v = starterVoice(s);+ if (s.surface === "faceless" || s.surface === "content-factory" || s.surface === "explainer") expect(v?.src, s.id).toBe(`/starters/${s.id}/1/voice.m4a`);+ else expect(v, s.id).toBeUndefined();+ }+ // Read like Fuobe's other sample files once published, never by a path that steps out of public/.+ expect(sampleFile("/starters/x/../../package.json")).toBeNull();});});@@ -135,6 +152,16 @@ describe("who may use a starter", () => {}});+ it("keeps a starter with no cover yet the owner's: the proxy's 404 for others matches the catalog's covers", () => {+ for (const s of STARTERS) {+ expect(starterCovered(s.id), s.id).toBe(!!starterCover(s));+ expect(hiddenStarterPage(starterHref(s)), s.id).toBe(!starterCover(s));+ expect(hiddenStarterPage(`${starterHref(s)}/`), s.id).toBe(!starterCover(s));+ }+ expect(hiddenStarterPage("/explainer/start/nope.x")).toBe(false);+ expect(hiddenStarterPage("/faceless/abc/new")).toBe(false);+ });+it("answers a real 404 for a starter page that isn't that studio's (the proxy's client-safe id list matches the catalog)", () => {for (const surface of SURFACES) expect([...STARTER_IDS[surface]].sort(), surface).toEqual(starterIds(surface).sort());expect(unknownStarterPage("/ads/start/faceless.boat-hotels")).toBe(true);@@ -147,12 +174,14 @@ describe("who may use a starter", () => {it("makes a starter for the owner only: an account's POST is a library change", () => {for (const s of STARTERS) expect(isLibraryChange("POST", `/api/starters/${s.id}`), s.id).toBe(true);expect(isLibraryChange("GET", "/api/starters/faceless.boat-hotels")).toBe(false);+ // The owner's list of every starter (with the cover-less ones) is closed to guests and accounts.+ expect(guestRead("/api/starters")).toEqual({ kind: "closed" });});});describe("a starter's card", () => {const covered = starterCards("marketing")[0];- const bare = starterCards("faceless").find((c) => !c.cover);+ const bare = starterCards("faceless", { all: true }).find((c) => !c.cover);it("shows a visitor the cover, the steps in a few words and how it works; the owner a Use template", () => {const visitor = tile({ s: covered, owner: false, busy: false, onUse: () => {} });diff --git a/tests/starters-create.test.ts b/tests/starters-create.test.tsindex 8192535a..c4eb9cdd 100644--- a/tests/starters-create.test.ts+++ b/tests/starters-create.test.ts@@ -30,6 +30,7 @@ const ads = await import("@/server/ads");const { absolutePath, filesRel, listAssets } = await import("@/server/storage");const { sampleFile } = await import("@/server/canvas-samples");const route = await import("@/app/api/starters/[id]/route");+const listRoute = await import("@/app/api/starters/route");const explainerRoute = await import("@/app/api/explainer/route");const { STARTERS, facelessTopic, getStarter } = await import("@/lib/starters/catalog");const { getPreset } = await import("@/lib/catalog/content-factory");@@ -47,7 +48,7 @@ afterAll(() => {});const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));-const use = async (id: string, engine: "cloud" | "open" = "cloud") => {+const applyTemplate = async (id: string, engine: "cloud" | "open" = "cloud") => {const res = await route.POST(new Request("http://x/api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ engine }) }), { params: Promise.resolve({ id }) });return { status: res.status, body: (await res.json()) as { href?: string; error?: string } };};@@ -79,8 +80,8 @@ const of = (surface: string) => STARTERS.filter((s) => s.surface === surface);describe("Use template", () => {it("answers 404 for an unknown starter, and 400 for one that only fills its studio's composer", async () => {- expect((await use("faceless.nope")).status).toBe(404);- const fill = await use("cf.underwater-fashion-week");+ expect((await applyTemplate("faceless.nope")).status).toBe(404);+ const fill = await applyTemplate("cf.underwater-fashion-week");expect(fill.status).toBe(400);expect(fill.body.error).toMatch(/opens in its studio/);});@@ -89,7 +90,7 @@ describe("Use template", () => {const runs = of("faceless").map(async (s) => {const seed = s.seed.kind === "faceless" ? s.seed : null;if (!seed) throw new Error(s.id);- const { status, body } = await use(s.id);+ const { status, body } = await applyTemplate(s.id);expect(status, s.id).toBe(201);const m = /^\/faceless\/([^/]+)\/new\?starter=(.+)$/.exec(body.href ?? "");expect(m, body.href).toBeTruthy();@@ -108,6 +109,81 @@ describe("Use template", () => {await Promise.all(runs);}, 300_000);+ it("Faceless: Use template again opens the same channel, not a second one with the same name", async () => {+ const s = of("faceless")[0];+ const first = await applyTemplate(s.id);+ const again = await applyTemplate(s.id);+ expect(again.status).toBe(201);+ expect(again.body.href).toBe(first.body.href);+ const seed = s.seed.kind === "faceless" ? s.seed : null;+ expect(faceless.listChannels().filter((c) => c.name === seed!.channel.name)).toHaveLength(1);+ });++ it("Faceless and Explainer on the open engine: the starter's own narrator sample is in place, and the episode runs", async () => {+ // A starter whose narrator sample is published (here a copy of Fuobe's clean voice sample, at the starter's place).+ const s = of("faceless")[1];+ const ex = of("explainer")[0];+ const made: string[] = [];+ for (const id of [s.id, ex.id]) {+ const dirOf = path.join(process.cwd(), "public", "starters", id);+ if (!fs.existsSync(dirOf)) made.push(dirOf);+ fs.mkdirSync(path.join(dirOf, "1"), { recursive: true });+ fs.copyFileSync(path.join(process.cwd(), "public", "samples", "clean-voice", "clean.m4a"), path.join(dirOf, "1", "voice.m4a"));+ }+ try {+ const { status, body } = await applyTemplate(s.id, "open");+ expect(status, body.error).toBe(201);+ const channel = faceless.getChannel(/^\/faceless\/([^/]+)\/new/.exec(body.href!)![1])!;+ expect(channel.settings.voice).toMatchObject({ kind: "sample", url: expect.stringMatching(/^\/api\/files\//) });+ const topic = facelessTopic(s.id)!;+ const ep = faceless.createEpisode({ kind: "faceless", channelId: channel.id, topic, settings: { ...channel.settings, styleRefs: [], elements: [], engine: "open" } });+ await faceless.scriptWritten(ep.id);+ const v = await finished(ep.id);+ expect(v.episode.status, `${s.id}: ${v.episode.error ?? ""}`).toBe("done");+ expect(v.episode.settings.voice?.kind).toBe("sample");++ // The owner's list carries the explainer's sample, stored, in its fill; a page's props never do.+ const res = await listRoute.GET(new Request("http://x/api/starters?surface=explainer"));+ expect(res.status).toBe(200);+ const owner = (await res.json()) as { starters: { id: string }[]; fills: Record<string, { voiceSample?: string }> };+ expect(owner.starters.map((x) => x.id).sort()).toEqual(of("explainer").map((x) => x.id).sort());+ expect(owner.fills[ex.id]?.voiceSample).toMatch(/^\/api\/files\//);+ const f = ex.seed.kind === "fill" && ex.seed.fill.kind === "explainer" ? ex.seed.fill : null;+ const base = defaultSettings("open", genreInfo("education"), { explainer: true });+ const settings: EpisodeSettings = { ...base, engine: "open", styleId: f!.styleId, aspect: f!.aspect, voice: { kind: "sample", url: owner.fills[ex.id].voiceSample!, name: "Narrator" } };+ const made2 = await explainerRoute.POST(new Request("http://x/api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ prompt: f!.prompt, sources: [], settings }) }));+ expect(made2.status).toBe(201);+ const exEp = (await made2.json()) as { id: string };+ await faceless.scriptWritten(exEp.id);+ const ev = await finished(exEp.id);+ expect(ev.episode.status, `${ex.id}: ${ev.episode.error ?? ""}`).toBe("done");+ } finally {+ for (const d of made) fs.rmSync(d, { recursive: true, force: true });+ const root = path.join(process.cwd(), "public", "starters");+ if (fs.existsSync(root) && !fs.readdirSync(root).length) fs.rmdirSync(root);+ }+ expect((await listRoute.GET(new Request("http://x/api/starters?surface=nope"))).status).toBe(400);+ }, 300_000);++ it("on the open engine before a starter's own narrator exists: Fuobe's clean voice sample narrates, and the episode runs", async () => {+ const s = of("faceless")[2];+ expect(fs.existsSync(path.join(process.cwd(), "public", "starters", s.id, "1", "voice.m4a"))).toBe(false);+ const { status, body } = await applyTemplate(s.id, "open");+ expect(status, body.error).toBe(201);+ const channel = faceless.getChannel(/^\/faceless\/([^/]+)\/new/.exec(body.href!)![1])!;+ expect(channel.settings.voice).toMatchObject({ kind: "sample", url: expect.stringMatching(/^\/api\/files\//) });+ const ep = faceless.createEpisode({ kind: "faceless", channelId: channel.id, topic: facelessTopic(s.id)!, settings: { ...channel.settings, styleRefs: [], elements: [], engine: "open" } });+ await faceless.scriptWritten(ep.id);+ const v = await finished(ep.id);+ expect(v.episode.status, `${s.id}: ${v.episode.error ?? ""}`).toBe("done");++ // Every Content Factory and Explainer fill carries a narrator for the owner, so each runs on the open engine too.+ for (const surface of ["content-factory", "explainer"] as const) {+ const owner = (await (await listRoute.GET(new Request(`http://x/api/starters?surface=${surface}`))).json()) as { fills: Record<string, { voiceSample?: string }> };+ for (const x of of(surface)) expect(owner.fills[x.id]?.voiceSample, x.id).toMatch(/^\/api\/files\//);+ }+ }, 300_000);+it("Content Factory: each ready series plans on its trending style and makes its episode", async () => {const runs = of("content-factory").map(async (s) => {const f = s.seed.kind === "fill" && s.seed.fill.kind === "content-factory" ? s.seed.fill : null;@@ -146,7 +222,7 @@ describe("Use template", () => {it("Ads, Click to Ad and Marketing: one brand kit and product per brand, its photo stored once, out of the Library", async () => {for (const s of STARTERS.filter((x) => x.seed.kind === "product")) {- const { status, body } = await use(s.id);+ const { status, body } = await applyTemplate(s.id);expect(status, `${s.id} ${body.error ?? ""}`).toBe(201);expect(body.href, s.id).toMatch(s.surface === "ads" ? /^\/ads\/[^/?]+\?step=new$/ : s.surface === "click-to-ad" ? /^\/marketing\/click-to-ad\?product=/ : /^\/marketing\?template=[^&]+&product=/);}@@ -168,7 +244,7 @@ describe("Use template", () => {const marlow = brands.find((b) => b.name === "Studio Marlow")!;const bag = brand.listProducts(marlow.id)[0];brand.updateProduct(bag.id, { images: [] });- const again = await use("mk.bag-packshot");+ const again = await applyTemplate("mk.bag-packshot");expect(again.status).toBe(201);expect(again.body.href).toContain(`product=${bag.id}`);expect(brand.listProducts(marlow.id)).toHaveLength(1);@@ -177,7 +253,7 @@ describe("Use template", () => {it("Ads Studio: the ready brand makes its ads on the demo provider", async () => {for (const s of of("ads")) {- const { body } = await use(s.id);+ const { body } = await applyTemplate(s.id);const brandId = new URL(body.href!, "http://x").pathname.split("/").pop()!;const product = brand.listProducts(brandId)[0];const { creatives, run } = ads.createBatch({ brandId, engine: "cloud", items: [{ productId: product.id, count: 2 }] });@@ -193,7 +269,7 @@ describe("Use template", () => {it("Click to Ad: the ready product makes its 9:16 video ad on the demo provider", async () => {for (const s of of("click-to-ad")) {- const { body } = await use(s.id);+ const { body } = await applyTemplate(s.id);const productId = new URL(body.href!, "http://x").searchParams.get("product")!;const { run, script } = await mk.runClickToAd({ engine: "cloud", productId, styleId: "clean-minimal" });expect(script.length, s.id).toBeGreaterThan(10);@@ -206,7 +282,7 @@ describe("Use template", () => {it("Marketing Studio: the ready shoot runs its template on its product", async () => {for (const s of of("marketing")) {- const { body } = await use(s.id);+ const { body } = await applyTemplate(s.id);const q = new URL(body.href!, "http://x").searchParams;const template = TEMPLATE_INDEX.get(q.get("template")!)!;const product = brand.getProduct(q.get("product")!)!;