Archilyzer · Source

archilyzer

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

commit 9478b2398c91e76bf5505d9b0f207ffdefdc4b4d
parent decdd5fd9641f90c372a350f21f7d57c30ec6822
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sun,  1 Nov 2026 12:21:18 -0500

umtool Play: the piece after a gap's join is primed on the elements too (the second <video>, seeked and paused, a slot of its own), and a primed decoder keeps its decode queue full while holding few frames; a take whose patch sets its own sections says what a move changes; the stamp-fix boxes get their own attributes per copy

Measured on the 127-clip copy (t03: a 49 s gap; scripts in the lane's
scratch): on the <video> path the join used to seek one element through a long
GOP -- the frame held while the sound jumped; primed, the drawn frame steps
from 18.90 to 67.89 on time, the longest hold 0 ms. On WebCodecs the piece is
decoded ahead by its own decoder (PRIME_FRAMES held, MAX_FRAMES in flight);
on this machine under load the decoders could not keep up with 1080p and were
demoted to the elements before and after, so that path's number is the
machine's.

- playView `sectionsDiffer`: the take's patch carries markers out of step with
  the cut's (Ember's draft-1.patch.json); the strip says a move changes the
  cut's sections and the seams shown are the take's.
- ClipBench: the refused-save fix is drawn on the desk and on the phone with
  their own attributes (data-bench-fix / data-walk-fix), as the walk's
  convention is.

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

Diffstat:
Mumtool/components/projects/ClipBench.tsx | 13+++++++------
Mumtool/components/projects/review/PlayCut.tsx | 7+++++++
Mumtool/components/projects/review/ReelStrip.tsx | 8++++++++
Mumtool/components/projects/review/playEngine/codecPicture.ts | 18+++++++++++++-----
Mumtool/components/projects/review/playEngine/engine.ts | 40++++++++++++++++++++++++++++------------
Mumtool/e2e/play-walk.spec.ts | 6++++--
Mumtool/lib/report/playView.mjs | 5+++++
7 files changed, 72 insertions(+), 25 deletions(-)

diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx @@ -2884,8 +2884,9 @@ export default function ClipBench({ const c = cues.find((x) => sec >= x.start && sec < x.end) ?? cues.find((x) => x.start >= sec); return c ? c.text.replace(/\s+/g, " ").trim().slice(0, 60) : null; }; - const fixBox = fix ? ( - <div role="group" aria-label="fix the refused save" data-bench-fix={fix.outside.kind} className="flex flex-wrap items-center gap-1.5 text-[12px]"> + // Drawn twice (the desk's note row, the phone's): each copy its own attributes, so no selector matches both. + const fixBox = (w: "bench" | "walk") => fix ? ( + <div role="group" aria-label="fix the refused save" {...{ [`data-${w}-fix`]: fix.outside.kind }} className="flex flex-wrap items-center gap-1.5 text-[12px]"> <span className="text-text-2"> {fix.outside.kind === "mute" ? "The mute mark" : fix.outside.marks.length > 1 ? `${fix.outside.marks.length} stamps` : "The stamp"} at {fix.outside.marks.map((m) => m.at.toFixed(2)).join(", ")} would be outside {fix.outside.window.start.toFixed(2)}–{fix.outside.window.end.toFixed(2)}: </span> @@ -2898,7 +2899,7 @@ export default function ClipBench({ <button key={how} type="button" - data-bench-fix-move={how} + {...{ [`data-${w}-fix-move`]: how }} disabled={!!busy} className={buttonVariants({ variant: "outline", size: "sm" })} title={w ? `it lands on “${w}”` : undefined} @@ -2910,7 +2911,7 @@ export default function ClipBench({ })} <button type="button" - data-bench-fix-clear="" + {...{ [`data-${w}-fix-clear`]: "" }} disabled={!!busy} className={buttonVariants({ variant: "outline", size: "sm" })} onClick={() => void save({ ...fix.patch, ...(fix.outside.kind === "mute" ? { muteFix: "clear" } : { markFix: "clear" }) })} @@ -3059,7 +3060,7 @@ export default function ClipBench({ {note} </span> )} - <span className="md:hidden">{fixBox}</span> + <span className="md:hidden">{fixBox("walk")}</span> <span data-walk-verdict={verdict} className={cn("ml-auto", verdict === "confirmed" ? "text-kept-text" : verdict === "incorrect" || verdict === "rejected" ? "text-doubt-text" : "text-muted")}> {verdictLabel(clip)} </span> @@ -3638,7 +3639,7 @@ export default function ClipBench({ {note} </span> )} - {fixBox} + {fixBox("bench")} </div> {/* ---- the instrument ---- diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -126,6 +126,8 @@ export type PlayViewData = { sectionOf?: Record<string, number>; /** The manifest's token when the view was read: a reorder from a stale view is refused, not lost. */ token?: string; + /** The take's patch sets its own sections (markers out of step with the cut's): a drop changes the cut, not them. */ + sectionsDiffer?: boolean; counter: { verdicts: { id: string; label: string }[]; stamps: { landed: number; verdict: string; count: number }[] }; markers: { after: string; label: string }[]; leadIn: number; @@ -1098,6 +1100,11 @@ export default function PlayCut({ editable={editableWhy} onEdit={(e) => void runEdit(e)} busy={edit.busy} + notice={ + view.sectionsDiffer && view.take + ? `take ${view.take.id}'s patch sets its own sections (render.chrome.deck.markers), out of step with the cut's: a move here changes the cut's clips and sections; the strip's seams are this take's until its patch's markers are brought in step` + : null + } /> {(edit.done || edit.error) && ( <p role="status" data-strip-toast={edit.error ? "error" : edit.done?.undone ? "undone" : "done"} className={cn("m-0 flex flex-wrap items-center gap-2 text-[11.5px]", edit.error ? "text-reject-text" : "text-text-2")}> diff --git a/umtool/components/projects/review/ReelStrip.tsx b/umtool/components/projects/review/ReelStrip.tsx @@ -73,6 +73,7 @@ export default function ReelStrip({ editable = null, onEdit, busy = false, + notice = null, }: { items: PlayItem[]; total: number; @@ -97,6 +98,8 @@ export default function ReelStrip({ editable?: string | null; onEdit?: (e: StripEdit) => void; busy?: boolean; + /** A word about what a move here does and does not change (a take with sections of its own). */ + notice?: string | null; }) { const cells = useRef<HTMLDivElement | null>(null); const [hover, setHover] = useState<number | null>(null); @@ -578,6 +581,11 @@ export default function ReelStrip({ ) : editable ? ( <span data-strip-locked="">{editable}</span> ) : null} + {notice && ( + <span data-strip-notice="" className="text-doubt-text"> + {notice} + </span> + )} {busy && <span data-strip-busy="">moving…</span>} {refusal && ( <span role="alert" className="text-reject-text" data-strip-refusal=""> diff --git a/umtool/components/projects/review/playEngine/codecPicture.ts b/umtool/components/projects/review/playEngine/codecPicture.ts @@ -23,6 +23,8 @@ type Track = NonNullable<ReturnType<typeof videoTrackOf>>; /** Frames decoded ahead of the one on screen, at most. */ const MAX_FRAMES = 10; +/** Frames a primed decoder (the piece after a gap's join, not on screen yet) holds ready. */ +const PRIME_FRAMES = 3; /** How far ahead of the clock (s, in decode order) chunks are fed. */ const AHEAD_S = 0.6; /** @@ -245,8 +247,12 @@ class ClipDecoder { this.flushed = false; } - /** Decode toward media time t (s): seek when t is outside what is queued or coming, then feed ahead. */ - want(t: number) { + /** + * Decode toward media time t (s): seek when t is outside what is queued or coming, then feed + * ahead -- at most `limit` frames decoded or queued (a primed piece holds a few, not a full queue: + * every open VideoFrame is decoder memory, and three decoders' full queues stall a decoder). + */ + want(t: number, limit = MAX_FRAMES) { if (this.state !== "ready" || !this.dec || !this.track) return; const s = this.track.samples; const tUs = t * 1e6; @@ -258,7 +264,9 @@ class ClipDecoder { const farAhead = this.q.head < tUs - 1e6 && this.feed >= 0 && seekPoint(s, t).key > this.feed; if (this.feed < 0 || behind || farAhead) this.seek(t); try { - while (this.dec.decodeQueueSize + this.q.size < MAX_FRAMES && this.feed < s.length) { + // The decoder kept busy (MAX_FRAMES in flight, the way through a long GOP to the frame wanted), + // the frames HELD bounded by `limit`. + while (this.q.size < limit && this.dec.decodeQueueSize + this.q.size < MAX_FRAMES && this.feed < s.length) { const x = s[this.feed]; if (x.dts > t + AHEAD_S) break; const data = this.bytesOf(this.feed); @@ -323,7 +331,7 @@ export class CodecPicture { private tick = 0; /** Decode toward each wanted (url, media time); close the decoders nobody wants now. */ - sync(wants: { url: string; mediaTime: number }[]) { + sync(wants: { url: string; mediaTime: number; prime?: boolean }[]) { this.tick += 1; for (const w of wants) { let d = this.clips.get(w.url); @@ -333,7 +341,7 @@ export class CodecPicture { this.clips.set(w.url, d); } d.used = this.tick; - d.want(w.mediaTime); + d.want(w.mediaTime, w.prime ? PRIME_FRAMES : MAX_FRAMES); } for (const [url, d] of this.clips) { // A refusal is remembered (cheap, and asking again would fetch the moov again); anything else unwanted is closed. diff --git a/umtool/components/projects/review/playEngine/engine.ts b/umtool/components/projects/review/playEngine/engine.ts @@ -83,6 +83,8 @@ const DUE = 0.06; const START_LEAD = 0.08; /** A WebCodecs clip this far behind the sound (s) for this long (ms) plays on an element instead. */ const LAG_S = 0.25; +/** A gapped clip's later piece is a slot of its own on the elements: item index + piece × this. */ +const PIECE_SLOT = 100_000; const LAG_FOR = 700; /** Clips decoded ahead of and behind the playhead. */ const DECODE_AHEAD = 3; @@ -202,7 +204,7 @@ export class PlayEngine { /** A slot's media will not play: that clip plays as a placeholder from here on. */ slotFailed(k: number) { const i = this.elements.fail(k); - const item = this.plan.items[i]; + const item = this.plan.items[i % PIECE_SLOT]; if (!item) return; this.failed.add(item.id); this.o.onFailed(item.id, "the media did not load"); @@ -520,8 +522,8 @@ export class PlayEngine { private pieceKeys(i: number, t: number, url: string) { const it = this.plan.items[i]; const e = this.entries.get(it.id); - if (!it.clip?.gaps?.length) return [{ key: url, mediaTime: this.mediaTimeOf(i, t) }]; - return pieceWants(it, t, e?.media?.from ?? 0, { ahead: 2 * Math.max(1, this.rate) }).map((w) => ({ key: w.piece ? `${url}#p${w.piece}` : url, mediaTime: w.mediaTime })); + if (!it.clip?.gaps?.length) return [{ key: url, mediaTime: this.mediaTimeOf(i, t), piece: 0 }]; + return pieceWants(it, t, e?.media?.from ?? 0, { ahead: 2 * Math.max(1, this.rate) }).map((w) => ({ key: w.piece ? `${url}#p${w.piece}` : url, mediaTime: w.mediaTime, piece: w.piece })); } private mediaTimeOf(i: number, t: number) { @@ -546,29 +548,43 @@ export class PlayEngine { const inFootage = (i: number) => !!items[i].clip && t <= items[i].clip!.playEnd && t >= items[i].start; const layers: { i: number; alpha: number; source: CanvasImageSource | null; w: number; h: number }[] = []; const viaElement: { i: number; alpha: number }[] = []; - const codecWants: { url: string; mediaTime: number }[] = []; + const codecWants: { url: string; mediaTime: number; prime?: boolean }[] = []; // A gapped clip decodes per kept piece (`<url>#p<k>`), the piece after the next join primed // before it (playCut.mjs pieceWants): the picture no longer holds at a long gap's jump. - const keyOf = new Map<number, { key: string; mediaTime: number }>(); + const keyOf = new Map<number, { key: string; mediaTime: number; piece: number }>(); + // On the elements too: the piece after the join waits in the second <video>, seeked, so the + // join swaps slots instead of seeking one (pieces are slots of their own: PIECE_SLOT). + let elementPrime: { i: number; piece: number; mediaTime: number } | null = null; + const pieceWantsOf = new Map<number, { key: string; mediaTime: number; piece: number }[]>(); for (const v of vis) { const url = this.mediaUrl(v.i)!; const wants = this.pieceKeys(v.i, t, url); + pieceWantsOf.set(v.i, wants); keyOf.set(v.i, wants[0]); const st = this.codecs?.status(wants[0].key); - if (this.codecs && st !== "unsupported" && st !== "failed") for (const w of wants) codecWants.push({ url: w.key, mediaTime: w.mediaTime }); - else viaElement.push(v); + if (this.codecs && st !== "unsupported" && st !== "failed") wants.forEach((w, k) => codecWants.push({ url: w.key, mediaTime: w.mediaTime, prime: k > 0 })); + else { + viaElement.push(v); + if (wants[1] && vis.length === 1) elementPrime = { i: v.i, piece: wants[1].piece, mediaTime: wants[1].mediaTime }; + } } + const slotOf = (i: number) => (keyOf.get(i)?.piece ? i + keyOf.get(i)!.piece * PIECE_SLOT : i); const nextUrl = nextI >= 0 ? this.mediaUrl(nextI) : null; const nextSt = nextUrl && this.codecs ? this.codecs.status(nextUrl) : "unsupported"; if (nextUrl && this.codecs && nextSt !== "unsupported" && nextSt !== "failed") { - codecWants.push({ url: nextUrl, mediaTime: this.mediaTimeOf(nextI, items[nextI].start) }); + codecWants.push({ url: nextUrl, mediaTime: this.mediaTimeOf(nextI, items[nextI].start), prime: true }); } this.codecs?.sync(codecWants); // The elements hold what WebCodecs does not: the clips it refused, and the next one when it refused that. const elementNext = nextI >= 0 && (!this.codecs || nextSt === "unsupported" || nextSt === "failed") ? nextI : -1; + const ep = elementPrime as { i: number; piece: number; mediaTime: number } | null; this.elements.sync( - viaElement.map((v) => ({ index: v.i, id: items[v.i].id, url: this.mediaUrl(v.i)!, mediaTime: this.mediaTimeOf(v.i, t), play: runs && inFootage(v.i) })), - elementNext >= 0 ? { index: elementNext, id: items[elementNext].id, url: this.mediaUrl(elementNext)!, mediaTime: this.mediaTimeOf(elementNext, items[elementNext].start), play: false } : null, + viaElement.map((v) => ({ index: slotOf(v.i), id: items[v.i].id, url: this.mediaUrl(v.i)!, mediaTime: keyOf.get(v.i)?.mediaTime ?? this.mediaTimeOf(v.i, t), play: runs && inFootage(v.i) })), + ep + ? { index: ep.i + ep.piece * PIECE_SLOT, id: items[ep.i].id, url: this.mediaUrl(ep.i)!, mediaTime: ep.mediaTime, play: false } + : elementNext >= 0 + ? { index: elementNext, id: items[elementNext].id, url: this.mediaUrl(elementNext)!, mediaTime: this.mediaTimeOf(elementNext, items[elementNext].start), play: false } + : null, this.rate, ); for (const v of vis) { @@ -579,8 +595,8 @@ export class PlayEngine { if (runs && inFootage(v.i)) this.keepingUp(key, f ? want - f.timestamp / 1e6 : Infinity); layers.push({ ...v, source: f, w: f?.displayWidth ?? 0, h: f?.displayHeight ?? 0 }); } else { - const el = this.elements.sourceFor(v.i); - if (el && runs && inFootage(v.i)) this.measure(items[v.i].id, this.elements.presentedFor(v.i) ?? el.currentTime, this.mediaTimeOf(v.i, t), this.elements.frameFor(v.i)); + const el = this.elements.sourceFor(slotOf(v.i)); + if (el && runs && inFootage(v.i)) this.measure(items[v.i].id, this.elements.presentedFor(slotOf(v.i)) ?? el.currentTime, this.mediaTimeOf(v.i, t), this.elements.frameFor(slotOf(v.i))); layers.push({ ...v, source: el, w: el?.videoWidth ?? 0, h: el?.videoHeight ?? 0 }); } } diff --git a/umtool/e2e/play-walk.spec.ts b/umtool/e2e/play-walk.spec.ts @@ -194,6 +194,7 @@ test("Play → Edit → the bench in place → Back: the same clip, second and t const t0 = await tNow(page); const item = "c02"; const hist = await page.evaluate(() => history.length); + const composed = (await root(page).getAttribute("data-play-compose"))!; await page.locator("[data-play-edit]").click(); // In place: Play hidden (kept), the bench on the clip, its address the bench's. await expect(page.locator(`[data-cut-app-bench="${item}"] [data-bench-shell="clip"]`)).toBeVisible({ timeout: 20_000 }); @@ -213,8 +214,9 @@ test("Play → Edit → the bench in place → Back: the same clip, second and t await expect(root(page)).toHaveAttribute("data-play-cut", "draft-1"); await expect(page).toHaveURL(/\/play\?/); expect(await page.evaluate(() => history.length)).toBe(hist + 2); - // ...and Play did not start over: its deck stays composed. - await expect(root(page)).toHaveAttribute("data-play-compose", /ready|no-deck/); + // ...and Play did not start over: the deck is not being composed again (nothing changed). + await expect(root(page)).toHaveAttribute("data-play-compose", composed); + expect(composed).not.toBe("composing"); }); test("Back and Forward step between Play and the bench; the bench on its own goes to Play from here", async ({ page }) => { diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs @@ -146,12 +146,17 @@ export async function playView(project, { take = null, bare = false } = {}) { // section and each section's label and colour (sectionEdit.mjs sectionModel) -- as many as // the markers make, no limit assumed here. const model = sectionModel(base); + // A take whose patch sets its OWN markers, out of step with the cut's (patchMarkers.mjs: a patch + // not synced): a drop moves the cut's clips and sections, and this take keeps showing its own. + const markersOf = (m) => JSON.stringify(m?.render?.chrome?.deck?.markers ?? null); + const sectionsDiffer = !!takeInfo && markersOf(selected) !== markersOf(selectVariant(base, DEFAULT_VARIANT)); const sections = model.sections.map((x) => ({ index: x.index, label: x.label, color: x.color, marker: x.marker, count: x.clips.length })); return { project: project.id, title: text(manifest.title) || project.id, sections, sectionOf: Object.fromEntries(model.sectionOf), + sectionsDiffer, // The manifest's token: a reorder written from a view older than the file is refused (409), not lost. token: await manifestToken(project.dir), counter,