commit ab7a62731740d6db2a96b5cf224aa6da9c36244b
parent 0d215526ef4a5d3809c7d375868ba416c9e98b06
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 2 Nov 2026 17:12:32 -0500
umtool reels: the walk and Play say what the reel was cut against -- the reel's line, "walk only the changed beats", each beat's state with its fix; a cut's record names the reel's version and the master it read
ReelSource.tsx: the reel's line over the walk and Play the reel ("cut against
draft-6; take draft-7 changes beat 7") with the filter that walks only the
changed beats (`?changed=1`: N, P, the head's ‹ › and its "k of n changed
beats"); per beat its state, why, old vs new edges, and the fix -- Clamp a
clipped beat into its clip's new limits, Remove or Re-point an orphan, or
anchor a looked-at beat to this take. Every walk write carries the take, so
an edit or a confirm re-anchors the beat; each fix is one write, an undo
point and a history entry.
A cut's record (makeTrailer) names the take's build, the master's mtime and
the reel's version (trailerBeats.mjs reelVersion: the seconds, gaps,
crossfade and intro -- not a verdict, label or anchor). reelCuts' `stale` reads
the master's mtime from the record when it is there, and `reelChanged` says
the reel was edited since the cut; the Cut panel says both.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
14 files changed, 224 insertions(+), 28 deletions(-)
diff --git a/umtool/components/projects/ProjectView.tsx b/umtool/components/projects/ProjectView.tsx
@@ -95,7 +95,7 @@ export default async function ProjectView({
return <ReelPlayPage project={project} reel={search.reel} take={search.take} beat={search.beat} note={search.note} />;
}
if (rest.length === 2 && rest[0] === "trailer" && rest[1] === "walk") {
- return <ReelWalkPage project={project} reel={search.reel} take={search.take} beat={search.beat} />;
+ return <ReelWalkPage project={project} reel={search.reel} take={search.take} beat={search.beat} changed={search.changed === "1"} />;
}
if (rest.length === 1 && rest[0] === "play") return <PlayCutPage project={project} take={search.take} bare={search.cut === "1"} note={search.note} clip={search.clip} at={search.at} />;
return notFound();
diff --git a/umtool/components/projects/reel/ReelBench.tsx b/umtool/components/projects/reel/ReelBench.tsx
@@ -22,7 +22,8 @@ import { useBenchPlayer } from "../bench/useBenchPlayer";
import { useGapEditor, type GapOp } from "../bench/useGapEditor";
import { usePeaks } from "../bench/usePeaks";
import { Composer, type ReelAnchor } from "./ReelPlay";
-import { clock, r2, readReelView, reelWrite, sourceClock, type ReelRow, type ReelView } from "./reelTypes";
+import { BeatStatusBar, SourceBanner } from "./ReelSource";
+import { CHANGED_STATES, clock, r2, readReelView, reelWrite, sourceClock, type ReelRow, type ReelView } from "./reelTypes";
// ---------------------------------------------------------------------------
// A BEAT REEL'S WALK (`/projects/<p>/trailer/walk?reel=&take=&beat=n`,
@@ -50,14 +51,16 @@ const BIG = 0.5;
const RATES = [0.75, 1, 1.25, 1.5, 2] as const;
type Cue = { start: number; end: number; text: string; endsSentence: boolean };
-export default function ReelBench({ initial }: { initial: ReelBenchData }) {
+export default function ReelBench({ initial, changed = false }: { initial: ReelBenchData; changed?: boolean }) {
const router = useRouter();
const [view, setView] = useState<ReelView>(initial.view);
const project = view.project;
const reel = view.reel;
const take = view.take?.id ?? null;
const beat = initial.beat;
- const rows = useMemo(() => view.rows ?? [], [view.rows]);
+ const all = useMemo(() => view.rows ?? [], [view.rows]);
+ // `changed`: the walk visits only the beats the take changed under the reel (the one on screen either way).
+ const rows = useMemo(() => (changed ? all.filter((r) => r.n === beat || (r.status && CHANGED_STATES.includes(r.status.state))) : all), [all, changed, beat]);
const row = rows.find((r) => r.n === beat) ?? null;
const idx = row ? rows.indexOf(row) : -1;
const prevRow = idx > 0 ? rows[idx - 1] : null;
@@ -78,6 +81,8 @@ export default function ReelBench({ initial }: { initial: ReelBenchData }) {
if (!row || !initial.media) {
return (
<main className="deck-main flex-1 space-y-2 p-4" data-reel-walk="" data-reel-beat={beat}>
+ <SourceBanner view={view} beat={beat} changed={changed} />
+ {row && <BeatStatusBar view={view} row={row} clips={initial.clips} onDone={() => router.refresh()} />}
<p className="m-0 text-[13px] text-text">
{row ? `Beat ${beat} does not play from take ${take}'s master: ${row.problem ?? "it does not map"}.` : `The reel ${reel} has no beat ${beat}.`}{" "}
<Link href={trailerHref(project, { reel })} className="ink-link">
@@ -87,7 +92,7 @@ export default function ReelBench({ initial }: { initial: ReelBenchData }) {
</main>
);
}
- return <BeatEditor key={`${reel}:${take}:${beat}`} view={view} setView={setView} row={row} data={initial} prevRow={prevRow} nextRow={nextRow} fps={fps} isClip={isClip} router={router} />;
+ return <BeatEditor key={`${reel}:${take}:${beat}`} view={view} setView={setView} row={row} data={initial} prevRow={prevRow} nextRow={nextRow} fps={fps} isClip={isClip} router={router} changed={changed} />;
}
/** The saved beat as source seconds: a clip beat's start–end, a master beat's at–at+dur. */
@@ -104,6 +109,7 @@ function BeatEditor({
fps,
isClip,
router,
+ changed,
}: {
view: ReelView;
setView: (v: ReelView) => void;
@@ -114,6 +120,7 @@ function BeatEditor({
fps: number;
isClip: boolean;
router: ReturnType<typeof useRouter>;
+ changed: boolean;
}) {
const project = view.project;
const reel = view.reel;
@@ -148,7 +155,8 @@ function BeatEditor({
async (op: string, args: Record<string, unknown>, said: string | null) => {
setBusy(true);
try {
- const r = await reelWrite(project, reel, token.current, op, args);
+ // The take this edit is made against: the writer anchors the beat to it (reelAnchor.mjs).
+ const r = await reelWrite(project, reel, token.current, op, { ...args, take });
if (!r.ok) {
setMsg(r.error);
if (r.stale) await reload();
@@ -162,7 +170,7 @@ function BeatEditor({
setBusy(false);
}
},
- [project, reel, reload],
+ [project, reel, reload, take],
);
/** A patch in the bench's words (start/end source seconds, gaps, verdict) as the beat's. */
const save = useCallback(
@@ -300,7 +308,7 @@ function BeatEditor({
}, [wordsKey, nearWords?.key, project, data.clip]);
// ---- the verdict, notes, undo, the walk ----------------------------------------------------
- const go = useCallback((n: number) => router.push(reelWalkHref(project, { reel, take, beat: n })), [router, project, reel, take]);
+ const go = useCallback((n: number) => router.push(reelWalkHref(project, { reel, take, beat: n, changed })), [router, project, reel, take, changed]);
const confirm = useCallback(async () => {
const ok = await save({ verdict: "confirmed", ...(dirty ? { start: sel.from, end: sel.to } : {}) });
if (ok && nextRow) go(nextRow.n);
@@ -390,6 +398,8 @@ function BeatEditor({
>
<div className="flex min-h-0 min-w-0 flex-col">
<main className="deck-main min-h-0 flex-1 space-y-2 overflow-y-auto p-4">
+ <SourceBanner view={view} beat={row.n} changed={changed} />
+ <BeatStatusBar view={view} row={row} clips={data.clips} onDone={() => void reload()} />
<div className="relative mx-auto aspect-video w-full max-w-[900px] overflow-hidden rounded-[3px] bg-black">
<video
ref={video}
@@ -534,7 +544,7 @@ function BeatEditor({
)}
<span className="ml-auto flex items-center gap-2 text-[12px]">
{prevRow && (
- <Link href={reelWalkHref(project, { reel, take, beat: prevRow.n })} data-reel-walk-prev="" className="ink-link">
+ <Link href={reelWalkHref(project, { reel, take, beat: prevRow.n, changed })} data-reel-walk-prev="" className="ink-link">
‹ beat {prevRow.n}
</Link>
)}
@@ -542,7 +552,7 @@ function BeatEditor({
Back to the reel (B)
</Link>
{nextRow && (
- <Link href={reelWalkHref(project, { reel, take, beat: nextRow.n })} data-reel-walk-next="" className="ink-link">
+ <Link href={reelWalkHref(project, { reel, take, beat: nextRow.n, changed })} data-reel-walk-next="" className="ink-link">
beat {nextRow.n} ›
</Link>
)}
diff --git a/umtool/components/projects/reel/ReelCutPanel.tsx b/umtool/components/projects/reel/ReelCutPanel.tsx
@@ -170,6 +170,7 @@ export default function ReelCutPanel({ project, reel }: { project: string; reel:
· {here.seconds !== null ? clock(here.seconds) : "?"} · {fmtBytes(here.size)} · cut {new Date(here.builtAt).toLocaleString()}
{here.encodeSeconds !== null ? ` in ${Math.round(here.encodeSeconds)} s` : ""}
{here.stale ? " · OLDER than the master (re-rendered since): cut it again" : ""}
+ {here.reelChanged ? " · the reel was edited since this cut: cut it again" : ""}
</span>
</p>
{here.record && <p className="m-0 font-mono text-[10.5px] text-[var(--color-dim)]">{here.record}</p>}
diff --git a/umtool/components/projects/reel/ReelPlay.tsx b/umtool/components/projects/reel/ReelPlay.tsx
@@ -9,6 +9,7 @@ import { NoteThread } from "@/components/notes/NoteThread";
import type { CutAsk, Note } from "@/lib/annotations/types";
import { reelPlayHref, reelWalkHref, takesHref, trailerHref } from "@/lib/hrefs";
import { cn } from "@/lib/utils";
+import { SourceBanner } from "./ReelSource";
import { clock, itemAt, masterAt, masterOfSource, masterSrc, reelAtMaster, readReelView, reelItems, sourceClock, sourceOfMaster, type ReelRow, type ReelView } from "./reelTypes";
import { useReelPlayer } from "./useReelPlayer";
@@ -243,6 +244,8 @@ export default function ReelPlay({ initial, initialBeat = null, initialNote = nu
return (
<div className="flex min-h-0 flex-1 flex-col lg:grid lg:grid-cols-[minmax(0,1fr)_minmax(300px,26%)]" data-reel-play="" data-reel={reel} data-reel-take={take} data-reel-state={playing ? "playing" : "paused"} data-reel-t={t.toFixed(2)} data-reel-beat={item?.n ?? ""}>
<main className="deck-main min-h-0 space-y-2 overflow-y-auto p-4">
+ {/* What the reel was cut against, and the beats this take changed (ReelSource.tsx). */}
+ <SourceBanner view={view} beat={item?.n || 1} changed={false} />
<div className="relative mx-auto aspect-video w-full max-w-[1100px] overflow-hidden rounded-[3px] bg-black" data-reel-player="">
{[0, 1].map((k) => (
<video
diff --git a/umtool/components/projects/reel/ReelSource.tsx b/umtool/components/projects/reel/ReelSource.tsx
@@ -0,0 +1,110 @@
+"use client";
+
+import Link from "next/link";
+import { useState } from "react";
+import { buttonVariants } from "@/components/ui/button";
+import { reelWalkHref } from "@/lib/hrefs";
+import { cn } from "@/lib/utils";
+import { STATE_LABEL, r2, reelWrite, sourceClock, type ReelRow, type ReelView } from "./reelTypes";
+
+// ---------------------------------------------------------------------------
+// WHAT THE REEL WAS CUT AGAINST (lib/report/reelAnchor.mjs): the reel's line
+// ("cut against draft-6; take draft-7 changes beats 7") with the filter that
+// walks only the changed beats, and per beat its state, why, and the fix --
+// clamp a clipped beat into its clip's new limits, remove or re-point an
+// orphan, or anchor a beat to this take once it has been looked at. Every
+// fix is one write through the beats' writer, an undo point, and in the
+// reel's history.
+// ---------------------------------------------------------------------------
+
+export function SourceBanner({ view, beat, changed }: { view: ReelView; beat: number; changed: boolean }) {
+ const st = view.status;
+ if (!st || !view.take) return null;
+ const n = st.changed.length;
+ return (
+ <p data-reel-source-banner={n ? "changed" : "same"} className={cn("m-0 flex flex-wrap items-center gap-2 rounded-[3px] border px-3 py-1.5 text-[12.5px]", n ? "border-[var(--color-dirty)] text-text" : "border-seam text-text-2")}>
+ <span data-reel-source-line="">{st.line}</span>
+ {n > 0 &&
+ (changed ? (
+ <Link href={reelWalkHref(view.project, { reel: view.reel, take: view.take.id, beat })} data-reel-walk-filter="all" className="ink-link">
+ Walk every beat
+ </Link>
+ ) : (
+ <Link href={reelWalkHref(view.project, { reel: view.reel, take: view.take.id, beat: st.changed.includes(beat) ? beat : st.changed[0], changed: true })} data-reel-walk-filter="changed" className="ink-link">
+ Walk only the changed beats ({n})
+ </Link>
+ ))}
+ </p>
+ );
+}
+
+export function BeatStatusBar({ view, row, clips, onDone }: { view: ReelView; row: ReelRow; clips: string[]; onDone: () => void }) {
+ const st = row.status;
+ const [busy, setBusy] = useState(false);
+ const [said, setSaid] = useState<string | null>(null);
+ const [to, setTo] = useState("");
+ if (!st || !view.take) return null;
+ const take = view.take.id;
+ const run = async (op: string, args: Record<string, unknown>, done: string) => {
+ setBusy(true);
+ try {
+ const r = await reelWrite(view.project, view.reel, view.token, op, { ...args, take });
+ setSaid(r.ok ? done : r.error);
+ if (r.ok) onDone();
+ } finally {
+ setBusy(false);
+ }
+ };
+ const now = st.now as { start: number; end: number } | null | undefined;
+ const was = st.was as { start: number; end: number } | null | undefined;
+ const b = row.beat as { start?: number; end?: number; gaps?: { from: number; to: number }[] };
+ const clamp =
+ st.state === "clipped" && now && b.start !== undefined && b.end !== undefined
+ ? (() => {
+ const start = r2(Math.max(b.start, now.start));
+ const end = r2(Math.min(b.end, now.end));
+ return end - start >= 0.2 ? { start, end, ...(b.gaps ? { gaps: b.gaps.filter((g) => g.from >= start + 0.5 && g.to <= end - 0.5) } : {}) } : null;
+ })()
+ : null;
+ const quiet = st.state === "unchanged" || st.state === "rerendered";
+ return (
+ <div data-reel-beat-state={st.state} className={cn("flex flex-wrap items-center gap-2 text-[12px]", quiet ? "text-muted" : "text-text")}>
+ <span className={cn("rounded-[2px] border px-1.5 py-px font-mono text-[11px]", quiet ? "border-seam" : "border-[var(--color-dirty)] text-[var(--color-dirty)]")}>{STATE_LABEL[st.state]}</span>
+ <span data-reel-beat-why="">{st.why}</span>
+ {st.state === "edges" && was && now && (
+ <span data-reel-beat-was="" className="num font-mono text-text-2">
+ was {sourceClock(was.start)}–{sourceClock(was.end)} · now {sourceClock(now.start)}–{sourceClock(now.end)}
+ </span>
+ )}
+ {clamp && (
+ <button type="button" data-reel-clamp="" disabled={busy} onClick={() => void run("set", { index: row.n - 1, patch: clamp }, `clamped to ${clamp.start}–${clamp.end}`)} className={buttonVariants({ variant: "go", size: "sm" })}>
+ Clamp to {sourceClock(clamp.start)}–{sourceClock(clamp.end)}
+ </button>
+ )}
+ {st.state === "orphan" && (
+ <>
+ <button type="button" data-reel-remove="" disabled={busy} onClick={() => void run("remove", { index: row.n - 1 }, `beat ${row.n} removed`)} className={buttonVariants({ size: "sm" })}>
+ Remove the beat
+ </button>
+ <select data-reel-repoint-to="" value={to} onChange={(e) => setTo(e.target.value)} className="rounded border border-[var(--color-line)] bg-[var(--color-panel-2)] px-1 py-0.5 text-[11px]">
+ <option value="">re-point to…</option>
+ {clips.map((c) => (
+ <option key={c} value={c}>
+ {c}
+ </option>
+ ))}
+ </select>
+ <button type="button" data-reel-repoint="" disabled={busy || !to} onClick={() => void run("set", { index: row.n - 1, patch: { id: to } }, `beat ${row.n} re-pointed to ${to}`)} className={buttonVariants({ size: "sm" })}>
+ Re-point
+ </button>
+ </>
+ )}
+ {(st.state === "edges" || st.state === "look" || st.state === "unanchored" || st.state === "rerendered") && (
+ <button type="button" data-reel-anchor="" disabled={busy} onClick={() => void run("anchor", { only: [row.n - 1] }, `beat ${row.n} anchored to take ${take}`)} className={buttonVariants({ variant: quiet ? "quiet" : "outline", size: "sm" })} title={`it has been looked at against take ${take}: anchor it there (an edit or a confirm does this too)`}>
+ {st.state === "rerendered" ? `Anchor to ${take}` : `Looked at — anchor to ${take}`}
+ </button>
+ )}
+ {said && <span data-reel-status-said="" className="text-text-2">{said}</span>}
+ </div>
+ );
+}
diff --git a/umtool/components/projects/reel/ReelWalkPage.tsx b/umtool/components/projects/reel/ReelWalkPage.tsx
@@ -7,6 +7,7 @@ import { isTakeId } from "@/lib/report/takes.mjs";
import { DEFAULT_REEL, isReelId } from "@/lib/report/trailerBeats.mjs";
import { BenchFrame, BenchTop } from "../bench/BenchShell";
import ReelBench from "./ReelBench";
+import { CHANGED_STATES } from "./reelTypes";
// `/projects/<project>/trailer/walk?reel=<name>&take=<t>&beat=<n>` -- the
// reel's editor over one beat, on the take's rendered master (ReelBench.tsx,
@@ -16,18 +17,23 @@ export default async function ReelWalkPage({
reel = DEFAULT_REEL,
take,
beat,
+ changed = false,
}: {
project: ProjectRef;
reel?: string;
take?: string;
beat?: string;
+ /** Walk only the beats the take changed under the reel (reelAnchor.mjs). */
+ changed?: boolean;
}) {
const r = reel || DEFAULT_REEL;
if (!isReelId(r) || (take && !isTakeId(take))) notFound();
const n = Number(beat) > 0 ? Math.floor(Number(beat)) : 1;
const data = await reelBenchData(project, { reel: r, take: take || null, beat: n });
const view = data.view;
- const rows = view.rows ?? [];
+ const all = view.rows ?? [];
+ // `changed`: the walk visits only the beats the take changed (the beat asked for is shown either way).
+ const rows = changed ? all.filter((x) => x.n === n || (x.status && CHANGED_STATES.includes(x.status.state))) : all;
const i = rows.findIndex((x) => x.n === n);
const t = view.take?.id ?? null;
return (
@@ -47,15 +53,15 @@ export default async function ReelWalkPage({
{ keys: ["b"], label: "the reel" },
]}
here={`beat ${n}${rows[i]?.id ? ` · ${rows[i].id}` : ""}`}
- pos={i >= 0 ? { index: i + 1, total: rows.length, of: "beats" } : null}
- prev={i > 0 ? { href: reelWalkHref(project.id, { reel: r, take: t, beat: rows[i - 1].n }), label: `beat ${rows[i - 1].n}` } : null}
- next={i >= 0 && i < rows.length - 1 ? { href: reelWalkHref(project.id, { reel: r, take: t, beat: rows[i + 1].n }), label: `beat ${rows[i + 1].n}` } : null}
+ pos={i >= 0 ? { index: i + 1, total: rows.length, of: changed ? "changed beats" : "beats" } : null}
+ prev={i > 0 ? { href: reelWalkHref(project.id, { reel: r, take: t, beat: rows[i - 1].n, changed }), label: `beat ${rows[i - 1].n}` } : null}
+ next={i >= 0 && i < rows.length - 1 ? { href: reelWalkHref(project.id, { reel: r, take: t, beat: rows[i + 1].n, changed }), label: `beat ${rows[i + 1].n}` } : null}
note={view.take ? `take ${view.take.id} · ${rows.filter((x) => x.verdict === "confirmed").length} of ${rows.length} confirmed` : "no master"}
/>
}
>
<NotesProvider target={{ project: project.id }}>
- <ReelBench key={`${r}:${t ?? ""}:${n}`} initial={data} />
+ <ReelBench key={`${r}:${t ?? ""}:${n}`} initial={data} changed={changed} />
</NotesProvider>
</BenchFrame>
);
diff --git a/umtool/components/projects/reel/reelTypes.ts b/umtool/components/projects/reel/reelTypes.ts
@@ -32,6 +32,27 @@ export type ReelRow = {
channel: string | null;
video: string | null;
date: string | null;
+ /** What the beat was cut against, read against the take now (lib/report/reelAnchor.mjs). */
+ status?: BeatStatus | null;
+};
+
+export type BeatState = "unanchored" | "orphan" | "clipped" | "edges" | "look" | "rerendered" | "unchanged";
+export type BeatStatus = {
+ state: BeatState;
+ why: string;
+ was?: { start: number; end: number; gaps?: { from: number; to: number }[] } | Record<string, unknown> | null;
+ now?: { start: number; end: number; gaps?: { from: number; to: number }[] } | Record<string, unknown> | null;
+};
+/** The states the walk's "changed beats" filter keeps (reelAnchor.mjs CHANGED_STATES). */
+export const CHANGED_STATES: BeatState[] = ["orphan", "clipped", "edges", "look"];
+export const STATE_LABEL: Record<BeatState, string> = {
+ unanchored: "not anchored",
+ orphan: "clip gone",
+ clipped: "clipped",
+ edges: "clip's edges moved",
+ look: "chrome changed",
+ rerendered: "re-rendered, same",
+ unchanged: "unchanged",
};
export type ReelCut = {
@@ -45,6 +66,8 @@ export type ReelCut = {
encodeSeconds: number | null;
notes: number;
stale: boolean;
+ /** The reel was edited since this cut (its record names the reel's version). */
+ reelChanged?: boolean;
};
export type ReelJob = {
@@ -81,6 +104,8 @@ export type ReelView = {
intro?: { at: number; master: { start: number; end: number; duration: number } } | null;
total?: number;
rows?: ReelRow[];
+ /** The reel against the take now: the takes it was cut against, the beats that changed, the line. */
+ status?: { take: string; against: string[]; changed: number[]; counts: Record<string, number>; line: string } | null;
planNotes?: string[];
reels?: ReelListing[];
job?: ReelJob | null;
diff --git a/umtool/lib/hrefs.ts b/umtool/lib/hrefs.ts
@@ -306,9 +306,9 @@ export function reelPlayHref(project: string, q: NoteOpt & { reel?: string | nul
);
}
-/** A beat reel's walk: the bench over beat `beat` (from 1) on the take's master. */
-export function reelWalkHref(project: string, q: { reel?: string | null; take?: string | null; beat?: number | null } = {}): string {
- return withQuery(`/projects/${encodePath(project)}/trailer/walk`, { reel: q.reel && q.reel !== "trailer" ? q.reel : null, take: q.take, beat: q.beat ?? 1 });
+/** A beat reel's walk: the bench over beat `beat` (from 1) on the take's master; `changed` walks only the beats the take changed. */
+export function reelWalkHref(project: string, q: { reel?: string | null; take?: string | null; beat?: number | null; changed?: boolean } = {}): string {
+ return withQuery(`/projects/${encodePath(project)}/trailer/walk`, { reel: q.reel && q.reel !== "trailer" ? q.reel : null, take: q.take, beat: q.beat ?? 1, changed: q.changed ? "1" : null });
}
export function takesHref(project: string, q: NoteOpt = {}): string {
diff --git a/umtool/lib/report/reelAnchor.test.mjs b/umtool/lib/report/reelAnchor.test.mjs
@@ -140,3 +140,12 @@ test("the writer stamps a beat with the take it was edited against, anchors a re
await rm(dir, { recursive: true, force: true });
}
});
+
+test("a reel's version for its cut: the seconds, the gaps, the crossfade and the intro -- never a verdict, a label or an anchor", async () => {
+ const { reelVersion } = await import("./trailerBeats.mjs");
+ const v = reelVersion({ beats: [{ id: "a", start: 1, end: 2 }], settings: { xfade: 0.3 } });
+ assert.equal(reelVersion({ beats: [{ id: "a", start: 1, end: 2, verdict: "confirmed", label: "x", anchor: { take: "t" } }], settings: { xfade: 0.3, title: "T", limit: 90 } }), v);
+ assert.notEqual(reelVersion({ beats: [{ id: "a", start: 1, end: 2.5 }], settings: { xfade: 0.3 } }), v);
+ assert.notEqual(reelVersion({ beats: [{ id: "a", start: 1, end: 2, gaps: [{ from: 1.2, to: 1.5 }] }], settings: { xfade: 0.3 } }), v);
+ assert.notEqual(reelVersion({ beats: [{ id: "a", start: 1, end: 2 }], settings: { xfade: 0 } }), v);
+});
diff --git a/umtool/lib/report/reelBenchData.ts b/umtool/lib/report/reelBenchData.ts
@@ -23,6 +23,8 @@ export type ReelBenchData = {
cues: ReelBenchCue[];
/** The master as the bench plays it; null when there is none or the beat does not map. */
media: { path: string; v: number | null; map: FileMap; span: { from: number; to: number } } | null;
+ /** The clips of the take's cut, in order: what an orphaned beat can be re-pointed to. */
+ clips: string[];
};
const r3 = (n: number) => Number(n.toFixed(3));
@@ -30,8 +32,10 @@ const r3 = (n: number) => Number(n.toFixed(3));
export async function reelBenchData(project: ProjectRef, { reel, take, beat }: { reel: string; take: string | null; beat: number }): Promise<ReelBenchData> {
const view = (await reelPlayView(project, { reel, take })) as ReelView;
const row = (view.rows ?? []).find((r) => r.n === beat) ?? null;
- const out: ReelBenchData = { view, beat, clip: null, cues: [], media: null };
+ const out: ReelBenchData = { view, beat, clip: null, cues: [], media: null, clips: [] };
if (!row || !view.take?.master || view.noMaster) return out;
+ const takeManifest = await readManifest(path.dirname(path.dirname(view.take.master))).catch(() => null);
+ out.clips = ((takeManifest?.timeline ?? []) as Record<string, unknown>[]).filter((e) => e?.type === "clip" && typeof e.id === "string").map((e) => String(e.id));
const rel = path.relative(project.dir, view.take.master).split(path.sep).join("/");
if (rel.startsWith("..") || path.isAbsolute(rel)) return out;
const v = view.take.masterMtimeMs ?? null;
@@ -47,7 +51,6 @@ export async function reelBenchData(project: ProjectRef, { reel, take, beat }: {
const span = { from: r3(row.limits.source?.start ?? map.recStart), to: r3(Math.min(row.limits.source?.end ?? endSrc, endSrc)) };
out.media = { path: rel, v, map, span };
// The clip, from the take's manifest (what the master was built from), else the project's.
- const takeManifest = await readManifest(path.dirname(path.dirname(view.take.master))).catch(() => null);
const projectManifest = await readManifest(project.dir).catch(() => null);
const find = (m: Record<string, unknown> | null) => ((m?.timeline ?? []) as Record<string, unknown>[]).find((e) => e?.id === row.id && e?.type === "clip") ?? null;
const manifest = find(takeManifest) ? takeManifest : find(projectManifest) ? projectManifest : null;
diff --git a/umtool/lib/report/reelPlay.mjs b/umtool/lib/report/reelPlay.mjs
@@ -36,7 +36,7 @@ import {
import { anchorContext, reelStatus } from "./reelAnchor.mjs";
import { BUILD_LOCK, lockIsLive, readBuildLock } from "./takePrune.mjs";
import { listTakes, takesDirOf } from "./takes.mjs";
-import { DEFAULT_REEL, TRAILER_LIMIT_DEFAULT, readTrailerBeats, reelFileOf } from "./trailerBeats.mjs";
+import { DEFAULT_REEL, TRAILER_LIMIT_DEFAULT, readTrailerBeats, reelFileOf, reelVersion } from "./trailerBeats.mjs";
const r3 = (n) => Number(Number(n).toFixed(3));
const readJson = (file) => readFile(/* turbopackIgnore: true */ file, "utf8").then(JSON.parse, () => null);
@@ -87,7 +87,7 @@ export async function takeMasters(projectDir) {
* @param {Awaited<ReturnType<typeof takeMasters>>} masters
* @param {string} reel
*/
-export async function reelCuts(masters, reel = DEFAULT_REEL) {
+export async function reelCuts(masters, reel = DEFAULT_REEL, { version = null } = {}) {
const out = [];
for (const t of masters) {
if (!t.slug) continue;
@@ -106,8 +106,11 @@ export async function reelCuts(masters, reel = DEFAULT_REEL) {
seconds: Number.isFinite(rec?.seconds) ? rec.seconds : null,
encodeSeconds: Number.isFinite(rec?.encodeSeconds) ? rec.encodeSeconds : null,
notes: Array.isArray(rec?.notes) ? rec.notes.length : 0,
- // Cut before the master there now was written: the take was rendered again since.
- stale: t.masterMtimeMs !== null && st.mtimeMs < t.masterMtimeMs,
+ // Cut from another master than the one there now (its record names the master's mtime;
+ // an older record, before that: cut before the master was written): rendered again since.
+ stale: t.masterMtimeMs !== null && (Number.isFinite(rec?.source?.masterMtimeMs) ? rec.source.masterMtimeMs !== t.masterMtimeMs : st.mtimeMs < t.masterMtimeMs),
+ // The reel edited since the cut (its record names the reel's version, trailerBeats.mjs reelVersion).
+ reelChanged: !!(version && typeof rec?.reel?.version === "string" && rec.reel.version !== version),
});
}
out.sort((a, b) => String(b.builtAt).localeCompare(String(a.builtAt)));
@@ -269,7 +272,7 @@ export async function reelPlayView(project, { reel = DEFAULT_REEL, take = null }
const doc = await readTrailerBeats(project.dir, { reel });
const settings = doc.settings ?? {};
const masters = await takeMasters(project.dir);
- const cuts = await reelCuts(masters, reel);
+ const cuts = await reelCuts(masters, reel, { version: doc.exists ? reelVersion(doc) : null });
const chosen = pickReelTake({ asked: take, pinned: settings.take ?? null, cuts, masters });
const base = {
project: project.id,
diff --git a/umtool/lib/report/trailerBeats.mjs b/umtool/lib/report/trailerBeats.mjs
@@ -33,6 +33,7 @@
// `undoTrailerBeats` puts back.
//
// Plain ESM: the CLI runs it under bare node.
+import { createHash } from "node:crypto";
import { copyFile, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
import path from "node:path";
import { gappedLength, gapsOf } from "umtool-report-to-video/gaps";
@@ -509,6 +510,20 @@ export async function setTrailerSettings(dir, patch, { token = null, reel = DEFA
}, { reel, what: `settings: ${Object.keys(isObj(patch) ? patch : {}).join(", ")}` });
}
+/**
+ * A reel's VERSION as its cut sees it: a fingerprint of what the cut reads
+ * (each beat's clip and seconds and gaps, the crossfade, the intro) -- not a
+ * verdict, a label or an anchor, which change nothing cut. Named in a cut's
+ * record, so the reel's Play can say the cut is older than the reel.
+ *
+ * @param {{ beats: any[], settings?: Record<string, any> }} doc
+ */
+export function reelVersion(doc) {
+ const beats = (doc?.beats ?? []).map((b) => (isObj(b) ? [b.id ?? null, b.start ?? b.at ?? null, b.end ?? b.dur ?? null, b.gaps ?? null] : b));
+ const s = doc?.settings ?? {};
+ return createHash("sha256").update(JSON.stringify({ beats, xfade: s.xfade ?? null, intro: s.intro ?? null })).digest("hex").slice(0, 16);
+}
+
/** Spans merged where they touch or overlap, sorted. */
function unionSpans(list) {
const out = [];
diff --git a/umtool/lib/report/trailerCli.mjs b/umtool/lib/report/trailerCli.mjs
@@ -14,7 +14,7 @@ import { takesDirOf } from "./takes.mjs";
import { readManifest } from "../projects/report.mjs";
import { candidateBeats, trailerCandidates } from "./trailerCandidates.mjs";
import { pickReelTake, reelCuts, reelOutArg, takeMasters } from "./reelPlay.mjs";
-import { isReelId, readTrailerBeats, reelFileOf } from "./trailerBeats.mjs";
+import { isReelId, readTrailerBeats, reelFileOf, reelVersion } from "./trailerBeats.mjs";
import {
TRAILER_ESTIMATE_MB,
TRAILER_XFADE_DEFAULT,
@@ -153,6 +153,7 @@ export async function trailerCommand(args, { reportsRoot = REPORTS_ROOT, log = c
/** The reel's own settings, under the flags. */
let reelSettings = /** @type {Record<string, any>} */ ({});
let reelBeats = null;
+ let reelProvenance = null;
let outArg = p.flags["--out"] ?? null;
if (reel !== null) {
if (!isReelId(reel)) throw new CliError(`--reel ${reel}: a reel name (lower case, digits and dashes)`);
@@ -161,6 +162,8 @@ export async function trailerCommand(args, { reportsRoot = REPORTS_ROOT, log = c
if (!doc.exists) throw new CliError(`no reel ${reel}: ${reelFileOf(reel)} is not there (\`umtool trailer-beats ${r.project.id} new-reel ${reel}\`)`);
reelSettings = doc.settings ?? {};
reelBeats = doc.beats;
+ // The reel's version, named in the cut's record: a later edit makes the cut stale.
+ reelProvenance = { name: reel, file: reelFileOf(reel), version: reelVersion(doc) };
const masters = await takeMasters(r.project.dir);
if (!take) {
const chosen = pickReelTake({ pinned: reelSettings.take ?? null, cuts: await reelCuts(masters, reel), masters });
@@ -194,6 +197,7 @@ export async function trailerCommand(args, { reportsRoot = REPORTS_ROOT, log = c
out: outArg,
dryRun: p.has("--dry-run"),
snap: !p.has("--no-snap"),
+ ...(reelProvenance ? { reel: reelProvenance } : {}),
...(deps.measure ? { measure: deps.measure } : {}),
...(deps.run ? { run: deps.run } : {}),
...(deps.probe ? { probe: deps.probe } : {}),
diff --git a/umtool/report-to-video/trailer.mjs b/umtool/report-to-video/trailer.mjs
@@ -66,7 +66,7 @@
import { execFile } from "node:child_process";
import { rmSync } from "node:fs";
-import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
+import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
import path from "node:path";
import { promisify } from "node:util";
@@ -708,7 +708,7 @@ export async function runFfmpeg(argv) {
export async function makeTrailer({
takeDir, beats, intro = false, finale = null, xfade = TRAILER_XFADE_DEFAULT, out = null, dryRun = false,
run = runFfmpeg, probe = probeMasterSeconds, slot = (fn) => fn(), now = Date.now,
- snap = true, measure = (build, list) => trailerPauses({ build, beats: list }),
+ snap = true, measure = (build, list) => trailerPauses({ build, beats: list }), reel = null,
}) {
const build = await loadTakeBuild(takeDir);
// Checked once without the pauses first: a beat that is refused is refused
@@ -727,12 +727,19 @@ export async function makeTrailer({
const outPath = trailerOutPath(takeDir, build.slug, out);
if (path.resolve(outPath) === path.resolve(build.master)) throw new TrailerError(`--out ${out}: that is the master`);
const recordPath = trailerRecordPath(outPath);
+ // What it was cut from, named so a later read can say the cut is stale: the
+ // master by its mtime and the take's build, the reel by its file's version.
+ const masterStat = await stat(build.master).catch(() => null);
+ const takeMeta = await readFile(path.join(takeDir, "take.json"), "utf8").then(JSON.parse, () => null);
const record = {
version: 1,
kind: "trailer",
+ ...(reel ? { reel } : {}),
source: {
take: path.basename(takeDir),
+ build: typeof takeMeta?.builtAt === "string" ? takeMeta.builtAt : null,
master: build.master,
+ masterMtimeMs: masterStat ? Math.round(masterStat.mtimeMs) : null,
masterSeconds: r3(masterSeconds),
schedule: path.join(takeDir, "out", "sourced", "schedule.json"),
},