Archilyzer · Source

archilyzer

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

commit b677e8fb8ce97d8bc7d3bb59109d1aaf36243b99
parent 58ff3d09e49ce358a48beb1dae3d70e9c576c628
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 26 Oct 2026 15:04:51 -0400

Merge lane/feed-lone: a post alone in the feed column fills the card; the tally cell reads a short tallyLabel and never ellipsizes

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

Diffstat:
Meditor/CHANGELOG.md | 2++
Mumtool/docs/knobs.md | 1+
Mumtool/lib/report/knobsCli.mjs | 2+-
Mumtool/report-to-video/chrome-deck.mjs | 6++++--
Mumtool/report-to-video/chrome-feed.mjs | 42++++++++++++++++++++++++++++++++++++++++--
Mumtool/report-to-video/chrome-feed.test.mjs | 49++++++++++++++++++++++++++++++++++++++++++++++---
Mumtool/report-to-video/deck.mjs | 2+-
Mumtool/report-to-video/factcheck.mjs | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mumtool/report-to-video/factcheck.test.mjs | 42+++++++++++++++++++++++++++++++++++++++++-
Mumtool/report-to-video/finale.test.mjs | 12++++++++++++
10 files changed, 236 insertions(+), 19 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +- **A report video's fact-check counter never cuts its label short.** The deck's count box showed the verdict's label and cut what did not fit with "…", so the Huck cut's count read "HUCK'S BLEND …". A verdict can now carry a `tallyLabel` (`render.chrome.factcheck.verdicts.<V>.tallyLabel`), a short word for the count box alone, and the Huck cut's says "Pitches"; the finale's totals and stats keep the full "Huck's Blend pitches". Without one, the box shows the label if it fits, else the longest run of the label's last words that fits. A `tallyLabel` that does not fit, or a label with no last words that fit, is refused by name when the manifest is checked, not found in the render. Labels that already fit draw exactly as before. +- **A post screenshot alone in the posts feed fills the card's width.** The feed only let a tall screenshot grow into the room beside the card under it, and it kept that room even when the card under it was about to be pushed out of the column, so the Huck video's 21 October "new kind of seizure" post stood alone at 345 px wide in a 556 px card with the column empty under it. A screenshot whose card arrives alone, or pushes the one under it out, now takes the card's full width, its height following the picture, up to the column's height (larger than the screenshot itself if the width needs it). With a card under it that stays on screen, the feed draws exactly as before, and a feed with no screenshots builds the same page, so its cached render is reused. - **A twin of a finished report-video take renders in a fraction of the time.** A full build of the Huck cut took about 1 h 45 m, and its uncensored twin — the same cut with `render.blur` off — took as long again, because every build encoded all 66 clips again (about 8 minutes), which in turn redid every crossfade batch, and captured the on-screen chrome again (about 47 minutes) once the first build had pruned its frames. Now a clip's segment is encoded again only when something that makes its picture or sound changed (its cut, snap, room, blur, framing, captions, loudness, encode settings or source file); otherwise the one on disk is reused untouched, and so are the crossfade batches over it. `umtool take <project> --id <id> --from <other take> …` starts a take from another take's render: it hard-links that take's clip segments, chrome frames and crossfade batches in (no copies, and the other take's files never change) and renders, rebuilding only what differs — for the uncensored twin, the blurred clip and the batch it sits in, then the final overlay. Make the first take with `--keep-frames` so its chrome frames are still there for the twin (they are 1–3 GB a layer; without it they are pruned after the render as before). `--from` refuses a take that does not exist, the take itself, or a take never rendered. Needs a restart of umtool for the Takes page's jobs; the CLI has it at once. - **A report video's fact-check counter can stay off screen until it first counts.** The deck's tally drew every verdict's cell from the first frame, so in the Huck cut the "Huck's Blend pitches" cell read 0 for about 23 of its 29 minutes. With `render.chrome.factcheck.tally.showAt: "first"` a cell is hidden until the stamp that gives it its first count lands; then it pops in already reading that count, flashes, and stays to the end. `{ "PARTLY": "first" }` sets it for one verdict's cell only. The default, `"always"`, is the tally as before. A hidden cell keeps its place in the row, and the finale's totals still show every verdict. Set it in the On-screen tab's fact-check labels (**pop in**, per verdict), with `umtool look <project> factcheck.tally.showAt=first` (or `factcheck.tally.showAt.PARTLY=first`; `factcheck.tally.showAt=` clears it), or in a take (`--set render.chrome.factcheck.tally.showAt=first`). An unknown value is refused by name. The clip editor's live preview and the Play view show the same deck page as the render, so the cell pops in at the same moment there. Needs a restart of umtool and a rebuild of the video. - **A report video's finale timeline no longer prints words over words.** In the Huck cut's finale the claim checks' words all stood on one line over the rail (`“less than ten” a year`, `19 seizures on camera`, `12 in a day · 4 in a week`, both pill-test goalposts), the `12 IN A DAY`/`4 IN A WEEK` labels ran into the markers' flags, and the turned dates under the rail overlapped. Now the claim checks take turns (`deck.finale.claims`: `rotate`, the default — one claim at a time for an even share of the finale's time, at least 6 s each, with a short crossfade; `all` stacks them), every claim's words, span label and marker label is laid in its own place in rows over the rail, with its stick kept inside its bracket and clear of the words under it, and a crowded rail says each date once and fans the turned labels out on thin leaders so no two meet. The timeline takes the height its rows need (`deck.finale.timelineShare`: `auto`, up to just over half the frame, its words set larger when there is room; or a share 0.38–0.6), and the clip, the totals and the stats shrink to fit under it. A finale without claim checks and with room for its labels renders as before. Re-render a take to see it. diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -120,6 +120,7 @@ that mentions the seizure in question and one before it. The Marks box is on eve |---|---|---|---| | `render.chrome.factcheck.stamp.scale` (0.5–2), `.motion` (`slam` `pop` `fade` `none`), `.opacity` (0.3–1) | Structure, **fact-check labels**: scale, motion, opacity | `umtool look <p> factcheck.stamp.scale=1.3 factcheck.stamp.motion=pop` | `POST /api/report/timeline {op: "factcheck", factcheck}` | | `render.chrome.factcheck.verdicts.<V>.stampLabel` — the stamp's word (singular, `SEIZURE`) beside `label` (the tally's, `SEIZURES`) | fact-check labels, the third column | `factcheck.verdicts.CONTRADICTED.stampLabel=SEIZURE` | same | +| `render.chrome.factcheck.verdicts.<V>.tallyLabel` — the deck tally cell's word (`PITCHES`) beside `label` (the finale's totals and stats keep the full `Huck's Blend pitches`). The cell never cuts a label short: without a `tallyLabel` it shows the `label` if it fits, else the longest run of the label's last words that fits (`Huck's Blend pitches` → `Blend pitches`); a `tallyLabel` that does not fit, or a `label` no run of whose last words fits, is refused by name at check time. Measured as drawn: 13 px capitals, 0.08 em spacing, 112 px, in Fira Sans Bold's advances (or 0.6 em a character in a `fontBold` named Mono) | none yet: `umtool look` | `umtool look <p> factcheck.verdicts.PARTLY.tallyLabel=Pitches` (`=` clears it) | `POST /api/report/timeline {op: "factcheck", factcheck}` | | `render.chrome.factcheck.tally.showAt` — `always` (default: every cell from the first frame, dim at 0) or `first` (a cell hidden until the stamp that gives it its first count lands, then it pops in — scale 0.5→1, 0.35 s, the markers' ease — already reading its count, and stays); one value for every cell, or `{ "<VERDICT>": "first" }` for each on its own (unnamed: `always`). A hidden cell keeps its place in the row; the finale's totals show every verdict as ever | fact-check labels, **pop in** per verdict (every one ticked writes `first`) | `umtool look <p> factcheck.tally.showAt=first`, or one cell: `factcheck.tally.showAt.PARTLY=first` (`factcheck.tally.showAt=` clears it) | same | | `render.chrome.deck.markers[]` — `{after, label ≤ 24, color?, align?}`, at most 12; `align` `auto` `left` `right` `center` | On-screen, **markers**: add, the clip picker, label, colour, align, ↑ ↓, remove | `umtool look <p> deck.markers='[{"after":"c03","label":"Rescue","align":"right"}]'` | `PUT /api/report/chrome {project, token, markers}` | | `render.chrome.deck.<key>` — any of the deck's own keys (`finale`, `pip`, …), as JSON; refused in the build's words when it does not know the key or the value | On-screen settings (the ones it has a field for) | `umtool look <p> deck.finale='{…}'` | — | diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -69,7 +69,7 @@ export const SET_USAGE = [ export const LOOK_USAGE = [ "usage: umtool look <project> key=value … [--json]", " factcheck.stamp.scale (0.5–2) .motion (slam|pop|fade|none) .opacity (0.3–1) .seconds .show .position", - " factcheck.verdicts.<VERDICT>.stampLabel | .label | .color", + " factcheck.verdicts.<VERDICT>.stampLabel | .tallyLabel | .label | .color", " factcheck.tally.showAt (always|first: a cell hidden until its first count lands, then popped in;", " factcheck.tally.showAt.<VERDICT>=first for one cell) .show .position (right|left)", " deck.markers='[{\"after\":\"c01\",\"label\":\"Arrival\",\"align\":\"left\"}]' deck.markerLayout=stagger|truncate", diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs @@ -41,7 +41,7 @@ import { claimsLayout, deckChoreography, deckLayout, deckMarkers, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, resolveDeck, } from "./deck.mjs"; import { claimsCues, claimsMarkup } from "./chrome-claims.mjs"; -import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyOf, tallyPopIns, VERDICT_SHAPES } from "./factcheck.mjs"; +import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyLabelOf, tallyOf, tallyPopIns, VERDICT_SHAPES } from "./factcheck.mjs"; /** * GSAP, vendored, for every chrome region. @@ -492,7 +492,9 @@ export function deckHtml(schedule, render, opts = {}) { (byVerdict ? `<div class="tshape" data-shape="${VERDICT_SHAPES[v]}" style="${shapeCss(VERDICT_SHAPES[v], 12, esc(color))}"></div>` : "") + - `<div class="tlabel">${esc(verdictSet[v].label)}</div>` + + // tallyLabelOf: the cell's own short word, else the label (or its + // last words) that fits -- never an ellipsis. + `<div class="tlabel">${esc(tallyLabelOf(verdictSet[v], { fontBold: render.fontBold ?? null }) ?? verdictSet[v].label)}</div>` + `<div class="tflash" data-k="${tallyKey(v, "flash")}"></div></div>` ); }) diff --git a/umtool/report-to-video/chrome-feed.mjs b/umtool/report-to-video/chrome-feed.mjs @@ -224,6 +224,40 @@ export function feedShotRoom({ heights, shots, column, gap = 16 }) { } /** + * feedShotRoom, and the room a card is left ALONE in: the card under it + * counts only if it stays on screen once this one lands. feedCues pushes it + * down by this card's height (at the cap) and the gap; when that already puts + * it past the column's bottom it leaves anyway, and the picture takes the + * whole column -- the card's full inner width, its height following the + * picture's aspect (upscaled if need be), capped at the column's height. The + * first card is alone too. With a card under it that stays, the room is + * exactly feedShotRoom's. PURE and SELF-CONTAINED (embedded like feedCues). + * + * Only a page with a screenshot carries it (in place of feedShotRoom, which is + * a no-op without one), so a page without one is byte-for-byte what it was and + * its cached render still hits. + * + * @returns {{ imgs: Array<number|null>, heights: number[] }} + */ +export function feedShotLone({ heights, shots, column, gap = 16 }) { + const out = heights.slice(); + const imgs = heights.map(() => null); + for (let j = 0; j < out.length; j += 1) { + const s = shots[j]; + if (!s || !(s.full > s.drawn + 1)) continue; + const chrome = (heights[j] || 0) - s.drawn; + const stays = j > 0 && (heights[j] || 0) + gap + out[j - 1] <= column; + const beside = stays ? out[j - 1] + gap : 0; + const room = Math.floor(column - beside - chrome); + const img = Math.min(Math.round(s.full), room); + if (img <= s.drawn) continue; + imgs[j] = img; + out[j] = chrome + img; + } + return { imgs, heights: out }; +} + +/** * Who the feed is, for its header: the one author's name and platform when * every post is theirs, else "Posts" and every platform there is. */ @@ -267,6 +301,10 @@ export function feedHtml(schedule, render, opts = {}) { const left = deck.posts.position === "top-left"; const c = lay.card; const who = feedWho(posts); + // A picture alone in the column takes all of it (feedShotLone); a page + // without a picture keeps feedShotRoom's text, so its bytes -- and the + // render cache keyed on them -- are what they were. + const anyShot = posts.some((p) => shotSrcs[p.id]); const panel = deck.background === "panel"; // The column's ground meets the deck's top edge in the deck's own colour, @@ -435,7 +473,7 @@ export function feedHtml(schedule, render, opts = {}) { const byK = {}; for (const el of document.querySelectorAll("[data-k]")) byK[el.dataset.k] = el; ${embedFn("feedCues", feedCues)} - ${embedFn("feedShotRoom", feedShotRoom)} + ${anyShot ? embedFn("feedShotLone", feedShotLone) : embedFn("feedShotRoom", feedShotRoom)} const params = new URLSearchParams(location.search); // A window plays the cut's [from, from + dur]; the page is seeked in its own seconds. @@ -485,7 +523,7 @@ export function feedHtml(schedule, render, opts = {}) { const full = (img.parentElement.clientWidth - 2 * F.shotPad) * img.naturalHeight / img.naturalWidth; return { drawn: img.offsetHeight, full }; }); - const room = feedShotRoom({ heights: cards.map((c) => c.offsetHeight), shots, column: F.column, gap: F.motion.gap }); + const room = ${anyShot ? "feedShotLone" : "feedShotRoom"}({ heights: cards.map((c) => c.offsetHeight), shots, column: F.column, gap: F.motion.gap }); room.imgs.forEach((h, j) => { if (h != null) cards[j].querySelector("img.shot").style.maxHeight = h + "px"; }); const heights = cards.map((c) => c.offsetHeight); document.documentElement.dataset.shots = room.imgs.map((h) => h ?? "").join(","); diff --git a/umtool/report-to-video/chrome-feed.test.mjs b/umtool/report-to-video/chrome-feed.test.mjs @@ -11,7 +11,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import test from "node:test"; -import { FEED_MOTION, feedCues, feedHtml, feedLayout, feedShotRoom, feedWho } from "./chrome-feed.mjs"; +import { FEED_MOTION, feedCues, feedHtml, feedLayout, feedShotLone, feedShotRoom, feedWho } from "./chrome-feed.mjs"; import { deckChoreography, deckGeometry, deckSchedule, estimateSchedule, feedGeometry, feedOn, postHolds, postSchedule, postsGeometry, postWindows, validateChrome, validatePosts, @@ -463,11 +463,54 @@ test("feedShotRoom: a tall screenshot grows into the room beside the card under assert.deepEqual(two.imgs, [680, null], "the first takes the empty column; the second has no room past its cap"); }); +test("feedShotLone: a tall picture alone in the column fills the card's width, capped at the column's height", () => { + // The first card, a picture drawn at 290 of a full 470 (chrome 20), column 760: its full-width height. + assert.deepEqual(feedShotLone({ heights: [310], shots: [{ drawn: 290, full: 470 }], column: 760 }).imgs, [470]); + // Upscaled past its natural size if the width asks for it, but never past the column (760 - 20 chrome). + const tall = feedShotLone({ heights: [310], shots: [{ drawn: 290, full: 1400 }], column: 760 }); + assert.deepEqual(tall.imgs, [740]); + assert.deepEqual(tall.heights, [760]); + // The card under it leaves anyway: 310 + 16 + 600 > 760, so feedCues pushes it out as this one + // lands -- the column is this card's, not the 760 - 616 - 20 = 124 feedShotRoom left (no growth). + const alone = { heights: [600, 310], shots: [null, { drawn: 290, full: 470 }], column: 760, gap: 16 }; + assert.deepEqual(feedShotRoom(alone).imgs, [null, null]); + assert.deepEqual(feedShotLone(alone).imgs, [null, 470]); + assert.ok(310 + 16 + 600 > 760, "the card under it is the one feedCues pushes out"); + const plan = feedCues({ posts: [{ id: "a", in: 1 }, { id: "b", in: 5 }], heights: feedShotLone(alone).heights, column: 760 }); + assert.deepEqual(plan.gone, [5, null], "the grown one is alone on screen once it lands"); + // A run of them: each pushes the last out, and each takes the column. + const run = feedShotLone({ heights: [310, 310, 310], shots: [{ drawn: 290, full: 900 }, { drawn: 290, full: 900 }, { drawn: 290, full: 470 }], column: 760 }); + assert.deepEqual(run.imgs, [740, 740, 470]); +}); + +test("feedShotLone: with a card under it that stays, the room is exactly feedShotRoom's", () => { + for (const args of [ + { heights: [200, 310], shots: [null, { drawn: 290, full: 900 }], column: 700, gap: 16 }, + { heights: [200, 310, 280], shots: [null, { drawn: 290, full: 290 }, { drawn: 270, full: 900 }], column: 700 }, + { heights: [150, 120, 310, 140], shots: [null, null, { drawn: 290, full: 520 }, null], column: 760 }, + { heights: [120, 310, 130, 310], shots: [null, { drawn: 290, full: 380 }, null, { drawn: 290, full: 330 }], column: 760 }, + ]) { + assert.deepEqual(feedShotLone(args), feedShotRoom(args), JSON.stringify(args)); + } +}); + +test("the page: one without a screenshot keeps feedShotRoom (its bytes unchanged); one with a screenshot carries feedShotLone", () => { + const plain = page(POSTS).html; + assert.match(plain, /const feedShotRoom = /); + assert.match(plain, /const room = feedShotRoom\(\{ heights/); + assert.doesNotMatch(plain, /feedShotLone/); + const posts = POSTS.map((p) => (p.id === "b" ? { ...p, shot: "shots/b.webp" } : p)); + const shot = page(posts, { shotSrcs: { b: "assets/shot00.webp" } }).html; + assert.match(shot, /const feedShotLone = /); + assert.match(shot, /const room = feedShotLone\(\{ heights/); + assert.doesNotMatch(shot, /feedShotRoom = /); +}); + test("the page: the screenshot rule rides in the page and sizes the pictures before the plan", () => { const posts = POSTS.map((p) => (p.id === "b" ? { ...p, shot: "shots/b.webp" } : p)); const { html } = page(posts, { shotSrcs: { b: "assets/shot00.webp" } }); - assert.match(html, /const feedShotRoom = /); - const grow = html.indexOf("feedShotRoom({"); + assert.match(html, /const feedShotLone = /); + const grow = html.indexOf("feedShotLone({"); const plan = html.indexOf("feedCues({", grow); assert.ok(grow > 0 && plan > grow, "pictures are sized before the stack is planned from the heights"); assert.match(html, /"shotPad":10/); diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -207,7 +207,7 @@ export function validateChrome(chrome, render = {}) { // here too, so a writer that validates the deck refuses a bad one. errors.push(...validateEndFade(render)); // The fact-check stamps and tally (factcheck.mjs): drawn only by the deck. - errors.push(...validateFactcheck(chrome.factcheck)); + errors.push(...validateFactcheck(chrome.factcheck, undefined, { fontBold: render.fontBold ?? null })); // The thread rail (threads.mjs): the deck's layout only, beside the footage. errors.push(...validateThreads(chrome.threads)); // The flips panel (flips.mjs): the same region as the rail, so not both. diff --git a/umtool/report-to-video/factcheck.mjs b/umtool/report-to-video/factcheck.mjs @@ -120,6 +120,69 @@ function unknownKeys(obj, allowed, where, errors) { } } +// --------------------------------------------------------------------------- +// The tally cell's label: it must fit, every time. +// --------------------------------------------------------------------------- + +/** + * The tally cell's label as chrome-deck.mjs sets it: 13 px capitals in the + * deck's bold, letter-spaced 0.08 em, in the cell's width less 6 px a side + * (deck.mjs deckLayout's 124 px cell). The page ellipsizes what overruns, so + * a label is fitted HERE, before the page is written. + */ +export const TALLY_LABEL = Object.freeze({ size: 13, tracking: 0.08, width: 124 - 12 }); + +// Fira Sans Bold's advances (the deck's bold unless a brand sets one), per +// character a capitalised label can hold, in 1/1000 em, rounded UP -- +// measured from /usr/share/fonts/TTF/FiraSans-Bold.ttf. Kerning is not +// counted; the 2 % margin below covers it. +const FIRA_BOLD_CHARS = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~’‘“”…–—ÀÁÂÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÖØÙÚÛÜ"; +const FIRA_BOLD_ADV = "237,240,439,557,549,859,760,238,325,325,449,531,240,407,240,520,585,464,517,520,565,536,564,468,581,560,240,240,519,519,519,481,1020,590,617,575,651,526,487,645,666,293,317,633,513,786,663,691,600,690,617,572,540,651,570,847,581,594,544,324,520,324,559,520,340,324,376,324,514,243,243,448,448,727,520,796,590,590,590,590,590,575,526,526,526,526,293,293,293,293,663,691,691,691,691,691,651,651,651,651"; + +/** + * How wide a tally label draws, px, as the page sets it (upper-cased, the + * cell's size and letter-spacing): Fira Sans Bold's own advances, or 0.6 em a + * character in a monospaced bold (the brand's IBM Plex Mono Bold, `fontBold` + * naming a "Mono" face). Another face, or a character the table lacks, is + * counted at 1.02 em (wider than any capital Fira draws but @), so a label + * called fitting fits. 2 % over the sum, for kerning. + */ +export function tallyLabelWidth(label, { fontBold = null, size = TALLY_LABEL.size } = {}) { + const mono = typeof fontBold === "string" && /mono/i.test(fontBold); + const fira = !fontBold || /fira ?sans[-_ ]?bold/i.test(String(fontBold).split("/").pop() ?? ""); + const adv = FIRA_BOLD_ADV.split(","); + let em = 0; + const chars = [...String(label ?? "").toUpperCase()]; + for (const ch of chars) { + const i = FIRA_BOLD_CHARS.indexOf(ch); + em += mono ? 0.6 : fira && i >= 0 ? Number(adv[i]) / 1000 : 1.02; + em += TALLY_LABEL.tracking; + } + return Math.ceil(em * size * 1.02); +} + +/** + * The words a verdict's tally cell shows (a resolveVerdicts entry): its + * `tallyLabel`, else its `label` when that fits the cell, else the longest run + * of the label's LAST words that does ("Huck's Blend pitches" → "pitches"), + * else null (validateFactcheck refuses it). The finale and the stamp keep + * their own words. + * + * @returns {string|null} + */ +export function tallyLabelOf(v, { fontBold = null } = {}) { + const fits = (s) => tallyLabelWidth(s, { fontBold }) <= TALLY_LABEL.width; + if (typeof v?.tallyLabel === "string" && v.tallyLabel.trim()) return fits(v.tallyLabel.trim()) ? v.tallyLabel.trim() : null; + const label = String(v?.label ?? ""); + if (fits(label)) return label; + const words = label.trim().split(/\s+/); + for (let i = 1; i < words.length; i += 1) { + const tail = words.slice(i).join(" "); + if (fits(tail)) return tail; + } + return null; +} + /** The fact-check settings with every default filled in. */ export function resolveFactcheck(render) { const f = isObj(render?.chrome?.factcheck) ? render.chrome.factcheck : {}; @@ -137,7 +200,7 @@ export function resolveFactcheck(render) { * * @returns {string[]} */ -export function validateFactcheck(f, where = "render.chrome.factcheck") { +export function validateFactcheck(f, where = "render.chrome.factcheck", { fontBold = null } = {}) { if (f === undefined) return []; if (!isObj(f)) return [`${where} must be an object`]; const errors = []; @@ -148,19 +211,35 @@ export function validateFactcheck(f, where = "render.chrome.factcheck") { for (const [k, v] of Object.entries(f.verdicts)) { const w = `${where}.verdicts.${k}`; if (!VERDICTS.includes(k)) { errors.push(`${w} is not a verdict (${VERDICTS.join(", ")})`); continue; } - // `stampLabel` is the video's own (the stamp's word beside the tally's - // `label`); the rest is common's override, checked by common's rule. - if (isObj(v) && v.stampLabel !== undefined) { - const { stampLabel, ...rest } = v; - if (typeof stampLabel !== "string" || !stampLabel.trim()) errors.push(`${w}.stampLabel must be words, not empty`); - else if (/[\r\n]/.test(stampLabel)) errors.push(`${w}.stampLabel must be one line`); - else if (stampLabel.trim().length > VERDICT_LABEL_MAX) { - errors.push(`${w}.stampLabel is ${stampLabel.trim().length} characters (at most ${VERDICT_LABEL_MAX})`); + // `stampLabel` (the stamp's word) and `tallyLabel` (the tally cell's) + // are the video's own, beside the `label` the finale and the report + // read; the rest is common's override, checked by common's rule. + if (isObj(v) && (v.stampLabel !== undefined || v.tallyLabel !== undefined)) { + const { stampLabel, tallyLabel, ...rest } = v; + for (const [key, word] of [["stampLabel", stampLabel], ["tallyLabel", tallyLabel]]) { + if (word === undefined) continue; + if (typeof word !== "string" || !word.trim()) errors.push(`${w}.${key} must be words, not empty`); + else if (/[\r\n]/.test(word)) errors.push(`${w}.${key} must be one line`); + else if (word.trim().length > VERDICT_LABEL_MAX) { + errors.push(`${w}.${key} is ${word.trim().length} characters (at most ${VERDICT_LABEL_MAX})`); + } } errors.push(...verdictOverrideProblems(rest, w)); } else { errors.push(...verdictOverrideProblems(v, w)); } + // The tally cell never ellipsizes: its words fit, or the check says so. + if (isObj(v) && !errors.some((e) => e.startsWith(`${w}.`))) { + if (typeof v.tallyLabel === "string") { + const px = tallyLabelWidth(v.tallyLabel.trim(), { fontBold }); + if (px > TALLY_LABEL.width) { + errors.push(`${w}.tallyLabel "${v.tallyLabel.trim()}" is ${px} px wide in the tally's cell, which has ${TALLY_LABEL.width} px: shorten it`); + } + } else if (typeof v.label === "string" && tallyLabelOf(v, { fontBold }) === null) { + const px = tallyLabelWidth(v.label, { fontBold }); + errors.push(`${w}.label "${v.label.trim()}" is ${px} px wide in the tally's cell, which has ${TALLY_LABEL.width} px, and no run of its last words fits: set ${w}.tallyLabel to a shorter word`); + } + } } } } diff --git a/umtool/report-to-video/factcheck.test.mjs b/umtool/report-to-video/factcheck.test.mjs @@ -12,7 +12,7 @@ import test from "node:test"; import { claimOf, FACTCHECK_DEFAULTS, FACTCHECK_LIMITS, normalizeClaim, originalUrlAt, resolveFactcheck, roundStamps, STAMP_MOTION, stampSchedule, - TALLY_POP, tallyCues, tallyOf, tallyPopIns, tallyShowAt, tallySteps, tallyVerdicts, validateClaims, validateFactcheck, VERDICTS, + TALLY_LABEL, TALLY_POP, tallyCues, tallyLabelOf, tallyLabelWidth, tallyOf, tallyPopIns, tallyShowAt, tallySteps, tallyVerdicts, validateClaims, validateFactcheck, VERDICTS, } from "./factcheck.mjs"; import { VERDICT_DEFAULTS, VERDICT_LABEL_MAX, VERDICTS as COMMON_VERDICTS, @@ -469,3 +469,43 @@ for (let i = 1; i <= Math.round(dur * fps); i += 1) writeFileSync(out + "/frame_ rmSync(dir, { recursive: true, force: true }); } }); + +test("the tally cell's label always fits: a tallyLabel, else the label, else its last words; refused by name when none fits", () => { + // The cell's width is deckLayout's cell less 6 px a side. + assert.equal(TALLY_LABEL.width, deckLayout(RENDER, { tally: ["PARTLY"] }).tally.cell - 12); + // Every stock label fits as it is (Fira Sans Bold and the brand's mono bold). + for (const v of VERDICTS) { + assert.equal(tallyLabelOf(resolveFactcheck(RENDER).verdicts[v]), VERDICT_DEFAULTS[v].label, v); + assert.equal(tallyLabelOf(resolveFactcheck(RENDER).verdicts[v], { fontBold: "fonts/IBMPlexMono-Bold.ttf" }), VERDICT_DEFAULTS[v].label, v); + } + // The widest stock label, against Fira Sans Bold's own advances (107.9 px at 13 px, 0.08 em). + assert.ok(tallyLabelWidth("Corroborated") >= 108 && tallyLabelWidth("Corroborated") <= TALLY_LABEL.width); + // A long label with no tallyLabel: its last words that fit. + assert.ok(tallyLabelWidth("Huck's Blend pitches") > TALLY_LABEL.width); + assert.equal(tallyLabelOf({ label: "Huck's Blend pitches" }), "Blend pitches"); + assert.equal(tallyLabelOf({ label: "Huck's Blend Coffee pitches" }), "Coffee pitches"); + assert.equal(tallyLabelOf({ label: "Huck's Blend Coffee Superpitches" }), "Superpitches"); + assert.equal(tallyLabelOf({ label: "Huck's Blend pitches", tallyLabel: " Pitches " }), "Pitches"); + assert.deepEqual(validateFactcheck({ verdicts: { PARTLY: { label: "Huck's Blend pitches" } } }), []); + assert.deepEqual(validateFactcheck({ verdicts: { PARTLY: { label: "Huck's Blend pitches", tallyLabel: "Pitches" } } }), []); + // A tallyLabel that does not fit, or a label no run of whose last words fits: refused by name. + assert.match(validateFactcheck({ verdicts: { PARTLY: { tallyLabel: "Blend pitches galore" } } })[0], + /^render\.chrome\.factcheck\.verdicts\.PARTLY\.tallyLabel "Blend pitches galore" is \d+ px wide in the tally's cell, which has 112 px: shorten it$/); + assert.match(validateFactcheck({ verdicts: { PARTLY: { label: "Misrepresentations" } } })[0], + /verdicts\.PARTLY\.label "Misrepresentations" is \d+ px wide .* set render\.chrome\.factcheck\.verdicts\.PARTLY\.tallyLabel/); + assert.match(validateFactcheck({ verdicts: { PARTLY: { tallyLabel: "" } } })[0], /tallyLabel must be words/); + // validateChrome measures in the render's own bold (here the brand's mono). + const mono = { ...RENDER, fontBold: "/x/IBMPlexMono-Bold.ttf", chrome: { ...CHROME, factcheck: { verdicts: { PARTLY: { tallyLabel: "Pitches" } } } } }; + assert.deepEqual(validateChrome(mono.chrome, mono), []); +}); + +test("the tally: a page whose labels fit is byte-for-byte what it was, a long one is drawn shortened", () => { + const s = sched(); + const html = deckHtml(s, RENDER, {}); + assert.match(html, /<div class="tlabel">Partly true<\/div>/); + assert.match(html, /<div class="tlabel">Contradicted<\/div>/); + const long = { ...RENDER, chrome: { ...CHROME, factcheck: { verdicts: { PARTLY: { label: "Huck's Blend Coffee pitches" } } } } }; + const longHtml = deckHtml(sched(long), long, {}); + assert.match(longHtml, /<div class="tlabel">Coffee pitches<\/div>/); + assert.doesNotMatch(longHtml, /class="tlabel">Huck/); +}); diff --git a/umtool/report-to-video/finale.test.mjs b/umtool/report-to-video/finale.test.mjs @@ -216,3 +216,15 @@ test("byte identity: no finale entry -- the schedule and the deck page are as th // An estimate carries the finale as the build's schedule does. assert.ok(estimateSchedule({ render: withSettings, timeline: clips(), provenance: PROV }).finale); }); + +test("tallyLabel: the deck's tally cell shows it, the finale's totals keep the full label", () => { + const r = renderWith({ finale: { stats: STATS } }); + r.chrome.factcheck.verdicts.CONTRADICTED = { label: "Huck's Blend pitches", tallyLabel: "Pitches", color: "#e3b23c" }; + assert.deepEqual(validateChrome(r.chrome, r), []); + const s = sched(clips(), r); + const deck = deckHtml(s, r, {}); + assert.match(deck, /<div class="tlabel">Pitches<\/div>/); + assert.doesNotMatch(deck, /class="tlabel">Huck/); + const totals = finaleLayout(s, r).totals; + assert.deepEqual(totals.map((t) => t.label).sort(), ["Huck's Blend pitches", "Seizure episodes"]); +});