Archilyzer · Source

archilyzer

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

commit 3a333a7fad130f1149cdf72cbd8e399a100e07d9
parent 6d91c82603dc53bf863268da531c839d4cfd0880
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 02:29:29 -0500

umtool e2e: media-scenes -- one picture answered in a row: Play draws the scene (the join item's slot, the anchor's picture and censor, the message before in full then giving way, the earlier ones stacked above), the band censor blurred, black and pixelated in Play, the bench's band line dragged and saved, an item kept out of the scene; the anchor's bench previews its own censor edits

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

Diffstat:
Mumtool/components/projects/PostBench.tsx | 11++++++++++-
Mumtool/e2e/fixtures/make-fixture.mjs | 3+++
Aumtool/e2e/fixtures/media-scenes-fixture.mjs | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/e2e/media-scenes.spec.ts | 194+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 268 insertions(+), 1 deletion(-)

diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx @@ -107,7 +107,16 @@ export default function PostBench({ const [error, setError] = useState<string | null>(null); // In a media scene (post-media-scene.mjs) the item plays as the scene does: the shared attachment the // anchor's, the scene's earlier messages above its card. Out of it (scene: false, unsaved) at once. - const scene = entry.scene === false ? null : savedScene; + // The anchor's own bench: its attachment as it is being edited (its crop, its censor), not as saved. + const scene = useMemo( + () => + entry.scene === false || !savedScene + ? null + : savedScene.anchor.id === entry.id + ? { ...savedScene, anchor: { ...savedScene.anchor, entry: { ...savedScene.anchor.entry, media: (entry.media ?? []) as Array<Record<string, unknown>> } } } + : savedScene, + [entry, savedScene], + ); const shown = useMemo(() => sceneEntry(entry, scene) as Entry, [entry, scene]); const plan = useMemo(() => (entry === initial ? initialPlan : (postItemPlan(shown, render, { prev: before, mediaScene: scene }) as PostPlan)), [entry, shown, initial, initialPlan, render, before, scene]); const total = plan.total; diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -56,6 +56,7 @@ import { makeIntakeFixture } from "./intake-fixture.mjs"; import { makePostItemsFixture } from "./post-items-fixture.mjs"; import { makePostNarrationFixture } from "./post-narration-fixture.mjs"; import { makePostComboFixture } from "./post-combo-fixture.mjs"; +import { makeMediaScenesFixture } from "./media-scenes-fixture.mjs"; const CODE = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "song"); const dest = path.resolve(process.argv[2] ?? path.join(process.cwd(), ".e2e-song")); @@ -1916,6 +1917,8 @@ makePostItemsFixture({ reports, channels: CHANNELS, deckManifest, cachedWindow: makePostNarrationFixture({ reports, deckManifest }); // The combo counter (report-to-video/post-combo.mjs): one GIF answering three people (post-combo.spec.ts). makePostComboFixture({ reports, channels: CHANNELS, deckManifest }); +// Media scenes and the band censor (post-media-scene.mjs, post-censor.mjs): one picture answered three times in a row (media-scenes.spec.ts). +makeMediaScenesFixture({ reports, deckManifest }); // Gaps inside a clip and the bench waveform's zoom (gaps-zoom.spec.ts), which WRITES (gaps cut, // undone, put back): its own project on gapvid, a recording id of its own (the fixture's vid1 // window -- tone, silences at 2.9-3.1 and 5.9-6.1 -- so nothing another spec fetches moves it). diff --git a/umtool/e2e/fixtures/media-scenes-fixture.mjs b/umtool/e2e/fixtures/media-scenes-fixture.mjs @@ -0,0 +1,61 @@ +// MEDIA SCENES (report-to-video/post-media-scene.mjs) and the BAND CENSOR +// (post-censor.mjs `band`): a posts cut where one picture is answered by +// several messages in a row (media-scenes.spec.ts). +// +// media-scenes-fixture p-j words only, `scene: "join"`: it joins the scene after it +// p-a the picture's first use (the anchor): censored below the middle +// p-b the same bytes, another X id +// p-c the same again +// p-x another picture (no repeat) +// the deck on, no narration: each item is its read (3 s and more), +// the picture beside the card from the first frame. WRITES its manifest +// (the bench's band, the scene knob): the spec puts it back before each test. +// +// Synthetic, like every fixture. +import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { createHash } from "node:crypto"; +import { spawnSync } from "node:child_process"; +import path from "node:path"; + +const ff = (args) => { + const r = spawnSync("ffmpeg", ["-v", "error", "-y", ...args]); + if (r.status !== 0) throw new Error(`ffmpeg ${args.join(" ")}: ${String(r.stderr)}`); +}; + +export const SCENE_CHANNEL = "scenechan-x"; + +/** @param {{ reports: string, deckManifest: Function }} o */ +export function makeMediaScenesFixture({ reports, deckManifest }) { + const name = "media-scenes-fixture"; + const dir = path.join(reports, name); + const media = path.join(dir, "posts-media", SCENE_CHANNEL); + for (const id of ["a", "b", "c", "x"]) mkdirSync(path.join(media, id), { recursive: true }); + const pic = path.join(media, "a", "a_1.png"); + ff(["-f", "lavfi", "-i", "testsrc=size=640x360:rate=1:duration=1", "-frames:v", "1", pic]); + ff(["-f", "lavfi", "-i", "testsrc2=size=640x360:rate=1:duration=1", "-frames:v", "1", path.join(media, "x", "x_1.png")]); + copyFileSync(pic, path.join(media, "b", "b_1.png")); + copyFileSync(pic, path.join(media, "c", "c_1.png")); + const bytes = readFileSync(pic); + const sha = createHash("sha256").update(bytes).digest("hex"); + // The captures' records: the same bytes under three X ids (re-uploaded each time). + for (const [id, xid] of [["a", "AAAA"], ["b", "BBBB"], ["c", "CCCC"]]) { + writeFileSync(path.join(media, id, "capture.json"), JSON.stringify({ version: 1, id, media: [{ name: `${id}_1.png`, bytes: bytes.length, sha256: sha, url: `https://pbs.twimg.com/media/${xid}?format=png` }] })); + } + const at = (h) => `2026-11-02T2${h}:00:00.000Z`; + const base = (id, h, text, o = {}) => ({ + type: "post", id, post: `${SCENE_CHANNEL}/${id.replace(/^p-/, "")}`, platform: "x", author: "Scene Subject", handle: "scenesubject", + date: at(h), text, url: `https://x.com/scenesubject/status/${id}`, engagement: { likes: 2 }, subjects: ["scenesubject"], ...o, + }); + const img = (id, o = {}) => [{ src: `posts-media/${SCENE_CHANNEL}/${id}/${id}_1.png`, kind: "image", width: 640, height: 360, ...o }]; + const timeline = [ + base("p-j", 0, "Look at this picture, everyone.", { scene: "join" }), + base("p-a", 1, "First message about the picture.", { media: img("a", { blur: { on: true, band: { below: 0.5 } } }) }), + base("p-b", 2, "Second message, the same picture again.", { media: img("b") }), + base("p-c", 3, "Third message, still the same picture.", { media: img("c") }), + base("p-x", 3, "Something else entirely.", { media: img("x") }), + ]; + const m = deckManifest(name, "The Media Scenes Fixture", timeline); + m.provenance = { ...m.provenance, channelSlug: SCENE_CHANNEL }; + writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); + return { dir }; +} diff --git a/umtool/e2e/media-scenes.spec.ts b/umtool/e2e/media-scenes.spec.ts @@ -0,0 +1,194 @@ +import { test, expect, type Page } from "@playwright/test"; +import { execFileSync } from "node:child_process"; +import { copyFileSync, existsSync, readFileSync, rmSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// MEDIA SCENES and the BAND CENSOR (report-to-video/post-media-scene.mjs, +// post-censor.mjs; knobs.md, "Media scenes" and "A post item"; operator, 4 +// Nov: "make it obvious he's posted multiple different messages about this +// same picture" -- "censor everything neck down"). Fixture: +// e2e/fixtures/media-scenes-fixture.mjs -- p-j (words, joins), p-a (the +// picture, censored below the middle: the anchor), p-b and p-c (the same +// bytes again), p-x (another picture). No narration: each item is its read. +// +// MEDIA_SCENES_SHOTS=<dir> screenshots there +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const FIXTURE = path.join(HERE, "..", ".e2e-song"); +const DIR = path.join(FIXTURE, "reports", "media-scenes-fixture"); +const MANIFEST = path.join(DIR, "video.manifest.json"); +const PROJECT = "reports/media-scenes-fixture"; +const SHOTS = process.env.MEDIA_SCENES_SHOTS ?? null; +const PIC = "posts-media/scenechan-x/a/a_1.png"; + +type Entry = { id: string; type: string; scene?: unknown; media?: Array<{ blur?: { band?: { below?: number }; style?: string } }> }; +const timeline = () => (JSON.parse(readFileSync(MANIFEST, "utf8")) as { timeline: Entry[] }).timeline; +const umtool = (args: string[]) => + execFileSync("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_PRINTS_CACHE: path.join(FIXTURE, "cache", "media-prints"), UMTOOL_MEDIA_DIR: "" }, + }); + +test.beforeAll(() => { + if (!existsSync(`${MANIFEST}.pristine`)) copyFileSync(MANIFEST, `${MANIFEST}.pristine`); +}); +test.beforeEach(() => { + test.setTimeout(120_000); + copyFileSync(`${MANIFEST}.pristine`, MANIFEST); + rmSync(path.join(DIR, "revisions"), { recursive: true, force: true }); +}); + +/** Play opened paused `at` seconds into `id`. */ +async function playAt(page: Page, id: string, at: number) { + await page.goto(urls.playHref(PROJECT, { bare: true, clip: id, at })); + const player = page.locator(`[data-post-play="${id}"]`); + await expect(player).toBeVisible({ timeout: 15_000 }); + await expect.poll(async () => Math.abs(Number(await player.getAttribute("data-post-s")) - at)).toBeLessThan(0.3); + return { player, frame: page.frameLocator('[data-post-card-frame="read"]') }; +} +const tilesOf = async (player: ReturnType<Page["locator"]>) => + Object.fromEntries(((await player.getAttribute("data-post-thread-tiles")) ?? "").split(" ").filter(Boolean).map((x) => { + const [sc, v] = x.split("="); + return [sc, v.split("/").map(Number)]; + })) as Record<string, number[]>; + +test("Play: one picture, several messages -- the picture held as the anchor's, the earlier messages stacked above, the one before giving way", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 1000 }); + // The join item (words only): in the scene, the picture beside its words -- the anchor's, censored as it is. + { + const { player } = await playAt(page, "p-j", 1); + await expect(player).toHaveAttribute("data-post-scene", "s1"); + await expect(player).toHaveAttribute("data-post-scene-n", "1/4"); + const m = player.locator("[data-post-media]"); + await expect(m).toHaveCount(1); + await expect(m.locator("img")).toHaveAttribute("src", new RegExp(encodeURIComponent(PIC))); + await expect(m).toHaveAttribute("data-post-blurred", "band"); + } + // p-b, its first frame: p-a (the message just before) in full, his own hidden under it. + { + const { player, frame } = await playAt(page, "p-b", 0); + await expect(player).toHaveAttribute("data-post-scene-n", "3/4"); + await expect(frame.locator('[data-thread-slot="scene:0"] [data-scene-post="p-j"]')).toHaveCount(1); + await expect(frame.locator('[data-thread-slot="scene:1"] [data-scene-post="p-a"]')).toHaveCount(1); + const t = await tilesOf(player); + expect(t["scene:1"][0]).toBeGreaterThan(0.95); + expect(t.post[1]).toBeLessThan(0.2); + expect(t["scene:0"]).toEqual([0.62, 0.5]); + // The picture: the ANCHOR's file and censor, not its own copy's. + await expect(player.locator("[data-post-media] img")).toHaveAttribute("src", new RegExp(encodeURIComponent(PIC))); + await expect(player.locator("[data-post-media]")).toHaveAttribute("data-post-censor-band", "0,0.5,1,0.5"); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-p-b-start.png") }); + } + // Two seconds in: both earlier messages small and dim above, his own up, lit. + { + const { player, frame } = await playAt(page, "p-b", 2); + await expect(player).toHaveAttribute("data-post-thread-tiles", "scene:0=0.62/0.5 scene:1=0.62/0.5 post=1/1"); + await expect.poll(async () => frame.locator('[data-thread-slot="scene:1"]').getAttribute("data-thread-state")).toBe("context"); + await expect.poll(async () => frame.locator('[data-thread-slot="post"]').getAttribute("data-thread-state")).toBe("focus"); + // Oldest up top: the earlier messages above his post. + const tops = await frame.locator("[data-thread-slot]").evaluateAll((els) => els.map((el) => [el.getAttribute("data-thread-slot"), Math.round(el.getBoundingClientRect().top)])); + expect(tops.map((x) => x[0])).toEqual(["scene:0", "scene:1", "post"]); + expect(Number(tops[0][1])).toBeLessThan(Number(tops[2][1])); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-p-b-later.png") }); + } + // Another picture: no scene, its own card alone. + { + const { player, frame } = await playAt(page, "p-x", 1); + await expect(player).not.toHaveAttribute("data-post-scene", /./); + await expect(frame.locator("[data-thread-slot]")).toHaveCount(0); + } + // umtool posts scenes says the same. + const v = JSON.parse(umtool(["posts", "scenes", PROJECT, "--json"])) as { scenes: { ids: string[]; anchor: string }[] }; + expect(v.scenes.map((s) => `${s.ids.join(",")}@${s.anchor}`)).toEqual(["p-j,p-a,p-b,p-c@p-a"]); +}); + +test("Play: the band censor -- blurred below the middle, then black above a line, then pixelated (set-item's censor knob)", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 1000 }); + { + const { player } = await playAt(page, "p-a", 1); + const m = player.locator("[data-post-media]"); + await expect(m).toHaveAttribute("data-post-blurred", "band"); + await expect(m).toHaveAttribute("data-post-censor-style", "blur"); + await expect(m).toHaveAttribute("data-post-censor-band", "0,0.5,1,0.5"); + const box = m.locator("[data-post-blur-box]"); + await expect(box).toHaveCount(1); + expect(await box.evaluate((el) => (el as HTMLElement).style.top)).toBe("50%"); + expect(await box.evaluate((el) => getComputedStyle(el).backdropFilter)).toMatch(/blur/); + // The label at the band's corner, not the picture's. + expect(await m.locator("[data-post-blur-label]").evaluate((el) => (el as HTMLElement).style.top)).toContain("50%"); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-band-blur.png") }); + } + umtool(["posts", "set-item", PROJECT, "p-a", "media.0.censor=above:0.4:black"]); + expect(timeline().find((e) => e.id === "p-a")?.media?.[0].blur).toEqual({ on: true, band: { above: 0.4 }, style: "black" }); + { + const { player } = await playAt(page, "p-a", 1); + const m = player.locator("[data-post-media]"); + await expect(m).toHaveAttribute("data-post-censor-style", "black"); + await expect(m).toHaveAttribute("data-post-censor-band", "0,0,1,0.4"); + expect(await m.locator("[data-post-blur-box]").evaluate((el) => getComputedStyle(el).backgroundColor)).toBe("rgb(0, 0, 0)"); + // The scene's later message draws the anchor's censor. + const b = (await playAt(page, "p-c", 1)).player.locator("[data-post-media]"); + await expect(b).toHaveAttribute("data-post-censor-style", "black"); + } + umtool(["posts", "set-item", PROJECT, "p-a", "media.0.censor=below:0.5:pixelate:9"]); + { + const { player } = await playAt(page, "p-a", 1); + const m = player.locator("[data-post-media]"); + await expect(m).toHaveAttribute("data-post-censor-style", "pixelate"); + // The pixels drawn coarse on a canvas over the band, the head left alone. + const canvas = m.locator("[data-post-pixelated]"); + await expect(canvas).toHaveCount(1); + await expect.poll(async () => canvas.evaluate((c) => { + const cv = c as HTMLCanvasElement; + const ctx = cv.getContext("2d"); + if (!ctx || !cv.width) return "none"; + const at = (y: number) => ctx.getImageData(Math.floor(cv.width / 2), Math.floor(cv.height * y), 1, 1).data[3]; + return `${at(0.25) > 0 ? "head" : "-"}/${at(0.75) > 0 ? "band" : "-"}`; + }), { timeout: 10_000 }).toBe("-/band"); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-band-pixelate.png") }); + } + umtool(["posts", "set-item", PROJECT, "p-a", "media.0.censor=off"]); + expect(timeline().find((e) => e.id === "p-a")?.media?.[0].blur).toEqual({ on: false, strength: 9 }); +}); + +test("the bench: the band's line dragged writes the censor; the scene block names the anchor and keeps an item out of the scene", async ({ page }) => { + await page.setViewportSize({ width: 1500, height: 1100 }); + await page.goto(urls.postBenchHref(PROJECT, "p-a")); + const block = page.locator('[data-post-bench-scene="s1"]'); + await expect(block).toBeVisible(); + await expect(block.locator("[data-post-bench-scene-members]")).toContainText("message 2 of 4"); + await expect(page.locator('[data-post-bench-censor-band="0"]')).toHaveValue("below"); + const line = page.locator('[data-post-bench-band-line="below"]'); + await expect(line).toHaveAttribute("data-band-at", "0.5"); + // Drag the line up to 30% of the picture's height. + const pad = page.locator('[data-post-bench-blur-pad="0"]'); + const pb = (await pad.boundingBox())!; + const lb = (await line.boundingBox())!; + await page.mouse.move(lb.x + lb.width / 3, lb.y + lb.height / 2); + await page.mouse.down(); + await page.mouse.move(lb.x + lb.width / 3, pb.y + pb.height * 0.3, { steps: 6 }); + await page.mouse.up(); + await expect.poll(async () => Number(await line.getAttribute("data-band-at"))).toBeCloseTo(0.3, 1); + // The player shows it at once (the anchor's own bench previews its edit). + await expect.poll(async () => (await page.locator("[data-post-play] [data-post-media]").getAttribute("data-post-censor-band")) ?? "").toMatch(/^0,0\.(2|3)\d*,1,/); + await page.locator('[data-post-bench-censor-style="0"]').selectOption("pixelate"); + await expect(page.locator("[data-post-play] [data-post-media]")).toHaveAttribute("data-post-censor-style", "pixelate"); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-bench-band.png") }); + await page.locator("[data-post-bench-save]").click(); + await expect.poll(() => timeline().find((e) => e.id === "p-a")?.media?.[0].blur?.style).toBe("pixelate"); + expect(timeline().find((e) => e.id === "p-a")?.media?.[0].blur?.band?.below).toBeCloseTo(0.3, 1); + + // A later message's bench: the anchor named (its censor is set there); kept out, the scene shrinks. + await page.goto(urls.postBenchHref(PROJECT, "p-b")); + await expect(page.locator('[data-post-bench-scene-anchor="p-a"]')).toBeVisible(); + await page.locator("[data-post-bench-scene-knob]").selectOption("off"); + await page.locator("[data-post-bench-save]").click(); + await expect.poll(() => timeline().find((e) => e.id === "p-b")?.scene).toBe(false); + const v = JSON.parse(umtool(["posts", "scenes", PROJECT, "--json"])) as { scenes: { ids: string[] }[] }; + expect(v.scenes.map((s) => s.ids.join(","))).toEqual(["p-j,p-a"]); +});