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:
@@ -506,6 +506,9 @@ export async function listExports(filter: ListExportsFilter) {
|
||||
statusChangedAt: e.statusChangedAt,
|
||||
createdAt: e.createdAt,
|
||||
outputDir: e.outputDir,
|
||||
// Lets the shot's Exports tab offer this export's frame as the shot
|
||||
// thumbnail (§9.1a) without a second round trip per row.
|
||||
thumbnailUrl: e.thumbnailKey ? `/api/files/${e.thumbnailKey}` : null,
|
||||
job: e.renderJobs[0]
|
||||
? {
|
||||
id: e.renderJobs[0].id,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { db } from "@/lib/db";
|
||||
import { PipelineError } from "./errors";
|
||||
import { applyTransition } from "./transitions";
|
||||
import { getConfigNumber, getPreviewConfig } from "./config";
|
||||
import { resolveProjectTemplates } from "./project-templates";
|
||||
import { resolveProjectTemplates, autoShotThumbnailEnabled } from "./project-templates";
|
||||
|
||||
/** Slate date format used by the panel's getDateString (YYYY/MM/DD). */
|
||||
function slateDate(d = new Date()): string {
|
||||
@@ -407,6 +407,30 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
}
|
||||
}
|
||||
|
||||
// Promote the render frame onto the shot, for shows that opted in.
|
||||
//
|
||||
// Only `generatedThumbnailUrl` is written — `thumbnailUrl` holds the
|
||||
// reference frame that came with the brief and the pipeline never touches
|
||||
// it. Shows that supply stills therefore look exactly as they did; shows
|
||||
// that supply none get their empty grids filled from the renders instead.
|
||||
let thumbnailPromoted = false;
|
||||
if (artifacts.thumbnailKey) {
|
||||
const shot = await tx.shot.findUnique({
|
||||
where: { id: exportRow.shotId },
|
||||
select: { project: { select: { pipelineConfig: true } } },
|
||||
});
|
||||
if (shot && autoShotThumbnailEnabled(shot.project)) {
|
||||
await tx.shot.update({
|
||||
where: { id: exportRow.shotId },
|
||||
data: {
|
||||
generatedThumbnailUrl: `/api/files/${artifacts.thumbnailKey}`,
|
||||
generatedThumbnailFrom: exportRow.versionString,
|
||||
},
|
||||
});
|
||||
thumbnailPromoted = true;
|
||||
}
|
||||
}
|
||||
|
||||
// The task title carries the version it is showing (house convention:
|
||||
// "UNG_102_019_010_cmp_TT_v004"). The preview just uploaded *is* the task's
|
||||
// new latest version, so the title has to follow the file — the same rename
|
||||
@@ -444,7 +468,8 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
? " — review version media replaced"
|
||||
: ` — review version created (${inheritedApproval ?? "PENDING_REVIEW"})`
|
||||
: " — no preview media reported") +
|
||||
(taskRenamed ? ` — task renamed to ${taskTitle}` : ""),
|
||||
(taskRenamed ? ` — task renamed to ${taskTitle}` : "") +
|
||||
(thumbnailPromoted ? " — shot thumbnail updated from this render" : ""),
|
||||
},
|
||||
{
|
||||
...(versionId ? { versionId } : {}),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { conventionalNames } from "./project-templates";
|
||||
import { conventionalNames, autoShotThumbnailEnabled } from "./project-templates";
|
||||
|
||||
/**
|
||||
* The convention has to reproduce UNG's existing comp names exactly, or
|
||||
@@ -32,3 +32,31 @@ describe("conventionalNames", () => {
|
||||
expect(conventionalNames("").overlayComp).toBe("SHOW_VFX_OVERLAY");
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* The flag decides whether finished renders start writing shot thumbnails, so
|
||||
* anything short of an explicit `true` has to leave shots alone — a malformed
|
||||
* config in particular, which must not be read as consent.
|
||||
*/
|
||||
describe("autoShotThumbnailEnabled", () => {
|
||||
it("is on only when explicitly enabled", () => {
|
||||
expect(autoShotThumbnailEnabled({ pipelineConfig: { autoShotThumbnail: true } })).toBe(true);
|
||||
});
|
||||
|
||||
it("defaults to off", () => {
|
||||
expect(autoShotThumbnailEnabled({ pipelineConfig: {} })).toBe(false);
|
||||
expect(autoShotThumbnailEnabled({ pipelineConfig: null })).toBe(false);
|
||||
expect(autoShotThumbnailEnabled({})).toBe(false);
|
||||
expect(autoShotThumbnailEnabled({ pipelineConfig: { autoShotThumbnail: false } })).toBe(false);
|
||||
});
|
||||
|
||||
it("stays off when the config is malformed", () => {
|
||||
expect(autoShotThumbnailEnabled({ pipelineConfig: { autoShotThumbnail: "yes" } })).toBe(false);
|
||||
expect(autoShotThumbnailEnabled({ pipelineConfig: "not an object" })).toBe(false);
|
||||
});
|
||||
|
||||
it("does not disturb the other settings it shares a column with", () => {
|
||||
const cfg = { pipelineConfig: { templateAep: "X:/show.aep", autoShotThumbnail: true } };
|
||||
expect(autoShotThumbnailEnabled(cfg)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,6 +27,16 @@ export const pipelineConfigSchema = z.object({
|
||||
/** AE output-module templates, when this show does not use the studio defaults. */
|
||||
movTemplate: z.string().max(200).optional().nullable(),
|
||||
mp4Template: z.string().max(200).optional().nullable(),
|
||||
/**
|
||||
* Promote each finished export's thumbnail onto its shot
|
||||
* (`Shot.generatedThumbnailUrl`). Off by default and deliberately per-show:
|
||||
* productions that ship a still with every shot already have a reference
|
||||
* frame, and the renders should not compete with it. Turn it on for shows
|
||||
* that arrive with no stills at all, where an empty grid is the alternative.
|
||||
*
|
||||
* Never touches `Shot.thumbnailUrl` — see lib/shot-thumbnail.ts.
|
||||
*/
|
||||
autoShotThumbnail: z.boolean().optional().nullable(),
|
||||
});
|
||||
|
||||
export type PipelineConfigInput = z.infer<typeof pipelineConfigSchema>;
|
||||
@@ -55,6 +65,16 @@ export function conventionalNames(showId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether finished exports promote their thumbnail onto the shot. Defaults to
|
||||
* false, including when `pipelineConfig` is malformed — a broken config must
|
||||
* not start rewriting shot thumbnails.
|
||||
*/
|
||||
export function autoShotThumbnailEnabled(project: { pipelineConfig?: unknown }): boolean {
|
||||
const parsed = pipelineConfigSchema.safeParse(project.pipelineConfig ?? {});
|
||||
return parsed.success ? parsed.data.autoShotThumbnail === true : false;
|
||||
}
|
||||
|
||||
export async function resolveProjectTemplates(project: {
|
||||
showId: string | null;
|
||||
code: string;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { shotThumbnail, isGeneratedThumbnail } from "./shot-thumbnail";
|
||||
|
||||
/**
|
||||
* The whole point of the second column is that promotion can never destroy the
|
||||
* reference frame that came with the brief. These cases are that guarantee.
|
||||
*/
|
||||
describe("shotThumbnail", () => {
|
||||
it("prefers the reference frame over a render-derived one", () => {
|
||||
expect(
|
||||
shotThumbnail({ thumbnailUrl: "/api/files/image/ref.jpg", generatedThumbnailUrl: "/api/files/image/gen.jpg" })
|
||||
).toBe("/api/files/image/ref.jpg");
|
||||
});
|
||||
|
||||
it("falls back to the render frame when the show supplied no still", () => {
|
||||
expect(shotThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: "/api/files/image/gen.jpg" })).toBe(
|
||||
"/api/files/image/gen.jpg"
|
||||
);
|
||||
});
|
||||
|
||||
it("returns null when the shot has neither", () => {
|
||||
expect(shotThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: null })).toBeNull();
|
||||
expect(shotThumbnail(null)).toBeNull();
|
||||
expect(shotThumbnail({})).toBeNull();
|
||||
});
|
||||
|
||||
it("treats an empty string as no thumbnail", () => {
|
||||
// updateShot accepts "" from a cleared form field, which must not win over
|
||||
// a generated frame or render as a broken <img src="">.
|
||||
expect(shotThumbnail({ thumbnailUrl: "", generatedThumbnailUrl: "/api/files/image/gen.jpg" })).toBe(
|
||||
"/api/files/image/gen.jpg"
|
||||
);
|
||||
});
|
||||
|
||||
it("reports whether what is displayed came from a render", () => {
|
||||
expect(isGeneratedThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: "/g.jpg" })).toBe(true);
|
||||
expect(isGeneratedThumbnail({ thumbnailUrl: "/r.jpg", generatedThumbnailUrl: "/g.jpg" })).toBe(false);
|
||||
expect(isGeneratedThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: null })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Shot thumbnail resolution.
|
||||
*
|
||||
* A shot can carry two stills:
|
||||
*
|
||||
* • `thumbnailUrl` — the reference frame supplied with the brief
|
||||
* (client still, batch upload, ext API). Editorial
|
||||
* data: only ever written by a human.
|
||||
* • `generatedThumbnailUrl` — a frame promoted from a render export, either
|
||||
* automatically (projects with
|
||||
* `pipelineConfig.autoShotThumbnail`) or by hand.
|
||||
*
|
||||
* The reference always wins. Shows that arrive with stills look exactly as they
|
||||
* do today; shows that arrive without any get their empty grids filled from the
|
||||
* renders instead. Because the two live in different columns, a promotion can
|
||||
* never destroy the reference — clearing the generated one always falls back to
|
||||
* the brief.
|
||||
*/
|
||||
export interface ShotThumbnailFields {
|
||||
thumbnailUrl?: string | null;
|
||||
generatedThumbnailUrl?: string | null;
|
||||
}
|
||||
|
||||
/** The still to display for a shot, or null when it has neither. */
|
||||
export function shotThumbnail(shot: ShotThumbnailFields | null | undefined): string | null {
|
||||
return shot?.thumbnailUrl || shot?.generatedThumbnailUrl || null;
|
||||
}
|
||||
|
||||
/** True when the displayed still came from a render rather than the brief. */
|
||||
export function isGeneratedThumbnail(shot: ShotThumbnailFields | null | undefined): boolean {
|
||||
return !shot?.thumbnailUrl && !!shot?.generatedThumbnailUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prisma `select` fragment for the two columns. Spread it wherever a query
|
||||
* already selects `thumbnailUrl` so the fallback has something to fall back to.
|
||||
*/
|
||||
export const shotThumbnailSelect = {
|
||||
thumbnailUrl: true,
|
||||
generatedThumbnailUrl: true,
|
||||
} as const;
|
||||
Reference in New Issue
Block a user