Files
vfxreview/app/api/ext/exports/[exportId]/regenerate-preview/route.ts
T
twotalesanimation 0ce41123c5
Deploy / deploy (push) Successful in 5m58s
feat(render-pipeline): regenerate previews without re-rendering EXRs
A slate or burn-in mistake is usually caught after a preview has already
succeeded, and there was no way back: retryPreview required PREVIEW_FAILED, and
READY_FOR_QC only led on to QC_FAILED/READY_FOR_DELIVERY/SUPERSEDED. The only
recourse was a whole new export, re-rendering every EXR and burning a version
number to fix a typo.

- transitions: READY_FOR_QC and QC_FAILED can now go back to GENERATING_PREVIEW.
- regeneratePreview() rebuilds the manifest from scratch rather than patching
  anything, so shot code, episode/scene, frame count, slate date and burn-ins
  are all re-derived exactly as on a first-time preview. Validated EXRs are
  reused and the version number is untouched -- this re-delivers the same
  version, it does not make a new one.
- vfxScope and submissionNote are frozen onto the Export at submission time, so
  regenerating refreshes that snapshot from the shot's slate fields (explicit
  override wins, same precedence as createExport). Slate text edited on the web
  app's Slate tab is therefore picked up.
- finalizePreview replaces the media on the export's existing Version instead of
  stacking a second row, so the version number stays put and reviewer notes and
  annotations survive the reslate. First-time previews are unaffected.
- POST /api/ext/exports/{id}/regenerate-preview exposes it to the panel.
- Panel: Regenerate Previews button, gated on the same statuses as the server,
  with a confirm covering what is and is not reused.

Also fixes the slate description source: the Slate tab authors
shot.slateDescription (falling back to shot.description) but the preview
manifest only ever read shot.description, so edits made there never reached the
rendered slate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-12 11:02:23 +02:00

50 lines
1.8 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth";
import { toErrorResponse } from "@/lib/render-pipeline/errors";
import { regeneratePreview } from "@/lib/render-pipeline/preview";
// ── POST /api/ext/exports/{exportId}/regenerate-preview (E15b) ───────────────
//
// Rebuild the preview MOV/MP4 for an export that already delivered one, after a
// slate or burn-in mistake was caught. Reuses the validated EXRs and keeps the
// version number; slate text edited on the web app's Slate tab is picked up.
//
// Body (all optional):
// vfxScope per-export override; omit to re-read the shot's slate field
// submissionNote same
// note audit note for the ExportEvent
export async function POST(
req: NextRequest,
{ params }: { params: Promise<{ exportId: string }> }
) {
if (!isExtAuthorized(req)) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const { exportId } = await params;
let body: {
vfxScope?: string | null;
submissionNote?: string | null;
note?: string;
} = {};
try {
const parsed = await req.json();
if (parsed && typeof parsed === "object") body = parsed;
} catch {
// empty body is fine — everything falls back to the shot's slate fields
}
try {
const result = await regeneratePreview(exportId, {
...(body.vfxScope !== undefined ? { vfxScope: body.vfxScope } : {}),
...(body.submissionNote !== undefined ? { submissionNote: body.submissionNote } : {}),
note: typeof body.note === "string" ? body.note : "Regenerate preview from AE panel",
});
return NextResponse.json(result);
} catch (err) {
const { body: errBody, status } = toErrorResponse(err);
return NextResponse.json(errBody, { status });
}
}