commit 616f12ab4ffbb4cd57062996ead2d1da0d39cf0d
parent e61493aef5a73193e5637284288691e60e05b4a3
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 23 Oct 2026 01:33:28 -0400
report builds: a deck cut's job budget scales with its length (RENDER_BUDGET × the cut's seconds), so a 25-minute deck cut's final or full take is not stopped at the per-clip budget; live preview canvas redraws on a new canvas or size
The Huck cut (36 clips, ~25 min) renders its deck, feed and stamps for ~36
minutes before its segments and crossfades; the final preset's budget was
36 × 2 min = 72 min and a full take's 36 min. buildTimeoutMs / takeTimeoutMs
take the cut's estimated seconds (onscreen.mjs renderSeconds, 0 without the
deck) from the build and take routes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
7 files changed, 82 insertions(+), 22 deletions(-)
diff --git a/umtool/app/api/report/build/route.ts b/umtool/app/api/report/build/route.ts
@@ -5,6 +5,7 @@ import { PRESETS, buildSteps } from "@/lib/report/driver.mjs";
import { clipsOf, readManifest } from "@/lib/projects/report.mjs";
import { projectRef } from "@/lib/projects";
import { recordBuildSnapshot } from "@/lib/report/snapshots.mjs";
+import { renderSeconds } from "@/lib/report/onscreen.mjs";
import { DEFAULT_VARIANT, VARIANTS, variantPaths } from "umtool-report-to-video/build-video";
import { refuseCaller } from "@/lib/report/caller";
@@ -134,7 +135,9 @@ export async function POST(request: Request) {
if (!options.podcast && manifest.timeline?.some((e: { type?: string; narration?: unknown }) => e?.type === "card" && e.narration)) {
options.narrate = true;
}
- const steps = buildSteps(project, { preset, only, skipFetch, clipCount, options });
+ // A cut that renders its on-screen chrome is budgeted by its length too (driver.mjs buildTimeoutMs).
+ const seconds = renderSeconds(manifest, options.variant ?? null);
+ const steps = buildSteps(project, { preset, only, skipFetch, clipCount, seconds, options });
const view = {
project: project.id,
preset,
diff --git a/umtool/app/api/report/takes/make/route.ts b/umtool/app/api/report/takes/make/route.ts
@@ -2,6 +2,7 @@ import { getJob, jobView, runningJob, startJob } from "@/lib/jobs";
import { projectRef } from "@/lib/projects";
import { clipsOf, readManifest } from "@/lib/projects/report.mjs";
import { loadMontageStyles, takeSteps } from "@/lib/report/takeMaker.mjs";
+import { renderSeconds } from "@/lib/report/onscreen.mjs";
import { listTakes } from "@/lib/report/takes.mjs";
import { kindMakesTakes } from "@/lib/projects/kinds.mjs";
@@ -62,6 +63,7 @@ export async function POST(request: Request) {
styles,
existing: listing.takes,
clipCount: clipsOf(manifest).length,
+ seconds: renderSeconds(manifest),
});
} catch (e) {
return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
diff --git a/umtool/components/projects/review/LiveDeckPreview.tsx b/umtool/components/projects/review/LiveDeckPreview.tsx
@@ -156,7 +156,7 @@ export default function LiveDeckPreview({
const bg = doc?.background ?? "#000";
const bgRef = useRef(bg);
bgRef.current = bg;
- const lastDraw = useRef<{ media: HTMLMediaElement | null; t: number; w: number }>({ media: null, t: NaN, w: 0 });
+ const lastDraw = useRef<{ el: HTMLCanvasElement | null; media: HTMLMediaElement | null; t: number; bg: string; size: string }>({ el: null, media: null, t: NaN, bg: "", size: "" });
// Every animation frame while on: the playhead's cut second, and the
// editor's picture drawn into the footage box when it moved.
@@ -181,8 +181,8 @@ export default function LiveDeckPreview({
if (!el) return;
const ld = lastDraw.current;
const video = m instanceof HTMLVideoElement && m.readyState >= 2 && m.videoWidth > 0 ? m : null;
- if (ld.media === video && ld.t === (video?.currentTime ?? -1) && ld.w === el.width) return;
- lastDraw.current = { media: video, t: video?.currentTime ?? -1, w: el.width };
+ if (ld.el === el && ld.media === video && ld.t === (video?.currentTime ?? -1) && ld.bg === bgRef.current && ld.size === `${el.width}x${el.height}`) return;
+ lastDraw.current = { el, media: video, t: video?.currentTime ?? -1, bg: bgRef.current, size: `${el.width}x${el.height}` };
const ctx = el.getContext("2d");
if (!ctx) return;
ctx.fillStyle = bgRef.current;
@@ -380,7 +380,7 @@ export default function LiveDeckPreview({
{clock && seg && (
<div className="grid gap-1.5 sm:grid-cols-2" data-live-words="">
<label className="flex items-center gap-1.5 text-[12px] text-text-2">
- <span className="micro w-[4.5em]">Title</span>
+ <span className="micro shrink-0">Title</span>
<input
data-live-title=""
value={titleDraft ?? savedTitle}
@@ -394,7 +394,7 @@ export default function LiveDeckPreview({
/>
</label>
<label className="flex items-center gap-1.5 text-[12px] text-text-2">
- <span className="micro w-[4.5em]">Subtitle</span>
+ <span className="micro shrink-0">Subtitle</span>
<input
data-live-subtitle=""
value={subDraft ?? savedSub}
diff --git a/umtool/lib/report/driver.mjs b/umtool/lib/report/driver.mjs
@@ -57,9 +57,17 @@ export const PRESETS = {
final: { label: "final", xfade: true, chapters: true, only: false, final: true },
};
-/** A build's timeout, scaled to the work rather than to a global guess. */
-export const buildTimeoutMs = (clipCount, xfade) =>
- Math.max(15 * 60_000, clipCount * (xfade ? 120_000 : 60_000));
+/**
+ * A build's timeout, scaled to the work rather than to a global guess: per
+ * clip, and -- for a cut that renders its on-screen chrome (`seconds`, the
+ * cut's estimated length; onscreen.mjs renderSeconds) -- RENDER_BUDGET
+ * seconds of job per second of cut. A 36-clip deck cut of 25 minutes renders
+ * its deck, feed and stamps for about 36 minutes before its segments and
+ * crossfades are made; the per-clip budget alone (72 minutes) would stop it.
+ */
+export const RENDER_BUDGET = 5;
+export const buildTimeoutMs = (clipCount, xfade, seconds = 0) =>
+ Math.max(15 * 60_000, clipCount * (xfade ? 120_000 : 60_000), Math.round(seconds * RENDER_BUDGET * 1000));
/**
* The chain.
@@ -117,10 +125,10 @@ export function availabilityStep(project, env = {}) {
/**
* @param {{ id: string, dir: string }} project
- * @param {{ preset?: string, only?: string | null, skipFetch?: boolean, env?: Record<string,string>, clipCount?: number, options?: BuildOptions }} [opts]
+ * @param {{ preset?: string, only?: string | null, skipFetch?: boolean, env?: Record<string,string>, clipCount?: number, seconds?: number, options?: BuildOptions }} [opts]
* @returns {import("../trim").Step[]}
*/
-export function buildSteps(project, { preset = "fast", only = null, skipFetch = false, env = {}, clipCount = 20, options = {} } = {}) {
+export function buildSteps(project, { preset = "fast", only = null, skipFetch = false, env = {}, clipCount = 20, seconds = 0, options = {} } = {}) {
const p = PRESETS[preset] ?? PRESETS.fast;
const manifest = path.join(project.dir, "video.manifest.json");
const outDir = path.join(project.dir, "out");
@@ -197,7 +205,7 @@ export function buildSteps(project, { preset = "fast", only = null, skipFetch =
: p.label,
argv: buildArgv,
ndjson: true,
- timeoutMs: quick ? 5 * 60_000 : buildTimeoutMs(clipCount, p.xfade),
+ timeoutMs: quick ? 5 * 60_000 : buildTimeoutMs(clipCount, p.xfade, p.only && only ? 0 : seconds),
});
// A build can exit 0 and still be wrong: a concat that produced nothing, a
diff --git a/umtool/lib/report/livePreview.test.mjs b/umtool/lib/report/livePreview.test.mjs
@@ -13,9 +13,10 @@ import test from "node:test";
import { MANIFEST_NAME, StaleToken } from "./manifest.mjs";
import { clipEditorView, runClipEditorOp } from "./clipEditor.mjs";
import { clipRenderFile, clipRenderSteps, readClipRender, windowMoved } from "./clipRender.mjs";
-import { composeFinalePreview, scheduleForPreview } from "./onscreen.mjs";
+import { composeFinalePreview, renderSeconds, scheduleForPreview } from "./onscreen.mjs";
import { finalePreviewDir, finalePreviewSrc, previewDirFor } from "./serve.mjs";
-import { PIPELINE_DIR } from "./driver.mjs";
+import { PIPELINE_DIR, RENDER_BUDGET, buildSteps, buildTimeoutMs } from "./driver.mjs";
+import { takeTimeoutMs } from "./takeMaker.mjs";
const manifest = () => ({
schemaVersion: 1,
@@ -130,6 +131,26 @@ test("Render this clip: one step, build-video --clip-preview from what is on dis
assert.equal(clipRenderFile("/proj", "../x", "fed"), null);
});
+test("a deck cut's build is budgeted by its length too: the Huck cut's final is not stopped at 72 minutes", () => {
+ const m = manifest();
+ assert.equal(renderSeconds(m), Math.round(8.4 + 10));
+ assert.equal(renderSeconds({ ...m, render: { ...m.render, chrome: undefined } }), 0);
+ assert.equal(renderSeconds(null), 0);
+ // 36 clips, 25 minutes of cut: the per-clip budget alone was 72 minutes.
+ assert.equal(buildTimeoutMs(36, true), 72 * 60_000);
+ assert.equal(buildTimeoutMs(36, true, 1515), 1515 * RENDER_BUDGET * 1000);
+ assert.ok(buildTimeoutMs(36, true, 1515) > 2 * 60 * 60_000);
+ assert.equal(buildTimeoutMs(3, false, 0), 15 * 60_000);
+ const final = buildSteps({ id: "p", dir: "/p" }, { preset: "final", clipCount: 36, seconds: 1515 });
+ assert.equal(final.find((s) => s.label === "final").timeoutMs, 1515 * RENDER_BUDGET * 1000);
+ // One clip's preview build is not the cut's.
+ const one = buildSteps({ id: "p", dir: "/p" }, { preset: "preview", only: "c1", clipCount: 36, seconds: 1515 });
+ assert.equal(one.at(-1).timeoutMs, 36 * 60_000);
+ assert.equal(takeTimeoutMs(true, 36, 1515), 1515 * RENDER_BUDGET * 1000);
+ assert.equal(takeTimeoutMs(true, 36), 36 * 60_000);
+ assert.equal(takeTimeoutMs(false, 36, 1515), 15 * 60_000);
+});
+
test("a clip's render on disk, and whether its window moved since", async () => {
const p = await project();
try {
diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs
@@ -24,7 +24,9 @@ import {
attachPosts,
clipDay,
deckGeometry,
+ deckOn,
deckText,
+ estimatedDuration,
estimateSchedule,
footageMoves,
playWindow,
@@ -33,6 +35,7 @@ import {
postWindows,
resolveDeck,
roundPosts,
+ transitionOf,
} from "umtool-report-to-video/deck";
import { marksOf, rawMarksOf, roundStamps, stampSchedule } from "umtool-report-to-video/factcheck";
import { setMarks } from "./knobs.mjs";
@@ -426,6 +429,24 @@ export async function scheduleForPreview(
return { variantManifest, metas, schedule: previewSchedule({ variantManifest, built, draft, metas, postsDraft, claimsDraft }) };
}
+/**
+ * How long a cut is, estimated from the manifest, when its build renders the
+ * on-screen chrome (the deck on): the seconds a build's job budget scales with
+ * (driver.mjs buildTimeoutMs, takeMaker.mjs takeTimeoutMs). 0 without the deck.
+ *
+ * @param {Record<string, any> | null} manifest
+ * @param {string | null} [variant]
+ */
+export function renderSeconds(manifest, variant = null) {
+ if (!manifest) return 0;
+ const selected = selectVariant(manifest, variant || "sourced");
+ const render = selected.render ?? {};
+ if (!deckOn(render)) return 0;
+ const D = transitionOf(render);
+ const entries = selected.timeline ?? [];
+ return Math.round(entries.reduce((sum, e) => sum + estimatedDuration(e, render, D), 0));
+}
+
/** The most a preview request waits on the archive for its posts' links, all of them together. */
const PREVIEW_LINK_DEADLINE_MS = 10000;
diff --git a/umtool/lib/report/takeMaker.mjs b/umtool/lib/report/takeMaker.mjs
@@ -43,7 +43,7 @@ import path from "node:path";
import { pathToFileURL } from "node:url";
import { mergePatch } from "umtool-report-to-video/montage-styles";
import { applyMontageRulings, readMontageRulings, rulingsLines } from "umtool-report-to-video/montage-rulings";
-import { PIPELINE_DIR, UMTOOL_DIR } from "./driver.mjs";
+import { PIPELINE_DIR, RENDER_BUDGET, UMTOOL_DIR } from "./driver.mjs";
import { replaceManifest } from "./manifest.mjs";
import { withEditNotes } from "./edit-guard.mjs";
import { isTakeId, listTakes, parseWindow, setTakePicked, takesDirOf, TAKE_FILE, TAKE_KINDS } from "./takes.mjs";
@@ -693,8 +693,13 @@ export async function pickTake(project, takeId, { anyway = false, token = null,
// The app's jobs: the CLI above, as job steps (lib/jobs.ts runs them).
// ---------------------------------------------------------------------------
-/** A take render's timeout: a window is minutes; the whole cut is the fast build's own budget. */
-export const takeTimeoutMs = (full, clipCount) => (full ? Math.max(15 * 60_000, clipCount * 60_000) : 15 * 60_000);
+/**
+ * A take render's timeout: a window is minutes; the whole cut is the fast
+ * build's own budget, and a cut that renders its on-screen chrome (`seconds`,
+ * its estimated length) RENDER_BUDGET seconds of job per second of cut.
+ */
+export const takeTimeoutMs = (full, clipCount, seconds = 0) =>
+ (full ? Math.max(15 * 60_000, clipCount * 60_000, Math.round(seconds * RENDER_BUDGET * 1000)) : 15 * 60_000);
const umtoolCli = () => path.join(/* turbopackIgnore: true */ UMTOOL_DIR, "bin", "umtool.mjs");
@@ -710,10 +715,10 @@ const windowArgs = (w) => (w === "full" ? ["--full"] : ["--at", String(w.at), "-
*
* @param {{ id: string }} project
* @param {Record<string, any>} req
- * @param {{ styles: Record<string, { label: string }>, existing: Array<{ id: string, window?: unknown }>, clipCount: number }} ctx
+ * @param {{ styles: Record<string, { label: string }>, existing: Array<{ id: string, window?: unknown }>, clipCount: number, seconds?: number }} ctx
* @returns {{ kind: string, takes: string[], steps: Array<{ label: string, argv: string[], cwd: string, env: Record<string, string>, ndjson: true, timeoutMs: number }> }}
*/
-export function takeSteps(project, req, { styles, existing, clipCount }) {
+export function takeSteps(project, req, { styles, existing, clipCount, seconds = 0 }) {
const ids = new Set(existing.map((t) => t.id));
const base = { cwd: UMTOOL_DIR, env: {}, ndjson: /** @type {const} */ (true) };
const cli = ["node", umtoolCli()];
@@ -724,7 +729,7 @@ export function takeSteps(project, req, { styles, existing, clipCount }) {
return {
kind: `take ${project.id} ${t.id} (rebuild)`,
takes: [t.id],
- steps: [{ ...base, label: `rebuild take ${t.id}`, argv: [...cli, "take", project.id, "--id", t.id, "--rebuild", "--progress", "ndjson"], timeoutMs: takeTimeoutMs(t.window === "full", clipCount) }],
+ steps: [{ ...base, label: `rebuild take ${t.id}`, argv: [...cli, "take", project.id, "--id", t.id, "--rebuild", "--progress", "ndjson"], timeoutMs: takeTimeoutMs(t.window === "full", clipCount, seconds) }],
};
}
if (isObj(req.allStyles)) {
@@ -741,7 +746,7 @@ export function takeSteps(project, req, { styles, existing, clipCount }) {
...base,
label: `make ${recipe.takes.length} take(s), one per style`,
argv: [...cli, "takes", "make", project.id, "--all-styles", ...group, ...windowArgs(recipe.window), ...(recipe.quick ? ["--quick"] : []), ...force, "--progress", "ndjson"],
- timeoutMs: recipe.takes.length * takeTimeoutMs(recipe.window === "full", clipCount),
+ timeoutMs: recipe.takes.length * takeTimeoutMs(recipe.window === "full", clipCount, seconds),
}],
};
}
@@ -762,7 +767,7 @@ export function takeSteps(project, req, { styles, existing, clipCount }) {
return {
kind: `take ${project.id} ${spec.id}`,
takes: [spec.id],
- steps: [{ ...base, label: `make take ${spec.id}`, argv, timeoutMs: takeTimeoutMs(spec.window === "full", clipCount) }],
+ steps: [{ ...base, label: `make take ${spec.id}`, argv, timeoutMs: takeTimeoutMs(spec.window === "full", clipCount, seconds) }],
};
}
throw new Error("say what to make: take, allStyles or rebuild");