Files
vfxreview/components/shots/ShotExportsTab.tsx
twotalesanimation caaa333f02
Deploy / deploy (push) Failing after 19m11s
feat(pipeline): render-derived shot thumbnails, and bulk shot delete
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>
2026-08-27 17:06:55 +02:00

140 lines
5.0 KiB
TypeScript

"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, 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,
statusLabel,
} from "@/app/(dashboard)/pipeline/status-colors";
interface ExportRow {
id: string;
versionString: string;
status: string;
statusChangedAt: string;
createdAt: string;
outputDir: string;
thumbnailUrl: string | null;
job: {
attempt: number;
progress: number;
machineName: string | null;
errorMessage: string | null;
} | null;
}
/**
* "Exports" tab on the shot detail page (RenderPipeline2 §13) — the render
* 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 () => {
const res = await fetch(`/api/render/queue?shotId=${shotId}&limit=100`);
if (!res.ok) throw new Error("Failed to load exports");
return res.json() as Promise<{ exports: ExportRow[] }>;
},
refetchInterval: 10000,
});
const exports = data?.exports ?? [];
if (isLoading) {
return <div className="py-10 text-center text-sm text-muted-foreground">Loading exports…</div>;
}
if (exports.length === 0) {
return (
<div className="flex flex-col items-center justify-center py-16 gap-2 text-muted-foreground">
<Layers className="h-8 w-8 opacity-30" />
<p className="text-sm">No pipeline exports yet — queue one from the After Effects panel.</p>
</div>
);
}
return (
<div className="space-y-2">
{exports.map((e) => (
<div
key={e.id}
className="flex items-center gap-4 rounded-lg border border-border bg-card p-4 hover:border-zinc-600 transition-colors"
>
<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" />
)}
<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>
);
}