Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 9b8fe12af4cca540819f709517c3edbec5847082
parent 91525981661484ea71ae0ebeaacde3bd8bd153e1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sun,  1 Nov 2026 23:44:10 -0500

umtool Play: the clock no longer jumps back to the ?clip=&at= place 12-17 s into playback -- the place a page opens at is let go the moment the operator plays or seeks. The anchor effect re-placed it on every re-timing of the plan until the render's edges were measured AND the deck composed, so a cut already playing when cut-points (or the chrome preview) answered was seeked back to where it opened; the engine's setPlan already carries a moving playhead across a re-plan by its source second. play-cut.spec.ts holds both answers back until the clock has run on, then asserts the engine's clock never steps back (it stepped back twice, 2.4 -> 0.3 and 0.73 -> 0.3, before)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/components/projects/review/PlayCut.tsx | 30+++++++++++++++++++++++++++---
Mumtool/docs/knobs.md | 3++-
Mumtool/e2e/play-cut.spec.ts | 48++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -364,7 +364,7 @@ export default function PlayCut({ const engine = usePlayEngine({ plan, entries: entryOf, srcOf, audioOf, blurRendered: view.blurRendered, bg, style: edges.style, edgesPending: edges.state === "measuring", }); - const { ui, rate, failed, seekTo, setPlaying, now } = engine; + const { ui, rate, failed, now } = engine; const setRate = engine.setRate; // `?clip=&at=` (back from the clip bench): that clip, that far in -- the @@ -373,7 +373,31 @@ export default function PlayCut({ // placed again (cutAtSource) whenever the plan is re-timed under it: the // composed schedule replacing the estimate's, the render's edges arriving. // Let go once both have settled. A card keeps its offset. + // + // ...and let go the moment the operator takes the transport (plays, seeks, + // steps): from then on the place is the playhead's, and the engine carries a + // playhead across a re-plan itself (engine.ts setPlan: the same clip, by its + // source second). Held on, a plan re-timed under a PLAYING cut -- the render's + // edges measured, the deck composed, 12-17 s in on a long cut -- put the + // clock back on the place it opened at. const anchor = useRef<{ clip: string; at: number; src?: number; t?: number } | null>(initialAt); + // The anchor's own placing is the engine's seek; every other seek and every play is the operator's. + const placeAt = engine.seekTo; + const seekTo = useCallback( + (t: number) => { + anchor.current = null; + placeAt(t); + }, + [placeAt], + ); + const enginePlaying = engine.setPlaying; + const setPlaying = useCallback( + (on: boolean) => { + if (on) anchor.current = null; + enginePlaying(on); + }, + [enginePlaying], + ); // A place set to be found again (back from the bench, after a reorder): the effect below runs // for it even when the plan did not change. const [anchorTick, setAnchorTick] = useState(0); @@ -421,14 +445,14 @@ export default function PlayCut({ // (The offset was taken on the render's clock: turned into a source second once the render's edges are in.) if (it.clip && a.src === undefined && edges.state !== "measuring") a.src = sourceAt(it, inside(it.from + a.at)) ?? undefined; const landed = it.clip && a.src !== undefined ? inside(cutAtSource(it, a.src)) : inside(it.from + a.at); - seekTo(landed); + placeAt(landed); const waiting = awaitView.current > 0 && performance.now() - awaitView.current < 20_000; if (composeState !== "composing" && edges.state !== "measuring" && !waiting) { anchor.current = null; // The cut second it was left at is not where that clip's offset is now: an edit moved it. if (a.t !== undefined && Math.abs(landed - a.t) > 0.1) setBackToast(`Back at ${a.clip} · ${timecode(landed)} (the cut changed)`); } - }, [plan, composeState, edges.state, seekTo, anchorTick]); + }, [plan, composeState, edges.state, placeAt, anchorTick]); // A structural write landed (Reject, its undo): the view and the chrome are read again. const afterStructure = useCallback(() => { diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -479,7 +479,8 @@ drawn as a dissolve; the limiter after the loudness gain is not applied; a monta cuts. A clip whose source window is not on disk is a named placeholder that plays on (silent) — fetch it from the Cut tab. **Reload the cut** reads an edit made elsewhere, and the edges are measured again for what moved. **Edit this clip** (E) and the bench's **Back to the cut** come back to the same clip — and the same take — by its id and then by the SOURCE second you left (`?clip=&at=`, the offset turned into a source -second once the render's edges are in), so an edit that moves the clip's start does not move you off the word. The +second once the render's edges are in), so an edit that moves the clip's start does not move you off the word — until +you play or seek: from then the place is the playhead's, and edges or a deck arriving later never put it back. The bench draws the render's cut over its waveform and, on a phone, on the edge strip (a faint line, and its offset under each edge). diff --git a/umtool/e2e/play-cut.spec.ts b/umtool/e2e/play-cut.spec.ts @@ -238,3 +238,51 @@ test("a take plays its own timeline (its patch over the project's manifest); a r await page.locator('[data-play-row="c02"]').press("Enter"); expect(await tNow(page)).toBeCloseTo(2.133, 2); }); + +test("opened at ?clip=&at=, the clock never jumps back there when the render's edges and the deck arrive while it plays", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 1000 }); + // The late data, held until the clock has run on from the place: the render's edges + // (cut-points, 12-17 s on a long real cut) and the composed deck (the chrome preview). + let release!: () => void; + const gate = new Promise<void>((r) => (release = r)); + const held: string[] = []; + for (const late of ["/api/report/cut-points", "/api/report/chrome/preview"]) { + await page.route((u) => u.pathname === late, async (route) => { + held.push(new URL(route.request().url()).pathname); + await gate; + await route.continue(); + }); + } + await page.goto(urls.playHref(PROJECT, { clip: "c01", at: 0.3 })); + await expect(root(page)).toHaveAttribute("data-play-state", "paused"); + await expect(root(page)).toHaveAttribute("data-play-edges", "measuring"); + await expect.poll(() => tNow(page)).toBeCloseTo(0.3, 2); + // Every frame's clock, read off the engine itself (not the attribute React renders). + await page.evaluate(() => { + const w = window as Window & { __umtoolPlayEngine?: { now(): number; playing: boolean }; __clock?: number[] }; + w.__clock = []; + const loop = () => { + const e = w.__umtoolPlayEngine; + if (e?.playing) w.__clock!.push(e.now()); + requestAnimationFrame(loop); + }; + requestAnimationFrame(loop); + }); + await page.locator("[data-play-toggle]").click(); + await expect.poll(() => tNow(page), { timeout: 20_000 }).toBeGreaterThan(1.3); + expect(held).toEqual(expect.arrayContaining(["/api/report/cut-points", "/api/report/chrome/preview"])); + release(); + await expect(root(page)).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 }); + // On past the re-plan: the clock goes on from where it was. + const at = await tNow(page); + await expect.poll(() => tNow(page), { timeout: 20_000 }).toBeGreaterThan(at + 0.8); + await page.screenshot({ path: test.info().outputPath("play-at-no-jump.png") }); + await page.keyboard.press("k"); + const clock = await page.evaluate(() => (window as Window & { __clock?: number[] }).__clock ?? []); + expect(clock.length).toBeGreaterThan(30); + // The render's edges re-time the plan under the playhead (the same source second, a few + // frames either way); a jump back to the place it opened at is a second and more. + const back = clock.slice(1).map((t, i) => clock[i] - t); + expect(Math.max(...back), `the clock went back: ${JSON.stringify(clock.map((t) => Math.round(t * 100) / 100))}`).toBeLessThan(0.25); + expect(Math.min(...clock.slice(clock.length >> 1))).toBeGreaterThan(1.3); +});