Archilyzer · Source

archilyzer

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

commit 47a1a3079ccdfddff9215c951f98f75caa34b8eb
parent 45fc64badf1580c3f6e7772ac71dcee7342bc187
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 19:54:30 -0500

umtool: Play's gate trusts the MOUNTED player, not the item -- a post item's player reports "ahead" as it mounts on bytes all fetched ahead, "ready" once its card is drawn and its voice and first attachment can play, "gone" as it unmounts. Before, a ready said by the plain-frame player carried over to the deck's (the deck composed: mounted afresh, its card still loading -- pp-1 drawn 43% of its seconds), and an item whose fetch finished after its player had mounted from the network was let run (a jump to pp-6: 50%). post-narration.spec's read-rate test waits for the deck before it samples: a sample across the deck's remount read a player gone

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

Diffstat:
Mumtool/components/projects/review/PlayCut.tsx | 19+++++++++----------
Mumtool/components/projects/review/PostItemPlayer.tsx | 30++++++++++++++++++++++--------
Mumtool/e2e/post-narration.spec.ts | 2++
3 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -409,8 +409,9 @@ export default function PlayCut({ ); // THE GATE (engine.ts): a post item plays once its player is ready -- its card drawn, its voice and its first // attachment able to play -- and the clock waits on it, never cutting it short (a buffer stall's wait). Fetched - // ahead (postPreload.ts), it is ready as it comes on screen, with no wait; the clock holds on the item before - // while it is still fetching. `postReady`: the item whose player said so (one is mounted at a time). + // ahead (postPreload.ts), its player mounts "ahead" and plays on at once; the clock holds on the item before + // while it is still fetching. `postReady`: what the MOUNTED player said (one at a time; "gone" as it unmounts, + // so a player mounted again -- the deck composed -- is waited for afresh). const entryOfRef = useRef(entryOf); entryOfRef.current = entryOf; const postReady = useRef<string | null>(null); @@ -423,14 +424,13 @@ export default function PlayCut({ let since = gateAsked.current.get(key); if (since === undefined) gateAsked.current.set(key, (since = now)); if (now - since > GATE_MAX_MS) return "ready"; - const st = postPreload.itemState(id); - if (next) return st === "loading" ? "fetching" : "ready"; - // Fetched ahead, it plays on at once: its card is a srcdoc drawn in a frame, its voice (due `lead` in) a blob. - // Else it waits for its player to say it is ready. - return st === "ready" || postReady.current === id ? "ready" : "wait"; + if (next) return postPreload.itemState(id) === "loading" ? "fetching" : "ready"; + // Its player mounted on bytes fetched ahead ("ahead": a srcdoc card, a blob voice due `lead` in), or says it is ready. + return postReady.current === id ? "ready" : "wait"; }, []); - const onPostReady = useCallback((id: string) => { - postReady.current = id; + const onPostReady = useCallback((id: string, state: "ahead" | "ready" | "gone") => { + if (state !== "gone") postReady.current = id; + else if (postReady.current === id) postReady.current = null; }, []); const engine = usePlayEngine({ plan, entries: entryOf, srcOf, audioOf, blurRendered: view.blurRendered, bg, style: edges.style, edgesPending: edges.state === "measuring", gate, @@ -874,7 +874,6 @@ export default function PlayCut({ useEffect(() => { // A new item on screen: its gate is asked afresh (a revisit waits as the first visit did). gateAsked.current.clear(); - if (postReady.current !== (plan.items[ui.cur]?.id ?? null)) postReady.current = null; }, [ui.cur, plan]); useEffect(() => { const items = plan.items; diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -499,10 +499,12 @@ export default function PostItemPlayer({ project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, clock = null, joinFrom = null, onReady, }: { /** - * Called once the item can play from its first frame (Play's clock waits for it, engine.ts `gate`): its card - * drawn and measured, its voice and the attachment it opens on able to play (or failed: nothing to wait for). + * THIS player's readiness, for Play's clock (engine.ts `gate`): "ahead" as it mounts when its card, its voice + * and the attachment it opens on were all fetched ahead (postPreload.ts: it plays on at once); "ready" once its + * card is drawn and its voice and first attachment can play (or failed: nothing to wait for); "gone" as it + * unmounts (a player mounted again -- the deck composed -- is waited for afresh). */ - onReady?: (id: string) => void; + onReady?: (id: string, state: "ahead" | "ready" | "gone") => void; project: string; take?: string | null; entry: Record<string, unknown> & { id: string }; @@ -566,6 +568,14 @@ export default function PostItemPlayer({ // Fetched ahead by Play (postPreload.ts): drawn from those bytes, decided as each is first drawn. const docOf = useFirstDoc(); const fileOf = useFirstSrc(); + // Everything it opens on already here (fetched ahead), as it mounts: the card's page, the voice, the first step. + const [ahead] = useState(() => { + const here = (u: string) => postPreload.urlOf(u) !== u; + if (postPreload.docOf(pageUrl("read")) === null) return false; + const take = plan.narration ? (pickedTake(entry) as { file?: string } | null) : null; + if (take?.file && !here(takeFileUrl(project, take.file))) return false; + return (plan.steps[0]?.items ?? []).every((m) => here(postFileUrl(project, String(m.src)))); + }); const reading = s < plan.reading || !plan.steps.length; const current = stepAt(plan, s); // Beside the card, the first attachment is up (its first frame) while the words are read. @@ -838,11 +848,12 @@ export default function PostItemPlayer({ setClockState(clockSt && clockAt && s < until ? { ...clockAt, st: clockSt } : null, doc); }, [clockSt, clockAt, s, layout.mode, plan.steps]); // ---- READY (Play's clock waits for it): the card measured, the voice and the first attachment able to play ---- - const readyFor = useRef<string | null>(null); const onReadyRef = useRef(onReady); onReadyRef.current = onReady; useEffect(() => { - if (!onReadyRef.current || readyFor.current === entry.id) return; + if (!onReadyRef.current) return; + const mine = entry.id; + if (ahead) onReadyRef.current(mine, "ahead"); const id = setInterval(() => { const node = wrap.current; const doc = readFrame.current?.contentDocument; @@ -853,10 +864,13 @@ export default function PostItemPlayer({ for (const v of Array.from(node.querySelectorAll<HTMLVideoElement>("video[data-post-video]"))) if (v.readyState < 2 && !v.error) return; for (const im of Array.from(node.querySelectorAll<HTMLImageElement>("img[data-post-image]"))) if (!im.complete) return; clearInterval(id); - readyFor.current = entry.id; - onReadyRef.current?.(entry.id); + onReadyRef.current?.(mine, "ready"); }, 40); - return () => clearInterval(id); + return () => { + clearInterval(id); + onReadyRef.current?.(mine, "gone"); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [entry.id]); const src = shown && inStep ? mediaTimeAt(shown, s) : null; const cue = wordsRel && src !== null ? (cues[wordsRel] ?? []).find((c) => src >= c.start && src < c.end) ?? null : null; diff --git a/umtool/e2e/post-narration.spec.ts b/umtool/e2e/post-narration.spec.ts @@ -123,6 +123,8 @@ test("THE READ's RATE in Play: render.postNarration.rate 1.25 plays the voice at await page.setViewportSize({ width: 1366, height: 1000 }); await page.goto(urls.playHref(PROJECT, { bare: true, clip: "p-11" })); await expect(root(page)).toHaveAttribute("data-play-item", "p-11"); + // The deck composed first: its frame mounts the player afresh, and a sample across that would read a player gone. + await expect(root(page)).toHaveAttribute("data-play-compose", "ready", { timeout: 60_000 }); const player = page.locator('[data-post-play="p-11"]'); await page.locator("[data-play-toggle]").click(); await expect(player).toHaveAttribute("data-post-narration-playing", "1", { timeout: 15_000 });