commit 4af3f830f8328f88db76bb6db23aeb0aa730d842
parent ab178f486ecb0d309b0f87002542deeb688ac72e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 3 Nov 2026 17:16:25 -0500
umtool: the combo badge in Play and the post bench -- the build's own markup and motion on the item's clock beside the player (ComboBadge; Play the cut via playView's postCombo, its sfx as it pops), the bench's combo block (the repeat group in the cut's order with dates, tiers and links, which use this is, the badge on this item off/on: POST /api/report/post-combo, updatePostCombo), the build's lint of render.posts.combo and an item's combo; docs (report-video.md "The combo counter", knobs.md, cli.md); e2e post-combo.spec.ts on a fixture of one GIF answering three people
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
15 files changed, 602 insertions(+), 6 deletions(-)
diff --git a/umtool/app/api/report/post-combo/route.ts b/umtool/app/api/report/post-combo/route.ts
@@ -0,0 +1,72 @@
+import { readFile } from "node:fs/promises";
+import { COMBO_SFX } from "umtool-report-to-video/post-combo";
+import { projectCombos } from "umtool-report-to-video/post-combo-prints";
+import { comboSfxFile } from "umtool-report-to-video/post-combo-render";
+import { channelsDirFor } from "@/lib/projects/report.mjs";
+import { withEditNotes } from "@/lib/report/guard";
+import { StaleToken, StructureRefused, updatePostCombo, updatePostComboRender } from "@/lib/report/manifest.mjs";
+import { resolveReport } from "@/lib/report/serve.mjs";
+import { refuseCaller } from "@/lib/report/caller";
+
+export const dynamic = "force-dynamic";
+
+// THE COMBO COUNTER (report-to-video/post-combo.mjs; umtool/docs/knobs.md, "The
+// combo counter"): the cut's repeated attachments, the badge's sounds, and its
+// writers -- what the post bench's combo panel and Play draw with.
+//
+// GET ?project { match, groups, combos }: each repeat, each item's count
+// GET ?sfx=hit|coin a bundled sound (Play plays it as the badge pops)
+// POST {project, op: "set", id, combo, token} an item's: false (no badge, still counted), null (the cut's), {knobs}
+// POST {project, op: "cut", patch, token} the cut's: render.posts.combo (a key null: the default)
+
+const noStore = { "cache-control": "no-store" };
+
+export async function GET(request: Request) {
+ const q = new URL(request.url).searchParams;
+ const sfx = q.get("sfx");
+ if (sfx) {
+ if (!COMBO_SFX.includes(sfx) || sfx === "off") return new Response("no such sound", { status: 404 });
+ const body = await readFile(comboSfxFile(sfx) as string).catch(() => null);
+ if (!body) return new Response("the sound is not on disk", { status: 404 });
+ return new Response(new Uint8Array(body), { headers: { "content-type": "audio/wav", "cache-control": "max-age=3600" } });
+ }
+ const r = await resolveReport(q.get("project") ?? "");
+ if ("error" in r) return Response.json({ error: r.error }, { status: r.status });
+ try {
+ const m = r.manifest as Record<string, unknown>;
+ const { match, groups, combos } = await projectCombos(r.project.dir, m, { channelsDir: channelsDirFor(r.project.dir, m) });
+ return Response.json({ match, groups, combos }, { headers: noStore });
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 500 });
+ }
+}
+
+export async function POST(request: Request) {
+ const refused = refuseCaller(request, "/api/report/post-combo");
+ if (refused) return refused;
+ let body: Record<string, unknown>;
+ try {
+ body = await request.json();
+ } catch {
+ return Response.json({ error: "expected JSON" }, { status: 400 });
+ }
+ const r = await resolveReport(String(body.project ?? ""));
+ if ("error" in r) return Response.json({ error: r.error }, { status: r.status });
+ const token = body.token === undefined || body.token === null ? null : String(body.token);
+ try {
+ if (body.op === "set") {
+ const value = body.combo === false ? false : body.combo === null || body.combo === undefined ? null : (body.combo as Record<string, unknown>);
+ const { result, editNotes } = await withEditNotes(r.project, () => updatePostCombo(r.project.dir, String(body.id ?? ""), value, { token }));
+ return Response.json({ ok: true, entry: result.entry, combo: result.combo, token: result.token, editNotes }, { headers: noStore });
+ }
+ if (body.op === "cut") {
+ const { result, editNotes } = await withEditNotes(r.project, () => updatePostComboRender(r.project.dir, (body.patch ?? {}) as Record<string, unknown>, { token }));
+ return Response.json({ ok: true, combo: result.combo, token: result.token, editNotes }, { headers: noStore });
+ }
+ } catch (e) {
+ if (e instanceof StaleToken) return Response.json({ error: e.message, stale: true }, { status: 409 });
+ if (e instanceof StructureRefused) return Response.json({ error: e.message, errors: e.errors }, { status: 400 });
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
+ }
+ return Response.json({ error: "op is set or cut" }, { status: 400 });
+}
diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx
@@ -9,6 +9,9 @@ import { postBenchHref } from "@/lib/hrefs";
import { POST_HOLD, POST_MEDIA_MIN_SPAN, POST_PARAPHRASE_MAX, contextReadSeconds, postItemPlan, readingSeconds, ruleSeconds } from "umtool-report-to-video/post-item";
import PostItemPlayer, { type PostPlan } from "./review/PostItemPlayer";
import PostNarrationPanel from "./PostNarrationPanel";
+import PostComboPanel from "./PostComboPanel";
+import ComboBadge, { type ComboInfo } from "./review/ComboBadge";
+import { liveCombo } from "umtool-report-to-video/post-combo";
// ---------------------------------------------------------------------------
// THE POST BENCH, the client half (PostBenchPage.tsx): the item played on its
@@ -48,7 +51,7 @@ const CROPS: Array<{ label: string; crop: number[] | null }> = [
];
export default function PostBench({
- project, entry: initial, token: initialToken, box, plan: initialPlan, back, prev, next, fromPlay, render = {},
+ project, entry: initial, token: initialToken, box, plan: initialPlan, back, prev, next, fromPlay, render = {}, combo = null,
}: {
project: string;
entry: Entry;
@@ -61,6 +64,8 @@ export default function PostBench({
fromPlay: boolean;
/** The cut's render block (its `postNarration` knobs). */
render?: Record<string, unknown>;
+ /** Its combo (post-combo.mjs): the attachment the cut plays again here, its count, its group. */
+ combo?: ComboInfo | null;
}) {
const router = useRouter();
const [entry, setEntry] = useState<Entry>(initial);
@@ -235,6 +240,7 @@ export default function PostBench({
</div>
<div className="relative w-full overflow-hidden rounded border border-seam bg-black" style={{ aspectRatio: `${box.width} / ${box.height}` }}>
<PostItemPlayer project={project} entry={entry} plan={plan} box={box} s={s} playing={playing} cardKey={token} />
+ <ComboBadge project={project} entry={entry} plan={plan} combo={liveCombo(combo, render, entry) as ComboInfo | null} box={box} s={s} playing={playing} />
</div>
<div className="flex items-center gap-2 text-[12px]">
<button type="button" className={btn} data-post-bench-play="" onClick={() => (s >= total ? (setS(0), setPlaying(true)) : setPlaying((p) => !p))}>
@@ -336,6 +342,21 @@ export default function PostBench({
</label>
</section>
+ {combo && (
+ <PostComboPanel
+ project={project}
+ entry={entry}
+ token={token}
+ combo={combo}
+ render={render}
+ onEntry={(e, t) => {
+ setEntry(e as Entry);
+ setSaved(e as Entry);
+ setToken(t);
+ }}
+ />
+ )}
+
{contexts.map(({ key, label, ref, set }) => {
const para = typeof ref.paraphrase === "string" ? ref.paraphrase : "";
return (
diff --git a/umtool/components/projects/PostBenchPage.tsx b/umtool/components/projects/PostBenchPage.tsx
@@ -1,13 +1,15 @@
import { notFound } from "next/navigation";
import AppShell from "@/components/shell/AppShell";
import PostBench from "./PostBench";
-import { readManifest } from "@/lib/projects/report.mjs";
+import { channelsDirFor, readManifest } from "@/lib/projects/report.mjs";
import { manifestToken } from "@/lib/report/manifest.mjs";
import { projectHref, playHref } from "@/lib/hrefs";
import { deckGeometry, deckOn, feedGeometry, feedOn } from "umtool-report-to-video/deck";
import { postItemPlan } from "umtool-report-to-video/post-item";
+import { projectCombos } from "umtool-report-to-video/post-combo-prints";
import type { ProjectRef } from "@/lib/project-types";
import type { PostPlan } from "./review/PostItemPlayer";
+import type { ComboInfo } from "./review/ComboBadge";
// THE POST BENCH (report-to-video/post-item.mjs; knobs.md, "A post item"): one
// post item of the cut on its own -- its card and attachments played on the
@@ -30,6 +32,9 @@ export default async function PostBenchPage({ project, id, search = {} }: { proj
const neighbours = tl.filter((e) => e?.type === "post").map((e) => e.id);
const k = neighbours.indexOf(id);
const fromPlay = search.from === "play";
+ // Its combo (post-combo.mjs): counted over the whole cut, as the build counts it.
+ const combos = (await projectCombos(project.dir, m, { channelsDir: channelsDirFor(project.dir, m) }).catch(() => ({ combos: {} }))).combos as Record<string, ComboInfo>;
+ const combo = combos[id] ?? null;
const back = fromPlay ? playHref(project.id, { clip: id, at: Number(search.at ?? 0) || null }) : projectHref(project.id, { tab: "cut" });
return (
<div className="flex h-full flex-col">
@@ -46,6 +51,7 @@ export default async function PostBenchPage({ project, id, search = {} }: { proj
box={{ width: box.width, height: box.height }}
plan={postItemPlan(entry, render) as unknown as PostPlan}
render={render}
+ combo={combo}
back={{ href: back, label: fromPlay ? "‹ Back to the cut" : "‹ The Cut tab" }}
prev={k > 0 ? neighbours[k - 1] : null}
next={k < neighbours.length - 1 ? neighbours[k + 1] : null}
diff --git a/umtool/components/projects/PostComboPanel.tsx b/umtool/components/projects/PostComboPanel.tsx
@@ -0,0 +1,93 @@
+"use client";
+
+import Link from "next/link";
+import { useState } from "react";
+import { postBenchHref } from "@/lib/hrefs";
+import { comboKnobs } from "umtool-report-to-video/post-combo";
+import type { ComboInfo } from "./review/ComboBadge";
+
+// ---------------------------------------------------------------------------
+// THE POST BENCH's COMBO PANEL (report-to-video/post-combo.mjs; knobs.md, "The
+// combo counter"): when this item's attachment is one other items of the cut
+// play too -- its repeat group in the cut's order (each post's date, the tier
+// that matched, a link to its bench), which use this is, and the badge on THIS
+// item turned off or on: one write (updatePostCombo, POST /api/report/post-combo
+// {op: "set"}), the writer `umtool posts combo <p> <item> off|on` runs. An item
+// with its badge off still counts: the next use is still ×(n+1).
+// ---------------------------------------------------------------------------
+
+const TIER: Record<string, string> = { "media-id": "the same X media", sha256: "the same file", audio: "the same sound" };
+
+export default function PostComboPanel({
+ project, entry, token, combo, render, onEntry,
+}: {
+ project: string;
+ entry: Record<string, unknown> & { id: string; combo?: unknown };
+ token: string | null;
+ combo: ComboInfo;
+ render: Record<string, unknown>;
+ onEntry: (entry: Record<string, unknown> & { id: string }, token: string | null) => void;
+}) {
+ const [error, setError] = useState<string | null>(null);
+ const [busy, setBusy] = useState(false);
+ // The box follows the click at once; the write's answer settles it (a refusal puts it back).
+ const [pending, setPending] = useState<boolean | null>(null);
+ const cut = comboKnobs(render);
+ const off = entry.combo === false;
+ const members = combo.members ?? [];
+ const set = async (on: boolean) => {
+ setError(null);
+ setBusy(true);
+ setPending(on);
+ const res = await fetch("/api/report/post-combo", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ project, op: "set", id: entry.id, combo: on ? null : false, token }),
+ });
+ const j = (await res.json().catch(() => ({}))) as { entry?: Record<string, unknown> & { id: string }; token?: string; error?: string; errors?: string[] };
+ setBusy(false);
+ setPending(null);
+ if (!res.ok || !j.entry) {
+ setError(j.errors?.join("; ") ?? j.error ?? `HTTP ${res.status}`);
+ return;
+ }
+ onEntry(j.entry, j.token ?? null);
+ };
+ return (
+ <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-post-bench-combo={combo.count}>
+ <h2 className="micro mb-2">
+ combo · attachment {combo.media + 1} · use {combo.count} of {members.length}
+ </h2>
+ <ol className="m-0 list-none space-y-0.5 p-0 text-[12px]" data-post-bench-combo-group={combo.group ?? ""}>
+ {members.map((m) => (
+ <li key={m.id} className="flex items-baseline gap-2" data-post-bench-combo-member={m.id} aria-current={m.id === entry.id ? "true" : undefined}>
+ <span className="w-8 font-mono tabular-nums">{m.n >= Math.max(2, cut.minCount) ? `×${m.n}` : m.n}</span>
+ {m.id === entry.id ? (
+ <b>{m.id}</b>
+ ) : (
+ <Link href={postBenchHref(project, m.id)} className="ink-link">
+ {m.id}
+ </Link>
+ )}
+ <span className="text-text-2">{typeof m.date === "string" ? m.date.slice(0, 10) : ""}</span>
+ <span className="ml-auto text-text-2">{m.tier ? TIER[m.tier] ?? m.tier : "first"}</span>
+ </li>
+ ))}
+ </ol>
+ <label className="mt-2 flex items-center gap-2">
+ <input type="checkbox" checked={pending ?? !off} disabled={busy} onChange={(e) => void set(e.target.checked)} data-post-bench-combo-toggle="" />
+ the badge on this item
+ </label>
+ <p className="m-0 mt-1 text-[11.5px] text-text-2" data-post-bench-combo-note="">
+ {cut.on === false
+ ? "the cut's combo badge is off (umtool posts combo <p> on=on)"
+ : combo.count < Math.max(2, cut.minCount)
+ ? `the first use${combo.count > 1 ? "s" : ""} draw${combo.count > 1 ? "" : "s"} none: the badge from ×${cut.minCount}`
+ : off
+ ? "off here: it still counts, the next use stays ×" + (combo.count + 1)
+ : `“${String(combo.knobs?.label ?? cut.label)} ×${combo.count}” pops as the attachment starts`}
+ </p>
+ {error && <p className="m-0 mt-1 text-[var(--color-blocking,#c33)]" data-post-bench-combo-error="">{error}</p>}
+ </section>
+ );
+}
diff --git a/umtool/components/projects/review/ComboBadge.tsx b/umtool/components/projects/review/ComboBadge.tsx
@@ -0,0 +1,111 @@
+"use client";
+
+import { useEffect, useMemo, useRef, useState } from "react";
+import { comboBadgeHtml, comboFrame, comboPlace, comboStart, comboTransform } from "umtool-report-to-video/post-combo";
+import { postLayout, stepBoxes } from "umtool-report-to-video/post-item";
+import type { PostPlan } from "./PostItemPlayer";
+
+// ---------------------------------------------------------------------------
+// THE COMBO BADGE, PLAYED (report-to-video/post-combo.mjs; knobs.md, "The combo
+// counter"): over a post item that repeats an earlier item's attachment,
+// "COMBO ×<n>" pops onto that attachment's corner as it starts -- the build's
+// own markup (comboBadgeHtml), moved by the build's own motion (comboFrame) on
+// the item's clock, in the box's px scaled to the player. Laid beside the
+// PostItemPlayer (Play the cut, the post bench), never inside it. Its sound,
+// when the cut asks for one, plays as it pops while playing.
+// ---------------------------------------------------------------------------
+
+export type ComboInfo = {
+ count: number;
+ media: number;
+ show: boolean;
+ knobs: Record<string, unknown> & { sfx?: string };
+ group?: string;
+ tier?: string | null;
+ members?: Array<{ id: string; i: number; n: number; post: string | null; date: string | null; tier: string | null }>;
+};
+
+type Box = { width: number; height: number };
+
+export default function ComboBadge({
+ project, entry, plan, combo, box, s, playing,
+}: {
+ project: string;
+ entry: Record<string, unknown> & { id: string };
+ plan: PostPlan;
+ combo: ComboInfo | null | undefined;
+ box: Box;
+ /** The item's own second. */
+ s: number;
+ playing: boolean;
+}) {
+ const wrap = useRef<HTMLDivElement | null>(null);
+ const [scale, setScale] = useState(0);
+ useEffect(() => {
+ const node = wrap.current;
+ if (!node) return;
+ const ro = new ResizeObserver(([e]) => setScale(e.contentRect.width / box.width));
+ ro.observe(node);
+ return () => ro.disconnect();
+ }, [box.width]);
+ const geo = useMemo(() => {
+ if (!combo?.show) return null;
+ const at = comboStart(plan, combo.media);
+ const step = plan.steps.find((st) => st.items.some((m) => m.i === combo.media));
+ const layout = postLayout(entry, box);
+ if (at === null || !step || !layout.slot) return null;
+ const boxes = stepBoxes(step, layout.slot) as Array<{ x: number; y: number; width: number; height: number }>;
+ const mb = boxes[step.items.findIndex((m) => m.i === combo.media)] ?? boxes[0];
+ const place = comboPlace(combo.count, combo.knobs, mb, box);
+ const font = `/api/report/post-item?project=${encodeURIComponent(project)}&font=bold`;
+ return { at, place, html: comboBadgeHtml(combo.count, combo.knobs, place.size, { font }) };
+ }, [combo, plan, entry, box, project]);
+ const frame = geo ? comboFrame(s - geo.at, { mirror: geo.place.mirror }) : null;
+ // Its sound, as it pops while playing (not when scrubbed onto).
+ const sfx = typeof combo?.knobs?.sfx === "string" && combo.knobs.sfx !== "off" ? combo.knobs.sfx : null;
+ const audio = useRef<HTMLAudioElement | null>(null);
+ const up = !!frame;
+ const was = useRef(false);
+ useEffect(() => {
+ const a = audio.current;
+ if (up && !was.current && playing && a && geo && s - geo.at < 0.3) {
+ a.currentTime = 0;
+ void a.play().catch(() => {});
+ }
+ was.current = up;
+ }, [up, playing, geo, s]);
+ if (!combo) return null;
+ const size = geo?.place.size;
+ return (
+ <div
+ ref={wrap}
+ data-post-combo={combo.count}
+ data-post-combo-show={combo.show ? "1" : "0"}
+ data-post-combo-up={up ? "1" : "0"}
+ data-post-combo-at={geo ? String(geo.at) : undefined}
+ className="pointer-events-none absolute inset-0 overflow-hidden"
+ >
+ {sfx && (
+ // eslint-disable-next-line jsx-a11y/media-has-caption
+ <audio ref={audio} src={`/api/report/post-combo?sfx=${encodeURIComponent(sfx)}`} preload="auto" data-post-combo-sfx={sfx} />
+ )}
+ {geo && size && frame && scale > 0 && (
+ <div className="absolute left-0 top-0" style={{ width: box.width, height: box.height, transform: `scale(${scale})`, transformOrigin: "0 0" }}>
+ <div
+ style={{
+ position: "absolute",
+ left: geo.place.center.x - size.width / 2,
+ top: geo.place.center.y - size.height / 2,
+ width: size.width,
+ height: size.height,
+ transform: comboTransform(frame, size.k),
+ transformOrigin: "50% 50%",
+ opacity: frame.opacity,
+ }}
+ dangerouslySetInnerHTML={{ __html: geo.html }}
+ />
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx
@@ -28,6 +28,7 @@ import { useCutApp } from "../cutApp/CutApp";
import { ClipExportButtons, ClipExportStatus, useClipExport } from "../ClipExport";
import AddPost from "./AddPost";
import PostItemPlayer, { type PostPlan } from "./PostItemPlayer";
+import ComboBadge, { type ComboInfo } from "./ComboBadge";
// ---------------------------------------------------------------------------
// THE PLAY VIEW (umtool/docs/knobs.md, "Play the cut"): a screening room. The
@@ -121,6 +122,8 @@ export type PlayEntry = {
/** A post item (report-to-video/post-item.mjs): the entry its card is drawn from, and what plays when. */
post?: Record<string, unknown> & { id: string };
postPlan?: PostPlan;
+ /** Its combo badge (post-combo.mjs): the attachment it repeats, its count, the knobs. */
+ postCombo?: ComboInfo;
};
export type PlayViewData = {
@@ -836,6 +839,20 @@ export default function PlayCut({
speed={rate}
/>
) : null;
+ // A post item that repeats an earlier one's attachment: its combo badge, beside the player.
+ const comboBadge = (box2: { width: number; height: number }) =>
+ postNow?.entry.postCombo ? (
+ <ComboBadge
+ key={`combo-${postNow.item.id}`}
+ project={project}
+ entry={postNow.entry.post!}
+ plan={postNow.entry.postPlan!}
+ combo={postNow.entry.postCombo}
+ box={box2}
+ s={Math.max(0, t - postNow.item.start)}
+ playing={ui.playing && !ui.waiting}
+ />
+ ) : null;
const placeholderCard = placeholder ? (
<div
data-play-placeholder={placeholder.kind}
@@ -986,6 +1003,7 @@ export default function PlayCut({
{postNow && rect && (
<div className="absolute" style={{ left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H), background: bg }}>
{postPlayer({ width: box.width, height: box.height })}
+ {comboBadge({ width: box.width, height: box.height })}
</div>
)}
{placeholderCard}
@@ -1003,7 +1021,7 @@ export default function PlayCut({
) : (
<div className="relative w-full overflow-hidden rounded border border-seam bg-black max-md:rounded-none max-md:border-0" style={{ aspectRatio: "16 / 9" }} data-testid="play-plain">
{footageCanvas({ inset: 0, width: "100%", height: "100%" }, 1280, 720)}
- {postNow && <div className="absolute inset-0" style={{ background: bg }}>{postPlayer({ width: 1920, height: 1080 })}</div>}
+ {postNow && <div className="absolute inset-0" style={{ background: bg }}>{postPlayer({ width: 1920, height: 1080 })}{comboBadge({ width: 1920, height: 1080 })}</div>}
{placeholderCard}
</div>
)}
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -87,6 +87,8 @@ Inbox cannot disagree about what is wrong with one.
| `posts fit <project> [--all \| <item> …] [--linger <s>] [--dry-run] [--json]` · `posts set-item <project> <item> fit=read[:<linger>]` | narrated posts' video attachments cut to their **best part** for the read (lead + take + tail + linger): a scored scan of the sound (loudness, its peaks), the speech (a transcript) and the scene cuts, the start snapped to a pause or a cut, recorded with why (`narration.window`) -- ONE write; each post's old and new length printed. A video no longer than the read is left as it is |
| `posts avatar <project> [<handle> <image-file> \| <handle> off] [--json]` · `posts avatars <project> [--dry-run] [--json]` | the **authors' pictures** (`postAvatars`): `avatar` copies a picture into `posts-media/_avatars/` for every card that draws that handle (manual; never replaced by the archive's), `off` clears it, no handle lists them; `avatars` copies the archive's (the channels' `posts-media/_avatars/avatars.json`, capture-posts') for every author the cut's cards draw unblurred that it has none of. A blurred author never shows one |
| `posts context <project> [--dry-run] [--json]` | every **post item's context from its capture** (`postContext.mjs`): the post it quotes and the post it answers, as its page showed them (`capture.json`'s `context`, read by the editor's `capture-posts` -- `"contextOnly": true` reads it alone), filled where the archive row lacks them -- `quoted` where the entry has none (or a named one with no words, the same post), `parents` where it has none (a thread shot stays on the entry; the card draws the parents). What the archive gave is never replaced. ONE write for every entry (`setPostItemsContext`: one undo point, refused whole in the build's words); a re-run with nothing new writes nothing. A post whose capture read no context is listed with the call that reads it (`pnpm ops capture-posts --json '{"slug":…,"ids":[…],"contextOnly":true}' --wait`). The card's blur of other authors is unchanged ([report-video.md](report-video.md#post-items-a-post-as-an-entry-of-the-cut)) |
+| `posts repeats <project> [--match id\|file\|audio] [--json]` | the **combo counter**'s repeats ([report-video.md](report-video.md#the-combo-counter)): every attachment the cut's post items play more than once -- the same X media id (the capture's url), else the same file (the capture's sha256 when its bytes agree, else hashed; cached by path, size and mtime), else (`--match audio`) the same sound (fpcalc, else a coarse ffmpeg hash) -- its posts in the cut's ORDER with their dates, the tier that matched and the badge each draws (`×2` from the second use, `(×n)` counted but not drawn); a post whose CAPTURE holds the same file but whose entry carries no attachment is listed too, `NOT ATTACHED`, with the `timeline remove` + `insert post:<channel>/<postId>` that makes it again from the archive (the entry's own edits not kept). Reads only |
+| `posts combo <project> [on=on\|off] [label=L] [position=top-right\|top-left\|bottom-right\|bottom-left\|center] [color=#rrggbb] [scale=0.4-2.5] [sfx=off\|hit\|coin] [minCount=2-20] [match=id\|file\|audio] [--json]` · `posts combo <project> <item> off\|on\|auto\|label=…\|position=…\|color=…\|scale=…\|sfx=… [--json]` | the **combo badge's knobs** ([knobs.md](knobs.md#the-combo-counter)): the cut's (`render.posts.combo`, `updatePostComboRender`; no knobs prints them; `k=` the default again) or one post item's (`combo`, `updatePostCombo`): `off` draws no badge on it -- it still counts -- `on`/`auto` the cut's again. Refused in the build's words (**exit 1**) |
| `new <slug> --from-posts <channel> [--channel <more>…] [--since D] [--until D] [--own] [--with-media] [--replies …] [--order …] [--limit N]` | a **posts reel**: the scaffold with the deck on (no `siteOrigin`: each post's QR opens the post, `deck.qr.links: "original"`), then `posts reel` with the same filters |
| `timeline <project> insert (--after <id\|-> \| --to-section N \| --group G) post:<channel>/<postId> [--id ID]` | **one post item** among the cut's entries, made as `posts reel` makes one |
| `modules list [--json]` · `modules apply <project> [--config FILE] [--dry-run] [--json]` · `modules apply <project> [--config FILE] --take <id> [--label L] [--at S --dur S \| --full] [--quick] [--force] [--from TAKE] [--keep-frames] [--patch-out FILE]` | the **video modules** (release 39): `list` every module, its kind, slot and where its settings live; `apply` maps the project's `module-config.json` (the modules a video wants, in MODULES-DESIGN's vocabulary) into the manifest's homes (`report-to-video/modules/config-loader.mjs`) — the preset, the deck's subtitle and QR, the counter's series and each clip's marks, the stamps, the rail's markers, the chapters, the pairs, the status ledger, the intro, the finale — and lists every field with no home, by path. Without `--take` the manifest is rewritten through `replaceManifest` (a snapshot first); with `--take` it is that take's patch (`takes/<id>.modules-patch.json`, or `--patch-out`) and the take is made from it as `take` makes one, the manifest untouched. **Exit 1** when the result would not build (the build's sentences) ([knobs.md](knobs.md#look-presets)) |
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -693,6 +693,31 @@ the shape, the mix, recordings, parts, the best part). One writer for a post's n
none, approved) and links the next post to record; **N** / **P** walk the cut's posts, **Space** plays the item as the
render will (the take over the muffled attachment).
+## The combo counter
+
+A post item that plays an attachment an earlier post item of the cut already played gets a fighting-game badge,
+**COMBO ×2**, **×3** …, popped onto that attachment's corner as it starts ([report-video.md](report-video.md#the-combo-counter):
+what counts as the same attachment, the count, the motion). Render, Play and the post bench draw it. The cut's knobs are
+`render.posts.combo` (`updatePostComboRender`), an item's its `combo` (`updatePostCombo`; `lib/report/manifest.mjs`), refused
+in the build's words (`validatePostCombos`). `k=` (empty) takes the default (the cut's) again.
+
+| Knob | In umtool | From a terminal | Route |
+|---|---|---|---|
+| `render.posts.combo.on` — the badge at all (default on) | — | `umtool posts combo <p> on=off` (`on=on`) | `POST /api/report/post-combo {project, op: "cut", patch: {on}, token}` |
+| `render.posts.combo.label` — the word over the count (≤ 16 characters, default `COMBO`; `""` the count alone) | — | `label=HIT` | same, `patch: {label}` |
+| `render.posts.combo.position` — the attachment's corner it pops on: `top-right` (default) · `top-left` · `bottom-right` · `bottom-left` · `center` | — | `position=top-left` | same |
+| `render.posts.combo.color` — the count's fill, `#rrggbb` (default `#ffcf33`), running to a hot red | — | `color=#22ccff` | same |
+| `render.posts.combo.scale` — its size, 0.4–2.5 (default 1: a 150 px count in a 1080 frame) | — | `scale=1.4` | same |
+| `render.posts.combo.sfx` — a bundled sound as it pops: `off` (default) · `hit` · `coin` (the render's mix; Play plays it as it pops while playing) | — | `sfx=hit` | same; the sound `GET /api/report/post-combo?sfx=hit` |
+| `render.posts.combo.minCount` — the first use that draws it, 2–20 (default 2: ×2 on) | — | `minCount=3` | same |
+| `render.posts.combo.match` — how deep "the same attachment" goes: `id` (the X media id) · `file` (+ the sha256; default) · `audio` (+ the sound's fingerprint) | — | `match=audio` | same |
+| `combo` — one post item's: `false` draws no badge on it (it STILL counts: the next use stays ×(n+1)); an object overrides `on`, `label`, `position`, `color`, `scale`, `sfx` for it | post bench, **combo**: its repeat group in the cut's order (each post's date, the tier that matched, its bench), which use this is, **the badge on this item** | `umtool posts combo <p> <item> off` (`on`/`auto`: the cut's) · `… <item> label=HIT color=#22ccff` | `POST /api/report/post-combo {project, op: "set", id, combo: false \| null \| {…}, token}` |
+
+| | In umtool | From a terminal | Route |
+|---|---|---|---|
+| the repeats: each attachment played more than once, its posts in the cut's order with their dates, the tier that matched (`X media id`, `same file`, `same sound`) and the badge each draws; a post whose capture holds the same file but whose entry carries none, marked, with the `timeline remove` + `insert post:` that makes it again from the archive (its own edits not kept) | the post bench's **combo** block (this item's group) | `umtool posts repeats <p> [--match id\|file\|audio] [--json]` | `GET /api/report/post-combo?project` |
+| the badge on the item's clock | Play the cut, the post bench (the player) | the build: `segments/<id>.mp4` (the plain one `<id>.plain.mp4`, the record `<id>.combo.json`) | — |
+
## The source backlog (Sources · Prioritize · Re-sweep when complete)
The Overview tab's **sources** line (`components/projects/report/SourceBacklog.tsx`, `lib/report/sourceBacklog.*`): for each
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -659,6 +659,59 @@ post's insert and `umtool posts avatars <p>`, or set by hand with `umtool posts
<p> <handle> <image>` (never replaced by the archive's). Every card that draws that
author unblurred shows it — the render, Play and the bench; a redacted author never.
+### The combo counter
+
+When a post item's attachment is one an EARLIER post item of the cut already played —
+the same reaction video answering a third person — a fighting-game badge pops onto
+that attachment's corner as it starts: **COMBO ×2**, **×3** … (operator, 3 Nov: *"an
+effect that shows a combo counter or something when he uses the same video to reply
+to someone"*). `report-to-video/post-combo.mjs` is the rule (pure),
+`post-combo-prints.mjs` reads what each attachment is, `post-combo-render.mjs` lays
+the badge in the build, `components/projects/review/ComboBadge.tsx` in Play and the
+post bench.
+
+**The same attachment**, in order of trust: the X **media id** in the capture's source
+url (`amplify_video/<id>`, `ext_tw_video/<id>`, `tweet_video/<id>`, pbs `media/<id>`;
+the record is the project's `posts-media/<slug>/<postId>/capture.json`, else the
+corpus's), else the file's **sha256** (the capture's, trusted when its `bytes` match the
+project's copy; else the copy hashed), else — `match: "audio"` — the **sound**: its
+fingerprint (chromaprint's `fpcalc -raw`, else a coarse ffmpeg energy hash) alike and
+its length within 0.3 s. Any one tier links two; X gives a re-uploaded GIF a new id
+every time, so its bytes are what match. Each file's print is cached by path, size and
+mtime (`UMTOOL_PRINTS_CACHE`, default `~/.cache/umtool/media-prints`).
+
+**The count** is the use's number in the cut's ORDER (the timeline's post items), not
+by date: moved, the numbers follow. The badge shows from `minCount` (default 2). An
+item with `combo: false` draws none and STILL counts — the viewer saw it, so the next
+use stays ×(n+1). It is counted over the whole cut, so an `--only` rebuild draws the
+count the full build would.
+
+**The motion** (2.6 s from the attachment's start, cut at the item's end): a slam in
+from 0.3× to a 1.32× overshoot in 0.12 s, a spring back through 0.86× to rest, a shake
+that dies away by 0.56 s, tilted 7° (the other way on a left corner), held, then faded
+out over 0.4 s growing to 1.12×. The badge is a heavy face skewed, the count filled
+from `color` to a hot red with a dark outline and a red under-shadow, the label over it.
+
+**The build** draws the item's segment as it always did (`post-render.mjs`), then a
+pass of its own lays the badge's frames — the same markup Play draws, moved by the same
+`comboFrame`, shot frame by frame on a transparent page — over the attachment's corner,
+and the `sfx` (a bundled `hit` or `coin`) into its mix. The plain segment is kept as
+`segments/<id>.plain.mp4`: a new count re-lays only the badge; a badge that goes puts
+it back. `segments/<id>.combo.json` records what it was laid from.
+
+```jsonc
+"render": { "posts": { "combo": {
+ "on": true, "label": "COMBO", "position": "top-right", "color": "#ffcf33",
+ "scale": 1, "sfx": "off", "minCount": 2, "match": "file" } } },
+"timeline": [ { "type": "post", "id": "p-…", "combo": false }, … ] // or { "label": "HIT", … }
+```
+
+`umtool posts repeats <p>` lists every repeated attachment with its posts in the cut's
+order, their dates, the tier that matched and the badge each draws — and a post whose
+CAPTURE holds the same file while its entry carries no attachment (captured after it
+went in: it draws nothing and does not count until it plays the attachment), with how
+to make it again from the archive.
+
## The on-screen deck (`render.chrome`)
Its knobs — the stamp's moment and count per clip, the stamp's look and words, the markers, a clip's sync and
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -55,6 +55,7 @@ import { makeReelFixture } from "./reel-fixture.mjs";
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";
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"));
@@ -1913,6 +1914,8 @@ makeIntakeFixture({ reports, channels: CHANNELS, deckManifest, cachedWindow: pat
makePostItemsFixture({ reports, channels: CHANNELS, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
// Narrated post items (report-to-video/post-narration.mjs): a take read over a video, four pictures cycling (post-narration.spec.ts).
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 });
// 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/post-combo-fixture.mjs b/umtool/e2e/fixtures/post-combo-fixture.mjs
@@ -0,0 +1,62 @@
+// THE COMBO COUNTER (report-to-video/post-combo.mjs): a posts cut where the
+// same reaction GIF answers three people (post-combo.spec.ts).
+//
+// post-combo-fixture p-c1 the GIF's first use (no badge)
+// p-txt words only, between them
+// p-c2 the same bytes, another X id (re-uploaded): ×2
+// p-c3 again, its capture only in the corpus: ×3
+// p-oth another GIF (no repeat)
+// the deck on. Each GIF is 2 s of testsrc, silent, as X
+// serves a GIF. WRITES its manifest (the bench's
+// toggle): 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 COMBO_CHANNEL = "combochan-x";
+
+/** @param {{ reports: string, channels: string, deckManifest: Function }} o */
+export function makePostComboFixture({ reports, channels, deckManifest }) {
+ const name = "post-combo-fixture";
+ const dir = path.join(reports, name);
+ const media = path.join(dir, "posts-media", COMBO_CHANNEL);
+ for (const id of ["1", "3", "4", "5"]) mkdirSync(path.join(media, id), { recursive: true });
+ const gif = path.join(media, "1", "1_1.mp4");
+ ff(["-f", "lavfi", "-i", "testsrc=size=498x280:rate=25:duration=2", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-an", gif]);
+ ff(["-f", "lavfi", "-i", "testsrc2=size=498x280:rate=25:duration=2", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-an", path.join(media, "5", "5_1.mp4")]);
+ copyFileSync(gif, path.join(media, "3", "3_1.mp4"));
+ copyFileSync(gif, path.join(media, "4", "4_1.mp4"));
+ const bytes = readFileSync(gif);
+ const sha = createHash("sha256").update(bytes).digest("hex");
+ // The captures' records: p-c1's and p-c2's copied into the project; p-c3's only in the corpus.
+ writeFileSync(path.join(media, "1", "capture.json"), JSON.stringify({ version: 1, id: "1", media: [{ name: "1_1.mp4", bytes: bytes.length, sha256: sha, url: "https://video.twimg.com/tweet_video/AAAA.mp4" }] }));
+ writeFileSync(path.join(media, "3", "capture.json"), JSON.stringify({ version: 1, id: "3", media: [{ name: "3_1.mp4", bytes: bytes.length, sha256: sha, url: "https://video.twimg.com/tweet_video/BBBB.mp4" }] }));
+ const cap4 = path.join(channels, COMBO_CHANNEL, "posts-media", "4");
+ mkdirSync(cap4, { recursive: true });
+ writeFileSync(path.join(cap4, "capture.json"), JSON.stringify({ version: 1, id: "4", media: [{ name: "4_1.mp4", bytes: bytes.length, sha256: sha, url: "https://video.twimg.com/tweet_video/CCCC.mp4" }] }));
+ const at = (d) => `2026-11-0${d}T10:00:00.000Z`;
+ const base = (id, day, text, o = {}) => ({
+ type: "post", id, post: `${COMBO_CHANNEL}/${id.replace(/^p-c?/, "")}`, platform: "x", author: "Combo Subject", handle: "combosubject",
+ date: at(day), text, url: `https://x.com/combosubject/status/${id}`, engagement: { likes: 3 }, subjects: ["combosubject"], ...o,
+ });
+ const g = (id) => [{ src: `posts-media/${COMBO_CHANNEL}/${id}/${id}_1.mp4`, kind: "gif", seconds: 2, width: 498, height: 280 }];
+ const timeline = [
+ base("p-c1", 1, "Me, every time.", { post: `${COMBO_CHANNEL}/1`, media: g("1") }),
+ base("p-txt", 1, "Words only, between the replies.", { post: `${COMBO_CHANNEL}/2` }),
+ base("p-c2", 2, "Again.", { post: `${COMBO_CHANNEL}/3`, media: g("3") }),
+ base("p-c3", 3, "And again.", { post: `${COMBO_CHANNEL}/4`, media: g("4") }),
+ base("p-oth", 3, "Something else.", { post: `${COMBO_CHANNEL}/5`, media: g("5") }),
+ ];
+ const m = deckManifest(name, "The Combo Fixture", timeline);
+ m.provenance = { ...m.provenance, channelSlug: COMBO_CHANNEL, channelsDir: path.relative(dir, channels) };
+ writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n");
+ return { dir };
+}
diff --git a/umtool/e2e/post-combo.spec.ts b/umtool/e2e/post-combo.spec.ts
@@ -0,0 +1,108 @@
+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";
+
+// ---------------------------------------------------------------------------
+// THE COMBO COUNTER (report-to-video/post-combo.mjs; knobs.md, "The combo
+// counter"): one reaction GIF answering three people. Fixture:
+// e2e/fixtures/post-combo-fixture.mjs -- p-c1 (its first use), p-txt (words),
+// p-c2 (the same bytes re-uploaded: ×2), p-c3 (again, its capture in the
+// corpus only: ×3), p-oth (another GIF). Each item is its 3 s read, its GIF
+// beside the card from the first frame: the badge pops at the item's 0 s.
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const DIR = path.join(FIXTURE, "reports", "post-combo-fixture");
+const MANIFEST = path.join(DIR, "video.manifest.json");
+const PROJECT = "reports/post-combo-fixture";
+const SHOTS = process.env.POST_COMBO_SHOTS ?? null;
+
+type Entry = { id: string; type: string; combo?: unknown };
+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 });
+});
+
+const root = (page: Page) => page.locator("[data-play-cut]");
+
+test("Play shows the combo: none on the first use, ×2 then ×3 as the repeated GIF starts", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ await page.goto(urls.playHref(PROJECT, { bare: true, clip: "p-c1" }));
+ await expect(root(page)).toHaveAttribute("data-play-item", "p-c1");
+ await expect(page.locator('[data-post-play="p-c1"]')).toBeVisible();
+ // The first use counts, and draws nothing.
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo", "1");
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo-show", "0");
+ await expect(page.locator("[data-combo-badge]")).toHaveCount(0);
+
+ // The second use: the badge is up from the attachment's start (the item's 0 s: beside the card, the GIF plays from the first frame).
+ await page.goto(urls.playHref(PROJECT, { bare: true, clip: "p-c2" }));
+ await expect(root(page)).toHaveAttribute("data-play-item", "p-c2");
+ const badge = page.locator("[data-post-combo]");
+ await expect(badge).toHaveAttribute("data-post-combo", "2");
+ await expect(badge).toHaveAttribute("data-post-combo-show", "1");
+ await expect(badge).toHaveAttribute("data-post-combo-at", "0");
+ await expect(badge).toHaveAttribute("data-post-combo-up", "1");
+ await page.locator("[data-play-toggle]").click();
+ // Popped: scaled up and opaque.
+ await expect.poll(async () => Number(await page.locator('[data-combo-badge="2"]').evaluate((el) => getComputedStyle(el.parentElement as HTMLElement).opacity)), { timeout: 10_000 }).toBeGreaterThan(0.9);
+ await expect(page.locator('[data-combo-badge="2"]')).toContainText("COMBO");
+ await expect(page.locator('[data-combo-badge="2"]')).toContainText("×2");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-combo-play-x2.png") });
+ // Played on into the third use: ×3, from its start.
+ await expect(root(page)).toHaveAttribute("data-play-item", "p-c3", { timeout: 15_000 });
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo", "3");
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo-up", "1");
+ await expect(page.locator('[data-combo-badge="3"]')).toContainText("×3");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-combo-play-x3.png") });
+ // p-oth repeats nothing.
+ await expect(root(page)).toHaveAttribute("data-play-item", "p-oth", { timeout: 15_000 });
+ await expect(page.locator("[data-post-combo]")).toHaveCount(0);
+ await page.locator("[data-play-toggle]").click();
+});
+
+test("the post bench lists the repeat group and turns the badge off for one item (it still counts); posts repeats agrees", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ await page.goto(urls.postBenchHref(PROJECT, "p-c3"));
+ const panel = page.locator('[data-post-bench-combo="3"]');
+ await expect(panel).toBeVisible();
+ expect(await panel.locator("[data-post-bench-combo-member]").evaluateAll((els) => els.map((e) => e.getAttribute("data-post-bench-combo-member")))).toEqual(["p-c1", "p-c2", "p-c3"]);
+ await expect(panel.locator('[data-post-bench-combo-member="p-c2"]')).toContainText("the same file");
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo-show", "1");
+ // On the item's clock: up from the GIF's start for its 2.6 s, gone before the item's 3 s end.
+ const scrub = page.locator("[data-post-bench-scrub]");
+ await scrub.fill("1");
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo-up", "1");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-combo-bench.png") });
+ await scrub.fill("2.8");
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo-up", "0");
+ await expect(page.locator("[data-combo-badge]")).toHaveCount(0);
+ await panel.locator("[data-post-bench-combo-toggle]").uncheck();
+ await expect(panel.locator("[data-post-bench-combo-note]")).toContainText("still counts");
+ await expect.poll(() => timeline().find((e) => e.id === "p-c3")?.combo).toBe(false);
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo-show", "0");
+ await expect(page.locator("[data-combo-badge]")).toHaveCount(0);
+ const rep = JSON.parse(umtool(["posts", "repeats", PROJECT, "--json"])) as { groups: { members: { id: string; badge: number | null; show: boolean; tier: string | null }[] }[] };
+ expect(rep.groups).toHaveLength(1);
+ expect(rep.groups[0].members.map((m) => `${m.id}:${m.badge}:${m.show ? "shown" : "-"}:${m.tier ?? "first"}`)).toEqual(["p-c1:1:-:first", "p-c2:2:shown:sha256", "p-c3:3:-:sha256"]);
+ // On again: the item takes the cut's badge.
+ await panel.locator("[data-post-bench-combo-toggle]").check();
+ await expect.poll(() => "combo" in (timeline().find((e) => e.id === "p-c3") ?? {})).toBe(false);
+ await expect(page.locator("[data-post-combo]")).toHaveAttribute("data-post-combo-show", "1");
+});
diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs
@@ -11,7 +11,7 @@
import { DEFAULT_VARIANT, selectVariant } from "umtool-report-to-video/build-video";
import { deckOn, estimatedDuration, estimateSchedule, scheduleFrom, transitionOf } from "umtool-report-to-video/deck";
import { resolveFactcheck } from "umtool-report-to-video/factcheck";
-import { clipDateKey, readManifest } from "../projects/report.mjs";
+import { channelsDirFor, clipDateKey, readManifest } from "../projects/report.mjs";
import { rejectionOf } from "./rejectReasons.mjs";
import { dateKeyLabel } from "./playCut.mjs";
import { postDay, postItemPlan } from "umtool-report-to-video/post-item";
@@ -20,6 +20,7 @@ import { playableTakes, resolveTakeManifest } from "./takeManifest.mjs";
import { readWorkingCut } from "./workingCut.mjs";
import { sectionModel } from "./sectionEdit.mjs";
import { manifestToken } from "./manifest.mjs";
+import { projectCombos } from "umtool-report-to-video/post-combo-prints";
const fin = (v) => typeof v === "number" && Number.isFinite(v);
const text = (v) => (typeof v === "string" ? v.replace(/\s+/g, " ").trim() : "");
@@ -149,6 +150,12 @@ export async function playView(project, { take = null, bare = false } = {}) {
};
}),
);
+ // The combo counter (post-combo.mjs): a post item that repeats an earlier one's attachment carries its badge
+ // (`postCombo`: its count, which attachment, the knobs, whether it shows), counted over the cut played.
+ if (entries.some((e) => e.type === "post")) {
+ const { combos } = await projectCombos(project.dir, selected, { channelsDir: channelsDirFor(project.dir, base) }).catch(() => ({ combos: {} }));
+ for (const e of entries) if (e.type === "post" && combos[e.id]) Object.assign(e, { postCombo: combos[e.id] });
+ }
// The counter (the deck's tally): each stamp's landing second and count on
// the estimate's clock, and each verdict's word -- the reel strip's
// staircase before (or without) the chrome's own schedule.
diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs
@@ -87,6 +87,7 @@ import { validateGapEntries } from "./gaps.mjs";
import { postItemFiles, validatePostItems } from "./post-item.mjs";
import { postAvatarFiles, validatePostAvatars } from "./post-avatars.mjs";
import { validatePostNarrationRender } from "./post-narration.mjs";
+import { validatePostCombos } from "./post-combo.mjs";
import { validateFinaleEntries } from "./finale.mjs";
import { validateThreadEntries } from "./threads.mjs";
import { validateFlipEntries } from "./flips.mjs";
@@ -328,6 +329,8 @@ export function validatorErrors(whole) {
...validatePostAvatars(whole),
// A narrated post item's mix (post-narration.mjs): the cut's knobs.
...validatePostNarrationRender(whole.render),
+ // The combo counter (post-combo.mjs): render.posts.combo and each post item's `combo`.
+ ...validatePostCombos(whole),
];
if (deckOn(whole.render)) {
errors.push(...validatePosts(whole.posts, whole.timeline ?? [], whole.render).map((m) => `posts: ${m}`));
diff --git a/umtool/report-to-video/post-combo.mjs b/umtool/report-to-video/post-combo.mjs
@@ -227,6 +227,19 @@ export function comboKnobs(render, entry = null) {
return { ...COMBO_DEFAULTS, ...r, ...pick };
}
+/** Whether use `count` of item `entry` draws its badge: the cut's on, the item's own, count ≥ minCount. */
+export function comboShow(count, render, entry = null) {
+ const cut = comboKnobs(render);
+ return cut.on !== false && comboKnobs(render, entry).on !== false && count >= Math.max(COMBO_MIN_COUNT.min, cut.minCount);
+}
+
+/**
+ * The combo of an item as it stands NOW (the bench: its `combo` edited, not
+ * yet saved): its count and attachment as counted, its knobs and `show` read
+ * again from `render` and `entry`.
+ */
+export const liveCombo = (combo, render, entry) => (combo ? { ...combo, knobs: comboKnobs(render, entry), show: comboShow(combo.count, render, entry) } : null);
+
/**
* EACH ITEM's COMBO, pure: `{ [itemId]: { count, media, group, show, knobs,
* members } }` for every item in a repeat group -- `count` its use's number,
@@ -235,7 +248,6 @@ export function comboKnobs(render, entry = null) {
* (the cut's `on`, the item's own, count ≥ minCount).
*/
export function comboCounts(timeline, groups, render = undefined) {
- const cut = comboKnobs(render);
const out = {};
const byId = new Map((Array.isArray(timeline) ? timeline : []).filter(isObj).map((e) => [e.id, e]));
// The item's repeat: an attachment with an earlier use before one that is a first, then the lower index.
@@ -251,7 +263,7 @@ export function comboCounts(timeline, groups, render = undefined) {
media: m.i,
group: g.key,
tier: m.tier,
- show: cut.on !== false && knobs.on !== false && m.n >= Math.max(COMBO_MIN_COUNT.min, cut.minCount),
+ show: comboShow(m.n, render, entry),
knobs,
members: g.members.map(({ id, i, n, post, date, tier }) => ({ id, i, n, post, date, tier })),
};