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
@@ -64,6 +64,7 @@ interface ProjectTabsClientProps {
overlayComp?: string | null;
previewComp?: string | null;
lutComp?: string | null;
autoShotThumbnail?: boolean | null;
} | null;
};
clients: Client[];
@@ -41,7 +41,7 @@ export default async function KanbanPage({
where: { projectId: id },
orderBy: [{ status: "asc" }, { sortOrder: "asc" }],
include: {
shot: { select: { id: true, shotCode: true, thumbnailUrl: true } },
shot: { select: { id: true, shotCode: true, thumbnailUrl: true, generatedThumbnailUrl: true } },
asset: { select: { id: true, assetCode: true, name: true } },
assignedArtist: {
select: { id: true, name: true, email: true, image: true },
+2 -1
View File
@@ -60,7 +60,7 @@ async function getProject(id: string) {
tasks: {
orderBy: [{ status: "asc" }, { sortOrder: "asc" }],
include: {
shot: { select: { id: true, shotCode: true, thumbnailUrl: true } },
shot: { select: { id: true, shotCode: true, thumbnailUrl: true, generatedThumbnailUrl: true } },
asset: { select: { id: true, assetCode: true, name: true } },
assignedArtist: { select: { id: true, name: true, email: true, image: true } },
_count: { select: { versions: true } },
@@ -207,6 +207,7 @@ export default async function ProjectPage({ params }: { params: Promise<{ id: st
overlayComp?: string | null;
previewComp?: string | null;
lutComp?: string | null;
autoShotThumbnail?: boolean | null;
} | null,
}}
clients={clients}
@@ -76,6 +76,7 @@ const PRIORITY_CONFIG: Record<string, { label: string; dot: string }> = {
};
import { useToast } from "@/components/ui/use-toast";
import { shotThumbnail } from "@/lib/shot-thumbnail";
export default function ShotDetailPage() {
const params = useParams<{ id: string; shotId: string }>();
@@ -251,11 +252,11 @@ export default function ShotDetailPage() {
<ArrowLeft className="h-4 w-4" />
</Link>
</Button>
{shot.thumbnailUrl && (
{shotThumbnail(shot) && (
<div className="relative flex-shrink-0 w-72 aspect-[2.39] rounded-lg overflow-hidden border border-border">
<Image
src={shot.thumbnailUrl}
src={shotThumbnail(shot)!}
alt={shot.shotCode}
fill
className="object-cover"
@@ -53,7 +53,12 @@ export interface ScheduleTask {
email: string;
image: string | null;
} | null;
shot: { id: string; shotCode: string; thumbnailUrl: string | null } | null;
shot: {
id: string;
shotCode: string;
thumbnailUrl: string | null;
generatedThumbnailUrl: string | null;
} | null;
asset: { id: string; assetCode: string; name: string } | null;
project: { id: string; name: string; code: string };
}
+2 -2
View File
@@ -31,7 +31,7 @@ export default async function SchedulePage({
...(artist ? { assignedArtistId: artist } : {}),
},
include: {
shot: { select: { id: true, shotCode: true, thumbnailUrl: true } },
shot: { select: { id: true, shotCode: true, thumbnailUrl: true, generatedThumbnailUrl: true } },
asset: { select: { id: true, assetCode: true, name: true } },
project: { select: { id: true, name: true, code: true } },
assignedArtist: {
@@ -49,7 +49,7 @@ export default async function SchedulePage({
...(artist ? { assignedArtistId: artist } : {}),
},
include: {
shot: { select: { id: true, shotCode: true, thumbnailUrl: true } },
shot: { select: { id: true, shotCode: true, thumbnailUrl: true, generatedThumbnailUrl: true } },
asset: { select: { id: true, assetCode: true, name: true } },
project: { select: { id: true, name: true, code: true } },
assignedArtist: {
+119 -12
View File
@@ -18,11 +18,18 @@ import {
DialogTitle,
DialogFooter,
} from "@/components/ui/dialog";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { cn } from "@/lib/utils";
import { updateShotNotes, bulkUpdateDueDates, toggleKeyShot } from "@/actions/shots";
import { updateShotNotes, bulkUpdateDueDates, bulkDeleteShots, toggleKeyShot } from "@/actions/shots";
import { useToast } from "@/components/ui/use-toast";
import {
Film,
@@ -38,8 +45,11 @@ import {
ShieldCheck,
Eye,
Star,
Trash2,
ChevronsUpDown,
} from "lucide-react";
import { format } from "date-fns";
import { shotThumbnail } from "@/lib/shot-thumbnail";
type ShotRow = {
id: string;
@@ -51,6 +61,7 @@ type ShotRow = {
priority: string;
dueDate: Date | string | null;
thumbnailUrl: string | null;
generatedThumbnailUrl: string | null;
notes: string | null;
description: string | null;
isKeyShot: boolean;
@@ -209,6 +220,56 @@ function BulkDueDateDialog({
);
}
function BulkDeleteDialog({
open,
onClose,
onConfirm,
count,
}: {
open: boolean;
onClose: () => void;
onConfirm: () => Promise<void>;
count: number;
}) {
const [isPending, startTransition] = useTransition();
const handleConfirm = () => {
startTransition(async () => {
await onConfirm();
});
};
return (
<Dialog open={open} onOpenChange={(o) => { if (!o && !isPending) onClose(); }}>
<DialogContent className="sm:max-w-sm">
<DialogHeader>
<DialogTitle className="text-red-400">Delete {count} shot{count !== 1 ? "s" : ""}?</DialogTitle>
</DialogHeader>
<p className="text-sm text-zinc-300">
This will permanently delete <span className="font-semibold text-white">{count}</span>{" "}
shot{count !== 1 ? "s" : ""}, including all tasks, versions, footage, and annotations.
This cannot be undone.
</p>
<p className="text-xs text-zinc-500">
A shot with renders or deliveries already on record is protected and will be skipped
rather than deleted — you'll see which ones and why.
</p>
<DialogFooter className="mt-2">
<Button variant="ghost" onClick={onClose} disabled={isPending}>
Cancel
</Button>
<Button variant="destructive" onClick={handleConfirm} disabled={isPending}>
{isPending && <Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />}
{isPending ? "Deleting…" : `Yes, delete ${count} shot${count !== 1 ? "s" : ""}`}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
// ── NotesCell ─────────────────────────────────────────────────────────────────
function NotesCell({
@@ -382,9 +443,9 @@ function ShotTable({
{/* Thumbnail */}
<td className="py-2 px-3">
<div className="w-24 aspect-[2.39/1] rounded overflow-hidden bg-zinc-800 flex items-center justify-center shrink-0">
{shot.thumbnailUrl ? (
{shotThumbnail(shot) ? (
<Image
src={shot.thumbnailUrl}
src={shotThumbnail(shot)!}
alt={shot.shotCode}
width={96}
height={40}
@@ -513,6 +574,7 @@ export function ShotStatusClient({
}
}, [selectedProjectId]);
const [dueDateDialogOpen, setDueDateDialogOpen] = useState(false);
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const toggleEpisode = (ep: string) =>
setExpandedEpisodes((prev) => {
@@ -586,6 +648,26 @@ export function ShotStatusClient({
}
};
const handleBulkDelete = async () => {
try {
const result = await bulkDeleteShots([...selectedIds]);
if (result.failed.length > 0) {
toast({
title: `Deleted ${result.deleted} shot${result.deleted !== 1 ? "s" : ""}, ${result.failed.length} skipped`,
description: result.failed.map((f) => `${f.shotCode}: ${f.reason}`).join("; "),
variant: "destructive",
});
} else {
toast({ title: `Deleted ${result.deleted} shot${result.deleted !== 1 ? "s" : ""}` });
}
setDeleteDialogOpen(false);
clearSelection();
router.refresh();
} catch (e) {
toast({ title: "Failed to delete shots", description: e instanceof Error ? e.message : undefined, variant: "destructive" });
}
};
// Group by episode for episodic projects
const isEpisodic = selectedProject?.projectType === "EPISODIC";
const episodeGroups: [string, ShotRow[]][] = isEpisodic
@@ -722,15 +804,32 @@ export function ShotStatusClient({
<span className="text-sm font-medium text-blue-300">
{selectionCount} shot{selectionCount !== 1 ? "s" : ""} selected
</span>
<Button
size="sm"
variant="outline"
className="h-7 gap-1.5 border-blue-500/40 text-blue-300 hover:bg-blue-500/20 hover:text-blue-200"
onClick={() => setDueDateDialogOpen(true)}
>
<CalendarDays className="h-3.5 w-3.5" />
Change Due Date
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
size="sm"
variant="outline"
className="h-7 gap-1.5 border-blue-500/40 text-blue-300 hover:bg-blue-500/20 hover:text-blue-200"
>
Bulk Actions
<ChevronsUpDown className="h-3.5 w-3.5" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem onClick={() => setDueDateDialogOpen(true)}>
<CalendarDays className="h-3.5 w-3.5 mr-2" />
Change Due Date
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => setDeleteDialogOpen(true)}
className="text-red-400 focus:text-red-300"
>
<Trash2 className="h-3.5 w-3.5 mr-2" />
Delete Shots
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<button
onClick={clearSelection}
className="text-zinc-500 hover:text-zinc-300 transition-colors"
@@ -925,6 +1024,14 @@ export function ShotStatusClient({
onApply={handleBulkDueDate}
count={selectionCount}
/>
{/* Bulk delete dialog */}
<BulkDeleteDialog
open={deleteDialogOpen}
onClose={() => setDeleteDialogOpen(false)}
onConfirm={handleBulkDelete}
count={selectionCount}
/>
</div>
);
}
+1
View File
@@ -37,6 +37,7 @@ async function getShotsForProject(projectId: string) {
priority: true,
dueDate: true,
thumbnailUrl: true,
generatedThumbnailUrl: true,
notes: true,
description: true,
isKeyShot: true,
+8 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { validateReviewToken } from "@/lib/review-auth";
import { shotThumbnail } from "@/lib/shot-thumbnail";
/** GET /api/client/[token]/project — returns project + shots with tasks that have client-visible versions */
export async function GET(
@@ -49,6 +50,7 @@ export async function GET(
status: true,
shotApprovalStatus: true,
thumbnailUrl: true,
generatedThumbnailUrl: true,
tasks: {
where: {
versions: { some: { isClientVisible: true } },
@@ -113,7 +115,12 @@ export async function GET(
return NextResponse.json({
project,
shots,
// Shots the client sees resolve the same way as internally: the reference
// still first, a render-derived one only where the show supplied none.
shots: shots.map(({ generatedThumbnailUrl, ...shot }) => ({
...shot,
thumbnailUrl: shotThumbnail({ ...shot, generatedThumbnailUrl }),
})),
assetTasks,
sessionLabel: session.label,
});
@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { shotThumbnail } from "@/lib/shot-thumbnail";
// ── Auth ─────────────────────────────────────────────────────────────────────
@@ -91,6 +92,7 @@ export async function GET(
seqTimecodeStart: true,
seqTimecodeEnd: true,
thumbnailUrl: true,
generatedThumbnailUrl: true,
artist: {
select: { id: true, name: true, email: true },
},
@@ -111,6 +113,9 @@ export async function GET(
return NextResponse.json({
project,
pagination: { page, limit, total, pages: Math.ceil(total / limit) },
shots,
shots: shots.map(({ generatedThumbnailUrl, ...shot }) => ({
...shot,
thumbnailUrl: shotThumbnail({ ...shot, generatedThumbnailUrl }),
})),
});
}
+6 -1
View File
@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { shotThumbnail } from "@/lib/shot-thumbnail";
// ── Auth ─────────────────────────────────────────────────────────────────────
@@ -67,6 +68,7 @@ export async function GET(req: NextRequest) {
seqTimecodeEnd: true,
shotVersion: true,
thumbnailUrl: true,
generatedThumbnailUrl: true,
createdAt: true,
updatedAt: true,
project: {
@@ -104,5 +106,8 @@ export async function GET(req: NextRequest) {
return NextResponse.json({ error: "Shot not found" }, { status: 404 });
}
return NextResponse.json({ shot });
const { generatedThumbnailUrl, ...rest } = shot;
return NextResponse.json({
shot: { ...rest, thumbnailUrl: shotThumbnail(shot) },
});
}
+3 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { shotThumbnail } from "@/lib/shot-thumbnail";
export async function GET(req: NextRequest) {
const session = await auth();
@@ -33,6 +34,7 @@ export async function GET(req: NextRequest) {
shotApprovalStatus: true,
sharedWithClient: true,
thumbnailUrl: true,
generatedThumbnailUrl: true,
tasks: {
select: {
id: true,
@@ -75,7 +77,7 @@ export async function GET(req: NextRequest) {
status: shot.status,
shotApprovalStatus: shot.shotApprovalStatus,
sharedWithClient: shot.sharedWithClient,
thumbnailUrl: shot.thumbnailUrl,
thumbnailUrl: shotThumbnail(shot),
latestVersion: {
id: latest.id,
versionNumber: latest.versionNumber,
+7 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { shotThumbnail } from "@/lib/shot-thumbnail";
function requireRole(role: string) {
return ["ADMIN", "PRODUCER", "SUPERVISOR"].includes(role);
@@ -27,6 +28,7 @@ export async function GET(
scene: true,
episode: true,
thumbnailUrl: true,
generatedThumbnailUrl: true,
references: {
orderBy: { sortOrder: "asc" },
select: {
@@ -41,5 +43,9 @@ export async function GET(
});
if (!shot) return NextResponse.json({ error: "Not found" }, { status: 404 });
return NextResponse.json({ shot });
const { generatedThumbnailUrl, ...rest } = shot;
return NextResponse.json({
shot: { ...rest, thumbnailUrl: shotThumbnail(shot) },
});
}
+7 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { shotThumbnail } from "@/lib/shot-thumbnail";
// ─── Helpers ──────────────────────────────────────────────────────────────────
@@ -409,13 +410,18 @@ export async function GET(req: NextRequest) {
where: { projectId },
select: {
id: true, shotCode: true, scene: true, episode: true, shotNumber: true,
description: true, notes: true, status: true, thumbnailUrl: true,
description: true, notes: true, status: true,
thumbnailUrl: true, generatedThumbnailUrl: true,
frameStart: true, frameEnd: true, fps: true, isKeyShot: true, shotVersion: true,
shotGroup: { select: { id: true, name: true } },
},
orderBy: [{ episode: "asc" }, { scene: "asc" }, { shotNumber: "asc" }],
});
// Collapse the two columns before anything reads them, so the "only shots
// with thumbnails" filter and the page renderer agree on what counts as one.
shots = shots.map((s) => ({ ...s, thumbnailUrl: shotThumbnail(s) }));
if (onlyThumbs) shots = shots.filter((s) => !!s.thumbnailUrl);
if (epFilter.length) shots = shots.filter((s) => epFilter.includes(s.episode ?? ""));
if (grpFilter.length) shots = shots.filter((s) => grpFilter.includes(s.shotGroup?.id ?? ""));
+10 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { shotThumbnail } from "@/lib/shot-thumbnail";
// GET /api/storyboard/shots?projectId=xxx
export async function GET(req: NextRequest) {
@@ -26,6 +27,7 @@ export async function GET(req: NextRequest) {
notes: true,
status: true,
thumbnailUrl: true,
generatedThumbnailUrl: true,
frameStart: true,
frameEnd: true,
fps: true,
@@ -40,5 +42,12 @@ export async function GET(req: NextRequest) {
],
});
return NextResponse.json({ shots });
// The reference still wins; a render-derived one fills the gap where a show
// shipped no stills at all (lib/shot-thumbnail.ts).
return NextResponse.json({
shots: shots.map(({ generatedThumbnailUrl, ...shot }) => ({
...shot,
thumbnailUrl: shotThumbnail({ ...shot, generatedThumbnailUrl }),
})),
});
}