Archilyzer · Source

archilyzer

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

commit 372acc1e90a39c8a665caca0c7e2b351dcc356b4
parent ad8e6ac22ff610792528eac8451af3965635d2f0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 26 Oct 2026 10:06:21 -0400

Merge lane/tally-pop: factcheck.tally.showAt always|first|{VERDICT:first} -- a tally cell pops in on its first count

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

Diffstat:
Meditor/CHANGELOG.md | 1+
Mumtool/components/projects/StructureEditors.tsx | 22++++++++++++++++++++--
Mumtool/docs/knobs.md | 1+
Mumtool/docs/report-video.md | 5++++-
Mumtool/e2e/timeline-edit.spec.ts | 12++++++++++++
Mumtool/lib/report/knobsCli.mjs | 4+++-
Mumtool/lib/report/knobsCli.test.mjs | 9+++++++++
Mumtool/report-to-video/README.md | 13++++++++++++-
Mumtool/report-to-video/chrome-deck.mjs | 9++++++---
Mumtool/report-to-video/factcheck.mjs | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mumtool/report-to-video/factcheck.test.mjs | 78+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
11 files changed, 210 insertions(+), 17 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **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. - **An assistant can finish a report video from umtool's command line without hand fixes.** `umtool variants <project> --take <take>` now makes the delivery ladder (master, 1080p, 720p, fit24) of a finished take, and so does the Deliver tab's **Make variants** with a take picked. A take used to be refused with "has no build to make variants of" because its render was moved to `takes/<take>/preview.mp4`; the take maker now also leaves it in the take's `out/` under the build's name (a hard link, so no extra disk), and a take made before this is encoded from its `preview.mp4`. `umtool timeline <project> insert` writes a clip the way the rest of the cut is written: in a cut with the on-screen deck, `--title` sets the deck's title (`onscreen.title`; `--stream-title` sets the stream's), a cut whose deck titles are dates gets `--date` as one in the same format (`9 Dec 2024`), the clip takes the section of the clip it goes after unless `--section N` says otherwise, and `--lock` and `--lock-end` lock its edges. `umtool check` now says how to fix a clip with no cue file: `pnpm ops build-cues --json '{"slug":"<channel>","ids":["<video>"]}' --wait` when the video is in the archive, and the Rumble two-ids check when it is not. A take of part of a cut says in its log what timed the window: the last build's schedule, or the clips' own lengths when there is no schedule or it does not time clips inserted since the build. - **A streaming channel can fetch its live chats after its downloads, by itself.** A stream's chat replay (7–42 MB) came down with its captions and made each YouTube download 2–4× slower while the Ethanalyzer backlog was archived; the fix was a hand edit of `subLangs` and a hand-written watcher that ran `pnpm ops fetch-chat` per streamed episode once the downloads were done — and died on reboot. Configure → **Live chat replay** (`chat`: with the download, Later or Never): with Later the downloads leave the chat out and, once the channel has nothing left to download, the download lane queues one paced **Fetch chat backlog** job for every stream (by its metadata) whose chat is not here, 25 at a time, skipping what landed and the streams known to have none, and resumed after a restart. The Download stage has the button; `pnpm ops fetch-chat-backlog {slug, dryRun?, limit?}` runs it by hand. **Caption languages** (`subLangs`) is a Configure field and a `channel-config` patch key now. Needs a restart of the editor. - **What an import adds is work for the lanes at once, not when the import ends.** On 2026-10-26 an archive.org import added 64 recordings over several hours while the channel's report still listed the 32 it had at 01:10; the transcription lane reads its work from that report, so the 64 waited untranscribed and the GPU went to another site's backlog, and `pnpm ops transcribe-bucket` answered "64 of ids not in the downloadedNoTranscript bucket". An archive.org import, an attach of local media and a persist now regenerate the channel's report as items land (the first at once, then at least every 10 items or 2 minutes), and `transcribe-bucket` regenerates a report that is behind the disk before it answers. Needs a restart of the editor. diff --git a/umtool/components/projects/StructureEditors.tsx b/umtool/components/projects/StructureEditors.tsx @@ -21,7 +21,7 @@ type Doc = { posts: Post[]; deckOn: boolean; factcheck: { verdicts?: Record<string, Partial<Verdict>>; stamp?: Record<string, unknown>; tally?: Record<string, unknown> } | null; - factcheckResolved: { verdicts: Record<string, Verdict>; stamp: { show: boolean; seconds: number; position: string }; tally: { show: boolean; position: string } }; + factcheckResolved: { verdicts: Record<string, Verdict>; stamp: { show: boolean; seconds: number; position: string }; tally: { show: boolean; position: string; showAt?: string | Record<string, string> } }; verdicts: string[]; /** The stamp's knobs (video knobs): defaults, bounds, the motions. */ stampKnobs?: { defaults: { scale: number; motion: string; opacity: number }; limits: { scale: number[]; opacity: number[] }; motions: string[] }; @@ -273,6 +273,14 @@ function FactcheckEditor({ doc, busy, save }: { doc: Doc; busy: boolean; save: ( const [seconds, setSeconds] = useState(given.stamp?.seconds == null ? "" : String(given.stamp.seconds)); // `stamp.show`: off draws no stamp over the footage; the tally still counts. const [stampOn, setStampOn] = useState(given.stamp?.show !== false); + // `tally.showAt`: each verdict's cell hidden until its first count lands, then popped in + // ("first"); unticked, shown from the start (the default). Every verdict ticked writes "first". + const [popIn, setPopIn] = useState<Record<string, boolean>>(() => { + const at = given.tally?.showAt; + return Object.fromEntries( + doc.verdicts.map((k) => [k, at === "first" || (!!at && typeof at === "object" && (at as Record<string, unknown>)[k] === "first")]), + ); + }); const submit = () => { const verdicts: Record<string, Record<string, string>> = {}; for (const [k, o] of Object.entries(v)) { @@ -299,12 +307,19 @@ function FactcheckEditor({ doc, busy, save }: { doc: Doc; busy: boolean; save: ( else delete stamp.motion; if (Object.keys(stamp).length) out.stamp = stamp; else delete out.stamp; + const tally = { ...(given.tally ?? {}) } as Record<string, unknown>; + const popped = doc.verdicts.filter((k) => popIn[k]); + if (!popped.length) delete tally.showAt; + else if (popped.length === doc.verdicts.length) tally.showAt = "first"; + else tally.showAt = Object.fromEntries(popped.map((k) => [k, "first"])); + if (Object.keys(tally).length) out.tally = tally; + else delete out.tally; void save(Object.keys(out).length ? out : null); }; return ( <div data-testid="factcheck-editor" className="space-y-1 rounded border border-[var(--color-line)] p-2 text-[11px]"> <div className="micro">fact-check labels</div> - <div className="grid grid-cols-[max-content_1fr_max-content_max-content] items-center gap-x-2 gap-y-1"> + <div className="grid grid-cols-[max-content_1fr_max-content_max-content_max-content] items-center gap-x-2 gap-y-1"> {doc.verdicts.map((k) => { const def = doc.factcheckResolved.verdicts[k]; return ( @@ -324,6 +339,9 @@ function FactcheckEditor({ doc, busy, save }: { doc: Doc; busy: boolean; save: ( onChange={(e) => setV((x) => ({ ...x, [k]: { ...x[k], stampLabel: e.target.value } }))} className={`${input} w-28`} /> + <label className="flex items-center gap-1 text-[var(--color-dim)]" title="the tally's cell for this verdict: hidden until its first count lands, then it pops in; unticked, it shows from the start (at 0)"> + <input type="checkbox" data-testid={`fc-tally-first-${k}`} checked={!!popIn[k]} onChange={(e) => setPopIn((x) => ({ ...x, [k]: e.target.checked }))} /> pop in + </label> </div> ); })} 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.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='{…}'` | — | | `render.chrome.deck.markerLayout` — `stagger` or `truncate` when labels crowd (default: stagger only when a label would truncate) | markers, **layout** | `deck.markerLayout=truncate` | `PUT /api/report/chrome {project, token, markerLayout}` | diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -368,7 +368,9 @@ claimed clip's pip lit in its claim's verdict colour and shape) and **qr codes** under posts (`posts.qr`: off draws no QR on any post card, popup or feed). The fact-check form beside the structure editors has **stamp effect** (`factcheck.stamp.show`: off draws no stamp over the footage; the tally still -counts). `deck.markers` — flags on the pip track, `[{ after, label, color? }]` +counts) and, per verdict, **pop in** (`factcheck.tally.showAt`: the tally's cell +hidden until its first count lands, then popped in; every verdict ticked writes +`"first"`, some `{ <VERDICT>: "first" }`, none removes the key). `deck.markers` — flags on the pip track, `[{ after, label, color? }]` ([the pipeline's README](../report-to-video/README.md#deckmarkers--flags-on-the-pip-track)) — has no form: write them in the manifest. A settings save carries them through, with the fact-check block and the other regions (threads, flips, @@ -392,6 +394,7 @@ and default. | | `motion` | slam/pop/fade/none · slam | its entrance | | | `opacity` | 0.3–1 · 1 | | | `render.chrome.factcheck.verdicts.<V>` | `stampLabel` | ≤ 24 chars · its `label` | the stamp's word beside the tally's | +| `render.chrome.factcheck.tally` | `showAt` | always/first, or `{ <VERDICT>: always/first }` · always | first: a cell hidden until its first count lands, then popped in | | a clip's `audio` | `offset` | −2000–2000 ms · 0 | + = sound later | | | `gain` | −20–20 dB · 0 | | | | `fadeIn`, `fadeOut` | 0–5 s · 0 | | diff --git a/umtool/e2e/timeline-edit.spec.ts b/umtool/e2e/timeline-edit.spec.ts @@ -144,4 +144,16 @@ test("a post added, then removed; the fact-check's labels once the deck is on", await expect .poll(() => (manifest().render.chrome as { factcheck?: unknown }).factcheck) .toEqual({ verdicts: { CONTRADICTED: { label: "NOPE", color: "#ff0000" } }, stamp: { show: false } }); + + // A tally cell that pops in on its first count (tally.showAt): one verdict's, then every one's. + await page.getByTestId("fc-tally-first-PARTLY").check(); + await page.getByTestId("fc-save").click(); + await expect + .poll(() => ((manifest().render.chrome as { factcheck?: { tally?: unknown } }).factcheck ?? {}).tally) + .toEqual({ showAt: { PARTLY: "first" } }); + for (const v of ["CORROBORATED", "CONTRADICTED", "NOT_FOUND", "UNTESTABLE"]) await page.getByTestId(`fc-tally-first-${v}`).check(); + await page.getByTestId("fc-save").click(); + await expect + .poll(() => ((manifest().render.chrome as { factcheck?: { tally?: unknown } }).factcheck ?? {}).tally) + .toEqual({ showAt: "first" }); }); diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -11,7 +11,7 @@ // audio.offset audio.gain audio.fadeIn audio.fadeOut // blur.on blur.caption blur.strength blur.from blur.to // (`blur.on=` clears the whole blur; report-to-video clip-blur.mjs) -// umtool look <project> key=value … factcheck.stamp.<k>, factcheck.verdicts.<V>.<k>, +// umtool look <project> key=value … factcheck.stamp.<k>, factcheck.verdicts.<V>.<k>, factcheck.tally.<k>, // deck.markers=<json>, deck.markerLayout=…, deck.claims=<json>, variants=<json>, // and the look's keys (transition=0.3, …) // umtool variants <project> [--take <t>] [--list] [--json] make the encode ladder (or list it) @@ -70,6 +70,8 @@ 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.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", " deck.<key>=<json>: any of the deck's own keys (deck.finale='{…}', deck.pip='{…}', …), checked by the build's rules", " variants='[{\"name\":\"master\"},{\"name\":\"720p\",\"height\":720,\"crf\":23},{\"name\":\"fit24\",\"maxMiB\":24}]'", diff --git a/umtool/lib/report/knobsCli.test.mjs b/umtool/lib/report/knobsCli.test.mjs @@ -96,6 +96,15 @@ test("umtool look: the fact-check's stamp, a verdict's stamp word, markers, layo assert.equal(m.render.transition, 0.3); assert.equal(await run("look", "factcheck.stamp.motion=spin"), 1); assert.match(lines.at(-1), /stamp\.motion/); + // The tally's cells on their first count: for every cell, or one verdict's; an unknown value refused by name. + assert.equal(await run("look", "factcheck.tally.showAt=first"), 0, lines.join("\n")); + assert.deepEqual((await read(dir)).render.chrome.factcheck.tally, { showAt: "first" }); + assert.equal(await run("look", "factcheck.tally.showAt.PARTLY=first"), 0, lines.join("\n")); + assert.deepEqual((await read(dir)).render.chrome.factcheck.tally, { showAt: { PARTLY: "first" } }); + assert.equal(await run("look", "factcheck.tally.showAt=later"), 1); + assert.match(lines.at(-1), /tally\.showAt must be "always" or "first"/); + assert.equal(await run("look", "factcheck.tally.showAt="), 0); + assert.equal("tally" in ((await read(dir)).render.chrome.factcheck ?? {}), false); // Any of the deck's own keys, checked by the build's rules (an unknown one is refused in its words). assert.equal(await run("look", 'deck.pip={"color":"verdict"}'), 0, lines.join("\n")); assert.deepEqual((await read(dir)).render.chrome.deck.pip, { color: "verdict" }); diff --git a/umtool/report-to-video/README.md b/umtool/report-to-video/README.md @@ -441,7 +441,7 @@ whatever a manifest omits, one level deep: "factcheck": { // the fact-check stamps and tally (below); every key optional "verdicts": { "PARTLY": { "label": "Partly true", "color": "#e3b23c" } }, // per verdict: label ≤ 24 characters, a #rgb/#rrggbb colour "stamp": { "show": true, "seconds": 3, "position": "top-left" }, // show false: no stamp drawn, the tally still counts; seconds 1–10; top-left | top-right | bottom-left | bottom-right | center - "tally": { "show": true, "position": "right" } // position "right" (beside the QR) | "left" (before the title) + "tally": { "show": true, "position": "right", "showAt": "always" } // position "right" (beside the QR) | "left" (before the title); showAt "always" | "first" | { "<VERDICT>": "first" } }, "stats": { // a frame scan's running numbers over each clip (below); every key optional "position": "bottom-left", // top-left | top-right | bottom-left | bottom-right @@ -715,6 +715,17 @@ build fetches — umtool's writer refuses with the same function. flashes — at the moment its stamp lands; a cell is dim until its first. It is part of the deck's panel, so it slides away over a card with it, and the title's column gives it its room only in a cut that stamps something. +- **A cell on its first count (`tally.showAt`).** `"always"` (the default) is + the tally above. `"first"`: a cell is HIDDEN, not dim, until the stamp that + gives it its first count lands; then it pops in (`TALLY_POP`: scale 0.5 → 1 + and transparent → opaque over 0.35 s on `back.out(2.2)`, the markers' pop), + already reading that count — no 0 rolls out — and its flash fires; later + steps roll as ever and it stays to the end. `{ "PARTLY": "first" }` sets one + cell's (a verdict not named is `"always"`). A hidden cell keeps its place in + the row (the deck is laid for every cell the cut stamps), so nothing else + moves when it arrives. The finale's totals show every verdict, as ever. + The cues are `tallyCues(stamps, verdicts, { popIn })`; umtool's previews + load the same deck page, so they pop where the render does. - **The schedule.** A stamped segment carries `claim`, and `schedule.json` gains `factcheck: { stamps: [{ claim, verdict, segment, at, landed, out }] }` (`stampSchedule`) — only when a claim is stamped, so a cut without one 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, VERDICT_SHAPES } from "./factcheck.mjs"; +import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyOf, tallyPopIns, VERDICT_SHAPES } from "./factcheck.mjs"; /** * GSAP, vendored, for every chrome region. @@ -262,9 +262,12 @@ export function deckCues(schedule, render) { } // The fact-check tally (factcheck.mjs): its cells' counts step as each - // stamp lands. Part of the panel, so it slides away and back with it. + // stamp lands. Part of the panel, so it slides away and back with it. A + // cell with `tally.showAt: "first"` is hidden until its first count lands, + // then pops in; it keeps its place in the row (the deck is laid for every + // cell), so nothing else moves when it does. if (tally) { - const t = tallyCues(schedule.factcheck.stamps, tally); + const t = tallyCues(schedule.factcheck.stamps, tally, { popIn: tallyPopIns(render, tally) }); for (const [k, v] of Object.entries(t.init)) put(k, v); for (const e of t.events) add(e.k, e.at, e.dur, e.to, e.ease, e.why); } diff --git a/umtool/report-to-video/factcheck.mjs b/umtool/report-to-video/factcheck.mjs @@ -18,7 +18,7 @@ // render.chrome: "factcheck": { "verdicts": { "PARTLY": { "label": "Half true", "stampLabel": "Half" } }, // "stamp": { "show": true, "seconds": 3, "position": "top-left", // "scale": 1, "motion": "slam", "opacity": 1 }, -// "tally": { "show": true, "position": "right" } } +// "tally": { "show": true, "position": "right", "showAt": "always" } } // // `claim` is its own key: an entry's `verdict` is the clip review's // ("confirmed" / "incorrect"), a ruling on the CUT, not on what was said. @@ -56,6 +56,15 @@ export const STAMP_MOTIONS = Object.freeze(["slam", "pop", "fade", "none"]); export const TALLY_POSITIONS = Object.freeze(["right", "left"]); /** + * When a tally cell is on screen: "always" (from the first frame, dim at 0 -- + * as ever), or "first" (hidden until the stamp that gives it its first count + * lands, then popped in, and on for the rest of the cut). `tally.showAt` is + * one of these for every cell, or `{ <VERDICT>: … }` for each cell on its own + * (a verdict it does not name is "always"). + */ +export const TALLY_SHOW_AT = Object.freeze(["always", "first"]); + +/** * Every fact-check setting and its default. A manifest names only what it * changes; `resolveFactcheck` fills the rest, a verdict's label and colour * each on its own. The stamp's default corner is the one the popup posts @@ -68,7 +77,7 @@ export const FACTCHECK_DEFAULTS = Object.freeze({ // `scale` sizes the stamp's region (and so the stamp), `motion` is how it // comes in, `opacity` the whole stamp's. stamp: Object.freeze({ show: true, seconds: 3, position: "top-left", scale: 1, motion: "slam", opacity: 1 }), - tally: Object.freeze({ show: true, position: "right" }), + tally: Object.freeze({ show: true, position: "right", showAt: "always" }), }); /** The limits: a stamp's seconds on screen, a label's characters. */ @@ -176,11 +185,21 @@ export function validateFactcheck(f, where = "render.chrome.factcheck") { const [olo, ohi] = FACTCHECK_LIMITS.opacity; if (s.opacity !== undefined && !numIn(s.opacity, olo, ohi)) errors.push(`${where}.stamp.opacity must be from ${olo} to ${ohi}`); }); - sub("tally", ["show", "position"], (t) => { + sub("tally", ["show", "position", "showAt"], (t) => { if (t.show !== undefined && typeof t.show !== "boolean") errors.push(`${where}.tally.show must be true or false`); if (t.position !== undefined && !TALLY_POSITIONS.includes(t.position)) { errors.push(`${where}.tally.position must be ${TALLY_POSITIONS.map((p) => `"${p}"`).join(" or ")}`); } + const when = TALLY_SHOW_AT.map((w) => `"${w}"`).join(" or "); + if (t.showAt === undefined) return; + if (isObj(t.showAt)) { + for (const [k, w] of Object.entries(t.showAt)) { + if (!VERDICTS.includes(k)) errors.push(`${where}.tally.showAt.${k} is not a verdict (${VERDICTS.join(", ")})`); + else if (!TALLY_SHOW_AT.includes(w)) errors.push(`${where}.tally.showAt.${k} must be ${when}`); + } + } else if (!TALLY_SHOW_AT.includes(t.showAt)) { + errors.push(`${where}.tally.showAt must be ${when}, or { <VERDICT>: ${when} }`); + } }); return errors; } @@ -572,6 +591,33 @@ export function tallyOf(schedule, render) { return tallyVerdicts(stamps); } +/** + * Each verdict's `tally.showAt`, resolved: "always" or "first" for every + * verdict (the one value for all, or each its own; unnamed is "always"). + * + * @returns {Record<string, "always" | "first">} + */ +export function tallyShowAt(render) { + const w = resolveFactcheck(render).tally.showAt; + const one = (v) => (TALLY_SHOW_AT.includes(v) ? v : "always"); + return Object.fromEntries(VERDICTS.map((v) => [v, isObj(w) ? one(w[v]) : one(w)])); +} + +/** + * The tally cells that POP IN on their first count (`tally.showAt: "first"`), + * of the cells `verdicts` the tally shows: none by default. + */ +export function tallyPopIns(render, verdicts) { + const at = tallyShowAt(render); + return (verdicts ?? []).filter((v) => at[v] === "first"); +} + +/** + * A popped-in tally cell's motion: from this scale and hidden to full size + * over `seconds`, on the deck's marker ease, starting as the stamp lands. + */ +export const TALLY_POP = Object.freeze({ from: 0.5, seconds: 0.35, ease: "back.out(2.2)" }); + /** A tally cell's element keys, shared by the page and its cues. */ export const tallyKey = (verdict, part = null) => (part === null ? `ty.${verdict}` : `ty.${verdict}.${part}`); @@ -584,25 +630,40 @@ export const tallyKey = (verdict, part = null) => (part === null ? `ty.${verdict * on it rolls up and out and the next rolls up in, and the cell's flash * (`ty.<V>.flash`) fires. Absolute times, the cut's clock. * + * A cell in `popIn` (`tally.showAt: "first"`, tallyPopIns) is hidden -- not + * dim -- until its first step: as that stamp lands it pops in (TALLY_POP) + * already reading its count, no 0 rolling out, and its flash fires as any + * step's does. Its later steps roll as ever. With `popIn` empty the cues are + * exactly what they were before the knob. + * * @returns {{ init: Record<string, object>, events: Array<{ k: string, at: number, dur: number, * to: object, ease: string, why: string }> }} */ -export function tallyCues(stamps, verdicts = tallyVerdicts(stamps)) { +export function tallyCues(stamps, verdicts = tallyVerdicts(stamps), { popIn = [] } = {}) { const steps = tallySteps(stamps); const finals = Object.fromEntries(verdicts.map((v) => [v, 0])); for (const s of steps) finals[s.verdict] = s.count; + const pops = new Set(popIn.filter((v) => verdicts.includes(v))); const init = {}; for (const v of verdicts) { - init[tallyKey(v)] = { opacity: 0.42 }; + init[tallyKey(v)] = pops.has(v) ? { autoAlpha: 0, scale: TALLY_POP.from } : { opacity: 0.42 }; init[tallyKey(v, "flash")] = { opacity: 0 }; for (let k = 0; k <= finals[v]; k += 1) { - init[tallyKey(v, `n${k}`)] = k === 0 ? { yPercent: 0, autoAlpha: 1 } : { yPercent: 100, autoAlpha: 0 }; + // A popped-in cell never shows its 0: it arrives on its first count. + init[tallyKey(v, `n${k}`)] = k === 0 && !pops.has(v) ? { yPercent: 0, autoAlpha: 1 } : { yPercent: 100, autoAlpha: 0 }; } } const m = STAMP_MOTION; const events = []; for (const s of steps) { const why = `tally ${s.verdict} ${s.count}`; + if (s.count === s.step && pops.has(s.verdict)) { + events.push({ k: tallyKey(s.verdict), at: s.at, dur: TALLY_POP.seconds, to: { autoAlpha: 1, scale: 1 }, ease: TALLY_POP.ease, why: `${why} pop` }); + events.push({ k: tallyKey(s.verdict, `n${s.count}`), at: s.at, dur: 0, to: { yPercent: 0, autoAlpha: 1 }, ease: "none", why }); + events.push({ k: tallyKey(s.verdict, "flash"), at: s.at, dur: m.flashUp, to: { opacity: 1 }, ease: "none", why }); + events.push({ k: tallyKey(s.verdict, "flash"), at: s.at + m.flashUp, dur: m.flashDown, to: { opacity: 0 }, ease: "power2.out", why }); + continue; + } if (s.count === s.step) events.push({ k: tallyKey(s.verdict), at: s.at, dur: 0.2, to: { opacity: 1 }, ease: "power1.out", why }); events.push({ k: tallyKey(s.verdict, `n${s.count - s.step}`), at: s.at, dur: m.roll, to: { yPercent: -100, autoAlpha: 0 }, ease: "power2.in", why }); events.push({ k: tallyKey(s.verdict, `n${s.count}`), at: s.at, dur: m.roll, to: { yPercent: 0, autoAlpha: 1 }, ease: "power3.out", why }); 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, - tallyCues, tallyOf, tallySteps, tallyVerdicts, validateClaims, validateFactcheck, VERDICTS, + TALLY_POP, tallyCues, tallyOf, tallyPopIns, tallyShowAt, tallySteps, tallyVerdicts, validateClaims, validateFactcheck, VERDICTS, } from "./factcheck.mjs"; import { VERDICT_DEFAULTS, VERDICT_LABEL_MAX, VERDICTS as COMMON_VERDICTS, @@ -95,7 +95,7 @@ test("resolveFactcheck: every default, a verdict's label and colour filled on th assert.deepEqual(resolveFactcheck(RENDER), { verdicts: Object.fromEntries(VERDICTS.map((v) => [v, { ...FACTCHECK_DEFAULTS.verdicts[v] }])), stamp: { show: true, seconds: 3, position: "top-left", scale: 1, motion: "slam", opacity: 1 }, - tally: { show: true, position: "right" }, + tally: { show: true, position: "right", showAt: "always" }, }); const f = resolveFactcheck({ chrome: { ...CHROME, factcheck: { verdicts: { PARTLY: { label: "Half true" } }, stamp: { seconds: 5 } } } }); assert.deepEqual(f.verdicts.PARTLY, { label: "Half true", color: FACTCHECK_DEFAULTS.verdicts.PARTLY.color }); @@ -109,9 +109,18 @@ test("validateChrome refuses a bad factcheck block in sentences, unknown keys in factcheck: { verdicts: { CORROBORATED: { label: "Holds up", color: "#0a0" } }, stamp: { seconds: 2.5, position: "center" }, - tally: { show: false, position: "left" }, + tally: { show: false, position: "left", showAt: "first" }, }, }, RENDER), []); + assert.deepEqual(validateChrome({ ...CHROME, factcheck: { tally: { showAt: { PARTLY: "first", CORROBORATED: "always" } } } }, RENDER), []); + // showAt: an unknown value, or an unknown verdict, refused by name. + assert.deepEqual(validateFactcheck({ tally: { showAt: "later" } }), [ + 'render.chrome.factcheck.tally.showAt must be "always" or "first", or { <VERDICT>: "always" or "first" }', + ]); + assert.deepEqual(validateFactcheck({ tally: { showAt: { MAYBE: "first", PARTLY: "soon" } } }), [ + "render.chrome.factcheck.tally.showAt.MAYBE is not a verdict (CORROBORATED, PARTLY, CONTRADICTED, NOT_FOUND, UNTESTABLE)", + 'render.chrome.factcheck.tally.showAt.PARTLY must be "always" or "first"', + ]); const errs = validateChrome({ ...CHROME, factcheck: { @@ -251,6 +260,69 @@ test("the deck draws the tally: cells for the verdicts the cut uses, the text co assert.ok(deckCues(s, off).cues.every((c) => !c.k.startsWith("ty."))); }); +test("tally.showAt: one value for every cell, or each cell its own; unnamed is always", () => { + const withTally = (tally) => ({ ...RENDER, chrome: { ...CHROME, factcheck: { tally } } }); + assert.deepEqual(Object.values(tallyShowAt(RENDER)), VERDICTS.map(() => "always")); + assert.deepEqual(Object.values(tallyShowAt(withTally({ showAt: "first" }))), VERDICTS.map(() => "first")); + const one = tallyShowAt(withTally({ showAt: { PARTLY: "first" } })); + assert.equal(one.PARTLY, "first"); + assert.equal(one.CONTRADICTED, "always"); + assert.deepEqual(tallyPopIns(RENDER, ["PARTLY", "CONTRADICTED"]), []); + assert.deepEqual(tallyPopIns(withTally({ showAt: { PARTLY: "first" } }), ["PARTLY", "CONTRADICTED"]), ["PARTLY"]); +}); + +test("tally.showAt first: a cell is hidden until its first stamp lands, pops in reading its count, and stays", () => { + const s = sched(); + const stamps = s.factcheck.stamps; + const firstLanding = (v) => Math.min(...stamps.filter((x) => x.verdict === v).map((x) => x.landed)); + const always = deckCues(s, RENDER); + const first = { ...RENDER, chrome: { ...CHROME, factcheck: { tally: { showAt: "first" } } } }; + const { init, cues } = deckCues(s, first); + for (const v of ["PARTLY", "CONTRADICTED"]) { + const k = `ty.${v}`; + // Hidden, not dim, from the first frame; its 0 never shows. + assert.deepEqual(init[k], { autoAlpha: 0, scale: TALLY_POP.from }); + assert.deepEqual(init[`${k}.n0`], { yPercent: 100, autoAlpha: 0 }); + // Its one appearance: the pop, at the second its first stamp lands, and nothing hides it again. + const own = cues.filter((c) => c.k === k); + assert.equal(own.length, 1, `${k}: ${JSON.stringify(own)}`); + assert.equal(own[0].at, firstLanding(v)); + assert.deepEqual(own[0].from, { autoAlpha: 0, scale: TALLY_POP.from }); + assert.deepEqual(own[0].to, { autoAlpha: 1, scale: 1 }); + assert.equal(own[0].dur, TALLY_POP.seconds); + assert.equal(own[0].ease, TALLY_POP.ease); + // It arrives reading its first count, and the flash fires with it. + const n1 = cues.filter((c) => c.k === `${k}.n1`); + assert.equal(n1[0].at, firstLanding(v)); + assert.deepEqual(n1[0].to, { yPercent: 0, autoAlpha: 1 }); + assert.ok(cues.some((c) => c.k === `${k}.flash` && c.at === firstLanding(v) && c.to.opacity === 1)); + assert.ok(!cues.some((c) => c.k === `${k}.n0`), "the 0 is never rolled"); + } + // PARTLY's second step rolls as ever: 1 out, 2 in, at its landing. + const second = stamps.filter((x) => x.verdict === "PARTLY").map((x) => x.landed).sort((a, b) => a - b)[1]; + assert.ok(cues.some((c) => c.k === "ty.PARTLY.n1" && c.at === second && c.to.autoAlpha === 0)); + assert.ok(cues.some((c) => c.k === "ty.PARTLY.n2" && c.at === second && c.to.autoAlpha === 1)); + // Every cue still states the from the one before it left. + const state = Object.fromEntries(Object.entries(init).map(([k, v]) => [k, { ...v }])); + for (const c of cues) { + if (!c.k.startsWith("ty.")) continue; + for (const p of Object.keys(c.to)) assert.deepEqual(c.from[p], state[c.k][p], `${c.k}.${p} at ${c.at}`); + Object.assign(state[c.k], c.to); + } + // Per verdict: only PARTLY pops; CONTRADICTED is the cell it always was. + const per = { ...RENDER, chrome: { ...CHROME, factcheck: { tally: { showAt: { PARTLY: "first" } } } } }; + const p = deckCues(s, per); + assert.deepEqual(p.init["ty.PARTLY"], { autoAlpha: 0, scale: TALLY_POP.from }); + assert.deepEqual(p.init["ty.CONTRADICTED"], always.init["ty.CONTRADICTED"]); + const contra = (cs) => cs.filter((c) => c.k.startsWith("ty.CONTRADICTED")); + assert.deepEqual(contra(p.cues), contra(always.cues)); + // "always", written or not, is the page it always was, byte for byte. + const explicit = { ...RENDER, chrome: { ...CHROME, factcheck: { tally: { showAt: "always" } } } }; + assert.equal(deckHtml(s, explicit, {}), deckHtml(s, RENDER, {})); + // The page keeps every cell in its place: the same cells, hidden or not. + assert.equal((deckHtml(s, first, {}).match(/class="tcell"/g) ?? []).length, 2); +}); + // ---- the stamp page -------------------------------------------------------------- test("stampGeometry: a box in the footage at its position; the feed's box for a feed cut", () => {