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
N7-6: Turnaround video on Character Sheet and Soul Cast results, Fly around on a character
Claudeb93f232c4c7d
diff --git a/src/components/cinema/soul-builders.tsx b/src/components/cinema/soul-builders.tsxindex ed68afd5..7751f443 100644--- a/src/components/cinema/soul-builders.tsx+++ b/src/components/cinema/soul-builders.tsx@@ -10,6 +10,7 @@ import { Input } from "@/components/ui/input";import { Slider } from "@/components/ui/slider";import { Textarea } from "@/components/ui/textarea";import { useSoulFinish } from "@/components/studio/soul-finish";+import { TurnaroundButton } from "@/components/turnaround/turnaround-dialog";import { useSaveElement, useStatus } from "@/lib/api";import { getModel } from "@/lib/catalog";import {@@ -32,6 +33,7 @@ import {type DirectorSettings,} from "@/lib/catalog/cinema";import { soulLook } from "@/lib/catalog/soul";+import { sheetPictures } from "@/lib/catalog/turnaround";import { finishedUrl } from "@/lib/soul-post";import type { Engine, Generation } from "@/lib/catalog/types";import { formatCost } from "@/lib/format";@@ -336,6 +338,7 @@ function SoulCast({ projectId, folderId, engine, context, brief, onOpenChange }:<div className="space-y-3 border-t pt-3"><p className="text-[12.5px] font-medium">Select an image variant for your cast</p><Results items={results} picked={chosen} onPick={(u) => setPicked((p) => (p.map(current).includes(u) ? [] : [u]))} />+ <CastTurnaround projectId={projectId} folderId={folderId} engine={engine} name={castName(visible)} results={results} picked={chosen[0]} /><SaveElement kind="character" defaultName={castName(visible)} picked={chosen} description={castPrompt(visible, notes)} onSaved={() => onOpenChange(false)} /></div>)}@@ -343,6 +346,36 @@ function SoulCast({ projectId, folderId, engine, context, brief, onOpenChange }:);}+/**+ * A Soul Cast result filmed all the way round (build plan N7-6), as a take in the project: the picked variant's sheet (and,+ * on the open engine, its four cut views), else the first finished one.+ */+function CastTurnaround({ projectId, folderId, engine, name, results, picked }: { projectId: string; folderId: string | null; engine: Engine; name: string; results: Generation[]; picked?: string }) {+ const generate = useCinemaGenerate(projectId);+ const done = results.filter((g) => g.status === "succeeded");+ const g = (picked && done.find((x) => x.outputs.some((o) => o.url === picked || o.meta?.original === picked))) || done[0];+ if (!g) return null;+ return (+ <div className="flex flex-wrap items-center gap-x-3 gap-y-2">+ <p className="min-w-0 flex-1 text-[12px] text-muted-foreground">{picked ? "Film the picked variant all the way round, as a new take." : "Film the first variant all the way round, as a new take."}</p>+ <TurnaroundButton+ key={g.id}+ pictures={sheetPictures(g)}+ name={name}+ engine={engine}+ fictional+ features={["cinema-turnaround"]}+ onRun={async (body) => {+ // The run's engine is the project's; consent and the character are /api/turnaround's (Soul Cast makes the person).+ const { views, sheet, route, fill, path, duration, aspectRatio } = body;+ const turnaround = { views, sheet, route, fill, path, duration, aspectRatio, name };+ return (await generate.mutateAsync({ input: { engine, mode: "video", action: "turnaround", prompt: "", settings: {}, turnaround }, folderId })).items;+ }}+ />+ </div>+ );+}+/** Soul Location: describe a set → 16:9 empty establishing shots → a location element (plus extra views). */export function SoulLocationDialog(props: BuilderProps) {return (diff --git a/src/components/element-studio.tsx b/src/components/element-studio.tsxindex 16683d17..4c86bb07 100644--- a/src/components/element-studio.tsx+++ b/src/components/element-studio.tsx@@ -9,10 +9,13 @@ import { StudioSkeleton } from "@/components/skeletons";import { StudioPage } from "@/components/studio/studio-page";import type { StudioConfig } from "@/components/studio/studio-context";import { TrainDialog } from "@/components/train-dialog";+import { TurnaroundButton, useCharacterPictures } from "@/components/turnaround/turnaround-dialog";import { Button } from "@/components/ui/button";import { useElement } from "@/lib/api";import { loraFamily, TRAINING_FAMILIES } from "@/lib/catalog/training";+const NO_REFS: string[] = [];+/*** A studio for one element: the prompt starts with its @handle, references are resolved by the* server. Lives apart from the Elements list so /elements doesn't load the composer.@@ -22,6 +25,8 @@ export function ElementStudio({ id }: { id: string }) {const [editing, setEditing] = useState(false);const [training, setTraining] = useState(false);const el = q.data;+ // A character's pictures (a wide one is its sheet) for "Fly around this character".+ const pictures = useCharacterPictures(el?.kind === "character" ? el.references.slice(0, 12) : NO_REFS);const config = useMemo<StudioConfig | null>(() => {if (!el) return null;// A trained Soul ID runs on its family's lead model (Fuobe Soul, Soul HD, FLUX…): start there, on each engine it has.@@ -96,6 +101,9 @@ export function ElementStudio({ id }: { id: string }) {<span className="hidden sm:inline">{trainLabel}</span></Button>)}+ {el.kind === "character" && el.references.length > 0 && (+ <TurnaroundButton flyAround label="Fly around" variant="ghost" compact pictures={pictures} name={el.name} elementId={el.id} realPerson />+ )}<Button variant="ghost" size="sm" onClick={() => setEditing(true)} aria-label={`Edit ${el.name}`}><Pencil /> <span className="hidden sm:inline">Edit</span></Button>diff --git a/src/components/fashion/character-sheet.tsx b/src/components/fashion/character-sheet.tsxindex 932ed689..3a47bc0e 100644--- a/src/components/fashion/character-sheet.tsx+++ b/src/components/fashion/character-sheet.tsx@@ -14,8 +14,10 @@ import { radioKeys, radioTab } from "@/components/studio/radio-keys";import { useRun, useRunPreview } from "@/components/photodump/hooks";import { ResultsGrid } from "@/components/photodump/results";import { RunLine } from "@/components/photodump/steps";+import { TurnaroundButton } from "@/components/turnaround/turnaround-dialog";import { useElements, useEngine, useGenerations, useSaveElement } from "@/lib/api";import { castFieldVisible, castNameFor, randomCast, SHEET_MAX_REFS, type CastAnswers, type CastFieldData } from "@/lib/catalog/packs";+import { sheetPictures } from "@/lib/catalog/turnaround";import type { Generation } from "@/lib/catalog/types";import { cn } from "@/lib/utils";@@ -305,12 +307,24 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldDataonRetried={(from, to) => setIds((xs) => (xs.length ? xs.flatMap((id) => (id === from ? to : [id])) : xs))}/>{latest && (- <SaveCharacter- key={latest.id}- item={latest}- extra={(latest.request.inputs?.images ?? []).filter((u) => u.startsWith("/api/files/"))}- defaultName={mode === "cast" ? castNameFor(cast) : "My character"}- />+ <>+ <div className="flex flex-wrap items-center gap-x-3 gap-y-2 rounded-2xl border bg-background p-3">+ <p className="min-w-0 flex-1 text-[13px] text-muted-foreground">Film the character all the way round: front, right side, back, left side.</p>+ <TurnaroundButton+ key={latest.id}+ pictures={sheetPictures(latest)}+ name={mode === "cast" ? castNameFor(cast) : undefined}+ // Photos someone brought are of a real person: the consent line is asked for.+ realPerson={(latest.request.inputs?.images ?? []).some((u) => u.startsWith("/api/files/"))}+ />+ </div>+ <SaveCharacter+ key={`save-${latest.id}`}+ item={latest}+ extra={(latest.request.inputs?.images ?? []).filter((u) => u.startsWith("/api/files/"))}+ defaultName={mode === "cast" ? castNameFor(cast) : "My character"}+ />+ </>)}</>) : (diff --git a/src/components/turnaround/turnaround-dialog.tsx b/src/components/turnaround/turnaround-dialog.tsxnew file mode 100644index 00000000..3f573e06--- /dev/null+++ b/src/components/turnaround/turnaround-dialog.tsx@@ -0,0 +1,441 @@+"use client";++import { useMutation, useQuery, keepPreviousData } from "@tanstack/react-query";+import { AlertTriangle, Check, ImageOff, Loader2, Rotate3d, Sparkles } from "lucide-react";+import Link from "next/link";+import { useEffect, useMemo, useState } from "react";+import { toast } from "sonner";+import { EngineSwitch } from "@/components/studio/engine-switch";+import { radioKeys, radioTab } from "@/components/studio/radio-keys";+import { Button } from "@/components/ui/button";+import { Checkbox } from "@/components/ui/checkbox";+import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";+import { Progress } from "@/components/ui/progress";+import { Switch } from "@/components/ui/switch";+import { useEngine, useGenerations } from "@/lib/api";+import { SOUL_ID_COPY } from "@/lib/catalog/training";+import {+ SIDE_NAMES,+ SIDES_HINT,+ TURN_PATHS,+ TURN_ROUTES,+ TURN_SIDES,+ elementPictures,+ startingViews,+ type TurnPicture,+ type TurnRoute,+ type TurnSide,+ type TurnaroundPreview,+} from "@/lib/catalog/turnaround";+import type { Engine, Generation } from "@/lib/catalog/types";+import { formatCost } from "@/lib/format";+import { cn } from "@/lib/utils";++/** The body /api/turnaround takes (src/server/turnaround.ts TurnaroundSchema). */+export interface TurnaroundBody {+ engine: Engine;+ views: Partial<Record<TurnSide, string>>;+ sheet?: string;+ route?: TurnRoute;+ fill?: boolean;+ path?: string;+ duration?: number;+ aspectRatio?: "9:16" | "16:9";+ name?: string;+ realPerson?: boolean;+ consent?: boolean;+ elementId?: string;+}++interface Props {+ /** The pictures the sheet or the character offers (src/lib/catalog/turnaround.ts sheetPictures / elementPictures). */+ pictures: TurnPicture[];+ name?: string;+ /** Start with "A real person" on (photos the user brought), so the consent line is asked for. */+ realPerson?: boolean;+ /** Made from a character's page: the film goes into its feed. */+ elementId?: string;+ /** A fixed engine (Cinema's project engine); otherwise the app's engine switch. */+ engine?: Engine;+ /** Run it elsewhere (Cinema files it as a take); otherwise POST /api/turnaround. Returns the generations made. */+ onRun?: (body: TurnaroundBody) => Promise<Generation[]>;+ /** The features the run's rows are filed under, to follow its progress. */+ features?: string[];+ title?: string;+ /** "Fly around": the character page's wording, with the camera path's moves. */+ flyAround?: boolean;+ /** A person Fuobe made up (Soul Cast): no consent line to ask for. */+ fictional?: boolean;+}++async function post<T>(url: string, body: unknown): Promise<T> {+ const res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });+ const out = (await res.json().catch(() => ({}))) as T & { error?: string };+ if (!res.ok) throw new Error(out.error ?? `Request failed (${res.status})`);+ return out;+}++type Run = { ids: string[]; filmId: string };++const runFeatures = (p: Pick<Props, "features" | "elementId">) => p.features ?? (p.elementId ? [`element:${p.elementId}`, "turnaround-step"] : ["turnaround", "turnaround-step"]);++/** A run's rows as the live feed has them: how many steps are done, what is working, the film once it's made. */+function useRunState(run: Run | null, features: string[]) {+ const list = useGenerations({ features, limit: 200 });+ const rows = run ? (list.data ?? []).filter((g) => run.ids.includes(g.id)) : [];+ const film = run ? rows.find((g) => g.id === run.filmId) : undefined;+ const failed = rows.find((g) => g.status === "failed" || g.status === "canceled");+ return {+ rows,+ film,+ failed,+ done: rows.filter((g) => g.status === "succeeded").length,+ total: run?.ids.length ?? 0,+ working: rows.find((g) => g.status === "running") ?? rows.filter((g) => g.status === "queued" && g.id !== run?.filmId).at(-1),+ video: film?.status === "succeeded" ? film.outputs.find((o) => o.kind === "video") : undefined,+ };+}++/**+ * "Turnaround video" / "Fly around this character": a button that opens the dialog. The run it starts stays with the+ * button while the page is open: the button says how far it got, and opening it again shows the progress or the film.+ */+export function TurnaroundButton({+ label,+ variant = "outline",+ size = "sm",+ className,+ compact,+ ...props+}: Props & { label?: string; variant?: "outline" | "secondary" | "ghost" | "default"; size?: "sm" | "default"; className?: string; compact?: boolean }) {+ const [open, setOpen] = useState(false);+ const [run, setRun] = useState<Run | null>(null);+ const state = useRunState(run, runFeatures(props));+ const text = label ?? (props.flyAround ? "Fly around this character" : "Turnaround video");+ const status = !run ? undefined : state.video ? "ready" : state.failed ? "stopped" : `${state.done} of ${state.total}`;+ return (+ <>+ <Button+ type="button"+ variant={variant}+ size={size}+ className={className}+ disabled={!props.pictures.length}+ onClick={() => setOpen(true)}+ aria-label={compact ? `${text}${status ? ` (${status})` : ""}` : undefined}+ >+ {run && !state.video && !state.failed ? <Loader2 className="animate-spin" /> : <Rotate3d />}+ <span className={cn(compact && "hidden sm:inline")}>{text}</span>+ {status && <span className={cn("font-mono text-[11px] text-muted-foreground", compact && "hidden sm:inline")}>· {status}</span>}+ </Button>+ <Dialog open={open} onOpenChange={setOpen}>+ <DialogContent className="max-h-[92svh] gap-3 overflow-y-auto sm:max-w-[640px]">+ {open && (run ? <RunView heading={headingOf(props)} state={state} elementId={props.elementId} onAgain={() => setRun(null)} /> : <TurnaroundForm {...props} onStarted={setRun} />)}+ </DialogContent>+ </Dialog>+ </>+ );+}++const headingOf = (p: Pick<Props, "title" | "flyAround" | "name">) => p.title ?? (p.flyAround ? `Fly around ${p.name ?? "this character"}` : "Turnaround video");++const SLOT_KEYS = [...TURN_SIDES, "sheet"] as const;+type SlotKey = (typeof SLOT_KEYS)[number];++function Thumb({ url, className }: { url?: string; className?: string }) {+ // eslint-disable-next-line @next/next/no-img-element+ return url ? <img src={url} alt="" className={cn("size-full object-cover", className)} /> : null;+}++function TurnaroundForm({ pictures, name, realPerson: realDefault = false, elementId, engine: fixedEngine, onRun, title, flyAround, fictional, onStarted }: Props & { onStarted: (run: Run) => void }) {+ const [appEngine, setAppEngine] = useEngine();+ const engine = fixedEngine ?? appEngine;+ const start = useMemo(() => startingViews(pictures), [pictures]);+ const [views, setViews] = useState<Partial<Record<TurnSide, string>>>(start.views);+ const [sheet, setSheet] = useState<string | undefined>(start.sheet);+ const [fill, setFill] = useState<boolean | undefined>(undefined);+ // The route and length picked hold for the engine they were picked on: another engine starts from its own defaults.+ const [picked, setPicked] = useState<{ engine: Engine; route?: TurnRoute; duration?: number }>({ engine });+ const route = picked.engine === engine ? picked.route : undefined;+ const duration = picked.engine === engine ? picked.duration : undefined;+ const setRoute = (r: TurnRoute) => setPicked({ engine, route: r });+ const setDuration = (d: number) => setPicked((x) => ({ ...(x.engine === engine ? x : { engine }), duration: d }));+ const [path, setPath] = useState<string | undefined>(undefined);+ const [aspectRatio, setAspect] = useState<"9:16" | "16:9">("9:16");+ const [realPerson, setReal] = useState(realDefault);+ const [consent, setConsent] = useState(false);++ const body: TurnaroundBody = {+ engine,+ views,+ ...(sheet && { sheet }),+ ...(route && { route }),+ ...(fill !== undefined && { fill }),+ ...(path && { path }),+ ...(duration && { duration }),+ aspectRatio,+ ...(name && { name }),+ ...(realPerson && { realPerson, consent }),+ ...(elementId && { elementId }),+ };+ const preview = useQuery({+ queryKey: ["turnaround-preview", body],+ queryFn: () => post<TurnaroundPreview>("/api/turnaround?preview=1", body),+ placeholderData: keepPreviousData,+ staleTime: 15_000,+ });+ const p = preview.data;+ const make = useMutation({+ mutationFn: async (b: TurnaroundBody) => (onRun ? onRun(b) : (await post<{ items: Generation[] }>("/api/turnaround", { ...b, requestId: crypto.randomUUID() })).items),+ // The film: the joined clips, else the one video the run makes (the pictures drawn first are stills).+ onSuccess: (items) => onStarted({ ids: items.map((g) => g.id), filmId: (items.find((g) => g.op === "concat") ?? items.find((g) => g.kind === "video") ?? items[0])?.id }),+ onError: (e) => toast.error((e as Error).message),+ });++ const usedRoute = p?.route ?? route;+ const camera = usedRoute === "camera";+ const slotUrl = (k: SlotKey) => (k === "sheet" ? sheet : views[k]);+ const setSlot = (k: SlotKey, url: string | undefined) => {+ if (k === "sheet") setSheet(url);+ else setViews((v) => ({ ...v, [k]: url }));+ };+ const price = !p ? "" : p.demo ? "Demo · free" : engine === "open" ? `Free · on your GPU${p.gpuGb ? `, about ${p.gpuGb} GB` : ""}` : p.costUsd != null ? `≈ ${formatCost(p.costUsd)}` : "";+ const heading = headingOf({ title, flyAround, name });++ return (+ <>+ <DialogHeader>+ <DialogTitle className="font-heading text-[24px] font-normal">{heading}</DialogTitle>+ <DialogDescription>The camera goes all the way round {name ? name : "the character"}, starting and ending on the front: the front, their right side, their back, their left side.</DialogDescription>+ </DialogHeader>++ {!fixedEngine && (+ <div className="flex flex-wrap items-center gap-2">+ <EngineSwitch value={appEngine} onChange={setAppEngine} size="sm" compact={false} />+ </div>+ )}++ <section aria-label="Views" className="space-y-2">+ <div className="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1">+ <p className="text-[13px] font-medium">Views</p>+ <p className="text-[11.5px] text-muted-foreground">{SIDES_HINT}</p>+ </div>+ <div className="grid grid-cols-5 gap-1.5 sm:gap-2">+ {SLOT_KEYS.map((k) => {+ const url = slotUrl(k);+ const frame = p?.frames.find((f) => f.side === k);+ const drawn = !url && (frame?.from === "angles" || frame?.from === "sheet");+ const label = k === "sheet" ? "Sheet" : SIDE_NAMES[k];+ return (+ <DropdownMenu key={k}>+ <DropdownMenuTrigger asChild>+ <button+ type="button"+ aria-label={`${label}: ${url ? "a picture" : drawn ? "drawn first" : k === "front" ? "pick one" : "not used"} — change`}+ className="group flex min-w-0 flex-col gap-1 rounded-xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <span+ className={cn(+ "relative grid aspect-[3/4] w-full place-items-center overflow-hidden rounded-xl border bg-muted transition-colors group-hover:border-foreground/30",+ !url && "border-dashed",+ k === "front" && !url && !drawn && "border-destructive/60",+ )}+ >+ {url ? (+ <Thumb url={url} />+ ) : drawn ? (+ <span className="flex flex-col items-center gap-1 px-1 text-center text-[10.5px] leading-tight text-muted-foreground">+ <Sparkles className="size-4" aria-hidden />+ {frame?.from === "sheet" ? "From the sheet" : "Drawn first"}+ </span>+ ) : (+ <ImageOff className="size-4 text-muted-foreground/70" aria-hidden />+ )}+ </span>+ <span className="truncate text-[11.5px] font-medium">{label}</span>+ </button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" className="w-64">+ <DropdownMenuLabel>{label}</DropdownMenuLabel>+ {pictures+ .filter((pic) => (k === "sheet" ? pic.sheet : !pic.sheet))+ .map((pic) => (+ <DropdownMenuItem key={pic.url} onSelect={() => setSlot(k, pic.url)}>+ <span className="size-8 shrink-0 overflow-hidden rounded-md bg-muted">+ <Thumb url={pic.url} />+ </span>+ <span className="min-w-0 flex-1 truncate">{pic.label}</span>+ {slotUrl(k) === pic.url && <Check className="size-4" />}+ </DropdownMenuItem>+ ))}+ <DropdownMenuSeparator />+ <DropdownMenuItem onSelect={() => setSlot(k, undefined)}>+ {k === "sheet" ? "Don't use the sheet" : k === "front" ? (sheet ? "Draw it from the sheet" : "None") : "Draw it from the front, or leave it out"}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+ })}+ </div>+ {!camera && (+ <label className="flex items-center justify-between gap-3 rounded-xl border px-3 py-2">+ <span className="min-w-0">+ <span className="block text-[13px] font-medium">Draw the missing sides</span>+ <span className="block text-[11.5px] text-muted-foreground">The Angles app turns the front view round first; without it, the film goes from one view you have to the next</span>+ </span>+ <Switch checked={p?.fill ?? fill ?? true} onCheckedChange={(v) => setFill(v)} aria-label="Draw the missing sides" />+ </label>+ )}+ </section>++ {p && p.routes.length > 1 && (+ <Chips label="Route" value={usedRoute} options={p.routes.map((r) => ({ value: r, label: TURN_ROUTES[r].name }))} onChange={(v) => setRoute(v as TurnRoute)} hint={usedRoute ? TURN_ROUTES[usedRoute].detail : undefined} />+ )}+ {p && p.routes.length === 1 && usedRoute && <p className="text-[12px] text-muted-foreground">{TURN_ROUTES[usedRoute].detail}.</p>}+ {camera && <Chips label="Path" value={path ?? TURN_PATHS[0].id} options={TURN_PATHS.map((x) => ({ value: x.id, label: x.name }))} onChange={setPath} hint={TURN_PATHS.find((x) => x.id === (path ?? TURN_PATHS[0].id))?.description} />}+ <div className="flex flex-wrap gap-x-6 gap-y-3">+ {p && <Chips label="Length" value={String(p.duration)} options={p.durations.map((d) => ({ value: String(d), label: `${d} s` }))} onChange={(v) => setDuration(Number(v))} />}+ {!camera && (+ <Chips+ label="Shape"+ value={aspectRatio}+ options={[+ { value: "9:16", label: "Portrait" },+ { value: "16:9", label: "Landscape" },+ ]}+ onChange={(v) => setAspect(v as "9:16" | "16:9")}+ />+ )}+ </div>++ {!fictional && (+ <section aria-label="Consent" className="space-y-2 rounded-xl border p-3">+ <label className="flex items-center justify-between gap-3">+ <span className="text-[13px] font-medium">A real person</span>+ <Switch checked={realPerson} onCheckedChange={setReal} aria-label="These pictures show a real person" />+ </label>+ {realPerson ? (+ <label className="flex items-start gap-2 text-[12px] leading-snug text-muted-foreground">+ <Checkbox checked={consent} onCheckedChange={(v) => setConsent(v === true)} className="mt-0.5" aria-label="I confirm the consent line" />+ <span>{SOUL_ID_COPY.consent}</span>+ </label>+ ) : (+ <p className="text-[11.5px] text-muted-foreground">Turn this on when the pictures show someone real: their consent is needed, as for a Soul ID.</p>+ )}+ <p className="text-[11.5px] text-muted-foreground">Don't use a turnaround to pass someone off as doing something they didn't.</p>+ </section>+ )}++ {p && (p.notes.length > 0 || p.blocker) && (+ <ul className="space-y-0.5 text-[12px] text-muted-foreground">+ {p.notes.map((n) => (+ <li key={n}>{n}</li>+ ))}+ </ul>+ )}+ <div className="flex flex-wrap items-center justify-end gap-x-3 gap-y-2 border-t pt-3">+ {p?.blocker && (+ <p role="status" className="mr-auto flex min-w-0 items-center gap-1.5 text-[12.5px] text-destructive">+ <AlertTriangle className="size-3.5 shrink-0" aria-hidden /> {p.blocker}+ </p>+ )}+ <span className="font-mono text-[12px] whitespace-nowrap text-muted-foreground" aria-live="polite">+ {preview.isFetching && !p ? "Pricing…" : price}+ </span>+ <Button onClick={() => make.mutate(body)} disabled={!p || !!p.blocker || make.isPending || preview.isFetching}>+ {make.isPending ? <Loader2 className="animate-spin" /> : <Rotate3d />} {flyAround ? "Fly around" : "Make turnaround"}+ </Button>+ </div>+ </>+ );+}++function Chips({ label, value, options, onChange, hint }: { label: string; value?: string; options: { value: string; label: string }[]; onChange: (v: string) => void; hint?: string }) {+ return (+ <div className="min-w-0 space-y-1.5">+ <p className="text-[12.5px] font-medium">{label}</p>+ <div role="radiogroup" aria-label={label} onKeyDown={radioKeys} className="flex flex-wrap gap-1.5">+ {options.map((o) => (+ <button+ key={o.value}+ type="button"+ role="radio"+ aria-checked={value === o.value}+ tabIndex={radioTab(value === o.value)}+ onClick={() => onChange(o.value)}+ className={cn("h-8 rounded-full border px-3 text-[12.5px] font-medium transition-colors", value === o.value ? "border-primary bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent")}+ >+ {o.label}+ </button>+ ))}+ </div>+ {hint && <p className="text-[11.5px] text-muted-foreground">{hint}</p>}+ </div>+ );+}++/**+ * A character's pictures with their shapes, measured in the browser (a wide one is its sheet): elementPictures, before the+ * sizes are in with every picture taken as a photo.+ */+export function useCharacterPictures(urls: string[]): TurnPicture[] {+ const key = urls.join("\n");+ const [sizes, setSizes] = useState<{ key: string; list: { url: string; width?: number; height?: number }[] } | null>(null);+ useEffect(() => {+ let live = true;+ const list = key ? key.split("\n") : [];+ void Promise.all(+ list.map(+ (url) =>+ new Promise<{ url: string; width?: number; height?: number }>((done) => {+ const img = new Image();+ img.onload = () => done({ url, width: img.naturalWidth, height: img.naturalHeight });+ img.onerror = () => done({ url });+ img.src = url;+ }),+ ),+ ).then((measured) => live && setSizes({ key, list: measured }));+ return () => {+ live = false;+ };+ }, [key]);+ return useMemo(() => elementPictures(sizes?.key === key ? sizes.list : urls.map((url) => ({ url }))), [sizes, key, urls]);+}++/** A run's progress, then the finished turnaround. */+function RunView({ heading, state, elementId, onAgain }: { heading: string; state: ReturnType<typeof useRunState>; elementId?: string; onAgain: () => void }) {+ const { video, failed, done, total, working } = state;+ return (+ <>+ <DialogHeader>+ <DialogTitle className="font-heading text-[24px] font-normal">{heading}</DialogTitle>+ <DialogDescription>{video ? "Your turnaround is ready." : failed ? "A step didn't finish." : "Making it now: you can close this, it carries on."}</DialogDescription>+ </DialogHeader>+ {video ? (+ <video src={video.url} controls loop playsInline autoPlay muted className="max-h-[60svh] w-full rounded-xl bg-black object-contain" aria-label={`${heading}, the video`} />+ ) : failed ? (+ <p role="alert" className="rounded-xl border border-destructive/40 p-3 text-[13px] text-destructive">+ {failed.request.step?.label ? `${failed.request.step.label}: ` : ""}+ {failed.error ?? "It stopped before the end"}+ </p>+ ) : (+ <div className="space-y-2" role="status" aria-live="polite">+ <Progress value={total ? (done / total) * 100 : 0} aria-label="Turnaround progress" />+ <p className="text-[12.5px] text-muted-foreground">+ {done} of {total} steps done{working ? ` · ${working.request.step?.label ?? working.message ?? "Working"}` : ""}+ </p>+ </div>+ )}+ <div className="flex flex-wrap items-center justify-end gap-2 border-t pt-3">+ <p className="mr-auto text-[12px] text-muted-foreground">{elementId ? "It's in this character's feed and the Library." : "It's in the Library too."}</p>+ <Button asChild variant="ghost" size="sm">+ <Link href="/library">Open the Library</Link>+ </Button>+ <Button variant="outline" size="sm" onClick={onAgain}>+ Make another+ </Button>+ </div>+ </>+ );+}diff --git a/src/lib/catalog/turnaround.ts b/src/lib/catalog/turnaround.tsindex 5a58a925..71734265 100644--- a/src/lib/catalog/turnaround.ts+++ b/src/lib/catalog/turnaround.ts@@ -585,3 +585,24 @@ export function planTurnaround(input: TurnaroundInput, ctx: TurnaroundContext =costUsd: cost === null ? null : Math.round(cost * 1000) / 1000,};}++/** What /api/turnaround?preview=1 answers: the plan as this install would run it (src/server/turnaround.ts). */+export interface TurnaroundPreview {+ route: TurnRoute;+ routes: TurnRoute[];+ model: { id: string; name: string };+ duration: number;+ durations: number[];+ frames: TurnFrame[];+ fills: TurnSide[];+ frontFromSheet: boolean;+ fill: boolean;+ steps: number;+ notes: string[];+ blocker?: string;+ costUsd: number | null;+ /** Some step runs on the demo provider (no key, or ComfyUI not reachable, with demo mode on). */+ demo: boolean;+ /** The open engine: the most VRAM a step needs (GB). */+ gpuGb?: number;+}diff --git a/src/server/turnaround.ts b/src/server/turnaround.tsindex f964eeed..6e4deefb 100644--- a/src/server/turnaround.ts+++ b/src/server/turnaround.ts@@ -3,7 +3,7 @@ import { nanoid } from "nanoid";import { z } from "zod";import { getModel } from "@/lib/catalog";import { routesFor } from "@/lib/catalog/plan";-import { planTurnaround, type TurnaroundContext, type TurnaroundInput, type TurnaroundPlan, type TurnStep } from "@/lib/catalog/turnaround";+import { planTurnaround, type TurnaroundContext, type TurnaroundInput, type TurnaroundPlan, type TurnaroundPreview, type TurnStep } from "@/lib/catalog/turnaround";import type { Generation } from "@/lib/catalog/types";import { cancelGeneration, createGenerations, previewChained, previewGeneration } from "./generations";import { isOffered } from "./model-access";@@ -92,25 +92,6 @@ function gpuGb(plan: TurnaroundPlan): number | undefined {return most;}-export interface TurnaroundPreview {- route: TurnaroundPlan["route"];- routes: TurnaroundPlan["routes"];- model: { id: string; name: string };- duration: number;- durations: number[];- frames: TurnaroundPlan["frames"];- fills: TurnaroundPlan["fills"];- frontFromSheet: boolean;- fill: boolean;- steps: number;- notes: string[];- blocker?: string;- costUsd: number | null;- /** Some step runs on the demo provider (no key, or ComfyUI not reachable, with demo mode on). */- demo: boolean;- /** The open engine: the most VRAM a step needs (GB). */- gpuGb?: number;-}/** The run as the server would make it, priced, without running it. */export function previewTurnaround(input: TurnaroundRequest): TurnaroundPreview {