commit 340afde362fa1e21a7a11ae5a21c9605c656e3e3
parent 850d47f6b5259536c702a42b75df5995ac8b96b9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 20 Nov 2026 17:38:44 -0500
umtool: the gap-cue page gives a mark its room; a deck e2e; compose test
- the slice reckons a mark's width wide (the wider of a bold sans's and a
monospace's advances: the deck's bold may be either) and gives each mark
its room (its box less the insets, or the row from the line's end), so
the page never cuts a mark that fits (a real 640x360 build drew "dea…")
- gapCueHtml takes a look (the operator's variant stills only)
- composeChrome(gap-cue) with a stub renderer: one project and sequence per
mark where the overlay reads it, cached, another corner a new key, frame
keys model the page, a preview never renders
- e2e: gapcue-deck-fixture; Play under a deck shows the module's page as a
play layer, up inside its window saying the reason, no hand-drawn chip;
the bench's where writes gapCue.place
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
5 files changed, 152 insertions(+), 14 deletions(-)
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -2013,6 +2013,18 @@ makeMediaScenesFixture({ reports, deckManifest });
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", "gapcuevid_0.00-9.00.mp4"));
}
+// The gap mark under a DECK (lane gap-cue, slice 1d; gap-cue.spec.ts, which WRITES): the same two clips in a deck
+// cut, so the mark is the gap-cue module's page -- Play the cut lays it as a play layer. Its own project and window.
+{
+ const g = deckManifest("gapcue-deck-fixture", "The Gap Mark Deck Fixture", [
+ { type: "clip", id: "gd01", video: "gapdeckvid", start: 0.5, end: 8.5, cite: 1, section: 0, lock: true, quote: "a clip with a marked gap", onscreen: { title: "A marked gap" } },
+ { type: "clip", id: "gd02", video: "gapdeckvid", start: 1.0, end: 3.0, cite: 1, section: 0, lock: true, quote: "the clip after it", onscreen: { title: "After it" } },
+ ]);
+ g.render.fetchPad = 0;
+ const dir = writeProject("gapcue-deck-fixture", g);
+ 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", "gapdeckvid_0.00-9.00.mp4"));
+}
// Fetch more from where the edge is now (clip-bench.spec.ts): one clip, r01 reachvid 300-306, on a
// recording a thousand seconds long; nothing cached -- the spec fetches through the editor stub.
writeProject(
diff --git a/umtool/e2e/gap-cue.spec.ts b/umtool/e2e/gap-cue.spec.ts
@@ -178,3 +178,55 @@ test("the Modules panel: the project's label, and Play's mark says it", async ({
const seen = await playAndWatch(page, 4.5);
expect(seen.filter((s) => s.t > 3.2 && s.t < 3.9).map((s) => s.text)).toContain("2 s later");
});
+
+// ---- under a deck (slice 1d): the mark is the gap-cue module's own page ----------------------------------------
+// gapcue-deck-fixture: the same two clips in a deck cut, never built -- Play plays it on the estimate's clock, where
+// gd01 plays 0.5-8.5 less 3.5-5.5 from the cut's start, so the mark is up 3.0-4.1 s.
+
+const DECK = "reports/gapcue-deck-fixture";
+const DECK_MANIFEST = path.join(HERE, "..", ".e2e-song", "reports", "gapcue-deck-fixture", "video.manifest.json");
+const readDeck = () => JSON.parse(readFileSync(DECK_MANIFEST, "utf8")) as Manifest;
+const deckToken = async (request: APIRequestContext, clip = "gd01") =>
+ ((await (await request.get(`/api/report/clip?project=${encodeURIComponent(DECK)}&clip=${clip}`)).json()) as { token: string }).token;
+const putDeckWindow = async (request: APIRequestContext, data: Record<string, unknown>) =>
+ request.put("/api/report/window", { data: { project: DECK, clip: "gd01", token: await deckToken(request), ...data } });
+const putDeckLook = async (request: APIRequestContext, patch: Record<string, unknown>) => {
+ const t = ((await (await request.get(`/api/report/render?project=${encodeURIComponent(DECK)}`)).json()) as { token: string }).token;
+ return request.put("/api/report/render", { data: { project: DECK, token: t, patch } });
+};
+/** The mark's element inside the gap-cue layer's own page, and its opacity there (the build's pixels, seeked by Play). */
+const layerMark = (page: Page) => page.frameLocator('[data-testid="play-layer-gap-cue-iframe"]').locator(".gm[data-gm]");
+
+test("under a deck, Play shows the gap-cue module's own page: up inside its window saying the reason, no hand-drawn chip; the bench's where writes place", async ({ page, request }) => {
+ let r = await putDeckWindow(request, { gaps: [{ from: 3.5, to: 5.5, why: "dead-air" }], gapCue: null });
+ expect(r.ok(), await r.text()).toBeTruthy();
+ r = await putDeckLook(request, { gapCue: { mark: true } });
+ expect(r.ok(), await r.text()).toBeTruthy();
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ // 3.4 s into the cut: the mark is up (3.0-4.1).
+ await page.goto(urls.playHref(DECK, { clip: "gd01", at: 3.4 }));
+ const root = page.locator("[data-play-cut]");
+ await expect(root).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 });
+ await expect(page.locator('[data-testid="play-deck"]')).toBeVisible({ timeout: 30_000 });
+ const layer = page.locator('[data-play-layer="gap-cue"]');
+ await expect(layer).toHaveAttribute("data-play-layer-segment", "gd01.g0", { timeout: 30_000 });
+ await expect(layer).toHaveAttribute("data-play-layer-up", "1");
+ await expect(page.getByTestId("play-layer-gap-cue")).toHaveAttribute("data-feed-ready", "1", { timeout: 30_000 });
+ await expect(layerMark(page)).toHaveAttribute("data-gm", "» 2 s · dead air");
+ await expect.poll(() => layerMark(page).evaluate((el) => Number(getComputedStyle(el).opacity)), { timeout: 10_000 }).toBeGreaterThan(0.8);
+ await expect(page.locator("[data-gap-mark-chip]")).toHaveCount(0);
+ await page.screenshot({ path: test.info().outputPath("play-deck-gap-mark.png") });
+ // Past its window: the layer is down.
+ await page.goto(urls.playHref(DECK, { clip: "gd01", at: 5 }));
+ await expect(root).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 });
+ await expect(page.locator('[data-play-layer="gap-cue"][data-play-layer-up="1"]')).toHaveCount(0);
+
+ // The bench's where: in the deck (the CLI's gapCue.place).
+ await page.goto(urls.clipBenchHref(DECK, "gd01"));
+ await page.locator("[data-wave-box]").scrollIntoViewIfNeeded();
+ await page.locator("[data-gap-cue-place]").selectOption("deck");
+ await expect.poll(() => readDeck().timeline.find((e) => e.id === "gd01")!.gapCue?.place).toBe("deck");
+ // Back off for the next run.
+ expect((await putDeckWindow(request, { gaps: [{ from: 3.5, to: 5.5 }], gapCue: null })).ok()).toBeTruthy();
+ expect((await putDeckLook(request, { gapCue: null })).ok()).toBeTruthy();
+});
diff --git a/umtool/report-to-video/chrome-gap-cue.mjs b/umtool/report-to-video/chrome-gap-cue.mjs
@@ -28,13 +28,14 @@ export function gapCueWindows(schedule) {
/**
* One mark's page: the whole frame, transparent, the mark at its rect -- its right edge kept at the rect's when it
- * stands at a right corner or in the deck (the face's real width may differ from the slice's reckoning, so the
- * mark hugs the edge it is placed against).
+ * stands at a right corner or in the deck, its bottom at the rect's at a bottom corner (the face's real width is the
+ * text's own, so the mark hugs the edges it is placed against) -- never wider than its `room` (cut "…" past it).
*
* @param {Record<string, any>} schedule
* @param {Record<string, any>} render
* @param {{ segment: string, from: number, to: number }} window the snapped window
- * @param {{ fonts?: { regular?: string, bold?: string }, gsap?: string }} [opts]
+ * @param {{ fonts?: { regular?: string, bold?: string }, gsap?: string, look?: Record<string, unknown> }} [opts] `look` over
+ * GAP_CUE_LOOK's colours and box (the operator's stills of the variants; the build passes none)
*/
export function gapCueHtml(schedule, render, window, opts = {}) {
const w = gapCueWindows(schedule).find((x) => x.segment === window.segment);
@@ -64,8 +65,8 @@ export function gapCueHtml(schedule, render, window, opts = {}) {
bottom ? `bottom: ${H - (r.y + r.h)}px;` : `top: ${r.y}px;`,
].join(" ");
const line = m.place === "deck" ? GAP_CUE_DECK_LINE : 1.2;
- const css = `${gapCueCss(".gm", { font: m.font, stroke: m.stroke, lineHeight: line })}
- .gm { visibility: hidden; opacity: 0; ${at} max-width: ${Math.max(r.w, 1)}px; }`;
+ const css = `${gapCueCss(".gm", { font: m.font, stroke: m.stroke, lineHeight: line, ...(opts.look ? { look: opts.look } : {}) })}
+ .gm { visibility: hidden; opacity: 0; ${at} max-width: ${Math.max(Number(m.room) || r.w, 1)}px; }`;
const body = `<div class="gm" data-k="gm" data-gm="${esc(m.text)}" data-place="${esc(m.place)}">${esc(m.text)}</div>`;
return cuePageHtml({ id: "gap-cue", W, H, fps, fonts: opts.fonts, gsapSrc: opts.gsap, css, body, init, cues, window: { from, dur } });
}
diff --git a/umtool/report-to-video/gap-cue-slice.mjs b/umtool/report-to-video/gap-cue-slice.mjs
@@ -45,13 +45,20 @@ import { chatGeometry } from "./chrome-chat.mjs";
import { chapterCover, chapterWindows } from "./chrome-story.mjs";
import { deckGeometry, deckLayout, deckOn, deckScale, overlayBox, playWindow, postsGeometry, stampGeometry } from "./deck.mjs";
import { tallyOf } from "./factcheck.mjs";
-import { censorAvoidRects, gapMarkAsked, gapMarkPlaces, gapMarkSize, recordGapMarks, sansWidth, twoCropMarkBox } from "./gap-mark-place.mjs";
+import { censorAvoidRects, gapMarkAsked, gapMarkPlaces, gapMarkSize, monoWidth, recordGapMarks, sansWidth, twoCropMarkBox } from "./gap-mark-place.mjs";
import { clipTwoCrop, stackedGeometry, stackedOn } from "./vertical-deck.mjs";
const r4 = (v) => Math.round(v * 10000) / 10000;
const rectOf = (b) => ({ x: b.x, y: b.y, w: b.w ?? b.width, h: b.h ?? b.height });
const fin = (v) => typeof v === "number" && Number.isFinite(v);
+/**
+ * How wide a mark's text is reckoned in the deck's bold face, whatever face the brand gives it: the wider of a bold
+ * sans's advances (sansWidth) and a monospace's (monoWidth, Plex Mono -- the default deck's bold). A reckoning that
+ * errs wide places and hops the mark; the page sizes the element to its text, never cutting one that fits its room.
+ */
+export const deckFaceWidth = (text, fontSize) => Math.max(sansWidth(text, fontSize), monoWidth(text, fontSize));
+
/** The deck place's text against the source line's: a size under it (its box then sits inside the row and the air round it). */
export const GAP_CUE_DECK_FONT = 0.9;
/** The deck place's line box, in ems: the row is short, so the box is the text's own height. */
@@ -75,7 +82,7 @@ function basisOf(entry, render, rec) {
* The deck place's rect for one mark's text, frame px, or why it cannot stand there (`fell`): right-aligned at the
* source line row's end, centred on the row.
*
- * @returns {{ rect: { x: number, y: number, w: number, h: number }, font: number, stroke: number } | { fell: string }}
+ * @returns {{ rect: { x: number, y: number, w: number, h: number }, font: number, stroke: number, room: number } | { fell: string }}
*/
export function gapCueDeckRect({ render, schedule, segment, text }) {
if (stackedOn(render)) return { fell: "stacked" };
@@ -99,14 +106,15 @@ export function gapCueDeckRect({ render, schedule, segment, text }) {
const font = Math.max(12, Math.round(rowSize * GAP_CUE_DECK_FONT));
const stroke = Math.max(GAP_CUE_LOOK.strokeMin, Math.round(Math.min(render.width ?? 1920, render.height ?? 1080) * GAP_CUE_LOOK.stroke));
const edge = Math.round(font * GAP_CUE_LOOK.pad) + stroke;
- const w = sansWidth(text, font) + 2 * edge;
+ const w = deckFaceWidth(text, font) + 2 * edge;
const h = Math.ceil(font * GAP_CUE_DECK_LINE) + 2 * edge;
const right = t.x + t.width - z(22);
// The source line as it would draw at its longest (its status at its longest too), and air before the mark.
const lineText = two && Array.isArray(segment.subtitleLines) ? String(segment.subtitleLines.at(-1) ?? "") : String(segment.subtitle ?? "");
const lineW = sansWidth(lineText, rowSize);
if (t.x + lineW + z(24) > right - w) return { fell: "row" };
- return { rect: { x: band.x + right - w, y: band.y + rowY + Math.round((rowBox - h) / 2), w, h }, font, stroke };
+ // Its room: from the line's end (and the air after it) to the row's.
+ return { rect: { x: band.x + right - w, y: band.y + rowY + Math.round((rowBox - h) / 2), w, h }, font, stroke, room: right - (t.x + lineW + z(24)) };
}
/**
@@ -139,7 +147,8 @@ function moduleAvoids(schedule, render) {
/**
* The schedule's `gapCue` slice: `{ marks: [...], inSegment?: [clip ids] }`, or null when no clip wants a mark
* (or no deck is drawn). Each mark: `{ id, segment, at, until, seconds, count?, text, place, corner?, asked?,
- * rect, font, stroke, fell? }` -- `at`/`until` the cut's seconds, `rect` frame px, `font`/`stroke` px.
+ * rect, room, font, stroke, fell? }` -- `at`/`until` the cut's seconds, `rect` frame px (its width reckoned wide:
+ * deckFaceWidth), `room` the widest the element may draw, `font`/`stroke` px.
*
* @param {Record<string, any>} schedule the deck's (deckSchedule): its segments, stamps, posts, chat
* @param {{ entries: any[], render: any, records?: Map<string, any> | null, provenance?: any }} o
@@ -180,7 +189,9 @@ export function gapCueSlice(schedule, { entries, render, records = null, provena
sw: 1, sh: 1, dest: base, from: Number(basis.start), gaps: basis.gaps, seconds: segSeconds,
}).map((a) => ({ ...a, from: a.from == null ? null : seg.start + a.from, to: a.to == null ? null : seg.start + a.to }));
const onCut = own.map((m) => ({ ...m, at: r4(seg.start + m.at), until: r4(seg.start + m.until) }));
- const places = gapMarkPlaces({ marks: onCut, box: base, want: cue.corner, prefer: fb.prefer, size, avoid: [...censor, ...avoids], measure: sansWidth });
+ const places = gapMarkPlaces({ marks: onCut, box: base, want: cue.corner, prefer: fb.prefer, size, avoid: [...censor, ...avoids], measure: deckFaceWidth });
+ // Over the footage, a mark's room is its box less the insets.
+ const room = base.w - 2 * size.inset;
onCut.forEach((m, k) => {
const asked = gapMarkAsked(m, cue.corner);
const common = {
@@ -189,15 +200,15 @@ export function gapCueSlice(schedule, { entries, render, records = null, provena
if (cue.place === "deck") {
const d = gapCueDeckRect({ render, schedule, segment: seg, text: m.text });
if ("rect" in d) {
- marks.push({ ...common, text: m.text, place: "deck", rect: d.rect, font: d.font, stroke: d.stroke });
+ marks.push({ ...common, text: m.text, place: "deck", rect: d.rect, room: d.room, font: d.font, stroke: d.stroke });
return;
}
const p = places[k];
- marks.push({ ...common, text: p.text, place: "footage", fell: d.fell, corner: p.corner, ...(asked ? { asked } : {}), rect: p.rect, font: p.size.fontSize, stroke: p.size.stroke });
+ marks.push({ ...common, text: p.text, place: "footage", fell: d.fell, corner: p.corner, ...(asked ? { asked } : {}), rect: p.rect, room, font: p.size.fontSize, stroke: p.size.stroke });
return;
}
const p = places[k];
- marks.push({ ...common, text: p.text, place: "footage", corner: p.corner, ...(asked ? { asked } : {}), rect: p.rect, font: p.size.fontSize, stroke: p.size.stroke });
+ marks.push({ ...common, text: p.text, place: "footage", corner: p.corner, ...(asked ? { asked } : {}), rect: p.rect, room, font: p.size.fontSize, stroke: p.size.stroke });
});
}
if (!marks.length && !inSegment.length) return null;
diff --git a/umtool/report-to-video/gap-cue-slice.test.mjs b/umtool/report-to-video/gap-cue-slice.test.mjs
@@ -244,3 +244,65 @@ test("byte for byte in the stacked vertical deck and with a twocrop clip: off, n
const s = gapCueSlice(scheduleOf(v), { entries: v.timeline, render: v.render, records: new Map([["c01", OLD_RECORD]]) });
assert.equal(s.marks[0].corner, "tr");
});
+
+test("composeChrome(gap-cue): one project and frame sequence per mark, keyed; the same mark cached, another corner a new key; frame keys model the page", async () => {
+ const { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } = await import("node:fs");
+ const { tmpdir } = await import("node:os");
+ const path = (await import("node:path")).default;
+ const { fileURLToPath } = await import("node:url");
+ const { composeChrome } = await import("./compose-chrome.mjs");
+ const { frameKeys } = await import("./frame-keys.mjs");
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
+ const dir = mkdtempSync(path.join(tmpdir(), "gap-cue-c1-"));
+ const prevBin = process.env.HYPERFRAMES_BIN;
+ try {
+ // A stub renderer: as many empty frames as the page lasts, each run logged.
+ const stub = path.join(dir, "hf-stub.mjs");
+ writeFileSync(stub, `#!/usr/bin/env node
+import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import path from "node:path";
+const a = process.argv.slice(2);
+const out = a[a.indexOf("--output") + 1], fps = Number(a[a.indexOf("--fps") + 1]), proj = a[a.length - 1];
+const dur = Number(/data-duration="([\\d.]+)"/.exec(readFileSync(path.join(proj, "index.html"), "utf8"))[1]);
+mkdirSync(out, { recursive: true });
+for (let i = 1; i <= Math.round(dur * fps); i += 1) writeFileSync(path.join(out, "frame_" + String(i).padStart(6, "0") + ".png"), "");
+appendFileSync(${JSON.stringify(path.join(dir, "runs.log"))}, a.join(" ") + "\\n");
+`);
+ chmodSync(stub, 0o755);
+ process.env.HYPERFRAMES_BIN = stub;
+ const m = manifest({ gapCue: { mark: true } });
+ m.render.fontRegular = path.join(HERE, "fonts", "IBMPlexMono-Regular.ttf");
+ m.render.fontBold = path.join(HERE, "fonts", "IBMPlexMono-Bold.ttf");
+ const manifestPath = path.join(dir, "video.manifest.json");
+ writeFileSync(manifestPath, JSON.stringify({ slug: "t", ...m }));
+ const sched = withGapCue(scheduleOf(m), { entries: m.timeline, render: m.render, records: new Map([["c01", OLD_RECORD]]) });
+ const [w] = gapCueWindows(sched);
+ const runs = () => { try { return readFileSync(path.join(dir, "runs.log"), "utf8").trim().split("\n").length; } catch { return 0; } };
+ const first = await composeChrome({ manifestPath, region: "gap-cue", schedule: sched, window: { segment: w.segment, from: w.from, to: w.to }, doRender: true });
+ const [region] = gapCueModule.regions(sched, { render: m.render, outDir: path.join(dir, "out", "sourced") });
+ assert.equal(first.frames, region.frames, "where the overlay reads it");
+ assert.equal(first.frameCount, region.frameCount);
+ assert.equal(first.projDir, path.join(dir, "out", "sourced", "chrome", "gap-cue-c01.g0"));
+ const html = readFileSync(path.join(first.projDir, "index.html"), "utf8");
+ assert.match(html, /url\('assets\/DeckSansBold\.ttf'\)/);
+ assert.match(html, /data-composition-id="gap-cue"/);
+ assert.ok(frameKeys({ html, region: "gap-cue", assets: [], fps: 30, frames: first.frameCount, version: "x" }), "the frame-key model reads the page");
+ const again = await composeChrome({ manifestPath, region: "gap-cue", schedule: sched, segment: w.segment, doRender: true });
+ assert.equal(again.cached, true);
+ assert.equal(runs(), 1);
+ // Another corner: that page's key changes (and only that page's).
+ const moved = { ...sched, gapCue: { ...sched.gapCue, marks: sched.gapCue.marks.map((k) => ({ ...k, corner: "tr", rect: { ...k.rect, x: 1500 } })) } };
+ const third = await composeChrome({ manifestPath, region: "gap-cue", schedule: moved, segment: w.segment, doRender: true });
+ assert.equal(third.cached, false);
+ assert.notEqual(third.key, first.key);
+ // A preview composes beside it and never renders (Play's layer).
+ const prev = await composeChrome({ manifestPath, region: "gap-cue", schedule: sched, segment: w.segment, preview: true, doRender: true });
+ assert.equal(prev.projDir, path.join(dir, "out", "sourced", "chrome", "gap-cue-preview-c01.g0"));
+ assert.equal(prev.frames, null);
+ await assert.rejects(composeChrome({ manifestPath, region: "gap-cue", schedule: sched, segment: "c02.g0" }), /no gap mark c02\.g0/);
+ } finally {
+ if (prevBin === undefined) delete process.env.HYPERFRAMES_BIN;
+ else process.env.HYPERFRAMES_BIN = prevBin;
+ rmSync(dir, { recursive: true, force: true });
+ }
+});