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
Idol 3D: a clean splat's camera still is never a poster, tile or shown piece
Adarshde4d8baa45e7
diff --git a/src/components/assist-view.tsx b/src/components/assist-view.tsxindex 8a96b26f..7fb1bc24 100644--- a/src/components/assist-view.tsx+++ b/src/components/assist-view.tsx@@ -26,6 +26,7 @@ import { StarterSection, useStarters } from "@/components/starters/starter-sectiimport { useSkillBuilder } from "@/components/skills/skill-builder-provider";import { useAssistActions, useAssistThread, useEngine } from "@/lib/api";import { ASSIST_SUGGESTIONS, assistDraft, modeLabel, threadModeChoice, type AssistAvailability, type AssistModeChoice, type AssistProject, type AssistThread, type SkillSummary } from "@/lib/assist";+import { showableOutputs } from "@/lib/av/idol-camera-still";import type { Generation } from "@/lib/catalog/types";import { starterShown, type StarterCardData, type StarterFill } from "@/lib/starters/types";import { cn } from "@/lib/utils";@@ -135,7 +136,8 @@ export function AssistView({ starters: given = [], fills: givenFills = {} }: { s() =>(thread?.items ?? []).flatMap((i) => (i.role === "generations" ? i.ids : [])).flatMap((gid) => {const g = all.get(gid);- return g?.status === "succeeded" ? g.outputs.map((_, k) => ({ g, i: k })) : [];+ // The Viewer's arrows skip what the chat doesn't tile (a clean Idol splat's camera still).+ return g?.status === "succeeded" ? showableOutputs(g).map((k) => ({ g, i: k })) : [];}),[thread?.items, all],);diff --git a/src/components/assist/project-view.tsx b/src/components/assist/project-view.tsxindex 5634a465..ef8b611e 100644--- a/src/components/assist/project-view.tsx+++ b/src/components/assist/project-view.tsx@@ -48,6 +48,7 @@ import { AssistComposer } from "@/components/assist/composer";import { chatSkills, NewChatControls, SkillStarters } from "@/components/assist-view";import { useElements, useEngine } from "@/lib/api";import { MAX_PROJECT_SOURCES, type AssistProject, type ProjectSource, type SourceKind } from "@/lib/assist";+import { showableOutputs } from "@/lib/av/idol-camera-still";import { isPlaceholder, PLACEHOLDER_CHIP } from "@/lib/demo-mode";import { timeAgo } from "@/lib/format";import { cn } from "@/lib/utils";@@ -230,7 +231,9 @@ function Assets({ p, active }: { p: AssistProject; active: boolean }) {const assets = useProjectAssets(p.id, active);const [open, setOpen] = useState<{ at: number; i: number } | null>(null);const list = assets.data ?? [];- const tiles = list.flatMap((a, at) => a.generation.outputs.map((o, i) => ({ a, at, o, i })));+ // Every output but a clean Idol splat's camera still (src/lib/av/idol-camera-still.ts).+ const tiles = list.flatMap((a, at) => showableOutputs(a.generation).map((i) => ({ a, at, o: a.generation.outputs[i], i })));+ const first = (at: number) => showableOutputs(list[at].generation)[0] ?? 0;if (assets.isLoading)return (<div className="grid grid-cols-3 gap-2 sm:grid-cols-4">@@ -263,8 +266,8 @@ function Assets({ p, active }: { p: AssistProject; active: boolean }) {generation={cur.generation}index={open.i}onClose={() => setOpen(null)}- onPrev={open.at > 0 ? () => setOpen({ at: open.at - 1, i: 0 }) : undefined}- onNext={open.at < list.length - 1 ? () => setOpen({ at: open.at + 1, i: 0 }) : undefined}+ onPrev={open.at > 0 ? () => setOpen({ at: open.at - 1, i: first(open.at - 1) }) : undefined}+ onNext={open.at < list.length - 1 ? () => setOpen({ at: open.at + 1, i: first(open.at + 1) }) : undefined}/>)}</>diff --git a/src/components/assist/transcript.tsx b/src/components/assist/transcript.tsxindex 474219c9..ed809ca8 100644--- a/src/components/assist/transcript.tsx+++ b/src/components/assist/transcript.tsx@@ -8,6 +8,7 @@ import { PlaceholderChip } from "@/components/demo-mode";import { FailedTile, MediaThumb, PendingTile, tileRatio } from "@/components/studio/feed";import { useCreateGeneration } from "@/lib/api";import { memoryCardLine, planRunnable, type AssistItem, type AssistThread, type SkillSummary } from "@/lib/assist";+import { showableOutputs } from "@/lib/av/idol-camera-still";import type { Generation } from "@/lib/catalog/types";import { isPlaceholder, PLACEHOLDER_CHIP } from "@/lib/demo-mode";import { formatCost } from "@/lib/format";@@ -147,7 +148,9 @@ export function GenerationCards({ ids, all, storyboard, onOpen }: { ids: string[const tiles = gens.flatMap((g) => {const ratio = tileRatio(g);if (g.status === "succeeded") {- return g.outputs.map((o, i) => {+ // Every output but a clean Idol splat's camera still; a 3D model's tile plays its orbit (MediaThumb reads it from g).+ return showableOutputs(g).map((i) => {+ const o = g.outputs[i];const n = stills > 1 && g.kind === "image" && o.kind === "image" ? ++take : 0;return (<div key={`${g.id}-${i}`} className="relative">@@ -158,7 +161,7 @@ export function GenerationCards({ ids, all, storyboard, onOpen }: { ids: string[aria-label={`Open ${n ? `take ${n}: ` : ""}${g.request.prompt?.slice(0, 60) || "result"}`}>{/* A text card says "Placeholder" in its own header row: on a narrow tile a corner badge would cover its label. */}- <MediaThumb output={o} className="transition duration-300 group-hover:scale-[1.02]" tag={isPlaceholder(g) && o.kind === "text" ? PLACEHOLDER_CHIP : undefined} />+ <MediaThumb output={o} g={g} className="transition duration-300 group-hover:scale-[1.02]" tag={isPlaceholder(g) && o.kind === "text" ? PLACEHOLDER_CHIP : undefined} />{n > 0 && (<span aria-hidden className="absolute top-2 right-2 grid size-6 place-items-center rounded-full bg-background/85 text-[12px] font-medium tabular-nums shadow-soft">{n}diff --git a/src/components/model3d/model-card.tsx b/src/components/model3d/model-card.tsxindex d72a3a1d..3b89b2fa 100644--- a/src/components/model3d/model-card.tsx+++ b/src/components/model3d/model-card.tsx@@ -293,7 +293,7 @@ export function ModelCard({<ClipStill src={view.stillClip} label={`The ${label} splat, from its orbit`} />) : view.poster ? (// eslint-disable-next-line @next/next/no-img-element- <img src={view.poster} alt="The subject the splat was made from, cut out" loading="lazy" decoding="async" className="size-full object-contain p-4" />+ <img src={view.poster} alt={view.poster === view.photo ? "The photo the splat was made from" : "The subject the splat was made from, cut out"} loading="lazy" decoding="async" className="size-full object-contain p-4" />) : (<div className="grid size-full place-items-center p-6 text-center text-[13px] text-muted-foreground"><div>diff --git a/src/components/studio/result-media.tsx b/src/components/studio/result-media.tsxindex e0d2cdcc..fd0b7a87 100644--- a/src/components/studio/result-media.tsx+++ b/src/components/studio/result-media.tsx@@ -8,7 +8,7 @@ import { useHydrated } from "@/lib/api";import { FALLBACK_TEXT, hazeCutoffFor, splatFallback } from "@/lib/av/splat-view";import { TurnChips } from "@/components/model3d/turn-chips";import { FORMAT_INFO } from "@/lib/av/formats";-import { FRONT_YAW, splatFormatOf, turnOrbit, viewerGlb } from "@/lib/av/model3d";+import { firstFrameSrc, FRONT_YAW, splatFormatOf, turnOrbit, viewerGlb } from "@/lib/av/model3d";import type { Generation, OutputFile, VideoFormat } from "@/lib/catalog/types";import { extensionOf } from "@/lib/library";import { cuesOf, cueTime, editOnlyFormat, isLayered, layerInfo, modelPreview, textOf, videoPoster } from "@/lib/output-actions";@@ -271,6 +271,9 @@ function SplatPanel({ output, format, poster, video, g }: { output: OutputFile;const [note, setNote] = useState<string | null>(null);const fallback = !hydrated ? "reduced-motion" : note ? "too-big" : splatFallback({ webgl2: hasWebgl2(), coarse: false, reducedMotion, asked });const name = (g.modelName ?? "splat").replace(/[^\w .-]+/g, "");+ // The picture while the splat loads, and where nothing plays: its still, else the photo it was made from (the card's+ // order; a clean Idol splat has no still of its own: modelPreview leaves out its camera still).+ const picture = poster ?? g.request.inputs?.images?.[0];const download = (<a href={output.url} download={`${name}.${format}`} className="inline-flex h-8 items-center gap-1.5 rounded-full bg-white/15 px-3.5 text-[13px] font-medium text-white hover:bg-white/25"><Download className="size-4" aria-hidden /> .{format}@@ -280,7 +283,7 @@ function SplatPanel({ output, format, poster, video, g }: { output: OutputFile;return (<div className="flex size-full flex-col"><div className="relative min-h-0 flex-1 overflow-hidden md:rounded-lg">- <SplatViewer url={output.url} format={format} poster={poster} name={name} defaultCutoff={hazeCutoffFor(g.modelId)} tone="panel" label={g.request.prompt || "the splat"} autoFocus={asked} onUnavailable={setNote} />+ <SplatViewer url={output.url} format={format} poster={picture} name={name} defaultCutoff={hazeCutoffFor(g.modelId)} tone="panel" label={g.request.prompt || "the splat"} autoFocus={asked} onUnavailable={setNote} /></div><div className="flex shrink-0 justify-center pt-2">{download}</div></div>@@ -290,11 +293,22 @@ function SplatPanel({ output, format, poster, video, g }: { output: OutputFile;return (<div className="flex size-full flex-col items-center justify-center gap-3 p-4 text-center text-white/80">{video ? (- // Reduced motion: the orbit video waits for play.- <video src={video} poster={poster} controls autoPlay={!reducedMotion} loop muted playsInline aria-label="Orbit video of the splat" className="max-h-[70%] max-w-full" />- ) : poster ? (+ // Reduced motion: the orbit video waits for play, on its still or, without one, its own first frame.+ <video+ src={poster ? video : firstFrameSrc(video)}+ poster={poster}+ preload="metadata"+ controls+ autoPlay={!reducedMotion}+ loop+ muted+ playsInline+ aria-label="Orbit video of the splat"+ className="max-h-[70%] max-w-full"+ />+ ) : picture ? (// eslint-disable-next-line @next/next/no-img-element- <img src={poster} alt="The subject the splat was made from" className="max-h-[70%] max-w-full object-contain" />+ <img src={picture} alt="The subject the splat was made from" className="max-h-[70%] max-w-full object-contain" />) : (<Box className="size-10" aria-hidden />)}diff --git a/src/lib/av/idol-camera-still.ts b/src/lib/av/idol-camera-still.tsnew file mode 100644index 00000000..6e834fa9--- /dev/null+++ b/src/lib/av/idol-camera-still.ts@@ -0,0 +1,31 @@+import type { Generation, OutputFile } from "@/lib/catalog/types";++/**+ * Idol 3D's clean graph (image-to-splat-idol-clean) saves, beside the splat and its orbit, a still of the input view+ * (role "preview") rendered from the camera Idol predicts. That camera can miss a product seen side on: the red stiletto+ * in profile comes out as a few coloured squares on black, while the same run's orbit is clean from every side. Nothing+ * here can tell a good one from a collapsed one, so the still is never a result's cover, poster, tile or shown piece:+ * the orbit (its still, else its first frame) and the photo stand in. Every place that lists a result's outputs or picks+ * its picture asks here: the card (model3d.ts), the Library and feed Viewer and tiles (output-actions.ts modelPreview),+ * share and Publish pages (output-actions.ts sharedOutputs), Assist's chat and project tiles.+ */++/** Whether a splat came from the clean graph: its saved file says it was pruned (the core graph's says it wasn't). */+export const isIdolClean = (meta: Record<string, unknown> | undefined) => meta?.pruned === true;++/** The URLs of a result's camera stills: its role "preview" pictures when it holds a clean Idol splat, else none. */+export function idolCameraStills(g: Pick<Generation, "outputs">): Set<string> {+ if (!g.outputs.some((o) => o.kind === "model3d" && isIdolClean(o.meta))) return new Set();+ return new Set(g.outputs.filter((o) => o.kind === "image" && o.meta?.role === "preview").map((o) => o.url));+}++/** Whether an output is a clean Idol splat's camera still (see above): never a cover, poster, tile or shown piece. */+export function isIdolCameraStill(g: Pick<Generation, "outputs">, o: Pick<OutputFile, "kind" | "url">): boolean {+ return o.kind === "image" && idolCameraStills(g).has(o.url);+}++/** A result's outputs (their indexes, in order) without a camera still: the pieces a chat, a project or a page shows. */+export function showableOutputs(g: Pick<Generation, "outputs">): number[] {+ const still = idolCameraStills(g);+ return g.outputs.flatMap((o, i) => (o.kind === "image" && still.has(o.url) ? [] : [i]));+}diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.tsindex 7b6ece7e..38b76ad3 100644--- a/src/lib/av/model3d.ts+++ b/src/lib/av/model3d.ts@@ -2,6 +2,9 @@ import type { Engine, Generation, GenerationRequest, OutputFile } from "@/lib/caimport type { OwnSetup } from "@/lib/own-setup";import { PATH_FRAMES, keyAt } from "@/lib/camera-path";import { exactOrbitKeys, type ExactOrbit } from "@/lib/exact-orbit";+import { idolCameraStills, isIdolClean } from "./idol-camera-still";++export { idolCameraStills, isIdolCameraStill, isIdolClean, showableOutputs } from "./idol-camera-still";/*** Image to 3D / Product spin: the modes (from an image, from several images, from text, pick an object, a splat),@@ -197,9 +200,6 @@ export function idolKept(text: string | undefined): number | undefined {return t && Number.isInteger(n) && n >= 0 ? n : undefined;}-/** Whether a splat came from the clean graph: its saved file says it was pruned (the core graph's says it wasn't). */-export const isIdolClean = (meta: Record<string, unknown> | undefined) => meta?.pruned === true;-/*** A clip's first frame, for a <video> that stands in for a still: the media fragment makes browsers that wait for a* play (iOS Safari) show the frame too. A link that already has a fragment is left as it is.@@ -367,8 +367,8 @@ export interface Model3dView {/** The material class the server's finish read from the textures (matte, metal, mixed, unknown). */material?: string;/**- * The still, as a picture: the card's poster, the next steps' picture. An Idol 3D clean splat with an orbit and no- * still of it has the photo here, and `stillClip` for the card.+ * The still, as a picture: the card's poster, the next steps' picture. An Idol 3D clean splat with no still of its+ * orbit has the photo here (and `stillClip` for the card when it has an orbit), never the graph's camera still.*/poster?: string;/**@@ -433,12 +433,15 @@ export function model3dView(g: Pick<Generation, "outputs" | "request">): Model3dconst photo = g.request.inputs?.images?.[0];const images = g.outputs.filter((o) => o.kind === "image");// Idol 3D's clean graph: its own still (role "preview") is rendered from the camera Idol predicts, which can collapse- // for a product seen side on (a heel in profile comes out as a few squares on black). Its card shows the orbit- // instead: a still made of it (by the server, the graph, or on the clip), else the clip's first frame, with the photo- // as the picture the next steps take.- const fromOrbit = !!splat && !!turntable && isIdolClean(meta);+ // for a product seen side on (a heel in profile comes out as a few squares on black; idol-camera-still.ts). Its card+ // shows the orbit instead: a still made of it (by the server, the graph, or on the clip), else the clip's first frame,+ // with the photo as the picture the next steps take. Without an orbit, the photo is the still.+ const idolClean = !!splat && isIdolClean(meta);+ const cameraStills = idolClean ? idolCameraStills(g) : new Set<string>();+ const fromOrbit = idolClean && !!turntable;const orbit = fromOrbit ? g.outputs.find((o) => o.kind === "video" && o.url === turntable) : undefined;- const orbitStill = fromOrbit ? (str(meta.poster) ?? images.find((o) => o.meta?.role === "poster")?.url ?? str(orbit?.meta?.poster) ?? str(orbit?.meta?.thumbnail)) : undefined;+ const still = (v: unknown) => (str(v) && !cameraStills.has(v as string) ? (v as string) : undefined);+ const orbitStill = idolClean ? (still(meta.poster) ?? still(images.find((o) => o.meta?.role === "poster")?.url) ?? still(orbit?.meta?.poster) ?? still(orbit?.meta?.thumbnail)) : undefined;return {glb: splat ? fromSplat?.url : mesh?.url,web: mesh && !splat ? viewerGlb(mesh) : fromSplat?.url,@@ -447,7 +450,7 @@ export function model3dView(g: Pick<Generation, "outputs" | "request">): Model3dturntable,rendering: pending ? { queued: finish.turntable === "queued", progress: typeof finish.turntableProgress === "number" ? finish.turntableProgress : 0 } : undefined,material: str(finish.material),- poster: fromOrbit ? (orbitStill ?? photo) : (str(meta.preview) ?? str(meta.poster) ?? images[0]?.url),+ poster: idolClean ? (orbitStill ?? photo) : (str(meta.preview) ?? str(meta.poster) ?? images[0]?.url),...(fromOrbit && !orbitStill && { stillClip: turntable }),photo,formats,diff --git a/src/lib/next-steps.ts b/src/lib/next-steps.tsindex 981a3738..f7fad60d 100644--- a/src/lib/next-steps.ts+++ b/src/lib/next-steps.ts@@ -139,7 +139,8 @@ export function keepGoing(g: Generation, index: number, ctx: KeepGoingContext =if (view.poster) {const P = q(view.poster);add({ id: "product-360", verb: "Put it in an ad", where: "Product 360", href: `/apps/app-product-360?image=${P}`, cover: STEP_COVERS.spin });- add({ id: "upscale", verb: "Sharpen the still", where: "Upscale", href: `/upscale?image=${P}`, cover: STEP_COVERS.upscale });+ // Where no still of the model exists (an Idol 3D clean splat) the picture is the photo it was made from: it says so.+ add({ id: "upscale", verb: view.poster === view.photo ? "Sharpen the photo" : "Sharpen the still", where: "Upscale", href: `/upscale?image=${P}`, cover: STEP_COVERS.upscale });}break;}diff --git a/src/lib/output-actions.ts b/src/lib/output-actions.tsindex 689c173a..ac7e7a11 100644--- a/src/lib/output-actions.ts+++ b/src/lib/output-actions.ts@@ -12,6 +12,7 @@ import { PRESETS as GRADE_PRESETS } from "./grade";import { storedPath } from "./share";import { decodeMoss, LAYOUT_PARAM, readLayout, type LayoutDraft } from "./layout-prompt";import { REMOVE_DIALOGUE_FEATURE } from "./av/remove-dialogue";+import { idolCameraStills, showableOutputs } from "./av/idol-camera-still";import { canEnhance, canRerender, ENHANCE_LABEL, REGEN_OFFERED, regenerateFamily, regenerateHref, rerenderLabel } from "./catalog/regenerate";import { CLEAN_FEATURE } from "./av/clean-voice";import { exportsCleanly } from "./av/keying";@@ -473,7 +474,8 @@ export function textOf(o: Pick<OutputFile, "text" | "meta">): string {* its preview, not a result of its own, and so is a splat beside the GLB made from it.*/export function shownOutputs(g: Pick<Generation, "kind" | "outputs">): number[] {- const all = g.outputs.map((_, i) => i);+ // A clean Idol splat's camera still is never a tile (src/lib/av/idol-camera-still.ts).+ const all = showableOutputs(g);if (g.kind !== "model3d") return all;// A splat that came beside the GLB made from it (Photo to 3D) is one of the GLB's downloads, not a tile of its own.const mesh = g.outputs.some((o) => o.kind === "model3d" && !o.meta?.role);@@ -481,6 +483,15 @@ export function shownOutputs(g: Pick<Generation, "kind" | "outputs">): number[]return own.length ? own : all;}+/**+ * The outputs a share link or published page shows of a result (src/server/shares.ts lists its pieces with this): a 3D+ * result shows its own files (the turntable plays, the model and its other files download), all but a clean Idol+ * splat's camera still, which is never a piece, a cover or a link preview; any other result, what feeds show.+ */+export function sharedOutputs(g: Pick<Generation, "kind" | "outputs">): number[] {+ return g.kind === "model3d" ? showableOutputs(g) : shownOutputs(g);+}+/** A layer's name and stacking order (meta.name / meta.z, or meta.layer.{name,z}). */export function layerInfo(o: Pick<OutputFile, "meta">, index: number): { name: string; z: number } {const m = (o.meta ?? {}) as Record<string, unknown>;@@ -523,12 +534,17 @@ export function editOnlyFormat(g: Partial<Pick<Generation, "op" | "request">> |return undefined;}-/** A 3D model's still and turntable: meta.poster / meta.preview, meta.video / meta.turntable, or a sibling output. */+/**+ * A 3D model's still and turntable: meta.poster / meta.preview, meta.video / meta.turntable, or a sibling output. Never+ * a clean Idol splat's camera still (src/lib/av/idol-camera-still.ts): such a splat has no still unless one was made of+ * its orbit, and its orbit stands in.+ */export function modelPreview(g: Pick<Generation, "outputs">, o: OutputFile): { poster?: string; video?: string } {const m = (o.meta ?? {}) as Record<string, unknown>;- const str = (...keys: string[]) => keys.map((k) => m[k]).find((v): v is string => typeof v === "string" && v.length > 0);+ const cameraStills = idolCameraStills(g);+ const str = (...keys: string[]) => keys.map((k) => m[k]).find((v): v is string => typeof v === "string" && v.length > 0 && !cameraStills.has(v));return {- poster: str("poster", "preview", "thumbnail", "image") ?? g.outputs.find((x) => x.kind === "image")?.url,+ poster: str("poster", "preview", "thumbnail", "image") ?? g.outputs.find((x) => x.kind === "image" && !cameraStills.has(x.url))?.url,video: str("video", "turntable") ?? g.outputs.find((x) => x.kind === "video")?.url,};}diff --git a/tests/idol-camera-still.test.ts b/tests/idol-camera-still.test.tsnew file mode 100644index 00000000..98c15025--- /dev/null+++ b/tests/idol-camera-still.test.ts@@ -0,0 +1,205 @@+import fs from "node:fs";+import path from "node:path";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { createElement, type ReactElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vitest";+import type { Generation, OutputFile } from "@/lib/catalog/types";+import type { PublicItem, PublicMedia, PublicShare, ShareLayout } from "@/lib/share";++vi.mock("next/navigation", () => ({+ useRouter: () => ({ prefetch: () => {}, push: () => {}, replace: () => {}, back: () => {}, refresh: () => {} }),+ usePathname: () => "/library",+ useSearchParams: () => new URLSearchParams(),+}));++const { idolCameraStills, isIdolCameraStill, showableOutputs } = await import("@/lib/av/idol-camera-still");+const { firstFrameSrc, model3dView } = await import("@/lib/av/model3d");+const { modelPreview, sharedOutputs, shownOutputs } = await import("@/lib/output-actions");+const { keepGoing } = await import("@/lib/next-steps");+const { outputFiles, previewImage, shareFileUrl, storedPath } = await import("@/lib/share");++/**+ * Idol 3D's clean graph saves a still rendered from the camera Idol predicts (role "preview"); for the red stiletto seen+ * side on it is a few coloured squares on black (tests/idol-clean-poster.test.ts measures it). It is never a cover,+ * poster, tile or shown piece anywhere: the Library and feed Viewer, share and Publish pages, Assist's chat and project+ * tiles, the result card. The fixtures are the two real runs on the clean graph, as stored.+ */++const dir = path.join(process.cwd(), "tests", "fixtures", "idol-clean");+type Run = Pick<Generation, "id" | "feature" | "modelId" | "engine" | "provider" | "op" | "kind" | "status" | "request" | "outputs">;+const runs = JSON.parse(fs.readFileSync(path.join(dir, "runs.json"), "utf8")) as Record<"stiletto" | "headphones", Run>;+const byRole = (r: Run, role: string) => r.outputs.find((o) => o.meta?.role === role)!;+const photoOf = (r: Run) => r.request.inputs!.images![0];+const full = (r: Run): Generation =>+ ({ ...r, batchId: null, presetId: null, progress: null, message: null, prompt: "", error: null, costUsd: 0, favorite: false, createdAt: 0, updatedAt: 0, completedAt: 0, modelName: "Idol 3D" }) as Generation;+const html = (el: ReactElement) => renderToStaticMarkup(createElement(QueryClientProvider, { client: new QueryClient() }, el));+const both = Object.entries(runs) as ["stiletto" | "headphones", Run][];++describe("which output is the camera still", () => {+ it.each(both)("the %s run: its role \"preview\" picture, nothing else", (_, r) => {+ const preview = byRole(r, "preview");+ expect([...idolCameraStills(r)]).toEqual([preview.url]);+ expect(r.outputs.map((o) => isIdolCameraStill(r, o))).toEqual([false, false, true]);+ expect(showableOutputs(r)).toEqual([0, 1]);+ });++ it("only on a clean splat: the core graph's (not pruned), TripoSplat's and any other result keep every output", () => {+ const r = runs.stiletto;+ for (const meta of [{ role: "splat", format: "spz", pruned: false }, { role: "splat", format: "spz" }]) {+ const g = { ...r, outputs: [{ ...r.outputs[0], meta }, ...r.outputs.slice(1)] };+ expect(idolCameraStills(g).size).toBe(0);+ expect(showableOutputs(g)).toEqual([0, 1, 2]);+ }+ const pictures = { outputs: [{ url: "/a.png", kind: "image", meta: { role: "preview" } }, { url: "/b.png", kind: "image" }] as OutputFile[] };+ expect(showableOutputs(pictures)).toEqual([0, 1]);+ });+});++describe("the Library and feed Viewer (modelPreview → SplatPanel)", () => {+ it.each(both)("the %s splat's poster is never the camera still; its orbit is the video", (_, r) => {+ const { poster, video } = modelPreview(r, r.outputs[0]);+ expect(poster).toBeUndefined();+ expect(video).toBe(byRole(r, "turntable").url);+ });++ it("a still made of the orbit is the poster; a camera still named on the splat isn't", () => {+ const r = runs.stiletto;+ const [splat, clip, preview] = r.outputs;+ const still = "/api/files/outputs/orbit-still.webp";+ expect(modelPreview({ outputs: [splat, clip, { url: still, kind: "image", meta: { role: "poster" } }, preview] }, splat).poster).toBe(still);+ const named = { ...splat, meta: { ...splat.meta, preview: preview.url } };+ expect(modelPreview({ outputs: [named, clip, preview] }, named).poster).toBeUndefined();+ });++ it("every other 3D result keeps its picture", () => {+ const glb: OutputFile = { url: "/m.glb", kind: "model3d" };+ expect(modelPreview({ outputs: [glb, { url: "/p.png", kind: "image", meta: { role: "preview" } }] }, glb).poster).toBe("/p.png");+ const core = { ...runs.stiletto.outputs[0], meta: { role: "splat", format: "spz", pruned: false } };+ expect(modelPreview({ outputs: [core, ...runs.stiletto.outputs.slice(1)] }, core).poster).toBe(byRole(runs.stiletto, "preview").url);+ });++ it.each(both)("the Viewer, rendered with the %s run, plays the orbit from its first frame and never names the camera still", async (_, r) => {+ const { ModelViewer } = await import("@/components/studio/result-media");+ const out = html(createElement(ModelViewer, { output: r.outputs[0], g: full(r) }));+ expect(out).not.toContain(byRole(r, "preview").url);+ // Before hydration (and with reduced motion) the panel is the orbit video, paused on its own first frame.+ const video = /<video[^>]*>/.exec(out)?.[0] ?? "";+ expect(video).toContain(`src="${firstFrameSrc(byRole(r, "turntable").url)}"`);+ expect(video).toContain('preload="metadata"');+ expect(video).not.toContain("poster=");+ });++ it("a clean splat with no orbit shows the photo it was made from, not the camera still", async () => {+ const { ModelViewer } = await import("@/components/studio/result-media");+ const r = runs.stiletto;+ const g = full({ ...r, outputs: r.outputs.filter((o) => o.kind !== "video") });+ const out = html(createElement(ModelViewer, { output: g.outputs[0], g }));+ expect(out).not.toContain(byRole(r, "preview").url);+ expect(out).toContain(`src="${photoOf(r)}"`);+ });++ it.each(both)("the %s splat's Library tile (MediaThumb with its run) is the orbit, and the run tiles only the splat", async (_, r) => {+ const { MediaThumb } = await import("@/components/studio/result-media");+ expect(shownOutputs(r)).toEqual([0]);+ const out = html(createElement(MediaThumb, { output: r.outputs[0], g: r }));+ expect(out).not.toContain(byRole(r, "preview").url);+ expect(out).toContain(byRole(r, "turntable").url);+ });+});++/**+ * A share link's or Publish page's pieces as src/server/shares.ts builds them from a result: its shared outputs+ * (sharedOutputs), each at its share-scoped URL with a clip's own poster, and the cover the page falls back to (the first+ * picture, or a clip with a poster). shares.ts lists a piece's outputs with sharedOutputs.+ */+function pageOf(r: Run, layout: ShareLayout, token = "T".repeat(44)): { page: PublicShare; files: string[] } {+ const g = full(r);+ const media: PublicMedia[] = sharedOutputs(g).map((i) => {+ const o = g.outputs[i];+ const poster = ["poster", "thumbnail", "preview"].map((k) => o.meta?.[k]).find((v): v is string => typeof v === "string" && !!storedPath(v));+ return { url: shareFileUrl(token, o.url)!, kind: o.kind, ...(o.contentType && { contentType: o.contentType }), ...(o.kind === "video" && poster && { poster: shareFileUrl(token, poster)! }), download: `idol-3d-${i + 1}` };+ });+ const items: PublicItem[] = [1, 2].map((n) => ({ key: String(n), title: "3D model", model: "Idol 3D", kind: "model3d", aspectRatio: null, media, createdAt: 0 }));+ const cover = items.flatMap((it) => it.media).find((x) => x.kind === "image" || x.poster) ?? null;+ const page: PublicShare = { kind: "publish", title: "Products", description: "", tags: [], layout, showPrompts: false, cover, coverKey: cover ? "1" : null, items, truncated: false, updatedAt: 0 };+ return { page, files: sharedOutputs(g).flatMap((i) => outputFiles(g.outputs[i])) };+}++describe("share links and Publish pages: pieces, cover, link preview", () => {+ it.each(both)("the %s run's piece is its splat and orbit, never the camera still", (_, r) => {+ expect(sharedOutputs(r)).toEqual([0, 1]);+ const { files } = pageOf(r, "grid");+ expect(files).toEqual([storedPath(r.outputs[0].url), storedPath(r.outputs[1].url)]);+ expect(files).not.toContain(storedPath(byRole(r, "preview").url));+ });++ it.each(both)("the %s run gives no cover picture, so no og:image of the camera still", (_, r) => {+ const { page } = pageOf(r, "series");+ expect(page.cover).toBeNull();+ expect(previewImage(page.cover)).toBeNull();+ });++ it.each(["grid", "feature", "series", "carousel"] as const)("the %s page never shows the camera still", async (layout) => {+ const { SharePage } = await import("@/app/s/share-page");+ for (const r of Object.values(runs)) {+ const out = html(createElement(SharePage, { share: pageOf(r, layout).page }));+ const preview = storedPath(byRole(r, "preview").url)!;+ expect(out).not.toContain(preview);+ expect(out).toContain(storedPath(byRole(r, "turntable").url)!);+ }+ });++ it("any other result's pieces are what they were: a 3D result all its files, others what feeds show", () => {+ const glb = { kind: "model3d" as const, outputs: [{ url: "/api/files/m.glb", kind: "model3d" }, { url: "/api/files/t.mp4", kind: "video" }, { url: "/api/files/p.png", kind: "image", meta: { role: "preview" } }] as OutputFile[] };+ expect(sharedOutputs(glb)).toEqual([0, 1, 2]);+ const pictures = { kind: "image" as const, outputs: [{ url: "/1.png", kind: "image" }, { url: "/2.png", kind: "image" }] as OutputFile[] };+ expect(sharedOutputs(pictures)).toEqual([0, 1]);+ });+});++describe("Assist: the chat's and the project's tiles", () => {+ it.each(both)("the chat tiles the %s run's splat (as its orbit) and orbit, never the camera still", async (_, r) => {+ const { GenerationCards } = await import("@/components/assist/transcript");+ const g = full(r);+ const opened: number[] = [];+ const out = html(createElement(GenerationCards, { ids: [g.id], all: new Map([[g.id, g]]), onOpen: (_g: Generation, i: number) => opened.push(i) }));+ expect(out).not.toContain(byRole(r, "preview").url);+ // Two tiles, the splat's showing its orbit (it isn't a bare "3D model" box).+ expect(out.match(/aria-label="Open /g)).toHaveLength(2);+ expect(out).not.toContain(">3D model<");+ expect(out.split(byRole(r, "turntable").url).length - 1).toBe(2);+ });++ it("the project's assets and the chat's Viewer list the same outputs", () => {+ for (const r of Object.values(runs)) expect(showableOutputs(full(r))).toEqual([0, 1]);+ });+});++describe("the result card and its next steps", () => {+ it("a clean splat with no orbit: the photo, never the camera still", async () => {+ const r = runs.stiletto;+ const outputs = r.outputs.filter((o) => o.kind !== "video");+ const view = model3dView({ ...r, outputs });+ expect(view).toMatchObject({ poster: photoOf(r), turntable: undefined });+ expect(view.stillClip).toBeUndefined();+ const { ModelCard } = await import("@/components/model3d/model-card");+ const out = html(createElement(ModelCard, { g: full({ ...r, outputs }), cloudAllowed: false }));+ expect(out).not.toContain(byRole(r, "preview").url);+ expect(out).toContain('alt="The photo the splat was made from"');+ });++ it.each(both)("the %s card never names the camera still", async (_, r) => {+ const { ModelCard } = await import("@/components/model3d/model-card");+ expect(html(createElement(ModelCard, { g: full(r), cloudAllowed: false }))).not.toContain(byRole(r, "preview").url);+ });++ it("Sharpen says what it sharpens: the photo on a clean splat, the still where the model has one", () => {+ const steps = keepGoing(full(runs.stiletto), 0, {}, 6);+ const up = steps.find((s) => s.id === "upscale")!;+ expect(up.verb).toBe("Sharpen the photo");+ expect(up.href).toBe(`/upscale?image=${encodeURIComponent(photoOf(runs.stiletto))}`);+ const glb = { ...full(runs.stiletto), modelId: "oss-trellis2", op: "image-to-3d", outputs: [{ url: "/api/files/m.glb", kind: "model3d", meta: { poster: "/api/files/m.webp" } }] } as Generation;+ expect(keepGoing(glb, 0, {}, 6).find((s) => s.id === "upscale")?.verb).toBe("Sharpen the still");+ });+});diff --git a/tests/idol-clean-poster.test.ts b/tests/idol-clean-poster.test.tsindex 308a3740..564e712e 100644--- a/tests/idol-clean-poster.test.ts+++ b/tests/idol-clean-poster.test.ts@@ -102,10 +102,10 @@ describe("the card's still on the clean graph: the orbit", () => {expect(steps.find((s) => s.id === "product-360")?.href).toContain(encodeURIComponent(photoOf(r)));});- it("a clean splat with no orbit keeps the old order", () => {+ it("a clean splat with no orbit shows the photo, never its camera still", () => {const r = runs.stiletto;const view = model3dView({ ...r, outputs: r.outputs.filter((o) => o.kind !== "video") });- expect(view).toMatchObject({ poster: byRole(r, "preview").url, turntable: undefined });+ expect(view).toMatchObject({ poster: photoOf(r), turntable: undefined });expect(view.stillClip).toBeUndefined();});});