"use client"; import { useState } from "react"; import Link from "next/link"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import { ArrowLeft, RotateCcw, XCircle, ShieldAlert } from "lucide-react"; import { Button } from "@/components/ui/button"; import { useToast } from "@/components/ui/use-toast"; import { cn } from "@/lib/utils"; import { EXPORT_STATUS_STYLES, FAILED_STATUSES, ACTIVE_STATUSES, statusLabel, } from "../../status-colors"; interface ExportDetail { export: { id: string; status: string; versionString: string; statusChangedAt: string; createdAt: string; aepPath: string; compName: string; outputDir: string; outputPattern: string; frameStart: number; frameEnd: number; fps: number; width: number; height: number; colorspace: string | null; exrFileCount: number | null; exrTotalBytes: number | null; vfxScope: string | null; submissionNote: string | null; submittedByName: string | null; shot: { id: string; shotCode: string; episode: string | null; project: { id: string; name: string; code: string }; }; renderJobs: { id: string; attempt: number; status: string; priority: number; progress: number; currentFrame: number | null; totalFrames: number | null; errorMessage: string | null; logTail: string | null; exitCode: number | null; claimedAt: string | null; startedAt: string | null; finishedAt: string | null; machine: { id: string; name: string } | null; }[]; events: { id: string; fromStatus: string | null; toStatus: string; actorType: string; actorId: string | null; note: string | null; createdAt: string; }[]; validations: { id: string; renderJobId: string; checkName: string; status: string; expected: string | null; actual: string | null; message: string | null; details: unknown; createdAt: string; }[]; qcReviews: { id: string; result: string; notes: string | null; reviewerName: string | null; source: string; createdAt: string; }[]; deliveryItems: { id: string; status: string; exrPath: string | null; linkMode: string | null; package: { id: string; name: string; episode: string; status: string; packageNumber: number }; }[]; }; } const CHECK_STYLES: Record = { PASS: "text-emerald-400", FAIL: "text-red-400", WARN: "text-amber-400", SKIPPED: "text-zinc-500", }; export function ExportDetailClient({ exportId }: { exportId: string }) { const { toast } = useToast(); const queryClient = useQueryClient(); const [overrideOpen, setOverrideOpen] = useState(false); const [overrideReason, setOverrideReason] = useState(""); const [overrideSkipPreview, setOverrideSkipPreview] = useState(false); const [overriding, setOverriding] = useState(false); const { data, isLoading, error } = useQuery({ queryKey: ["pipeline-export", exportId], queryFn: async () => { const res = await fetch(`/api/render/exports/${exportId}`); if (!res.ok) throw new Error((await res.json().catch(() => ({})))?.error ?? "Failed to load export"); return res.json() as Promise; }, refetchInterval: 5000, }); async function action(verb: "retry" | "cancel") { const res = await fetch(`/api/render/exports/${exportId}/${verb}`, { method: "POST" }); const body = await res.json().catch(() => ({})); if (!res.ok) { toast({ title: `${verb} failed`, description: body.error ?? res.statusText, variant: "destructive" }); } queryClient.invalidateQueries({ queryKey: ["pipeline-export", exportId] }); } async function overrideValidation() { setOverriding(true); try { const res = await fetch(`/api/render/exports/${exportId}/override-validation`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ reason: overrideReason, skipPreview: overrideSkipPreview }), }); const body = await res.json().catch(() => ({})); if (!res.ok) { toast({ title: "Override failed", description: body.error ?? res.statusText, variant: "destructive" }); return; } toast({ title: "Validation overridden", description: `${(body.overridden ?? []).join(", ") || "No failed checks recorded"} — continuing to preview and QC`, }); setOverrideOpen(false); setOverrideReason(""); queryClient.invalidateQueries({ queryKey: ["pipeline-export", exportId] }); } finally { setOverriding(false); } } if (isLoading) return
Loading…
; if (error || !data) { return (
{(error as Error)?.message ?? "Export not found"}
); } const e = data.export; const manifestRows: [string, string][] = [ ["Project", `${e.shot.project.name} (${e.shot.project.code})`], ["Shot", e.shot.shotCode], ["Comp", e.compName], ["AEP", e.aepPath], ["Output dir", e.outputDir], ["Pattern", e.outputPattern], ["Frames", `${e.frameStart}–${e.frameEnd} @ ${e.fps} fps`], ["Resolution", `${e.width}×${e.height}`], ["Colorspace", e.colorspace ?? "—"], ["EXR files", e.exrFileCount != null ? String(e.exrFileCount) : "—"], ["Submitted by", e.submittedByName ?? "—"], ]; return (

{e.shot.shotCode} · {e.versionString}

{statusLabel(e.status)}
{FAILED_STATUSES.includes(e.status) && ( )} {e.status === "VALIDATION_FAILED" && !overrideOpen && ( )} {ACTIVE_STATUSES.includes(e.status) && ( )}
{/* Override — a human overruling the checks, so the reason is required and kept on the export's timeline. */} {overrideOpen && (
Override the failed validation for {e.shot.shotCode} {e.versionString}?

The render continues to preview and then QC — it is not delivered directly, and the failed checks stay on record and still show up in the QC queue. Say why, so the next person reading this export knows what was waved through.