feat(pipeline): render-derived shot thumbnails, and bulk shot delete
Deploy / deploy (push) Failing after 19m11s

Two independent features landing together:

Generated shot thumbnails — a shot can now carry a thumbnail promoted
from a render export (Shot.generatedThumbnailUrl/generatedThumbnailFrom)
alongside the existing brief-supplied thumbnailUrl, which always takes
display precedence (lib/shot-thumbnail.ts) so a promoted frame can only
ever fill a gap, never overwrite the brief. Shows with
pipelineConfig.autoShotThumbnail promote automatically on every
finished export (lib/render-pipeline/preview.ts); promoteExportThumbnail/
clearGeneratedThumbnail (actions/shots.ts) are the manual equivalent for
everyone else. Worker-side seek logic for picking the promoted frame is
covered by RenderWorker/VFXReviewWorker.Tests/ThumbnailSeekTests.cs.

Bulk shot delete — the shot-status page's selection bar gets a "Bulk
Actions" dropdown (alongside the existing Change Due Date) with Delete
Shots. bulkDeleteShots() (actions/shots.ts) deletes one at a time rather
than in a single statement: exports_shotId_fkey is ON DELETE RESTRICT
by design, so a shot with renders or deliveries on record is protected
and gets skipped and reported by name rather than aborting the whole
selection or being silently destroyed along with its history.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
twotalesanimation
2026-08-27 17:06:55 +02:00
parent b151e8cc52
commit caaa333f02
39 changed files with 876 additions and 70 deletions
@@ -41,6 +41,7 @@ const settingsSchema = z.object({
overlayComp: z.string().optional(),
previewComp: z.string().optional(),
lutComp: z.string().optional(),
autoShotThumbnail: z.boolean().optional(),
});
type SettingsFormValues = z.infer<typeof settingsSchema>;
@@ -79,6 +80,7 @@ interface ProjectSettingsTabProps {
overlayComp?: string | null;
previewComp?: string | null;
lutComp?: string | null;
autoShotThumbnail?: boolean | null;
} | null;
};
clients: Client[];
@@ -127,6 +129,7 @@ export function ProjectSettingsTab({ project, clients, teamMembers }: ProjectSet
overlayComp: project.pipelineConfig?.overlayComp ?? "",
previewComp: project.pipelineConfig?.previewComp ?? "",
lutComp: project.pipelineConfig?.lutComp ?? "",
autoShotThumbnail: project.pipelineConfig?.autoShotThumbnail ?? false,
},
});
@@ -159,6 +162,7 @@ export function ProjectSettingsTab({ project, clients, teamMembers }: ProjectSet
overlayComp: data.overlayComp?.trim() || null,
previewComp: data.previewComp?.trim() || null,
lutComp: data.lutComp?.trim() || null,
autoShotThumbnail: data.autoShotThumbnail ?? false,
},
});
toast({ title: "Project settings saved" });
@@ -427,6 +431,28 @@ export function ProjectSettingsTab({ project, clients, teamMembers }: ProjectSet
<Input id="lutComp" placeholder="_SHOW LUT" {...register("lutComp")} />
</div>
</div>
<div className="pt-4 mt-4 border-t border-border/60">
<label className="flex items-start gap-2.5 cursor-pointer group">
<input
id="autoShotThumbnail"
type="checkbox"
className="accent-amber-500 h-3.5 w-3.5 mt-0.5"
{...register("autoShotThumbnail")}
/>
<span className="space-y-1">
<span className="block text-sm group-hover:text-foreground transition-colors">
Use render frames as shot thumbnails
</span>
<span className="block text-xs text-muted-foreground">
Every finished export sets its shot&apos;s thumbnail from the render.
A thumbnail supplied with the brief always takes priority and is
never overwritten &mdash; turn this on for shows that arrive with no
stills at all, where the alternative is an empty grid.
</span>
</span>
</label>
</div>
</div>
</section>
+2 -1
View File
@@ -23,6 +23,7 @@ import {
ActiveDragData,
} from "@/app/(dashboard)/schedule/SchedulePageClient";
import { TASK_TYPE_LABELS } from "@/components/tasks/TaskCard";
import { shotThumbnail } from "@/lib/shot-thumbnail";
const STATUS_STYLES: Record<
TaskStatus,
@@ -134,7 +135,7 @@ export function ScheduleTaskBlock({
const statusStyle = STATUS_STYLES[task.status];
const contextCode = task.shot?.shotCode ?? task.asset?.assetCode;
const contextName = task.shot?.shotCode ?? task.asset?.name ?? task.title;
const thumbnail = task.shot?.thumbnailUrl ?? null;
const thumbnail = shotThumbnail(task.shot);
const isOverdue =
task.dueDate &&
+3 -2
View File
@@ -33,6 +33,7 @@ import {
import type { ShotWithDetails } from "@/types";
import { duplicateShot } from "@/actions/shots";
import { useToast } from "@/components/ui/use-toast";
import { shotThumbnail } from "@/lib/shot-thumbnail";
interface ShotCardProps {
shot: ShotWithDetails;
@@ -128,9 +129,9 @@ export function ShotCard({ shot, projectId, compact = false, canManage = false }
{/* Thumbnail with cinema scope aspect ratio (2.39:1) */}
<div className="mb-3 -mx-6 -mt-6 overflow-hidden rounded-t-lg">
<div className="relative w-full aspect-[2.39]">
{shot.thumbnailUrl || latestVersion?.thumbnailUrl || latestVersion?.posterUrl ? (
{shotThumbnail(shot) || latestVersion?.thumbnailUrl || latestVersion?.posterUrl ? (
<Image
src={shot.thumbnailUrl || latestVersion?.thumbnailUrl || latestVersion?.posterUrl || ""}
src={shotThumbnail(shot) || latestVersion?.thumbnailUrl || latestVersion?.posterUrl || ""}
alt={shot.shotCode}
fill
className="object-cover"
+74 -20
View File
@@ -1,8 +1,13 @@
"use client";
import Link from "next/link";
import { useState } from "react";
import { useRouter } from "next/navigation";
import Image from "next/image";
import { useQuery } from "@tanstack/react-query";
import { Layers, ExternalLink } from "lucide-react";
import { Layers, ExternalLink, ImageIcon, Loader2 } from "lucide-react";
import { promoteExportThumbnail } from "@/actions/shots";
import { useToast } from "@/components/ui/use-toast";
import { cn } from "@/lib/utils";
import {
EXPORT_STATUS_STYLES,
@@ -16,6 +21,7 @@ interface ExportRow {
statusChangedAt: string;
createdAt: string;
outputDir: string;
thumbnailUrl: string | null;
job: {
attempt: number;
progress: number;
@@ -29,6 +35,29 @@ interface ExportRow {
* pipeline history for this shot, linking into the Export detail page.
*/
export function ShotExportsTab({ shotId }: { shotId: string }) {
const router = useRouter();
const { toast } = useToast();
const [promotingId, setPromotingId] = useState<string | null>(null);
// Take this export's frame as the shot's thumbnail. Fills in only where the
// shot has no reference frame of its own (§9.1a) — it never overwrites one.
const promote = async (exportId: string, versionString: string) => {
setPromotingId(exportId);
try {
await promoteExportThumbnail(shotId, exportId);
toast({ title: `Shot thumbnail taken from ${versionString}` });
router.refresh();
} catch (err) {
toast({
title: "Could not use that frame",
description: (err as Error).message,
variant: "destructive",
});
} finally {
setPromotingId(null);
}
};
const { data, isLoading } = useQuery({
queryKey: ["shot-exports", shotId],
queryFn: async () => {
@@ -56,29 +85,54 @@ export function ShotExportsTab({ shotId }: { shotId: string }) {
return (
<div className="space-y-2">
{exports.map((e) => (
<Link
<div
key={e.id}
href={`/pipeline/exports/${e.id}`}
className="flex items-center gap-4 rounded-lg border border-border bg-card p-4 hover:border-zinc-600 transition-colors"
>
<span className="font-mono text-sm text-white w-14">{e.versionString}</span>
<span
className={cn(
"rounded-full border px-2 py-0.5 text-xs whitespace-nowrap",
EXPORT_STATUS_STYLES[e.status] ?? "bg-zinc-500/15 text-zinc-300 border-zinc-500/30"
<Link href={`/pipeline/exports/${e.id}`} className="flex flex-1 min-w-0 items-center gap-4">
{e.thumbnailUrl ? (
<span className="relative h-8 w-[76px] shrink-0 overflow-hidden rounded border border-border">
<Image src={e.thumbnailUrl} alt="" fill className="object-cover" sizes="76px" />
</span>
) : (
<span className="h-8 w-[76px] shrink-0 rounded border border-border bg-zinc-900" />
)}
>
{statusLabel(e.status)}
</span>
<span className="flex-1 min-w-0 truncate text-xs text-muted-foreground">
{e.job?.machineName ? `${e.job.machineName} · attempt ${e.job.attempt} · ` : ""}
{e.outputDir}
</span>
<span className="text-xs text-muted-foreground whitespace-nowrap">
{new Date(e.createdAt).toLocaleDateString()}
</span>
<ExternalLink className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
</Link>
<span className="font-mono text-sm text-white w-14">{e.versionString}</span>
<span
className={cn(
"rounded-full border px-2 py-0.5 text-xs whitespace-nowrap",
EXPORT_STATUS_STYLES[e.status] ?? "bg-zinc-500/15 text-zinc-300 border-zinc-500/30"
)}
>
{statusLabel(e.status)}
</span>
<span className="flex-1 min-w-0 truncate text-xs text-muted-foreground">
{e.job?.machineName ? `${e.job.machineName} · attempt ${e.job.attempt} · ` : ""}
{e.outputDir}
</span>
<span className="text-xs text-muted-foreground whitespace-nowrap">
{new Date(e.createdAt).toLocaleDateString()}
</span>
<ExternalLink className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
</Link>
{e.thumbnailUrl && (
<button
type="button"
onClick={() => promote(e.id, e.versionString)}
disabled={promotingId !== null}
title="Use this frame as the shot thumbnail (never replaces one supplied with the brief)"
className="shrink-0 flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:border-zinc-600 disabled:opacity-50 transition-colors"
>
{promotingId === e.id ? (
<Loader2 className="h-3.5 w-3.5 animate-spin" />
) : (
<ImageIcon className="h-3.5 w-3.5" />
)}
Use frame
</button>
)}
</div>
))}
</div>
);
+102 -2
View File
@@ -18,9 +18,14 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { updateShot, deleteShot } from "@/actions/shots";
import {
updateShot,
deleteShot,
promoteExportThumbnail,
clearGeneratedThumbnail,
} from "@/actions/shots";
import { useToast } from "@/components/ui/use-toast";
import { Upload, X, Film, ImageIcon, Trash2, BookImage, Loader2 } from "lucide-react";
import { Upload, X, Film, ImageIcon, Trash2, BookImage, Loader2, Sparkles } from "lucide-react";
// ─── Shot References ──────────────────────────────────────────────────────────
@@ -191,6 +196,8 @@ interface ShotSettingsTabProps {
dueDate: Date | string | null;
artistId: string | null;
thumbnailUrl: string | null;
generatedThumbnailUrl?: string | null;
generatedThumbnailFrom?: string | null;
projectId: string;
};
artists: Artist[];
@@ -208,6 +215,48 @@ export function ShotSettingsTab({ shot, artists, onSaved }: ShotSettingsTabProps
const [clearThumbnail, setClearThumbnail] = useState(false);
const fileInputRef = useRef<HTMLInputElement>(null);
// Render-derived still, managed separately from the reference frame above.
const [generatedUrl, setGeneratedUrl] = useState(shot.generatedThumbnailUrl ?? null);
const [generatedFrom, setGeneratedFrom] = useState(shot.generatedThumbnailFrom ?? null);
const [isPromoting, setIsPromoting] = useState(false);
const handlePromote = async () => {
setIsPromoting(true);
try {
const res = await promoteExportThumbnail(shot.id);
setGeneratedUrl(res.generatedThumbnailUrl);
setGeneratedFrom(res.generatedThumbnailFrom);
toast({ title: `Thumbnail taken from ${res.generatedThumbnailFrom}` });
router.refresh();
} catch (err) {
toast({
title: "Could not use a render frame",
description: (err as Error).message,
variant: "destructive",
});
} finally {
setIsPromoting(false);
}
};
const handleClearGenerated = async () => {
setIsPromoting(true);
try {
await clearGeneratedThumbnail(shot.id);
setGeneratedUrl(null);
setGeneratedFrom(null);
router.refresh();
} catch (err) {
toast({
title: "Could not clear the render frame",
description: (err as Error).message,
variant: "destructive",
});
} finally {
setIsPromoting(false);
}
};
const formatDate = (d: Date | string | null) => {
if (!d) return "";
return new Date(d).toISOString().split("T")[0];
@@ -452,6 +501,57 @@ export function ShotSettingsTab({ shot, artists, onSaved }: ShotSettingsTabProps
className="hidden"
onChange={handleThumbnailChange}
/>
{/* ── From renders ───────────────────────────────────────────────────
A second, separate still taken from a finished export. It never
replaces the one above — it only shows where there is none — so a
show that ships reference frames keeps them, and a show that ships
none stops rendering empty grids. */}
<div className="pt-4 mt-2 border-t border-border/60 space-y-3">
<div className="flex items-center gap-2 text-xs font-medium text-zinc-400">
<Sparkles className="h-3.5 w-3.5 text-amber-500/70" />
From renders
</div>
{generatedUrl ? (
<div className="flex items-start gap-3">
<div className="relative w-40 aspect-[2.39] rounded-md overflow-hidden border border-border shrink-0">
<Image src={generatedUrl} alt={shot.shotCode} fill className="object-cover" />
</div>
<div className="space-y-2 min-w-0">
<p className="text-xs text-muted-foreground">
{generatedFrom ? <>Taken from <span className="font-mono">{generatedFrom}</span>.</> : "Taken from a render."}{" "}
{thumbnailPreview && !clearThumbnail
? "Not shown anywhere while this shot has a thumbnail of its own."
: "Shown wherever this shot appears, until a thumbnail is uploaded above."}
</p>
<div className="flex gap-2">
<Button type="button" variant="outline" size="sm" onClick={handlePromote} disabled={isPromoting}>
{isPromoting ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : "Refresh from latest"}
</Button>
<Button type="button" variant="ghost" size="sm" onClick={handleClearGenerated} disabled={isPromoting}>
Remove
</Button>
</div>
</div>
</div>
) : (
<div className="space-y-2">
<p className="text-xs text-muted-foreground">
Take a frame from this shot&apos;s most recent finished export. Never
replaces the thumbnail above &mdash; it only fills in where there
isn&apos;t one.
</p>
<Button type="button" variant="outline" size="sm" onClick={handlePromote} disabled={isPromoting}>
{isPromoting ? (
<><Loader2 className="h-3.5 w-3.5 animate-spin mr-1.5" /> Fetching&hellip;</>
) : (
"Use latest render frame"
)}
</Button>
</div>
)}
</div>
</div>
{/* References */}
+3 -2
View File
@@ -9,6 +9,7 @@ import { Textarea } from "@/components/ui/textarea";
import { useToast } from "@/components/ui/use-toast";
import { updateShotSlate } from "@/actions/shots";
import type { ShotWithDetails } from "@/types";
import { shotThumbnail } from "@/lib/shot-thumbnail";
interface Props {
shot: ShotWithDetails;
@@ -164,9 +165,9 @@ export function ShotSlateTab({ shot, projectName, onSaved }: Props) {
<div className="w-56 shrink-0 flex flex-col">
{/* Thumbnail */}
<div className="aspect-video bg-zinc-900 border-b border-zinc-800 overflow-hidden flex items-center justify-center">
{shot.thumbnailUrl ? (
{shotThumbnail(shot) ? (
<Image
src={shot.thumbnailUrl}
src={shotThumbnail(shot)!}
alt={shot.shotCode}
width={224}
height={126}
+5 -1
View File
@@ -42,7 +42,11 @@ interface KanbanTask {
status: TaskStatus;
priority: string;
dueDate: Date | null;
shot?: { shotCode: string; thumbnailUrl?: string | null } | null;
shot?: {
shotCode: string;
thumbnailUrl?: string | null;
generatedThumbnailUrl?: string | null;
} | null;
asset?: { assetCode: string; name: string } | null;
assignedArtist?: {
id: string;
+9 -3
View File
@@ -19,6 +19,7 @@ import {
import { TaskStatus, TaskType } from "@prisma/client";
import { TASK_STATUS_CONFIG, TASK_TYPE_LABELS } from "./TaskCard";
import { formatDistanceToNow } from "date-fns";
import { shotThumbnail } from "@/lib/shot-thumbnail";
const PRIORITY_DOT: Record<string, string> = {
LOW: "bg-zinc-500",
@@ -34,7 +35,11 @@ interface KanbanTask {
status: TaskStatus;
priority: string;
dueDate: Date | null;
shot?: { shotCode: string; thumbnailUrl?: string | null } | null;
shot?: {
shotCode: string;
thumbnailUrl?: string | null;
generatedThumbnailUrl?: string | null;
} | null;
asset?: { assetCode: string; name: string } | null;
assignedArtist?: { id: string; name: string | null; email: string; image: string | null } | null;
_count?: { versions: number };
@@ -71,11 +76,12 @@ export function KanbanCard({ task, isDragOverlay = false }: KanbanCardProps) {
const contextCode = task.shot?.shotCode ?? task.asset?.assetCode;
// Resolve thumbnail: prefer latest version thumbnail, then shot thumbnail
// Resolve thumbnail: prefer latest version thumbnail, then the shot's own
// (reference frame first, render-derived one only as a fallback).
const thumbnail =
latestVersion?.thumbnailUrl ??
latestVersion?.posterUrl ??
task.shot?.thumbnailUrl ??
shotThumbnail(task.shot) ??
null;
return (