feat(pipeline): render-derived shot thumbnails, and bulk shot delete
Deploy / deploy (push) Failing after 19m11s
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:
@@ -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's most recent finished export. Never
|
||||
replaces the thumbnail above — it only fills in where there
|
||||
isn'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…</>
|
||||
) : (
|
||||
"Use latest render frame"
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* References */}
|
||||
|
||||
Reference in New Issue
Block a user