Archilyzer · Source

archilyzer

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

commit de9def531aa0cddaa229b7db482187db3f1ed641
parent c44cd8ebc33b7f8db0597135cd43eeb941bfe691
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu,  5 Nov 2026 17:31:20 -0500

umtool: e2e preview-render.spec.ts -- a changes reel of two labelled pieces and changes.json, a 1280x720 preview beside the untouched full render, take status, the card's buttons through the queue

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

Diffstat:
Mumtool/e2e/fixtures/make-fixture.mjs | 17+++++++++++++++++
Aumtool/e2e/preview-render.spec.ts | 120+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 137 insertions(+), 0 deletions(-)

diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -2315,6 +2315,23 @@ copyFileSync( copyFileSync(path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), path.join(dir, "out", "clips-raw", "vid1_0.00-9.00.mp4")); } +// preview-render-fixture: fast feedback (lib/report/takePreview.mjs; preview-render.spec.ts, 5 Nov 2026). +// A 1920x1080 cut of three clips of vid1 (its window cached, so a take renders), no takes/ yet: the spec +// renders t0 whole, drafts t1 from it with one clip trimmed and one added, renders t1's changes reel +// against t0 (two labelled pieces) and t0's preview (1280x720, its full render untouched). +{ + const m = manifest("preview-render-fixture", "The Preview Render Fixture", { siteOrigin: "https://archive.example" }, [ + // Every clip inside 3–6 s: its window ± the fetch pad (3 s) is the cached 0–9 s one. + { type: "clip", id: "m01", video: "vid1", start: 3, end: 4, cite: 3, section: 0, lock: true, quote: "the first" }, + { type: "clip", id: "m02", video: "vid1", start: 4, end: 6, cite: 4, section: 0, lock: true, quote: "and because" }, + { type: "clip", id: "m03", video: "vid1", start: 3.5, end: 5, cite: 3, section: 0, lock: true, quote: "the last" }, + ]); + m.render = { ...m.render, width: 1920, height: 1080 }; + const dir = writeProject("preview-render-fixture", m); + mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true }); + copyFileSync(path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), path.join(dir, "out", "clips-raw", "vid1_0.00-9.00.mp4")); +} + // -- THE VIDEO-NOTES AND TIMELINE FIXTURES ------------------------------------ // // video-notes-fixture is a GENERATED manifest (`generatedBy`) with a built cut diff --git a/umtool/e2e/preview-render.spec.ts b/umtool/e2e/preview-render.spec.ts @@ -0,0 +1,120 @@ +import { test, expect } from "@playwright/test"; +import { spawnSync } from "node:child_process"; +import { readFileSync, statSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// FAST FEEDBACK (lib/report/takePreview.mjs; umtool/docs/report-video.md, "Fast feedback: preview and +// changes renders"): a take's PREVIEW (the whole take at 1280x720, veryfast) and its CHANGES REEL (only +// what changed against the take it was made from, each piece labelled with its time in the full cut). +// +// 1. the CLI: t0 rendered whole; t1 drafted from it (m02 trimmed, m04 added); t1's changes reel has two +// labelled pieces and changes.json lists them; t0's preview is 1280x720 and its full render's files +// (preview.mp4, out/<slug>.mp4, render.json, take.json, out/sourced/schedule…) are untouched; +// `take status --json` reports both +// 2. the Takes page: the card's Preview render / Render changes, a queue step the app runs, the state +// inline, the output's local path, Play of the file +// +// Fixture: preview-render-fixture (make-fixture.mjs), which this spec WRITES (takes/). +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const FIXTURE = path.join(HERE, "..", ".e2e-song"); +const PROJECT = "reports/preview-render-fixture"; +const DIR = path.join(FIXTURE, "reports", "preview-render-fixture"); +const SLUG = "preview-render-fixture"; + +function cli(args: string[], base = "") { + const r = spawnSync("node", ["bin/umtool.mjs", ...args], { + cwd: path.join(HERE, ".."), + encoding: "utf8", + env: { ...process.env, REPORTS_DIR: FIXTURE, CHANNELS_DIR: path.join(FIXTURE, "channels"), UMTOOL_CACHE_DIR: path.join(FIXTURE, "cache"), UMTOOL_MEDIA_DIR: "", ...(base ? { UMTOOL_URL: base } : {}) }, + timeout: 240_000, + }); + return { code: r.status, out: r.stdout, err: r.stderr }; +} + +function size(file: string) { + const r = spawnSync("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height", "-of", "csv=p=0", file], { encoding: "utf8" }); + return r.stdout.trim(); +} + +const clip = (id: string, start: number, end: number, quote: string) => ({ type: "clip", id, video: "vid1", start, end, cite: Math.floor(start), section: 0, lock: true, quote }); + +test.describe.configure({ mode: "serial" }); + +test("the CLI: a changes reel of two labelled pieces with changes.json; a 1280x720 preview beside the untouched full render", async () => { + test.setTimeout(400_000); + const t0 = cli(["take", PROJECT, "--id", "t0", "--label", "T0", "--full", "--force"]); + expect(t0.code, t0.err + t0.out).toBe(0); + const patch = { timeline: [clip("m01", 3, 4, "the first"), clip("m02", 4, 5.5, "and because"), clip("m03", 3.5, 5, "the last"), clip("m04", 5, 6, "one more")] }; + const d = cli(["take", PROJECT, "--id", "t1", "--draft", "--from", "t0", "--force", "--patch-json", JSON.stringify(patch)]); + expect(d.code, d.err).toBe(0); + expect(JSON.parse(readFileSync(path.join(DIR, "takes", "t1", "take.json"), "utf8")).draftedFrom).toBe("t0"); + + // The changes reel: against t0 (the draft's own from), two pieces, each labelled with its full-cut time. + const c = cli(["take", PROJECT, "--id", "t1", "--changes", "--json"]); + expect(c.code, c.err + c.out).toBe(0); + const list = JSON.parse(readFileSync(path.join(DIR, "takes", "t1", "changes.json"), "utf8")); + expect(list.from).toBe("t0"); + expect(list.tier).toBe("preview"); + expect(list.items.map((x: { id: string; kinds: string[] }) => [x.id, x.kinds])).toEqual([["m02", ["media trim"]], ["m04", ["added clip"]]]); + for (const it of list.items) expect(it.label).toMatch(new RegExp(`^\\d+:\\d\\d · ${it.id} · `)); + // t0's segments measured its clock: the times are its, moved by m02's new length. + expect(list.times.basis).toBe("measured"); + expect(list.items[0].at).toBeGreaterThan(0.5); + expect(list.items[1].at).toBeGreaterThan(list.items[0].at); + const reel = path.join(DIR, "takes", "t1", "out", `${SLUG}.changes.mp4`); + expect(size(reel)).toBe("1280,720"); + expect(list.items[1].reel.to).toBeGreaterThan(list.items[0].reel.to); + // The draft is still a draft: nothing of a full render was made for it. + expect(() => statSync(path.join(DIR, "takes", "t1", "preview.mp4"))).toThrow(); + + // The preview of t0: 1280x720, its full render's files untouched. + const full = ["preview.mp4", `out/${SLUG}.mp4`, "render.json", "take.json", "video.manifest.json", "out/sourced/segments/m02.mp4"].map((f) => path.join(DIR, "takes", "t0", f)); + const before = full.map((f) => { const s = statSync(f); return `${s.size}:${s.mtimeMs}:${s.ino}`; }); + const p = cli(["take", PROJECT, "--id", "t0", "--preview"]); + expect(p.code, p.err + p.out).toBe(0); + expect(size(path.join(DIR, "takes", "t0", "out", `${SLUG}.preview.mp4`))).toBe("1280,720"); + expect(size(path.join(DIR, "takes", "t0", "preview.mp4"))).toBe("1920,1080"); + expect(full.map((f) => { const s = statSync(f); return `${s.size}:${s.mtimeMs}:${s.ino}`; })).toEqual(before); + // Its own record, in its own dir; the take's render record still the full render's. + expect(JSON.parse(readFileSync(path.join(DIR, "takes", "t0", "out", "preview", "render.json"), "utf8")).state).toBe("done"); + expect(JSON.parse(readFileSync(path.join(DIR, "takes", "t0", "render.json"), "utf8")).mp4).toBe("preview.mp4"); + + const s0 = cli(["take", "status", PROJECT, "--id", "t0", "--json"]); + expect(s0.code).toBe(0); + const j0 = JSON.parse(s0.out); + expect(j0.state).toBe("done"); + expect(j0.preview.state).toBe("done"); + expect(j0.preview.mp4).toContain(`${SLUG}.preview.mp4`); + const j1 = JSON.parse(cli(["take", "status", PROJECT, "--id", "t1", "--json"]).out); + expect(j1.changes.items).toBe(2); + expect(j1.changes.from).toBe("t0"); +}); + +test("the Takes page: Preview render and Render changes are queue steps, their state and path inline, the file played", async ({ page, baseURL }) => { + test.setTimeout(300_000); + await page.goto(urls.takesHref(PROJECT)); + const card0 = page.locator("[data-fast-renders='t0']"); + await expect(card0.locator("[data-fast='preview']")).toHaveAttribute("data-fast-state", "done", { timeout: 30_000 }); + await expect(card0.locator("[data-fast='preview'] [data-fast-path]")).toContainText(`${SLUG}.preview.mp4`); + await card0.locator("[data-action='play-preview']").click(); + await expect(card0.locator("[data-fast-video='preview']")).toBeVisible(); + const served = await page.request.get(`/api/report/takes/fast?project=${encodeURIComponent(PROJECT)}&take=t0&file=preview`, { headers: { range: "bytes=0-99" } }); + expect(served.status()).toBe(206); + + // Render changes on the draft: a step of the app's queue, run, its state inline. + const card1 = page.locator("[data-fast-renders='t1']"); + const before = statSync(path.join(DIR, "takes", "t1", "changes.json")).mtimeMs; + await card1.locator("[data-action='render-changes']").click(); + await expect(card1.locator("[data-fast-queued]")).toContainText(/queued as q\d+/); + const qid = ((await card1.locator("[data-fast-queued]").textContent()) ?? "").match(/q\d+/)?.[0] ?? ""; + const st = cli(["queue", "status", qid, "--json"], String(baseURL)); + expect(JSON.parse(st.out).step?.argv ?? JSON.parse(st.out).argv).toEqual(["take", PROJECT, "--id", "t1", "--changes", "--from", "t0"]); + await expect(card1.locator("[data-fast='changes']")).toHaveAttribute("data-fast-state", "done", { timeout: 240_000 }); + expect(statSync(path.join(DIR, "takes", "t1", "changes.json")).mtimeMs).toBeGreaterThan(before); + await expect(card1.locator("[data-fast='changes'] [data-fast-said]")).toContainText("2 piece(s) against t0"); +});