commit 2d619080c27a9a340d40c1ecf7f1d4a3dd9159aa
parent d1c5cbbee6da498b61b5b93f28f20445c1b04882
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 24 Oct 2026 05:04:47 -0400
Play the cut: a take's edges are never another cut's; the play fixtures own their recording
useRenderCuts keys each answer by the cut it is for, so the render between
a switch of take and its effect never shows the last take's edges (or says
"render" for them). The play fixtures cut a recording id of their own
(playvid, vid1's window): the corpus's vid1 gains wider windows as other
specs fetch, and the render's edges -- Play's clock -- must not depend on
which spec ran first.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/umtool/components/projects/review/playEngine/useRenderCuts.ts b/umtool/components/projects/review/playEngine/useRenderCuts.ts
@@ -1,6 +1,6 @@
"use client";
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useState } from "react";
import type { RenderCut } from "@/lib/report/playCut.mjs";
// Where the render will cut each clip (GET /api/report/cut-points: the build's
@@ -20,37 +20,35 @@ export type RenderCuts = {
why: string | null;
};
+const MEASURING: RenderCuts = { state: "measuring", cuts: null, style: "fade", montage: false, why: null };
+
export function useRenderCuts(project: string, take: string | null, key: string): RenderCuts {
- const [got, setGot] = useState<RenderCuts>({ state: "measuring", cuts: null, style: "fade", montage: false, why: null });
- const cutOf = useRef("");
+ // Each answer says which cut it is for: another cut's (a take switched to, before its own
+ // answer) is never returned -- not even for the render between the switch and its effect.
+ const which = `${project}|${take ?? ""}`;
+ const [got, setGot] = useState<RenderCuts & { for: string }>({ ...MEASURING, for: which });
useEffect(() => {
let live = true;
- // Another cut (a take): nothing of the last one's applies. The same cut with an edge moved: its
- // edges stand until the new ones are measured (only what moved is).
- const which = `${project}|${take ?? ""}`;
- if (cutOf.current !== which) {
- cutOf.current = which;
- setGot({ state: "measuring", cuts: null, style: "fade", montage: false, why: null });
- }
const q = new URLSearchParams({ project, ...(take ? { take } : {}) });
fetch(`/api/report/cut-points?${q}`, { cache: "no-store" })
.then(async (r) => {
const j = (await r.json().catch(() => null)) as { clips?: Row[]; transitionStyle?: string; montage?: boolean; error?: string } | null;
if (!live) return;
if (!r.ok || !j?.clips) {
- setGot({ state: "estimate", cuts: null, style: "fade", montage: false, why: j?.error ?? `HTTP ${r.status}` });
+ setGot({ state: "estimate", cuts: null, style: "fade", montage: false, why: j?.error ?? `HTTP ${r.status}`, for: which });
return;
}
const cuts = new Map<string, RenderCut>();
for (const c of j.clips) if (c && !c.missing && !c.error && Number.isFinite(c.cutStart) && Number.isFinite(c.cutEnd)) cuts.set(c.id, c);
- setGot({ state: "render", cuts, style: j.transitionStyle ?? "fade", montage: !!j.montage, why: null });
+ setGot({ state: "render", cuts, style: j.transitionStyle ?? "fade", montage: !!j.montage, why: null, for: which });
})
.catch((e: unknown) => {
- if (live) setGot({ state: "estimate", cuts: null, style: "fade", montage: false, why: e instanceof Error ? e.message : String(e) });
+ if (live) setGot({ state: "estimate", cuts: null, style: "fade", montage: false, why: e instanceof Error ? e.message : String(e), for: which });
});
return () => {
live = false;
};
- }, [project, take, key]);
- return got;
+ }, [project, take, key, which]);
+ // The same cut with an edge moved: its edges stand until the new ones are measured (only what moved is).
+ return got.for === which ? got : MEASURING;
}
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -1861,7 +1861,7 @@ makeLivePreviewFixture({ reports, deckManifest, cachedWindow: path.join(REPORT,
makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
// The same cut for Play → Edit this clip → Back (phone-walk.spec.ts), which WRITES
// an edge: its own copy, so play-cut.spec's clock is never moved.
-makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), name: "play-edit-fixture", title: "The Play Edit Fixture" });
+makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), name: "play-edit-fixture", title: "The Play Edit Fixture", video: "vid1" });
// TWO MORE cached windows for vid1, and they are the regression rather than
// decoration.
diff --git a/umtool/e2e/fixtures/play-cut-fixture.mjs b/umtool/e2e/fixtures/play-cut-fixture.mjs
@@ -1,14 +1,16 @@
// What play-cut.spec.ts plays (umtool/docs/knobs.md, "Play the cut"): a short deck cut on
-// vid1 (the fixture corpus's synthetic source, its 0-9 s window cached in
-// out/clips-raw), never built -- the Play view plays it from the cached
+// playvid (the fixture's synthetic vid1 window -- tone, and silences at 2.9-3.1
+// and 5.9-6.1 -- cached in out/clips-raw under a recording id of its own: the
+// corpus's vid1 gains wider windows as other specs fetch, and the render's
+// edges, and so Play's clock, must not depend on which spec ran first), never built -- the Play view plays it from the cached
// window on the estimate's clock -- with a card between clips, a clip whose
// source was never fetched (a placeholder, not a stall), and two takes: one
// made (takes/short/take.json, its own timeline: c04 then c01) and one only
// a recipe names (quick-joins, a hard-cut look). And play-engine-fixture, the
// same cut for play-engine.spec.ts, which writes.
//
-// c01 vid1 1.0-3.0 c02 vid1 3.5-5.5 (k1 at 4.5) k01 card 1.5 s
-// c03 nofetch 2-4 (no window on disk) c04 vid1 6.0-8.0 (k2, counts 2)
+// c01 playvid 1.0-3.0 c02 playvid 3.5-5.5 (k1 at 4.5) k01 card 1.5 s
+// c03 nofetch 2-4 (no window on disk) c04 playvid 6.0-8.0 (k2, counts 2)
// sections 0 (c01, c02) and 1 (c03, c04); one counter, "Seizures"
//
// Synthetic, like every fixture.
@@ -16,22 +18,23 @@ import { copyFileSync, mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
/**
- * @param {{ reports: string, deckManifest: Function, cachedWindow: string, name?: string, title?: string }} o
+ * @param {{ reports: string, deckManifest: Function, cachedWindow: string, name?: string, title?: string, video?: string }} o
* `name`: a second copy under another name (play-edit-fixture, which a spec writes to).
+ * `video`: the recording id its clips cut (playvid; play-edit-fixture's walk needs vid1's cues).
*/
-export function makePlayCutFixture({ reports, deckManifest, cachedWindow, name = "play-cut-fixture", title = "The Play Cut Fixture" }) {
+export function makePlayCutFixture({ reports, deckManifest, cachedWindow, name = "play-cut-fixture", title = "The Play Cut Fixture", video = "playvid" }) {
const dir = path.join(reports, name);
mkdirSync(dir, { recursive: true });
const timeline = [
- { type: "clip", id: "c01", video: "vid1", start: 1.0, end: 3.0, cite: 1, section: 0, lock: true, quote: "This is a complete sentence.", onscreen: { title: "24 Oct 2020" } },
+ { type: "clip", id: "c01", video, start: 1.0, end: 3.0, cite: 1, section: 0, lock: true, quote: "This is a complete sentence.", onscreen: { title: "24 Oct 2020" } },
{
- type: "clip", id: "c02", video: "vid1", start: 3.5, end: 5.5, cite: 4, section: 0, lock: true, quote: "And this one runs on", onscreen: { title: "2 Dec 2024" },
+ type: "clip", id: "c02", video, start: 3.5, end: 5.5, cite: 4, section: 0, lock: true, quote: "And this one runs on", onscreen: { title: "2 Dec 2024" },
claim: { id: "k1", verdict: "CORROBORATED", at: 4.5 },
},
{ type: "card", id: "k01", style: "chapter", seconds: 1.5, heading: "Between the clips" },
{ type: "clip", id: "c03", video: "nofetch", start: 2.0, end: 4.0, cite: 2, section: 1, lock: true, quote: "never fetched" },
{
- type: "clip", id: "c04", video: "vid1", start: 6.0, end: 8.0, cite: 6, section: 1, lock: true, quote: "of that it finishes here.", onscreen: { title: "27 Feb 2025" },
+ type: "clip", id: "c04", video, start: 6.0, end: 8.0, cite: 6, section: 1, lock: true, quote: "of that it finishes here.", onscreen: { title: "27 Feb 2025" },
claim: { id: "k2", verdict: "CORROBORATED", count: 2 },
},
];
@@ -41,7 +44,7 @@ export function makePlayCutFixture({ reports, deckManifest, cachedWindow, name =
m.render.chrome = { ...m.render.chrome, factcheck: { verdicts: { CORROBORATED: { label: "Seizures", color: "#6fa8dc" } }, stamp: { seconds: 1 } } };
writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n");
mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true });
- copyFileSync(cachedWindow, path.join(dir, "out", "clips-raw", "vid1_0.00-9.00.mp4"));
+ copyFileSync(cachedWindow, path.join(dir, "out", "clips-raw", `${video}_0.00-9.00.mp4`));
// A made take with its own timeline (a JSON merge patch replaces the list).
mkdirSync(path.join(dir, "takes", "short"), { recursive: true });
writeFileSync(
@@ -63,7 +66,7 @@ export function makePlayCutFixture({ reports, deckManifest, cachedWindow, name =
const eng = path.join(reports, "play-engine-fixture");
mkdirSync(path.join(eng, "out", "clips-raw"), { recursive: true });
writeFileSync(path.join(eng, "video.manifest.json"), JSON.stringify({ ...m, slug: "play-engine-fixture", title: "The Play Engine Fixture" }, null, 2) + "\n");
- copyFileSync(cachedWindow, path.join(eng, "out", "clips-raw", "vid1_0.00-9.00.mp4"));
+ copyFileSync(cachedWindow, path.join(eng, "out", "clips-raw", `${video}_0.00-9.00.mp4`));
}
// A take only a recipe names: never rendered, still playable.
writeFileSync(
diff --git a/umtool/e2e/play-cut.spec.ts b/umtool/e2e/play-cut.spec.ts
@@ -13,7 +13,7 @@ import * as urls from "./urls";
// kind) lists, pins and seeks, and a take plays its own timeline.
//
// The clock is the RENDER'S: each clip at its snapped edges (the cut-points
-// route), in the encode's whole frames (15 fps here). On vid1's window
+// route), in the encode's whole frames (15 fps here). On the fixture's window (playvid)
// (silences 2.90-3.11 and 5.92-6.11) c01 plays 1.000-3.082 (2.133 s), c02
// 3.011-6.101 (3.133 s), c04 6.007-8.000 (2 s), so with the 0.2 s
// crossfades: c01 0-2.133 (shown to 2.033), c02 1.933-5.067 (shown 2.033-
diff --git a/umtool/e2e/play-engine.spec.ts b/umtool/e2e/play-engine.spec.ts
@@ -19,7 +19,7 @@ import * as urls from "./urls";
// dissolve is two layers), <video> elements otherwise (?picture=element)
//
// Fixture: e2e/fixtures/play-cut-fixture.mjs's play-engine-fixture (the
-// play-cut cut, which this spec WRITES). On vid1's window (silences
+// play-cut cut, which this spec WRITES). On the fixture's window (playvid; silences
// 2.90-3.11, 5.92-6.11) the render cuts c01 at 1.000-3.082, c02 3.011-6.101,
// c04 6.007-8.000; in whole frames at 15 fps c01 lasts 2.133 s, so c02's
// segment starts at 1.933 (the 0.2 s crossfade before c01's end).