commit da5be10c6dfba451f293c78a0b830c26e1e38734
parent a4ce00f42ff1907521a5cb7bd38358e96baeb84a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 4 Nov 2026 03:27:50 -0500
Merge main (lane/media-scenes) into lane/thread-tree: both scenes kept, the conversation's wins the card -- an item in a conversation's run and a media scene draws the conversation's scene (post-conversation.mjs planContext), the media scene keeps only the attachment (sceneEntry): read-follow.mjs's followSchedule drops the media scene when the conversation has one, the card route too; every call site passes planContext beside mediaScene (the build's segment, Play, the route, the bench -- its conversation prop beside the media scene's). The conversation's tiles are `conv:<id>` now, apart from the media scene's `scene:<n>`; post-conversation.test.mjs: an item with both. postThread.test.mjs keeps both lanes' tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
31 files changed, 1738 insertions(+), 136 deletions(-)
diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts
@@ -5,11 +5,14 @@ import { avatarUrls } from "umtool-report-to-video/post-avatars";
import { jobState, startJob } from "@/lib/research/case-editor";
import { withEditNotes } from "@/lib/report/guard";
import { StaleToken, StructureRefused, manifestToken, updatePostFx, updatePostItem, updatePostNarration } from "@/lib/report/manifest.mjs";
-import { pickedTake } from "umtool-report-to-video/post-narration";
+import { isNarrated, pickedTake } from "umtool-report-to-video/post-narration";
import { scriptWordTimes } from "umtool-report-to-video/word-zoom";
import { followKnobs } from "umtool-report-to-video/read-follow";
import { threadLayout } from "umtool-report-to-video/post-thread";
import { planContext } from "umtool-report-to-video/post-conversation";
+import { mediaSceneById, sceneEntry, sceneLayout } from "umtool-report-to-video/post-media-scene";
+import { projectCombos } from "umtool-report-to-video/post-combo-prints";
+import { channelsDirFor } from "@/lib/projects/report.mjs";
import { recognizedOf, takeWordSources, wordsFileOf } from "@/lib/report/postFxCli.mjs";
import { rangeResponse, resolveReport } from "@/lib/report/serve.mjs";
import { resolveTakeManifest } from "@/lib/report/takeManifest.mjs";
@@ -176,8 +179,24 @@ export async function GET(request: Request) {
} catch (e) {
return new Response(e instanceof Error ? e.message : String(e), { status: 500 });
}
- const followOn = q.get("phase") !== "media" && followKnobs(found.item, (found.manifest.render ?? render) as Record<string, unknown>).on;
- const html = postCardHtml(found.item, {
+ const cutRender = (found.manifest.render ?? render) as Record<string, unknown>;
+ const followOn = q.get("phase") !== "media" && followKnobs(found.item, cutRender).on;
+ // Its MEDIA SCENE (post-media-scene.mjs): neighbours that carry the same attachment, by the combo counter's
+ // groups -- the card drawn as the scene plays it (a join item gains the attachment's slot), the scene's
+ // earlier messages above it. Only looked for beside another post item.
+ const tl = (Array.isArray(found.manifest.timeline) ? found.manifest.timeline : []) as Entry[];
+ const at = tl.findIndex((e) => e?.id === found.item!.id);
+ const besidePost = tl[at - 1]?.type === "post" || tl[at + 1]?.type === "post";
+ const groups = besidePost
+ ? ((await projectCombos(r.project.dir, found.manifest, { channelsDir: channelsDirFor(r.project.dir, found.manifest) }).catch(() => ({ groups: [] }))).groups as unknown[])
+ : [];
+ const media = groups.length ? mediaSceneById(tl, found.item.id, groups as never, cutRender) : null;
+ const item = sceneEntry(found.item, media) as Entry;
+ // THE THREAD SCENE WINS (post-media-scene.mjs's header): with the conversation's scene (post-conversation.mjs) the
+ // media scene keeps only the attachment (sceneEntry above), never the card.
+ const scene = found.ctx.scene ? null : media;
+ const tlayout = threadLayout(item, cutRender, found.ctx);
+ const html = postCardHtml(item, {
width: w, height: h, avatars,
palette: (render.palette ?? {}) as Record<string, string>,
fonts: { regular: `${base}&font=regular`, bold: `${base}&font=bold` },
@@ -185,8 +204,10 @@ export async function GET(request: Request) {
parentShotUrl: parentShot,
// Its read-follow (read-follow.mjs): the blocks and the flow Play lights and pans, as the build's page has them.
follow: followOn,
- // A threaded card (post-thread.mjs): its tiles, as the plan's follow.thread has them.
- thread: followOn ? threadLayout(found.item, (found.manifest.render ?? render) as Record<string, unknown>, found.ctx) : null,
+ // A threaded card (post-thread.mjs): its tiles, as the plan's follow.thread has them -- the conversation's scene
+ // (post-conversation.mjs) or, with none, a media scene's earlier messages above them (a narrated item's thread
+ // read is its base; un-narrated, none).
+ thread: followOn ? (scene ? sceneLayout(isNarrated(item) ? tlayout : null, item, scene) ?? tlayout : tlayout) : null,
redaction,
});
return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", ...noStore } });
diff --git a/umtool/components/projects/BlurBoxPad.tsx b/umtool/components/projects/BlurBoxPad.tsx
@@ -1,14 +1,20 @@
"use client";
import { useEffect, useRef, useState } from "react";
+import { bandBox } from "umtool-report-to-video/post-censor";
// THE CENSOR BOXES, DRAWN (post-censor.mjs; knobs.md, "A post item"): the
// attachment on a still frame -- a picture as it is, a video paused at the
// bench's playhead (or its in point) -- shown as the cut shows it (its crop),
// each box over it; drag to draw a new one, × to take one away. The boxes are
// fractions of the picture as shown, which is what the render blurs.
+//
+// THE BAND (post-censor.mjs `band`): its line (two, between) drawn across the
+// frame -- an upright one for left/right -- each dragged to where the censor
+// starts; the region it censors tinted. A drag writes the knob (`onBand`).
type Box = number[];
+export type Band = { below?: number; above?: number; between?: number[]; left?: number; right?: number };
type Props = {
project: string;
media: { src: string; kind: string; width?: number; height?: number; crop?: number[] };
@@ -17,13 +23,31 @@ type Props = {
boxes: Box[];
onChange: (boxes: Box[]) => void;
index: number;
+ /** The band (null: none), and its writer: each line dragged sets its edge. */
+ band?: Band | null;
+ onBand?: (band: Band) => void;
};
+/** A band's lines: `[{ edge, at, upright }]` (between: its two). */
+const linesOf = (band: Band | null | undefined) => {
+ if (!band) return [] as Array<{ edge: string; at: number; upright: boolean; k?: number }>;
+ const out: Array<{ edge: string; at: number; upright: boolean; k?: number }> = [];
+ if (typeof band.below === "number") out.push({ edge: "below", at: band.below, upright: false });
+ else if (typeof band.above === "number") out.push({ edge: "above", at: band.above, upright: false });
+ else if (Array.isArray(band.between)) band.between.forEach((at, k) => out.push({ edge: "between", at, upright: false, k }));
+ if (typeof band.left === "number") out.push({ edge: "left", at: band.left, upright: true });
+ else if (typeof band.right === "number") out.push({ edge: "right", at: band.right, upright: true });
+ return out;
+};
+const r3 = (v: number) => Math.round(v * 1000) / 1000;
+
const r4 = (v: number) => Math.round(v * 10000) / 10000;
const clamp = (v: number) => Math.min(1, Math.max(0, v));
-export default function BlurBoxPad({ project, media, at, boxes, onChange, index }: Props) {
+export default function BlurBoxPad({ project, media, at, boxes, onChange, index, band = null, onBand }: Props) {
const pad = useRef<HTMLDivElement | null>(null);
+ const [line, setLine] = useState<{ edge: string; k?: number } | null>(null);
+ const region = bandBox(band) as number[] | null;
const video = useRef<HTMLVideoElement | null>(null);
const [drag, setDrag] = useState<{ x: number; y: number; x2: number; y2: number } | null>(null);
const crop = Array.isArray(media.crop) && media.crop.length === 4 ? media.crop : [0, 0, 1, 1];
@@ -59,16 +83,39 @@ export default function BlurBoxPad({ project, media, at, boxes, onChange, index
data-post-bench-blur-pad={index}
onPointerDown={(ev) => {
if ((ev.target as HTMLElement).closest("button")) return;
+ // A band's line: dragged, not a box drawn.
+ const handle = (ev.target as HTMLElement).closest("[data-post-bench-band-line]") as HTMLElement | null;
+ if (handle && band && onBand) {
+ (ev.currentTarget as HTMLDivElement).setPointerCapture(ev.pointerId);
+ const k = handle.getAttribute("data-band-k");
+ setLine({ edge: handle.getAttribute("data-post-bench-band-line") ?? "", ...(k ? { k: Number(k) } : {}) });
+ return;
+ }
(ev.currentTarget as HTMLDivElement).setPointerCapture(ev.pointerId);
const p = where(ev);
setDrag({ x: p.x, y: p.y, x2: p.x, y2: p.y });
}}
onPointerMove={(ev) => {
+ if (line && band && onBand) {
+ const p = where(ev);
+ const upright = line.edge === "left" || line.edge === "right";
+ const v = r3(Math.min(0.98, Math.max(0.02, upright ? p.x : p.y)));
+ if (line.edge === "between") {
+ const b = [...(band.between ?? [0.3, 0.6])];
+ b[line.k ?? 0] = v;
+ onBand({ ...band, between: [Math.min(b[0], b[1]), Math.max(b[0], b[1])].map(r3) });
+ } else onBand({ ...band, [line.edge]: v });
+ return;
+ }
if (!drag) return;
const p = where(ev);
setDrag({ ...drag, x2: p.x, y2: p.y });
}}
onPointerUp={() => {
+ if (line) {
+ setLine(null);
+ return;
+ }
if (!drag) return;
const b = box(drag);
setDrag(null);
@@ -81,6 +128,29 @@ export default function BlurBoxPad({ project, media, at, boxes, onChange, index
) : (
<video ref={video} src={src} muted playsInline preload="auto" style={inner} />
)}
+ {region && (
+ <div
+ data-post-bench-band-region={region.join(",")}
+ className="pointer-events-none absolute bg-sky-400/25 outline outline-1 outline-sky-300/70"
+ style={{ left: `${region[0] * 100}%`, top: `${region[1] * 100}%`, width: `${region[2] * 100}%`, height: `${region[3] * 100}%` }}
+ />
+ )}
+ {linesOf(band).map((l) => (
+ <div
+ key={`${l.edge}${l.k ?? ""}`}
+ data-post-bench-band-line={l.edge}
+ data-band-k={l.k === undefined ? undefined : String(l.k)}
+ data-band-at={String(l.at)}
+ title={`${l.edge} ${Math.round(l.at * 100)}% -- drag it`}
+ className={`absolute z-10 ${l.upright ? "top-0 h-full w-3 -translate-x-1/2 cursor-ew-resize" : "left-0 h-3 w-full -translate-y-1/2 cursor-ns-resize"}`}
+ style={l.upright ? { left: `${l.at * 100}%` } : { top: `${l.at * 100}%` }}
+ >
+ <div className={`absolute bg-sky-300 ${l.upright ? "left-1/2 top-0 h-full w-0.5 -translate-x-1/2" : "left-0 top-1/2 h-0.5 w-full -translate-y-1/2"}`} />
+ <span className={`absolute rounded bg-sky-300 px-1 text-[10px] font-mono leading-tight text-black ${l.upright ? "left-1/2 top-1 -translate-x-1/2" : "right-1 top-1/2 -translate-y-1/2"}`}>
+ {Math.round(l.at * 100)}%
+ </span>
+ </div>
+ ))}
{[...boxes, ...(drag ? [box(drag)] : [])].map((b, j) => (
<div
key={j}
@@ -103,7 +173,8 @@ export default function BlurBoxPad({ project, media, at, boxes, onChange, index
))}
</div>
<p className="m-0 text-[11.5px] text-text-2">
- drag on the frame to blur a region; no box blurs the whole frame{boxes.length ? ` · ${boxes.length} box${boxes.length === 1 ? "" : "es"}` : ""}
+ drag on the frame to censor a region; no box and no band censors the whole frame{boxes.length ? ` · ${boxes.length} box${boxes.length === 1 ? "" : "es"}` : ""}
+ {band ? " · drag the band's line" : ""}
</p>
</div>
);
diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx
@@ -10,13 +10,14 @@ import { POST_HOLD, POST_MEDIA_MIN_SPAN, POST_PARAPHRASE_MAX, contextReadSeconds
import PostItemPlayer, { type PostPlan } from "./review/PostItemPlayer";
import PostFollowPanel from "./PostFollowPanel";
import PostThreadPanel from "./PostThreadPanel";
-import BlurBoxPad from "./BlurBoxPad";
+import BlurBoxPad, { type Band } from "./BlurBoxPad";
import PostNarrationPanel from "./PostNarrationPanel";
import PostComboPanel from "./PostComboPanel";
import ComboBadge, { type ComboInfo } from "./review/ComboBadge";
import { liveCombo } from "umtool-report-to-video/post-combo";
import PostZoomPanel from "./PostZoomPanel";
import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom";
+import { sceneEntry } from "umtool-report-to-video/post-media-scene";
// ---------------------------------------------------------------------------
// THE POST BENCH, the client half (PostBenchPage.tsx): the item played on its
@@ -38,7 +39,7 @@ import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom";
// "paraphrased" label (its own text kept, shown beside)
// ---------------------------------------------------------------------------
-type Blur = { on: boolean; strength?: number; boxes?: number[][]; label?: string | false };
+type Blur = { on: boolean; strength?: number; boxes?: number[][]; label?: string | false; band?: Band; style?: "blur" | "black" | "pixelate" };
type Media = Record<string, unknown> & { src: string; kind: string; seconds?: number; start?: number; end?: number; mute?: boolean; crop?: number[]; push?: boolean; words?: string; audio?: boolean; width?: number; height?: number; blur?: Blur };
type Ref = Record<string, unknown> & { author?: string; handle?: string; text?: string; paraphrase?: string };
type Entry = Record<string, unknown> & { id: string; media?: Media[]; hold?: number; mediaLayout?: string; redact?: boolean; quoted?: Ref; parents?: Ref[] };
@@ -51,6 +52,22 @@ const withParaphrase = (ref: Ref, paraphrase: string | undefined): Ref => {
else out.paraphrase = paraphrase;
return out;
};
+/** A band's edge across: below, above, between, or none. */
+const bandAcross = (b: Band | undefined) => (typeof b?.below === "number" ? "below" : typeof b?.above === "number" ? "above" : Array.isArray(b?.between) ? "between" : "none");
+const bandEmpty = (b: Band) => (Object.keys(b).length ? b : undefined);
+/** The band with its edge across set to `to` (none: dropped), the line where it was (or a third of the way down). */
+const withAcross = (b: Band | undefined, to: string): Band | undefined => {
+ const { below, above, between, ...rest } = b ?? {};
+ const at = below ?? above ?? (between ? between[0] : 0.38);
+ if (to === "none") return bandEmpty(rest);
+ return { ...rest, ...(to === "between" ? { between: between ?? [Math.min(at, 0.6), Math.max(0.7, Math.min(0.95, at + 0.3))] } : { [to]: at }) };
+};
+/** The band with its upright edge set to `to` (all: dropped). */
+const withUpright = (b: Band | undefined, to: string): Band | undefined => {
+ const { left, right, ...rest } = b ?? {};
+ if (to === "all") return bandEmpty(rest);
+ return { ...rest, [to]: left ?? right ?? 0.5 };
+};
const CROPS: Array<{ label: string; crop: number[] | null }> = [
{ label: "none", crop: null },
{ label: "centre 80%", crop: [0.1, 0.1, 0.8, 0.8] },
@@ -58,8 +75,11 @@ const CROPS: Array<{ label: string; crop: number[] | null }> = [
{ label: "bottom half", crop: [0, 0.5, 1, 0.5] },
];
+/** Its media scene (post-media-scene.mjs mediaSceneOf), as the page counted it. */
+type Scene = { key: string; n: number; of: number; ids: string[]; media: number | null; anchor: { id: string; media: number; entry: { id: string; post: string; media: Array<Record<string, unknown>> } }; before: Array<Record<string, unknown>> } | null;
+
export default function PostBench({
- project, entry: initial, token: initialToken, box, plan: initialPlan, back, prev, next, fromPlay, render = {}, combo = null, before = null, scene = null,
+ project, entry: initial, token: initialToken, box, plan: initialPlan, back, prev, next, fromPlay, render = {}, combo = null, before = null, scene: savedScene = null, conversation = null,
}: {
project: string;
entry: Entry;
@@ -76,8 +96,10 @@ export default function PostBench({
combo?: ComboInfo | null;
/** The timeline entry before it in the cut (post-thread.mjs: a parent that is that item is carried in). */
before?: Record<string, unknown> | null;
- /** The posts its run leaves on screen (post-conversation.mjs planContext): kept on top or collapsed away. */
- scene?: Record<string, unknown> | null;
+ /** Its media scene (post-media-scene.mjs): the neighbours with the same attachment, as saved. */
+ scene?: Scene;
+ /** The posts its conversation's run leaves on screen (post-conversation.mjs planContext): kept on top or collapsed away. It wins the card over a media scene. */
+ conversation?: Record<string, unknown> | null;
}) {
const router = useRouter();
const [entry, setEntry] = useState<Entry>(initial);
@@ -85,7 +107,20 @@ export default function PostBench({
const [token, setToken] = useState(initialToken);
const [status, setStatus] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
- const plan = useMemo(() => (entry === initial ? initialPlan : (postItemPlan(entry, render, { prev: before, scene }) as PostPlan)), [entry, initial, initialPlan, render, before, scene]);
+ // In a media scene (post-media-scene.mjs) the item plays as the scene does: the shared attachment the
+ // anchor's, the scene's earlier messages above its card. Out of it (scene: false, unsaved) at once.
+ // The anchor's own bench: its attachment as it is being edited (its crop, its censor), not as saved.
+ const scene = useMemo(
+ () =>
+ entry.scene === false || !savedScene
+ ? null
+ : savedScene.anchor.id === entry.id
+ ? { ...savedScene, anchor: { ...savedScene.anchor, entry: { ...savedScene.anchor.entry, media: (entry.media ?? []) as Array<Record<string, unknown>> } } }
+ : savedScene,
+ [entry, savedScene],
+ );
+ const shown = useMemo(() => sceneEntry(entry, scene) as Entry, [entry, scene]);
+ const plan = useMemo(() => (entry === initial ? initialPlan : (postItemPlan(shown, render, { prev: before, scene: conversation, mediaScene: conversation ? null : scene }) as PostPlan)), [entry, shown, initial, initialPlan, render, before, scene, conversation]);
const total = plan.total;
const [s, setS] = useState(0);
const [playing, setPlaying] = useState(false);
@@ -147,6 +182,8 @@ export default function PostBench({
redact: typeof e.redact === "boolean" ? e.redact : null,
// Its read-follow (read-follow.mjs): false is off; its knobs, each null when it is the cut's.
follow: e.follow === false ? false : e.follow && typeof e.follow === "object" ? { on: null, dim: null, ease: null, ...(e.follow as Record<string, unknown>) } : null,
+ // Its media scene (post-media-scene.mjs): false (never in one), "join", or null (by its attachment).
+ scene: e.scene === false || e.scene === "join" ? e.scene : null,
// Its thread read (post-thread.mjs): its knobs, each null when it is the cut's.
thread: e.thread && typeof e.thread === "object" ? { parent: null, quoted: null, carry: null, reveal: null, shrink: null, dim: null, seconds: null, pan: null, ...(e.thread as Record<string, unknown>) } : null,
media: Object.fromEntries(
@@ -160,7 +197,7 @@ export default function PostBench({
push: m.push === true ? true : null,
// The censoring blur (post-censor.mjs), every key as it stands (null: cleared).
blur: m.blur
- ? { on: m.blur.on === true, strength: m.blur.strength ?? null, boxes: m.blur.boxes?.length ? m.blur.boxes : null, label: m.blur.label === undefined ? null : m.blur.label }
+ ? { on: m.blur.on === true, strength: m.blur.strength ?? null, boxes: m.blur.boxes?.length ? m.blur.boxes : null, label: m.blur.label === undefined ? null : m.blur.label, band: m.blur.band ?? null, style: m.blur.style ?? null }
: null,
},
]),
@@ -201,7 +238,9 @@ export default function PostBench({
setSaved(j.entry);
setToken(j.token ?? null);
setStatus("saved");
- }, [entry, project, token]);
+ // A scene knob changed: the page counts the scene again (its neighbours are read on the server).
+ if ((saved.scene ?? null) !== (j.entry.scene ?? null)) router.refresh();
+ }, [entry, project, token, saved, router]);
// Transcribe a video attachment through the editor (a job), then follow it.
const [jobs, setJobs] = useState<Record<number, { job: string; state: string; error?: string }>>({});
@@ -266,8 +305,8 @@ export default function PostBench({
</span>
</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} />
+ <PostItemPlayer project={project} entry={shown} plan={plan} box={box} s={s} playing={playing} cardKey={`${token}:${scene?.key ?? "-"}`} scene={scene} />
+ <ComboBadge project={project} entry={shown} 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))}>
@@ -317,7 +356,7 @@ export default function PostBench({
}}
/>
<PostFollowPanel entry={entry} plan={plan} render={render} s={s} setS={setS} setEntry={(f) => setEntry((e) => f(e) as Entry)} />
- <PostThreadPanel project={project} entry={entry} plan={plan} render={render} before={before} scene={scene} setS={setS} setEntry={(f) => setEntry((e) => f(e) as Entry)} />
+ <PostThreadPanel project={project} entry={entry} plan={plan} render={render} before={before} scene={conversation} setS={setS} setEntry={(f) => setEntry((e) => f(e) as Entry)} />
<PostNarrationPanel
project={project}
entry={entry}
@@ -388,6 +427,41 @@ export default function PostBench({
</label>
</section>
+ <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-post-bench-scene={savedScene ? savedScene.key : ""}>
+ <h2 className="micro mb-2">media scene</h2>
+ {savedScene && entry.scene !== false ? (
+ <p className="m-0 text-text-2" data-post-bench-scene-members="">
+ message {savedScene.n + 1} of {savedScene.of} about one attachment:{" "}
+ {savedScene.ids.map((id, k) => (
+ <span key={id}>
+ {k > 0 && " → "}
+ {id === entry.id ? <b>{id}</b> : <Link href={postBenchHref(project, id, fromPlay ? { play: { at: 0 } } : {})} className="ink-link">{id}</Link>}
+ </span>
+ ))}
+ . The attachment stays put through it; the earlier messages stack above this one.
+ {savedScene.anchor.id !== entry.id && (
+ <span className="block" data-post-bench-scene-anchor={savedScene.anchor.id}>
+ It is drawn as <Link href={postBenchHref(project, savedScene.anchor.id, fromPlay ? { play: { at: 0 } } : {})} className="ink-link">{savedScene.anchor.id}</Link>'s (the scene's first to carry it): set its crop and censor there.
+ </span>
+ )}
+ </p>
+ ) : (
+ <p className="m-0 text-text-2">{entry.scene === false ? "kept out of any scene" : "in no scene: no neighbour carries the same attachment"}</p>
+ )}
+ <label className="mt-2 flex items-center gap-2">
+ in a scene
+ <select
+ value={entry.scene === false ? "off" : entry.scene === "join" ? "join" : "auto"}
+ onChange={(e) => setEntry((x) => ({ ...x, scene: e.target.value === "off" ? false : e.target.value === "join" ? "join" : undefined }))}
+ data-post-bench-scene-knob=""
+ >
+ <option value="auto">auto (when a neighbour shares its attachment)</option>
+ <option value="off">never (this item breaks a scene)</option>
+ <option value="join">join the scene beside it (no attachment of its own)</option>
+ </select>
+ </label>
+ </section>
+
{combo && (
<PostComboPanel
project={project}
@@ -544,6 +618,39 @@ export default function PostBench({
</button>
)}
</div>
+ <div className="flex flex-wrap items-center gap-2">
+ style
+ <select
+ value={m.blur.style ?? "blur"}
+ onChange={(e) => setMedia(i, { blur: { ...m.blur!, style: e.target.value === "blur" ? undefined : (e.target.value as Blur["style"]) } })}
+ data-post-bench-censor-style={i}
+ >
+ <option value="blur">blurred</option>
+ <option value="black">black</option>
+ <option value="pixelate">pixelated</option>
+ </select>
+ band
+ <select
+ value={bandAcross(m.blur.band)}
+ onChange={(e) => setMedia(i, { blur: { ...m.blur!, band: withAcross(m.blur!.band, e.target.value) } })}
+ data-post-bench-censor-band={i}
+ >
+ <option value="none">none</option>
+ <option value="below">below a line</option>
+ <option value="above">above a line</option>
+ <option value="between">between two lines</option>
+ </select>
+ <select
+ value={typeof m.blur.band?.left === "number" ? "left" : typeof m.blur.band?.right === "number" ? "right" : "all"}
+ onChange={(e) => setMedia(i, { blur: { ...m.blur!, band: withUpright(m.blur!.band, e.target.value) } })}
+ data-post-bench-censor-side={i}
+ aria-label="the band's side"
+ >
+ <option value="all">the whole width</option>
+ <option value="left">left of a line</option>
+ <option value="right">right of a line</option>
+ </select>
+ </div>
<BlurBoxPad
project={project}
media={m}
@@ -551,6 +658,8 @@ export default function PostBench({
at={timed ? (srcNow ?? m.start ?? 0) : 0}
boxes={m.blur.boxes ?? []}
onChange={(boxes) => setMedia(i, { blur: { ...m.blur!, boxes: boxes.length ? boxes : undefined } })}
+ band={m.blur.band ?? null}
+ onBand={(band) => setMedia(i, { blur: { ...m.blur!, band } })}
/>
</>
)}
diff --git a/umtool/components/projects/PostBenchPage.tsx b/umtool/components/projects/PostBenchPage.tsx
@@ -8,6 +8,7 @@ import { deckGeometry, deckOn, feedGeometry, feedOn } from "umtool-report-to-vid
import { postItemPlan } from "umtool-report-to-video/post-item";
import { planContext } from "umtool-report-to-video/post-conversation";
import { projectCombos } from "umtool-report-to-video/post-combo-prints";
+import { mediaSceneOf, sceneEntry } from "umtool-report-to-video/post-media-scene";
import type { ProjectRef } from "@/lib/project-types";
import type { PostPlan } from "./review/PostItemPlayer";
import type { ComboInfo } from "./review/ComboBadge";
@@ -36,8 +37,11 @@ export default async function PostBenchPage({ project, id, search = {} }: { proj
const ctx = planContext(tl, at, render) as { prev: Record<string, unknown> | null; scene: Record<string, unknown> | null };
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 counted = await projectCombos(project.dir, m, { channelsDir: channelsDirFor(project.dir, m) }).catch(() => ({ combos: {}, groups: [] }));
+ const combos = counted.combos as Record<string, ComboInfo>;
const combo = combos[id] ?? null;
+ // Its media scene (post-media-scene.mjs): its neighbours with the same attachment, by the combo's groups.
+ const scene = mediaSceneOf(tl, at, counted.groups, render);
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">
@@ -52,10 +56,11 @@ export default async function PostBenchPage({ project, id, search = {} }: { proj
entry={entry}
token={await manifestToken(project.dir)}
box={{ width: box.width, height: box.height }}
- plan={postItemPlan(entry, render, ctx) as unknown as PostPlan}
+ plan={postItemPlan(sceneEntry(entry, scene), render, { ...ctx, mediaScene: ctx.scene ? null : scene }) as unknown as PostPlan}
+ scene={scene}
render={render}
before={ctx.prev}
- scene={ctx.scene}
+ conversation={ctx.scene}
combo={combo}
back={{ href: back, label: fromPlay ? "‹ Back to the cut" : "‹ The Cut tab" }}
prev={k > 0 ? neighbours[k - 1] : null}
diff --git a/umtool/components/projects/PostThreadPanel.tsx b/umtool/components/projects/PostThreadPanel.tsx
@@ -116,7 +116,7 @@ export default function PostThreadPanel({
<p className="m-0 mb-2 text-text-2" data-post-thread-scene={sceneTiles.length}>
one scene with the item before:{" "}
{sceneTiles.map((t, i) => (
- <span key={t.scope} data-post-thread-scene-tile={t.scope.slice(6)} data-action={t.action}>
+ <span key={t.scope} data-post-thread-scene-tile={t.scope.slice(5)} data-action={t.action}>
{i ? ", " : ""}
{t.ref?.redact ? "a post" : `@${t.ref?.handle ?? "?"}`} {t.action === "keep" ? "stays on top (context)" : "collapses away"}
</span>
diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx
@@ -124,6 +124,8 @@ export type PlayEntry = {
postPlan?: PostPlan;
/** Its combo badge (post-combo.mjs): the attachment it repeats, its count, the knobs. */
postCombo?: ComboInfo;
+ /** Its media scene (post-media-scene.mjs): which, its place in it, its items, the anchor. */
+ postScene?: { key: string; n: number; of: number; ids: string[]; anchor: string };
};
export type PlayViewData = {
@@ -854,6 +856,7 @@ export default function PlayCut({
speed={rate}
published={asPublished}
uncensored={uncensored}
+ scene={postNow.entry.postScene ?? null}
/>
) : null;
// A post item that repeats an earlier one's attachment: its combo badge, beside the player.
diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { POST_PUSH, mediaTimeAt, postLayout, stepAt, stepBoxes } from "umtool-report-to-video/post-item";
import { dryGainAt, mixPhaseAt, pickedTake, wetGainAt } from "umtool-report-to-video/post-narration";
import { applyFollowState, followPath, followStateAt, measureFollow } from "umtool-report-to-video/read-follow";
-import { blurCqw, blurOf } from "umtool-report-to-video/post-censor";
+import { blurCqw, blurOf, labelBoxOf, pixelGrid } from "umtool-report-to-video/post-censor";
import { WORD_ZOOM_HIGHLIGHT_ALPHA, findMatch, highlightAt, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomAt, zoomProgressAt, zoomSpan, zoomWindow } from "umtool-report-to-video/word-zoom";
// ---------------------------------------------------------------------------
@@ -183,6 +183,53 @@ function mixGraph(el: HTMLMediaElement, lowpassHz: number) {
}
}
+type Censor = { strength: number; boxes: number[][]; band: number[] | null; label: string | null; style: "blur" | "black" | "pixelate" };
+
+/**
+ * A PIXELATED region, live (post-censor.mjs `style: "pixelate"`): the element's
+ * pixels drawn coarse on a canvas over it -- each region (or the whole frame)
+ * read at the render's grid of blocks and scaled back up without smoothing --
+ * redrawn every frame, so a playing video stays censored.
+ */
+function PixelLayer({ source, crop, censor }: { source: React.RefObject<HTMLVideoElement | HTMLImageElement | null>; crop: number[] | null; censor: Censor }) {
+ const canvas = useRef<HTMLCanvasElement | null>(null);
+ const key = JSON.stringify([crop, censor.boxes, censor.strength]);
+ useEffect(() => {
+ let raf = 0;
+ const tiny = document.createElement("canvas");
+ const draw = () => {
+ const c = canvas.current;
+ const el = source.current;
+ raf = requestAnimationFrame(draw);
+ if (!c || !el) return;
+ const W = Math.max(1, Math.round(c.clientWidth));
+ const H = Math.max(1, Math.round(c.clientHeight));
+ if (c.width !== W || c.height !== H) [c.width, c.height] = [W, H];
+ const sw = el instanceof HTMLVideoElement ? el.videoWidth : el.naturalWidth;
+ const sh = el instanceof HTMLVideoElement ? el.videoHeight : el.naturalHeight;
+ const ctx = c.getContext("2d");
+ if (!ctx || !sw || !sh) return;
+ ctx.clearRect(0, 0, W, H);
+ const cr = crop ?? [0, 0, 1, 1];
+ for (const r of censor.boxes.length ? censor.boxes : [[0, 0, 1, 1]]) {
+ const [nx, ny] = pixelGrid(censor.strength, r[2], r[3], W, H);
+ [tiny.width, tiny.height] = [nx, ny];
+ const t = tiny.getContext("2d");
+ if (!t) continue;
+ t.imageSmoothingEnabled = true;
+ // The region of the picture as shown (after its crop), in the source's pixels.
+ t.drawImage(el, (cr[0] + r[0] * cr[2]) * sw, (cr[1] + r[1] * cr[3]) * sh, r[2] * cr[2] * sw, r[3] * cr[3] * sh, 0, 0, nx, ny);
+ ctx.imageSmoothingEnabled = false;
+ ctx.drawImage(tiny, 0, 0, nx, ny, r[0] * W, r[1] * H, r[2] * W, r[3] * H);
+ }
+ };
+ raf = requestAnimationFrame(draw);
+ return () => cancelAnimationFrame(raf);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [key, source]);
+ return <canvas ref={canvas} data-post-pixelated="" className="pointer-events-none absolute inset-0 h-full w-full" />;
+}
+
function MediaEl({
project, m, box, b, step, s, playing, inStep, mix = null, speed = 1,
}: {
@@ -200,6 +247,7 @@ function MediaEl({
speed?: number;
}) {
const ref = useRef<HTMLVideoElement | null>(null);
+ const img = useRef<HTMLImageElement | null>(null);
// The muffle follows the clock: the gains set from the item's second, as the render's expressions are.
const muffled = !!mix && mix.duck && step.sound;
useEffect(() => {
@@ -235,14 +283,19 @@ function MediaEl({
if (!run && !v.paused) v.pause();
}, [target, run, speed]);
const progress = inStep ? Math.min(1, Math.max(0, (s - step.at) / Math.max(0.1, step.seconds))) : 0;
- // CENSORED (post-censor.mjs): the whole frame blurred, or its boxes -- as the render blurs it.
- const blur = blurOf(m) as { strength: number; boxes: number[][]; label: string | null } | null;
- const blurCss = blur ? `blur(${blurCqw(blur.strength)}cqw)` : undefined;
+ // CENSORED (post-censor.mjs): the whole frame, or its regions (its boxes, its band) -- blurred, black or
+ // pixelated, as the render draws them.
+ const blur = blurOf(m) as Censor | null;
+ const blurCss = blur && blur.style === "blur" ? `blur(${blurCqw(blur.strength)}cqw)` : undefined;
+ const wholeBlur = blur && blur.style === "blur" && !blur.boxes.length ? blurCss : undefined;
+ const at = blur ? labelBoxOf(blur) : null;
return (
<div
data-post-media={m.i}
data-post-media-kind={m.kind}
- data-post-blurred={blur ? (blur.boxes.length ? "boxes" : "frame") : undefined}
+ data-post-blurred={blur ? (blur.boxes.length ? (blur.band ? "band" : "boxes") : "frame") : undefined}
+ data-post-censor-style={blur ? blur.style : undefined}
+ data-post-censor-band={blur?.band ? blur.band.join(",") : undefined}
className="absolute overflow-hidden"
style={{ left: pct(b.x, box.width), top: pct(b.y, box.height), width: pct(b.width, box.width), height: pct(b.height, box.height), containerType: blur ? "size" : undefined }}
>
@@ -257,18 +310,23 @@ function MediaEl({
playsInline
loop={step.loop}
muted={!(step.sound && run)}
- style={{ ...inner, objectFit: "fill", filter: blur && !blur.boxes.length ? blurCss : undefined }}
+ style={{ ...inner, objectFit: "fill", filter: wholeBlur }}
/>
) : (
// eslint-disable-next-line @next/next/no-img-element
<img
+ ref={img}
src={postFileUrl(project, String(m.src))}
alt=""
data-post-image={m.i}
- style={{ ...inner, objectFit: "fill", transform: m.push ? `scale(${1 + POST_PUSH * progress})` : undefined, transformOrigin: "center", filter: blur && !blur.boxes.length ? blurCss : undefined }}
+ style={{ ...inner, objectFit: "fill", transform: m.push ? `scale(${1 + POST_PUSH * progress})` : undefined, transformOrigin: "center", filter: wholeBlur }}
/>
)}
- {blur?.boxes.map((bx, j) => (
+ {blur?.style === "pixelate" && <PixelLayer source={timed ? ref : img} crop={crop} censor={blur} />}
+ {blur?.style === "black" && (blur.boxes.length ? blur.boxes : [[0, 0, 1, 1]]).map((bx, j) => (
+ <div key={j} data-post-blur-box={j} className="pointer-events-none absolute bg-black" style={{ left: `${bx[0] * 100}%`, top: `${bx[1] * 100}%`, width: `${bx[2] * 100}%`, height: `${bx[3] * 100}%` }} />
+ ))}
+ {blur?.style === "blur" && blur.boxes.map((bx, j) => (
<div
key={j}
data-post-blur-box={j}
@@ -276,8 +334,12 @@ function MediaEl({
style={{ left: `${bx[0] * 100}%`, top: `${bx[1] * 100}%`, width: `${bx[2] * 100}%`, height: `${bx[3] * 100}%`, backdropFilter: blurCss, WebkitBackdropFilter: blurCss }}
/>
))}
- {blur?.label && (
- <span data-post-blur-label="" className="pointer-events-none absolute left-[2%] top-[2%] rounded-[3px] bg-black/70 px-[1.2cqw] py-[0.4cqw] text-[2.4cqw] leading-none text-white">
+ {blur?.label && at && (
+ <span
+ data-post-blur-label=""
+ className="pointer-events-none absolute rounded-[3px] bg-black/70 px-[1.2cqw] py-[0.4cqw] text-[2.4cqw] leading-none text-white"
+ style={{ left: `calc(${at[0] * 100}% + 2cqw)`, top: `calc(${at[1] * 100}% + 2cqh)` }}
+ >
{blur.label}
</span>
)}
@@ -286,7 +348,7 @@ function MediaEl({
}
export default function PostItemPlayer({
- project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false,
+ project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null,
}: {
project: string;
take?: string | null;
@@ -304,6 +366,8 @@ export default function PostItemPlayer({
published?: boolean;
/** With `published`: the UNCENSORED cut -- the slurs as posted (post-slurs.mjs), the redaction kept. */
uncensored?: boolean;
+ /** Its media scene (post-media-scene.mjs): which, and its place in it. */
+ scene?: { key: string; n: number; of: number } | null;
}) {
const wrap = useRef<HTMLDivElement | null>(null);
const [scale, setScale] = useState(0);
@@ -465,6 +529,8 @@ export default function PostItemPlayer({
data-post-follow-offset={followNow && followRoute?.segments.length ? String(Math.round(followNow.offset)) : undefined}
data-post-follow-pans={followRoute ? String(followRoute.segments.length) : undefined}
data-post-thread={follow?.thread ? String(follow.thread.tiles.length) : undefined}
+ data-post-scene={scene ? scene.key : undefined}
+ data-post-scene-n={scene ? `${scene.n + 1}/${scene.of}` : undefined}
data-post-thread-tiles={followNow?.tiles ? Object.entries(followNow.tiles).map(([sc, v]) => `${sc}=${v[0]}/${v[1]}`).join(" ") : undefined}
className="pointer-events-none absolute inset-0 overflow-hidden"
>
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -653,6 +653,7 @@ its knobs are one writer, `updatePostItem` (`lib/report/manifest.mjs`), refused
| `media[i].crop` — `[x, y, w, h]`, fractions of the picture: what of it is shown | post bench, **crop** (none, centre 80%, top half, bottom half) | `media.0.crop=0,0.1,1,0.8` (`=off`) | same |
| `media[i].push` — an image's slow push-in (6% over its span) | post bench, **slow push-in** | `media.0.push=on` | same |
| `media[i].blur` — the attachment CENSORED (`post-censor.mjs`): `{on, strength?: 1–10 (7), boxes?: [[x, y, w, h], …], label?: "…" \| false}`. The render blurs it for real (ffmpeg `gblur`, its sigma grown with the strength and the picture's width) -- the whole frame, or only its boxes (fractions of the picture as shown, after its crop, held still over the clip) -- and draws the label ("Censored"; `false`: none) at its corner. The file is never touched; `on: false` keeps the settings. A channel's `posts-markup.json` may censor it for every project (`censor`, below); the item's own `blur` wins | post bench, **censor it**, **strength**, **label** / **no label**, the boxes drawn on a still frame (drag; × removes; **Whole frame**); Play and the bench preview it | `media.0.blur=on` · `media.0.blur.strength=5` · `media.0.blur.label="Censored"` (`=off`: none) · `media.0.blur.boxes=0.2,0.3,0.4,0.4;…` (`=off`) · `media.0.blur=off` | same, `patch: {media: {"0": {blur: {on, strength, boxes, label}}}}` (merged; a null key cleared) |
+| `media[i].blur.band` — a BAND censored across the attachment (operator, 4 Nov: "censor everything neck down"): `{below: f}` everything under a line `f` of the way down, `{above: f}`, `{between: [a, b]}`; with, or instead, `{left: f}` / `{right: f}` one side of an upright line (both: where they meet). Fractions of the picture as shown (after its crop). One more region beside the boxes (none of either: the whole frame); the label sits at its corner. `media[i].blur.style` — how every region is censored: `blur` (default; its strength), `black` (a solid fill), `pixelate` (blocks of 0.8% of the width per step of strength: 18 across at 7). A PRESENTATION choice: it stays on in the uncensored cut, like the rest of the censor | post bench, **censor it**: **style** (blurred / black / pixelated), **band** (none / below a line / above a line / between two lines) and its side (the whole width / left / right of a line); the band's line(s) drawn on the still frame, **dragged** to where it starts (its % beside it); Play and the bench preview it (a pixelated region drawn coarse on a canvas, live) | `media.0.censor=below:0.38` (the censor on, the band set; the strength and label kept) · `media.0.censor=below:0.38:pixelate:8` · `media.0.censor=between:0.2,0.6:black` · `media.0.censor=below:0.4:left:0.5` · `media.0.censor=off` (off, band and style cleared) · the long forms `media.0.blur.band=above:0.3` (`=off`) and `media.0.blur.style=black` (`=off`: blur) | same, `patch: {media: {"0": {blur: {on, band: {below}, style}}}}` (a null `band` or `style` cleared) |
| `media[i].words` — a video's transcript (`{cues: [{start, end, text}]}` beside it), its words shown under it in Play and the render | post bench, **Transcribe its words (the editor)**: the editor's `transcribe` op on the file (a job on a local worker), set when it is done | `pnpm ops transcribe --json '{"path": "<project>/posts-media/…_1.mp4", "words": true, "out": "<project>/posts-media/…_1.words.json"}'`, then set `words` by the bench | `POST {op: "transcribe", id, media}` → `{jobId}` · `GET ?project&id&media&job=` |
| | In umtool | From a terminal | Route |
@@ -845,6 +846,24 @@ in the build's words (`validatePostCombos`). `k=` (empty) takes the default (the
| attach what a capture holds to a post item that carries none (captured after it went in): its media copied in and set, nothing else of the entry changed; then it plays and counts | — | `umtool posts attach <p> <item>… \| --all [--dry-run]` | — |
| 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`) | — |
+## Media scenes (one attachment, several messages)
+
+Consecutive post items that carry the same attachment are one scene: the attachment shown once and held in
+place, each message stacking in beside it ([report-video.md](report-video.md#media-scenes): what counts, the
+anchor, the column, the thread rule). The rule is `report-to-video/post-media-scene.mjs` over the combo
+counter's groups. The cut's knob rides on `render.posts.scene` (`updatePostSceneRender`), an item's on the item
+(`updatePostItem`), each refused in the build's words (`validatePostSceneRender`, `validatePostScene`).
+
+| Knob | In umtool | From a terminal | Route |
+|---|---|---|---|
+| `render.posts.scene.on` — scenes at all (default on) | — | `umtool posts scenes <p> off` (`on`, `auto`: the default) | — |
+| `scene` on a post item — `false`: never in a scene (it breaks one); `"join"`: an item with no attachment of its own joins the scene beside it (after a scene: that one; before: the next); absent: in one when a neighbour shares its attachment | post bench, **media scene**: its scene (message n of N, each item linked, the anchor named), **in a scene** (auto / never / join) | `umtool posts set-item <p> <item> scene=off` · `scene=join` · `scene=auto` | `POST /api/report/post-item {project, op: "set", id, patch: {scene: false \| "join" \| null}, token}` |
+| the scene's look — the attachment is the ANCHOR's (its first item that carries it): its crop and censor; its motion is the thread read's | the anchor's bench (`media[i].crop`, `media[i].blur`); `thread.shrink` / `.dim` / `.seconds` / `.pan` on the item | `umtool posts set-item <p> <anchor> media.0.censor=below:0.38` · `umtool posts set-item <p> <item> thread.shrink=0.5` | as above |
+
+| | In umtool | From a terminal | Route |
+|---|---|---|---|
+| the scenes: each one's items in order and its anchor | the post bench's **media scene** block; Play the cut draws them (the player's `data-post-scene`) | `umtool posts scenes <p> [--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
@@ -845,14 +845,16 @@ p-2117379128664236113, "a full read thread progression"). An item's CHAIN is the
read-following post items whose chains share a post. `planContext(timeline, i, render)` →
`{ prev, scene }`: the SCENE is what the run had on screen as the item before ended — its drawn
ancestors and its post, and what its own scene kept — drawn first on this item's card as tiles
-`scene:<id>`, in the tree's depth-first order (a branch in the order the run first showed it: the
+`conv:<id>`, in the tree's depth-first order (a branch in the order the run first showed it: the
root, the branch collapsing, the new branch). A scene post that is an ANCESTOR of this item is
kept on top as context; any other COLLAPSES away (scale 0, opacity 0, its gap closing) while
this item's first piece is revealed and the column pans, all at the first read's lead; the
opening frame is the post the item before ended on, in full. A post the item draws itself is its
own tile (a parent the item before ended on is carried; one the run showed earlier is context).
Scene tiles are never read (no blocks, no word spans), their words redacted by the terms of the
-item they came from, their authors blurred by its rule; the slur filter masks them too.
+item they came from, their authors blurred by its rule; the slur filter masks them too. An item in both a
+conversation's run and a media scene (post-media-scene.mjs) draws the CONVERSATION's scene: the media
+scene keeps only the attachment (read-follow.mjs enforces it; the card route too).
`umtool timeline <p> threads` lists each conversation of two items or more (its root, its
items' places, one run or split, a reply placed before what it answers, an item re-reading a post
its run already read — with `posts set-item <p> <item> thread.parent.<i>=context`);
@@ -950,6 +952,58 @@ went in: it draws nothing and does not count until it plays the attachment).
and measured as `posts reel` would have made it, nothing else of the entry changed --
and from then it plays and counts.
+### Media scenes
+
+CONSECUTIVE post items that carry the same attachment are ONE SCENE (operator, 4 Nov, on
+the Mr. Obvious cut: *"show all these 'jiggle' messages in a way that makes it obvious
+he's posted multiple different messages about this same picture"*).
+`report-to-video/post-media-scene.mjs` is the rule (pure, memoised per timeline); the
+build, Play, the card's route, the post bench and `umtool posts scenes` all read it.
+
+**What is the same attachment** is the combo counter's answer: its repeat groups (the X
+media id, the bytes, `match: "audio"` the sound), never a second matcher. Two items are
+in one scene when they are next to each other in the cut and share a group; anything else
+between them (a clip, a post with another attachment, an item with `scene: false`)
+breaks it. A post that talks about the picture without carrying it joins with
+`scene: "join"`: after a scene it joins that scene, before one the scene that follows.
+
+**The attachment** is shown ONCE and stays put: every item of the scene draws the
+scene's ANCHOR's (its first item that carries it) -- its file, its crop, its censor --
+in the same box from the first frame, never pushed in. Set the crop and censor on the
+anchor (a later item's bench says so and links it). A video or a GIF keeps each item's
+own in and out point (each read is timed to its own); an image is held. A join item
+gains the attachment's slot beside its words.
+
+**The card**: an item after the scene's first is drawn as a column of tiles, the thread
+read's (`post-thread.mjs`; read-follow pans it): the scene's earlier messages oldest
+first, the one just before it in full as that item ended -- shrinking and dimming
+(`thread.shrink`, `.dim`, over `.seconds`) as its own words come in under it -- the
+older ones already small and dim. A narrated item's own thread read is kept under them
+(the posts it answers and quotes, each shown in full while it is read); a post that is
+both an earlier message and the post it answers (carried) is drawn once, as the
+thread's. An un-narrated item draws the posts it answers small and dim above its words.
+Each earlier message is drawn under its own redaction, slur mask and author rule. The
+column rides on read-follow (on by default): with `follow: false` each card is drawn
+alone and only the attachment carries the scene.
+
+**A thread scene and a media scene on the same item: the thread scene wins.** A
+conversation thread drawn across items (lane/thread-tree's `post-conversation.mjs`
+`planContext`) takes the card; the media scene keeps only the attachment.
+
+The combo badge still pops on each repeat (×2, ×3 … as each new message comes in);
+redaction bars, the slur pill and beep, read-follow, word zooms, the author blur (with
+an item's `redact: false` honoured) and the attachment's trims all play as before.
+
+```jsonc
+"render": { "posts": { "scene": { "on": true } } }, // the cut's (default on)
+"timeline": [ { "type": "post", "id": "p-…", "scene": false }, // never in a scene
+ { "type": "post", "id": "p-…", "scene": "join" } ]
+```
+
+`umtool posts scenes <p>` lists each scene, its items in order and its anchor;
+`umtool posts scenes <p> off` turns them off for the cut; `umtool posts set-item <p>
+<item> scene=off|join|auto` one item's.
+
## 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
@@ -56,6 +56,7 @@ import { makeIntakeFixture } from "./intake-fixture.mjs";
import { makePostItemsFixture } from "./post-items-fixture.mjs";
import { makePostNarrationFixture } from "./post-narration-fixture.mjs";
import { makePostComboFixture } from "./post-combo-fixture.mjs";
+import { makeMediaScenesFixture } from "./media-scenes-fixture.mjs";
const CODE = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "song");
const dest = path.resolve(process.argv[2] ?? path.join(process.cwd(), ".e2e-song"));
@@ -1916,6 +1917,8 @@ makePostItemsFixture({ reports, channels: CHANNELS, deckManifest, cachedWindow:
makePostNarrationFixture({ reports, deckManifest });
// The combo counter (report-to-video/post-combo.mjs): one GIF answering three people (post-combo.spec.ts).
makePostComboFixture({ reports, channels: CHANNELS, deckManifest });
+// Media scenes and the band censor (post-media-scene.mjs, post-censor.mjs): one picture answered three times in a row (media-scenes.spec.ts).
+makeMediaScenesFixture({ reports, deckManifest });
// Gaps inside a clip and the bench waveform's zoom (gaps-zoom.spec.ts), which WRITES (gaps cut,
// undone, put back): its own project on gapvid, a recording id of its own (the fixture's vid1
// window -- tone, silences at 2.9-3.1 and 5.9-6.1 -- so nothing another spec fetches moves it).
diff --git a/umtool/e2e/fixtures/media-scenes-fixture.mjs b/umtool/e2e/fixtures/media-scenes-fixture.mjs
@@ -0,0 +1,61 @@
+// MEDIA SCENES (report-to-video/post-media-scene.mjs) and the BAND CENSOR
+// (post-censor.mjs `band`): a posts cut where one picture is answered by
+// several messages in a row (media-scenes.spec.ts).
+//
+// media-scenes-fixture p-j words only, `scene: "join"`: it joins the scene after it
+// p-a the picture's first use (the anchor): censored below the middle
+// p-b the same bytes, another X id
+// p-c the same again
+// p-x another picture (no repeat)
+// the deck on, no narration: each item is its read (3 s and more),
+// the picture beside the card from the first frame. WRITES its manifest
+// (the bench's band, the scene knob): the spec puts it back before each test.
+//
+// Synthetic, like every fixture.
+import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import { createHash } from "node:crypto";
+import { spawnSync } from "node:child_process";
+import path from "node:path";
+
+const ff = (args) => {
+ const r = spawnSync("ffmpeg", ["-v", "error", "-y", ...args]);
+ if (r.status !== 0) throw new Error(`ffmpeg ${args.join(" ")}: ${String(r.stderr)}`);
+};
+
+export const SCENE_CHANNEL = "scenechan-x";
+
+/** @param {{ reports: string, deckManifest: Function }} o */
+export function makeMediaScenesFixture({ reports, deckManifest }) {
+ const name = "media-scenes-fixture";
+ const dir = path.join(reports, name);
+ const media = path.join(dir, "posts-media", SCENE_CHANNEL);
+ for (const id of ["a", "b", "c", "x"]) mkdirSync(path.join(media, id), { recursive: true });
+ const pic = path.join(media, "a", "a_1.png");
+ ff(["-f", "lavfi", "-i", "testsrc=size=640x360:rate=1:duration=1", "-frames:v", "1", pic]);
+ ff(["-f", "lavfi", "-i", "testsrc2=size=640x360:rate=1:duration=1", "-frames:v", "1", path.join(media, "x", "x_1.png")]);
+ copyFileSync(pic, path.join(media, "b", "b_1.png"));
+ copyFileSync(pic, path.join(media, "c", "c_1.png"));
+ const bytes = readFileSync(pic);
+ const sha = createHash("sha256").update(bytes).digest("hex");
+ // The captures' records: the same bytes under three X ids (re-uploaded each time).
+ for (const [id, xid] of [["a", "AAAA"], ["b", "BBBB"], ["c", "CCCC"]]) {
+ writeFileSync(path.join(media, id, "capture.json"), JSON.stringify({ version: 1, id, media: [{ name: `${id}_1.png`, bytes: bytes.length, sha256: sha, url: `https://pbs.twimg.com/media/${xid}?format=png` }] }));
+ }
+ const at = (h) => `2026-11-02T2${h}:00:00.000Z`;
+ const base = (id, h, text, o = {}) => ({
+ type: "post", id, post: `${SCENE_CHANNEL}/${id.replace(/^p-/, "")}`, platform: "x", author: "Scene Subject", handle: "scenesubject",
+ date: at(h), text, url: `https://x.com/scenesubject/status/${id}`, engagement: { likes: 2 }, subjects: ["scenesubject"], ...o,
+ });
+ const img = (id, o = {}) => [{ src: `posts-media/${SCENE_CHANNEL}/${id}/${id}_1.png`, kind: "image", width: 640, height: 360, ...o }];
+ const timeline = [
+ base("p-j", 0, "Look at this picture, everyone.", { scene: "join" }),
+ base("p-a", 1, "First message about the picture.", { media: img("a", { blur: { on: true, band: { below: 0.5 } } }) }),
+ base("p-b", 2, "Second message, the same picture again.", { media: img("b") }),
+ base("p-c", 3, "Third message, still the same picture.", { media: img("c") }),
+ base("p-x", 3, "Something else entirely.", { media: img("x") }),
+ ];
+ const m = deckManifest(name, "The Media Scenes Fixture", timeline);
+ m.provenance = { ...m.provenance, channelSlug: SCENE_CHANNEL };
+ writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n");
+ return { dir };
+}
diff --git a/umtool/e2e/media-scenes.spec.ts b/umtool/e2e/media-scenes.spec.ts
@@ -0,0 +1,194 @@
+import { test, expect, type Page } from "@playwright/test";
+import { execFileSync } from "node:child_process";
+import { copyFileSync, existsSync, readFileSync, rmSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// MEDIA SCENES and the BAND CENSOR (report-to-video/post-media-scene.mjs,
+// post-censor.mjs; knobs.md, "Media scenes" and "A post item"; operator, 4
+// Nov: "make it obvious he's posted multiple different messages about this
+// same picture" -- "censor everything neck down"). Fixture:
+// e2e/fixtures/media-scenes-fixture.mjs -- p-j (words, joins), p-a (the
+// picture, censored below the middle: the anchor), p-b and p-c (the same
+// bytes again), p-x (another picture). No narration: each item is its read.
+//
+// MEDIA_SCENES_SHOTS=<dir> screenshots there
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const DIR = path.join(FIXTURE, "reports", "media-scenes-fixture");
+const MANIFEST = path.join(DIR, "video.manifest.json");
+const PROJECT = "reports/media-scenes-fixture";
+const SHOTS = process.env.MEDIA_SCENES_SHOTS ?? null;
+const PIC = "posts-media/scenechan-x/a/a_1.png";
+
+type Entry = { id: string; type: string; scene?: unknown; media?: Array<{ blur?: { band?: { below?: number }; style?: string } }> };
+const timeline = () => (JSON.parse(readFileSync(MANIFEST, "utf8")) as { timeline: Entry[] }).timeline;
+const umtool = (args: string[]) =>
+ execFileSync("node", ["bin/umtool.mjs", ...args], {
+ cwd: path.join(HERE, ".."),
+ encoding: "utf8",
+ env: { ...process.env, REPORTS_DIR: FIXTURE, CHANNELS_DIR: path.join(FIXTURE, "channels"), UMTOOL_CACHE_DIR: path.join(FIXTURE, "cache"), UMTOOL_PRINTS_CACHE: path.join(FIXTURE, "cache", "media-prints"), UMTOOL_MEDIA_DIR: "" },
+ });
+
+test.beforeAll(() => {
+ if (!existsSync(`${MANIFEST}.pristine`)) copyFileSync(MANIFEST, `${MANIFEST}.pristine`);
+});
+test.beforeEach(() => {
+ test.setTimeout(120_000);
+ copyFileSync(`${MANIFEST}.pristine`, MANIFEST);
+ rmSync(path.join(DIR, "revisions"), { recursive: true, force: true });
+});
+
+/** Play opened paused `at` seconds into `id`. */
+async function playAt(page: Page, id: string, at: number) {
+ await page.goto(urls.playHref(PROJECT, { bare: true, clip: id, at }));
+ const player = page.locator(`[data-post-play="${id}"]`);
+ await expect(player).toBeVisible({ timeout: 15_000 });
+ await expect.poll(async () => Math.abs(Number(await player.getAttribute("data-post-s")) - at)).toBeLessThan(0.3);
+ return { player, frame: page.frameLocator('[data-post-card-frame="read"]') };
+}
+const tilesOf = async (player: ReturnType<Page["locator"]>) =>
+ Object.fromEntries(((await player.getAttribute("data-post-thread-tiles")) ?? "").split(" ").filter(Boolean).map((x) => {
+ const [sc, v] = x.split("=");
+ return [sc, v.split("/").map(Number)];
+ })) as Record<string, number[]>;
+
+test("Play: one picture, several messages -- the picture held as the anchor's, the earlier messages stacked above, the one before giving way", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ // The join item (words only): in the scene, the picture beside its words -- the anchor's, censored as it is.
+ {
+ const { player } = await playAt(page, "p-j", 1);
+ await expect(player).toHaveAttribute("data-post-scene", "s1");
+ await expect(player).toHaveAttribute("data-post-scene-n", "1/4");
+ const m = player.locator("[data-post-media]");
+ await expect(m).toHaveCount(1);
+ await expect(m.locator("img")).toHaveAttribute("src", new RegExp(encodeURIComponent(PIC)));
+ await expect(m).toHaveAttribute("data-post-blurred", "band");
+ }
+ // p-b, its first frame: p-a (the message just before) in full, his own hidden under it.
+ {
+ const { player, frame } = await playAt(page, "p-b", 0);
+ await expect(player).toHaveAttribute("data-post-scene-n", "3/4");
+ await expect(frame.locator('[data-thread-slot="scene:0"] [data-scene-post="p-j"]')).toHaveCount(1);
+ await expect(frame.locator('[data-thread-slot="scene:1"] [data-scene-post="p-a"]')).toHaveCount(1);
+ const t = await tilesOf(player);
+ expect(t["scene:1"][0]).toBeGreaterThan(0.95);
+ expect(t.post[1]).toBeLessThan(0.2);
+ expect(t["scene:0"]).toEqual([0.62, 0.5]);
+ // The picture: the ANCHOR's file and censor, not its own copy's.
+ await expect(player.locator("[data-post-media] img")).toHaveAttribute("src", new RegExp(encodeURIComponent(PIC)));
+ await expect(player.locator("[data-post-media]")).toHaveAttribute("data-post-censor-band", "0,0.5,1,0.5");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-p-b-start.png") });
+ }
+ // Two seconds in: both earlier messages small and dim above, his own up, lit.
+ {
+ const { player, frame } = await playAt(page, "p-b", 2);
+ await expect(player).toHaveAttribute("data-post-thread-tiles", "scene:0=0.62/0.5 scene:1=0.62/0.5 post=1/1");
+ await expect.poll(async () => frame.locator('[data-thread-slot="scene:1"]').getAttribute("data-thread-state")).toBe("context");
+ await expect.poll(async () => frame.locator('[data-thread-slot="post"]').getAttribute("data-thread-state")).toBe("focus");
+ // Oldest up top: the earlier messages above his post.
+ const tops = await frame.locator("[data-thread-slot]").evaluateAll((els) => els.map((el) => [el.getAttribute("data-thread-slot"), Math.round(el.getBoundingClientRect().top)]));
+ expect(tops.map((x) => x[0])).toEqual(["scene:0", "scene:1", "post"]);
+ expect(Number(tops[0][1])).toBeLessThan(Number(tops[2][1]));
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-p-b-later.png") });
+ }
+ // Another picture: no scene, its own card alone.
+ {
+ const { player, frame } = await playAt(page, "p-x", 1);
+ await expect(player).not.toHaveAttribute("data-post-scene", /./);
+ await expect(frame.locator("[data-thread-slot]")).toHaveCount(0);
+ }
+ // umtool posts scenes says the same.
+ const v = JSON.parse(umtool(["posts", "scenes", PROJECT, "--json"])) as { scenes: { ids: string[]; anchor: string }[] };
+ expect(v.scenes.map((s) => `${s.ids.join(",")}@${s.anchor}`)).toEqual(["p-j,p-a,p-b,p-c@p-a"]);
+});
+
+test("Play: the band censor -- blurred below the middle, then black above a line, then pixelated (set-item's censor knob)", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ {
+ const { player } = await playAt(page, "p-a", 1);
+ const m = player.locator("[data-post-media]");
+ await expect(m).toHaveAttribute("data-post-blurred", "band");
+ await expect(m).toHaveAttribute("data-post-censor-style", "blur");
+ await expect(m).toHaveAttribute("data-post-censor-band", "0,0.5,1,0.5");
+ const box = m.locator("[data-post-blur-box]");
+ await expect(box).toHaveCount(1);
+ expect(await box.evaluate((el) => (el as HTMLElement).style.top)).toBe("50%");
+ expect(await box.evaluate((el) => getComputedStyle(el).backdropFilter)).toMatch(/blur/);
+ // The label at the band's corner, not the picture's.
+ expect(await m.locator("[data-post-blur-label]").evaluate((el) => (el as HTMLElement).style.top)).toContain("50%");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-band-blur.png") });
+ }
+ umtool(["posts", "set-item", PROJECT, "p-a", "media.0.censor=above:0.4:black"]);
+ expect(timeline().find((e) => e.id === "p-a")?.media?.[0].blur).toEqual({ on: true, band: { above: 0.4 }, style: "black" });
+ {
+ const { player } = await playAt(page, "p-a", 1);
+ const m = player.locator("[data-post-media]");
+ await expect(m).toHaveAttribute("data-post-censor-style", "black");
+ await expect(m).toHaveAttribute("data-post-censor-band", "0,0,1,0.4");
+ expect(await m.locator("[data-post-blur-box]").evaluate((el) => getComputedStyle(el).backgroundColor)).toBe("rgb(0, 0, 0)");
+ // The scene's later message draws the anchor's censor.
+ const b = (await playAt(page, "p-c", 1)).player.locator("[data-post-media]");
+ await expect(b).toHaveAttribute("data-post-censor-style", "black");
+ }
+ umtool(["posts", "set-item", PROJECT, "p-a", "media.0.censor=below:0.5:pixelate:9"]);
+ {
+ const { player } = await playAt(page, "p-a", 1);
+ const m = player.locator("[data-post-media]");
+ await expect(m).toHaveAttribute("data-post-censor-style", "pixelate");
+ // The pixels drawn coarse on a canvas over the band, the head left alone.
+ const canvas = m.locator("[data-post-pixelated]");
+ await expect(canvas).toHaveCount(1);
+ await expect.poll(async () => canvas.evaluate((c) => {
+ const cv = c as HTMLCanvasElement;
+ const ctx = cv.getContext("2d");
+ if (!ctx || !cv.width) return "none";
+ const at = (y: number) => ctx.getImageData(Math.floor(cv.width / 2), Math.floor(cv.height * y), 1, 1).data[3];
+ return `${at(0.25) > 0 ? "head" : "-"}/${at(0.75) > 0 ? "band" : "-"}`;
+ }), { timeout: 10_000 }).toBe("-/band");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-band-pixelate.png") });
+ }
+ umtool(["posts", "set-item", PROJECT, "p-a", "media.0.censor=off"]);
+ expect(timeline().find((e) => e.id === "p-a")?.media?.[0].blur).toEqual({ on: false, strength: 9 });
+});
+
+test("the bench: the band's line dragged writes the censor; the scene block names the anchor and keeps an item out of the scene", async ({ page }) => {
+ await page.setViewportSize({ width: 1500, height: 1100 });
+ await page.goto(urls.postBenchHref(PROJECT, "p-a"));
+ const block = page.locator('[data-post-bench-scene="s1"]');
+ await expect(block).toBeVisible();
+ await expect(block.locator("[data-post-bench-scene-members]")).toContainText("message 2 of 4");
+ await expect(page.locator('[data-post-bench-censor-band="0"]')).toHaveValue("below");
+ const line = page.locator('[data-post-bench-band-line="below"]');
+ await expect(line).toHaveAttribute("data-band-at", "0.5");
+ // Drag the line up to 30% of the picture's height.
+ const pad = page.locator('[data-post-bench-blur-pad="0"]');
+ const pb = (await pad.boundingBox())!;
+ const lb = (await line.boundingBox())!;
+ await page.mouse.move(lb.x + lb.width / 3, lb.y + lb.height / 2);
+ await page.mouse.down();
+ await page.mouse.move(lb.x + lb.width / 3, pb.y + pb.height * 0.3, { steps: 6 });
+ await page.mouse.up();
+ await expect.poll(async () => Number(await line.getAttribute("data-band-at"))).toBeCloseTo(0.3, 1);
+ // The player shows it at once (the anchor's own bench previews its edit).
+ await expect.poll(async () => (await page.locator("[data-post-play] [data-post-media]").getAttribute("data-post-censor-band")) ?? "").toMatch(/^0,0\.(2|3)\d*,1,/);
+ await page.locator('[data-post-bench-censor-style="0"]').selectOption("pixelate");
+ await expect(page.locator("[data-post-play] [data-post-media]")).toHaveAttribute("data-post-censor-style", "pixelate");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "media-scene-bench-band.png") });
+ await page.locator("[data-post-bench-save]").click();
+ await expect.poll(() => timeline().find((e) => e.id === "p-a")?.media?.[0].blur?.style).toBe("pixelate");
+ expect(timeline().find((e) => e.id === "p-a")?.media?.[0].blur?.band?.below).toBeCloseTo(0.3, 1);
+
+ // A later message's bench: the anchor named (its censor is set there); kept out, the scene shrinks.
+ await page.goto(urls.postBenchHref(PROJECT, "p-b"));
+ await expect(page.locator('[data-post-bench-scene-anchor="p-a"]')).toBeVisible();
+ await page.locator("[data-post-bench-scene-knob]").selectOption("off");
+ await page.locator("[data-post-bench-save]").click();
+ await expect.poll(() => timeline().find((e) => e.id === "p-b")?.scene).toBe(false);
+ const v = JSON.parse(umtool(["posts", "scenes", PROJECT, "--json"])) as { scenes: { ids: string[] }[] };
+ expect(v.scenes.map((s) => s.ids.join(","))).toEqual(["p-j,p-a"]);
+});
diff --git a/umtool/e2e/thread-walk.spec.ts b/umtool/e2e/thread-walk.spec.ts
@@ -102,10 +102,10 @@ test("ONE SCENE: his answer to the stranger opens on his reply above it (carried
// At its first frame: the post p-11 ended on, in full; the root small and dim above it.
{
const { player, frame } = await playAt(page, "p-12", 0.05);
- await expect(frame.locator('[data-thread-slot="scene:771"]')).toHaveAttribute("data-thread-scene", "keep");
+ await expect(frame.locator('[data-thread-slot="conv:771"]')).toHaveAttribute("data-thread-scene", "keep");
const t = await tilesOf(player);
expect(t["parent:1"]).toEqual([1, 1]);
- expect(t["scene:771"][0]).toBeLessThan(1);
+ expect(t["conv:771"][0]).toBeLessThan(1);
expect(t["parent:0"][1]).toBe(0);
if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "walk-open.png") });
}
@@ -115,10 +115,10 @@ test("ONE SCENE: his answer to the stranger opens on his reply above it (carried
const { player, frame } = await playAt(page, "p-12", fox + 1.4);
const t = await tilesOf(player);
expect(t["parent:0"]).toEqual([1, 1]);
- expect(t["scene:771"]).toEqual([0.62, 0.5]);
+ expect(t["conv:771"]).toEqual([0.62, 0.5]);
expect(t["parent:1"]).toEqual([0.62, 0.5]);
await expect.poll(async () => frame.locator('[data-thread-slot="parent:0"]').getAttribute("data-thread-state")).toBe("focus");
- expect(await slotTop(frame, "scene:771")).toBeLessThan(await slotTop(frame, "parent:1"));
+ expect(await slotTop(frame, "conv:771")).toBeLessThan(await slotTop(frame, "parent:1"));
if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "walk-fox.png") });
}
});
@@ -127,23 +127,23 @@ test("THE SIBLING SWAP: the next branch's item opens on the post the last one en
await page.setViewportSize({ width: 1366, height: 1000 });
{
const { player, frame } = await playAt(page, "p-13", 0.05);
- for (const sc of ["scene:11", "scene:834", "scene:12"]) await expect(frame.locator(`[data-thread-slot="${sc}"]`)).toHaveAttribute("data-thread-scene", "collapse");
+ for (const sc of ["conv:11", "conv:834", "conv:12"]) await expect(frame.locator(`[data-thread-slot="${sc}"]`)).toHaveAttribute("data-thread-scene", "collapse");
const t = await tilesOf(player);
- expect(t["scene:12"].slice(0, 2)).toEqual([1, 1]);
+ expect(t["conv:12"].slice(0, 2)).toEqual([1, 1]);
if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "walk-swap-open.png") });
}
{
const [drac] = STARTS([DRAC.text, B]);
const { player, frame } = await playAt(page, "p-13", drac + 1.4);
const t = await tilesOf(player);
- for (const sc of ["scene:11", "scene:834", "scene:12"]) expect(t[sc].slice(0, 2)).toEqual([0, 0]);
+ for (const sc of ["conv:11", "conv:834", "conv:12"]) expect(t[sc].slice(0, 2)).toEqual([0, 0]);
expect(t["parent:0"]).toEqual([1, 1]);
expect(t["parent:1"]).toEqual([0.62, 0.5]);
- await expect.poll(async () => frame.locator('[data-thread-slot="scene:12"]').getAttribute("data-thread-state")).toBe("hidden");
+ await expect.poll(async () => frame.locator('[data-thread-slot="conv:12"]').getAttribute("data-thread-state")).toBe("hidden");
await expect.poll(async () => frame.locator('[data-thread-slot="parent:0"]').getAttribute("data-thread-state")).toBe("focus");
// The root on top, the new branch under it; the collapsed slots closed up.
expect(await slotTop(frame, "parent:1")).toBeLessThan(await slotTop(frame, "parent:0"));
- await expect.poll(async () => frame.locator('[data-thread-slot="scene:12"]').evaluate((el) => el.getBoundingClientRect().height)).toBeLessThan(1);
+ await expect.poll(async () => frame.locator('[data-thread-slot="conv:12"]').evaluate((el) => el.getBoundingClientRect().height)).toBeLessThan(1);
if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "walk-swap-drac.png") });
}
});
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -71,6 +71,7 @@ import { CHANNELS_DIR as POLICY_CHANNELS_DIR } from "../paths.mjs";
import { FACT_REASONS, applyVerdictPatch, rejectPatch, rejectReasonOf } from "./rejectReasons.mjs";
import { DELIVERABLES_MODES } from "./storage.mjs";
import { COMBO_DEFAULTS, COMBO_ITEM_KEYS, validatePostCombo, validatePostComboRender } from "umtool-report-to-video/post-combo";
+import { SCENE_DEFAULTS, validatePostSceneRender } from "umtool-report-to-video/post-media-scene";
import { createSnapshot, listSnapshots } from "./snapshots.mjs";
import { benchPrepAfterWrite } from "./benchPrepTrigger.mjs";
import { citeFollow, clockOf, qrFollowsCite } from "./citeFollow.mjs";
@@ -2355,7 +2356,7 @@ export async function insertEntries(dir, afterId, specs, { token = null, op = "i
}
/** The knobs of a post item a write may set (post-item.mjs; knobs.md, "A post item"). */
-export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "redact", "follow", "thread"]);
+export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "redact", "follow", "thread", "scene"]);
/** A post item attachment's knobs: its trim, its sound, its crop, the push-in, its transcript, its censoring blur. */
export const POST_MEDIA_KNOBS = Object.freeze(["start", "end", "mute", "crop", "push", "words", "blur"]);
/** A context post's knobs (`quoted`, `parents[i]`): the operator's paraphrase of its words. */
@@ -2363,7 +2364,7 @@ export const POST_CONTEXT_KNOBS = Object.freeze(["paraphrase"]);
/**
* SET A POST ITEM's KNOBS (the post bench, `umtool posts set-item`): `patch`
- * is `{ hold?, mediaLayout?, redact?, follow?: false | { on?, dim?, ease? }, thread?: { parent?, quoted?, carry?,
+ * is `{ hold?, mediaLayout?, redact?, scene?: false | "join", follow?: false | { on?, dim?, ease? }, thread?: { parent?, quoted?, carry?,
* reveal?, shrink?, dim?, seconds?, pan? }, media?: { <i>: { start?, end?, mute?,
* crop?, push?, words?, blur? } }, quoted?: { paraphrase? }, parents?: { <i>:
* { paraphrase? } } }`; a null clears a knob (the default again), and so
@@ -2548,6 +2549,37 @@ export async function updatePostComboRender(dir, patch, { token = null } = {}) {
}
/**
+ * THE CUT's MEDIA SCENES (`render.posts.scene`; `umtool posts scenes <p>
+ * on|off`): `{ on }` -- consecutive post items with the same attachment drawn
+ * as one scene (post-media-scene.mjs), on by default; a null knob back to the
+ * default. Validated with the build's check.
+ *
+ * @param {string} dir
+ * @param {Record<string, any>} patch
+ * @param {{ token?: string | null }} [opts]
+ */
+export async function updatePostSceneRender(dir, patch, { token = null } = {}) {
+ if (!isObj(patch) || !Object.keys(patch).length) throw new Error("nothing to set");
+ for (const k of Object.keys(patch)) if (!(k in SCENE_DEFAULTS)) throw new Error(`${k} is not a scene knob (${Object.keys(SCENE_DEFAULTS).join(", ")})`);
+ return structural(dir, "post-scene-cut", token, (m) => {
+ if (!isObj(m.render)) m.render = {};
+ const posts = isObj(m.render.posts) ? m.render.posts : {};
+ const c = isObj(posts.scene) ? posts.scene : {};
+ for (const [k, v] of Object.entries(patch)) {
+ if (v === null || v === undefined) delete c[k];
+ else c[k] = v;
+ }
+ if (Object.keys(c).length) posts.scene = c;
+ else delete posts.scene;
+ if (Object.keys(posts).length) m.render.posts = posts;
+ else delete m.render.posts;
+ const errors = [...validatePostSceneRender(m.render), ...validatePostComboRender(m.render)];
+ if (errors.length) throw new StructureRefused(errors);
+ return { scene: m.render.posts?.scene ?? null };
+ });
+}
+
+/**
* ATTACH A CAPTURE's MEDIA to post items that carry none (`umtool posts
* attach`): `patches` is `{ <id>: media[] }`, each list already copied into
* the project; an item that has an attachment by now is left as it is. One
diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs
@@ -22,6 +22,7 @@ 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";
+import { mediaSceneOf, sceneEntry } from "umtool-report-to-video/post-media-scene";
const fin = (v) => typeof v === "number" && Number.isFinite(v);
const text = (v) => (typeof v === "string" ? v.replace(/\s+/g, " ").trim() : "");
@@ -42,8 +43,11 @@ export function headingOf(e) {
* @param {Record<string, any>} [render]
* @param {{ prev?: Record<string, any> | null, scene?: Record<string, any> | null } | null} [ctx] the item before it
* in the cut and the scene its run leaves on screen (post-conversation.mjs planContext)
+ * @param {Record<string, any> | null} [mediaScene] its media scene (post-media-scene.mjs mediaSceneOf): `post` is
+ * the item as the scene plays it (the shared attachment the anchor's), its plan's card the scene's column -- unless
+ * the conversation's scene takes the card (it wins; the media scene keeps the attachment)
*/
-export function postPlayEntry(e, render = undefined, ctx = null) {
+export function postPlayEntry(e, render = undefined, ctx = null, mediaScene = null) {
const day = postDay(e.date);
const dateKey = day ? Number(day.replace(/-/g, "")) : null;
const words = String(e.text ?? "").replace(/^RT @[A-Za-z0-9_]+:\s*/, "").replace(/\s+/g, " ").trim();
@@ -56,10 +60,11 @@ export function postPlayEntry(e, render = undefined, ctx = null) {
dateLabel: dateKeyLabel(dateKey),
date: day || null,
quote: words || null,
- post: e,
+ post: sceneEntry(e, mediaScene),
// `prev`: the item before it in the cut (post-thread.mjs: a parent that is that item is carried in); `scene`: the
- // posts its run left on screen (post-conversation.mjs: one conversation played as one scene).
- postPlan: postItemPlan(e, render, { prev: ctx?.prev ?? null, scene: ctx?.scene ?? null }),
+ // posts its run left on screen (post-conversation.mjs: one conversation played as one scene) -- it wins the card.
+ postPlan: postItemPlan(sceneEntry(e, mediaScene), render, { prev: ctx?.prev ?? null, scene: ctx?.scene ?? null, mediaScene: ctx?.scene ? null : mediaScene }),
+ ...(mediaScene ? { postScene: { key: mediaScene.key, n: mediaScene.n, of: mediaScene.of, ids: mediaScene.ids, anchor: mediaScene.anchor.id } } : {}),
};
}
@@ -112,9 +117,14 @@ export async function playView(project, { take = null, bare = false } = {}) {
const { starts } = scheduleFrom(durs, D);
const segments = timeline.map((e, i) => ({ id: e.id, start: Math.round(starts[i] * 1000) / 1000, duration: Math.round(durs[i] * 1000) / 1000 }));
const cache = await projectCache(project, manifest);
+ // The combo counter's repeat groups (post-combo.mjs), counted over the cut played: its badges, and its media
+ // scenes (post-media-scene.mjs: neighbours with the same attachment).
+ const { combos, groups: repeatGroups } = timeline.some((e) => e.type === "post")
+ ? await projectCombos(project.dir, selected, { channelsDir: channelsDirFor(project.dir, base) }).catch(() => ({ combos: {}, groups: [] }))
+ : { combos: {}, groups: [] };
const entries = await Promise.all(
timeline.map(async (e, i) => {
- if (e.type === "post") return postPlayEntry(e, render, planContext(timeline, i, render));
+ if (e.type === "post") return postPlayEntry(e, render, planContext(timeline, i, render), mediaSceneOf(timeline, i, repeatGroups, render));
if (e.type !== "clip" || !fin(e.start) || !fin(e.end)) return { id: e.id, type: String(e.type ?? "entry"), heading: headingOf(e), section: e.section ?? null };
const win = pickWindow(await windowsFor(project, e, cache), null);
const dateKey = clipDateKey(e);
@@ -160,10 +170,7 @@ 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] });
- }
+ 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/lib/report/postComboCli.mjs b/umtool/lib/report/postComboCli.mjs
@@ -5,6 +5,7 @@
// umtool posts repeats <project> [--match id|file|audio] [--json]
// umtool posts combo <project> [k=v …] [--json] the cut's (render.posts.combo)
// umtool posts combo <project> <item> off|on|auto|k=v … [--json] one item's (`combo`)
+// umtool posts scenes <project> [on|off] [--json] the media scenes (post-media-scene.mjs)
//
// `repeats` lists each repeated attachment with its posts in the cut's order
// (their dates, the tier that matched) and the badge each draws; a post item
@@ -19,7 +20,8 @@ import { channelsDirFor, readManifest } from "../projects/report.mjs";
import { withEditNotes } from "./edit-guard.mjs";
import { copyFile, mkdir, realpath, stat } from "node:fs/promises";
import path from "node:path";
-import { attachPostMedia, manifestToken, updatePostCombo, updatePostComboRender } from "./manifest.mjs";
+import { attachPostMedia, manifestToken, updatePostCombo, updatePostComboRender, updatePostSceneRender } from "./manifest.mjs";
+import { mediaScenes, sceneKnobs, sceneLines } from "umtool-report-to-video/post-media-scene";
import { mediaKindOf, probeMediaFile } from "./postReel.mjs";
export class ComboError extends Error {}
@@ -35,6 +37,11 @@ export const REPEATS_USAGE = [
" the cut's badge (render.posts.combo; k= back to the default); no knobs prints them.",
" umtool posts combo <project> <item> off|on|auto [label=…] [position=…] [color=…] [scale=…] [sfx=…] [--json]",
" one post item's: off draws no badge on it (it still counts), on/auto the cut's again; its own label, …",
+ " umtool posts scenes <project> [on|off] [--json]",
+ " the MEDIA SCENES: neighbouring post items that carry the same attachment (matched as above), each scene's",
+ " items in order and its anchor (the first to carry it: its crop and censor are the scene's). The attachment",
+ " stays put through a scene; each message stacks in beside it. on|off: the cut's (render.posts.scene.on,",
+ " default on). One item: umtool posts set-item <project> <item> scene=off|join|auto.",
" umtool posts attach <project> [<item> … | --all] [--dry-run] [--json]",
" a post item with no attachment whose capture holds one (captured after it went in): its media copied in and",
" set, as posts reel would have made it -- nothing else of the entry changes. One write (one undo point).",
@@ -118,6 +125,26 @@ export async function repeatsView(project, { match = null, cacheDir = undefined,
return { project: project.id, match: cut.match, knobs: comboKnobs(manifest.render), groups, combos: cut.combos };
}
+/**
+ * THE MEDIA SCENES VIEW (post-media-scene.mjs): the cut's scenes over the
+ * combo counter's groups -- `{ project, on, scenes: [{ key, ids, anchor,
+ * members }], lines }`. Off for the cut: none, `on` false.
+ *
+ * @param {{ id: string, dir: string }} project
+ */
+export async function scenesView(project, { channelsDir = null } = {}) {
+ const manifest = await readManifest(project.dir);
+ if (!manifest) throw new ComboError(`${project.id} has no manifest`);
+ const cut = await projectCombos(project.dir, manifest, { channelsDir: channelsDir ?? channelsDirFor(project.dir, manifest) });
+ const { scenes } = mediaScenes(manifest.timeline, cut.groups, manifest.render);
+ return {
+ project: project.id,
+ on: sceneKnobs(manifest.render).on,
+ scenes: scenes.map((s) => ({ key: s.key, ids: s.ids, anchor: s.anchor.id, group: s.group, members: s.members.map((m) => ({ id: m.id, media: m.media, joins: m.media === null })) })),
+ lines: sceneLines(scenes, manifest.timeline),
+ };
+}
+
const TIER_WORDS = { "media-id": "X media id", sha256: "same file", audio: "same sound" };
const MATCH_WORDS = { id: "the X media id", file: "the X media id, then the file's bytes", audio: "the X media id, the bytes, then the sound" };
@@ -241,6 +268,23 @@ async function comboRun(verb, words, flags, { root, json, out, err }) {
}
return 0;
}
+ if (verb === "scenes") {
+ const word = rest.find((w) => !w.startsWith("--"));
+ if (word !== undefined) {
+ const w = word.toLowerCase();
+ if (!ON.has(w) && !OFF.has(w) && w !== "auto") throw new ComboError(`posts scenes takes on, off or auto (the default), not ${word}`);
+ const { result, editNotes } = await withEditNotes(project, async () => updatePostSceneRender(project.dir, { on: w === "auto" ? null : ON.has(w) }, { token: await manifestToken(project.dir) }));
+ out(json ? JSON.stringify({ ok: true, scene: result.scene, token: result.token, editNotes }, null, 2) : `the cut's media scenes: ${result.scene?.on === false ? "off" : "on"}`);
+ return 0;
+ }
+ const v = await scenesView(project);
+ if (json) out(JSON.stringify({ ok: true, ...v }, null, 2));
+ else {
+ out(`${v.scenes.length} media scene(s) in ${project.id}${v.on ? "" : " (OFF for the cut: render.posts.scene.on false)"}`);
+ for (const l of v.lines) out(` ${l}`);
+ }
+ return 0;
+ }
if (verb === "repeats") {
const m = flags.get("--match");
if (m !== undefined && !["id", "file", "audio"].includes(String(m))) throw new ComboError("--match takes id, file or audio");
diff --git a/umtool/lib/report/postThread.test.mjs b/umtool/lib/report/postThread.test.mjs
@@ -130,3 +130,13 @@ test("timeline threads: the cut's conversations (split, tree order, a re-read wi
await run(["threads", "undo"]);
assert.deepEqual((await manifest(p)).timeline.map((e) => e.id), ["p-776", "p-779", "p-831", "p-848"], "one undo point");
});
+
+test("set-item's censor knobs: a band in one knob, its edge, its style; off clears them", () => {
+ assert.deepEqual(postItemPatchOf(["media.0.censor=below:0.38:blur"]).media, { 0: { blur: { on: true, band: { below: 0.38 }, style: "blur" } } });
+ assert.deepEqual(postItemPatchOf(["media.1.censor=between:0.2,0.6:pixelate:8"]).media, { 1: { blur: { on: true, band: { between: [0.2, 0.6] }, style: "pixelate", strength: 8 } } });
+ assert.deepEqual(postItemPatchOf(["media.0.censor=off"]).media, { 0: { blur: { on: false, band: null, style: null } } });
+ assert.deepEqual(postItemPatchOf(["media.0.blur.band=above:0.3:left:0.5", "media.0.blur.style=black"]).media, { 0: { blur: { band: { above: 0.3, left: 0.5 }, style: "black" } } });
+ assert.deepEqual(postItemPatchOf(["media.0.blur.band=off", "media.0.blur.style=off"]).media, { 0: { blur: { band: null, style: null } } });
+ assert.throws(() => postItemPatchOf(["media.0.censor=below"]), /takes a fraction/);
+ assert.throws(() => postItemPatchOf(["media.0.blur.style=below:0.3"]), /blur, black or pixelate/);
+});
diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs
@@ -35,6 +35,7 @@ import { channelsDirFor, readManifest } from "../projects/report.mjs";
import { withEditNotes } from "./edit-guard.mjs";
import { PostsRefused, StaleToken, StructureRefused, addArchiveAvatars, manifestToken, setPostAvatar, updatePostItem, updatePostRedact, updatePosts, upsertPost } from "./manifest.mjs";
import { postWarnings } from "./postCards.mjs";
+import { censorSpecOf } from "umtool-report-to-video/post-censor";
// `umtool posts roles` (postThreadCli.mjs ROLES_USAGE): its lines, kept here so the usage is one block.
const ROLES_LINES = [
@@ -80,14 +81,15 @@ export const POSTS_USAGE = [
" POST ITEMS: each archived post as an entry of the cut, its card and its attachments (report-video.md, \"Post items\"):",
" the channels merged in time order, de-duplicated by post id; a post already in the cut is skipped, so a re-run",
" adds only what is new -- in ONE write (one undo point), at the end unless --after.",
- " umtool posts set-item <project> <item> [hold=<s>|off] [layout=sequence|grid] [redact=on|off|auto] [follow=on|off|auto] [follow.dim=<0.2-1>] [follow.ease=<s>]",
+ " umtool posts set-item <project> <item> [hold=<s>|off] [layout=sequence|grid] [redact=on|off|auto] [scene=off|join|auto] [follow=on|off|auto] [follow.dim=<0.2-1>] [follow.ease=<s>]",
" [thread.parent[.<i>]=auto|full|excerpt|context|carry|hidden] [thread.quoted=auto|full|excerpt|context|hidden]",
" [thread.carry=auto|on|off] [thread.reveal=on|off] [thread.shrink=<0.3-1>] [thread.dim=<0.15-1>]",
" [thread.seconds=<0-3>] [thread.pan=<0.1-3>] [thread=auto]",
" [media.<i>.start=<s>] [media.<i>.end=<s>] [media.<i>.mute=on|off] [media.<i>.crop=x,y,w,h|off]",
" [media.<i>.push=on|off] [media.<i>.trim=off] [quoted.paraphrase=\"…\"|off]",
" [media.<i>.blur=on|off] [media.<i>.blur.strength=1–10] [media.<i>.blur.label=\"…\"|off]",
- " [media.<i>.blur.boxes=x,y,w,h;…|off]",
+ " [media.<i>.blur.boxes=x,y,w,h;…|off] [media.<i>.blur.band=below:<f>|above:<f>|between:<a>,<b>[:left:<f>|:right:<f>]|off]",
+ " [media.<i>.blur.style=blur|black|pixelate|off] [media.<i>.censor=<edge>:<f>[:<style>][:<strength>]|off]",
" [parent.<i>.paraphrase=\"…\"|off] [narration.rate=0.8–1.5|narration.<mix knob>=…] [--json]",
" a post item's knobs (the post bench's writer, updatePostItem): its hold, its images' grid, the blur of other authors,",
" an attachment's trim, sound, crop (fractions of its picture) and push-in; fit=read[:linger] (a narrated post: its",
@@ -97,6 +99,11 @@ export const POSTS_USAGE = [
" media.<i>.blur=on: the attachment CENSORED in the render -- a real blur (strength 1-10, default 7) of the whole",
" frame, or of its boxes (fractions of the picture as shown: x,y,w,h;…), labelled \"Censored\" (label=… or off);",
" its file is never touched. Play and the bench preview it; the bench draws boxes on a paused frame.",
+ " scene=off: never in a MEDIA SCENE (neighbours with the same attachment: it stays put, the messages stack beside it;",
+ " umtool posts scenes); join: an item with no attachment of its own joins the scene beside it; auto: by its attachment.",
+ " media.<i>.censor=below:0.38[:blur|black|pixelate][:<strength>]: a BAND -- everything below a line across the picture",
+ " (above:<f>, between:<a>,<b>; :left:<f> / :right:<f> narrows it to one side of an upright line) censored in a style;",
+ " the blur on, the rest of its settings kept; off turns it off. Stays on in an uncensored cut (a presentation choice).",
" thread.*: a THREAD READ (post-thread.mjs) -- a narrated item that reads the post it answers or quotes is drawn as",
" the conversation, each post read shown in full and shrunk/dimmed as the next comes in: what each context post is",
" on screen (auto: full when read, carried in when it is the item before, else context), the shrink, dim and their",
@@ -128,6 +135,7 @@ export const POSTS_USAGE = [
" umtool posts repeats <project> [--match id|file|audio] [--json] the attachments played more than once (the combo counter)",
" umtool posts combo <project> [k=v …] · <item> off|on|k=v … the combo badge's knobs (umtool posts repeats --help)",
" umtool posts attach <project> [<item> … | --all] [--dry-run] a capture's media onto items that carry none",
+ " umtool posts scenes <project> [on|off] [--json] the MEDIA SCENES: neighbours with the same attachment",
].join("\n");
const VALUED = new Set(["--set", "--attach", "--flag", "--author", "--id", "--crop", "--since", "--until", "--replies", "--order", "--limit", "--after", "--script", "--note", "--voice", "--engine", "--speed", "--pick", "--linger", "--derive", "--op", "--delete", "--match", "--target", "--occurrence", "--at", "--scale", "--hold", "--lead", "--ease", "--highlight", "--worker", "--without", "--drop-parts"]);
@@ -470,7 +478,7 @@ export async function postsCommand(args, { root = REPORTS_ROOT, out = (s) => con
if (verb === "avatars" && projectArg && !flags.has("--help")) return await avatarsCommand(projectArg, { root, json, dryRun, out });
if (verb === "context" && projectArg && !flags.has("--help")) return await contextCommand(projectArg, { root, json, dryRun, out });
// The combo counter (postComboCli.mjs): the attachments played more than once, the badge's knobs.
- if (verb === "repeats" || verb === "combo" || verb === "attach") return await (await import("./postComboCli.mjs")).comboCommand(verb, words.slice(1), flags, { root, json, out, err });
+ if (verb === "repeats" || verb === "combo" || verb === "attach" || verb === "scenes") return await (await import("./postComboCli.mjs")).comboCommand(verb, words.slice(1), flags, { root, json, out, err });
if ((verb !== "add" && verb !== "set") || !projectArg || !ref || flags.has("--help")) {
err(POSTS_USAGE);
return 2;
@@ -650,6 +658,11 @@ export function postItemPatchOf(pairs) {
if (k === "hold") out.hold = OFF.has(v) || v === "" ? null : Number(raw);
else if (k === "layout") out.mediaLayout = v === "sequence" ? null : v;
else if (k === "redact") out.redact = v === "auto" || v === "" ? null : onOff(v, k);
+ // Its media scene (post-media-scene.mjs): off (never in one), join (joins the scene beside it), auto (by its attachment).
+ else if (k === "scene") {
+ if (!["off", "join", "auto", "on", ""].includes(v) && !OFF.has(v)) throw new CliError("scene= takes off, join or auto");
+ out.scene = OFF.has(v) ? false : v === "join" ? "join" : null;
+ }
// Its read-follow (read-follow.mjs): follow=on|off|auto, follow.dim=<0.2-1>, follow.ease=<s> (auto/default: the cut's).
else if (k === "follow") out.follow = v === "auto" || v === "default" || v === "" ? null : onOff(v, k) ? { on: true } : false;
else if (k === "follow.dim" || k === "follow.ease") {
@@ -680,18 +693,37 @@ export function postItemPatchOf(pairs) {
}
else if (k === "quoted.paraphrase") out.quoted = { paraphrase: paraphraseOf(raw) };
else if (/^parents?\.\d+\.paraphrase$/.test(k)) (out.parents ??= {})[k.split(".")[1]] = { paraphrase: paraphraseOf(raw) };
- else if (/^media\.\d+\.blur(\.(strength|label|boxes))?$/.test(k)) {
- // The censoring blur (post-censor.mjs): on|off, its strength, its label (off: none), its boxes (x,y,w,h;…|off).
- const [, i, , sub] = /^media\.(\d+)\.blur(\.(strength|label|boxes))?$/.exec(k) ?? [];
+ else if (/^media\.\d+\.blur(\.(strength|label|boxes|band|style))?$/.test(k)) {
+ // The censoring blur (post-censor.mjs): on|off, its strength, its label (off: none), its boxes (x,y,w,h;…|off),
+ // its band (below:0.38, between:0.2,0.6, left:0.5 … |off), its style (blur|black|pixelate|off: blur).
+ const [, i, , sub] = /^media\.(\d+)\.blur(\.(strength|label|boxes|band|style))?$/.exec(k) ?? [];
const blur = (((out.media ??= {})[i] ??= {}).blur ??= {});
if (!sub) blur.on = onOff(v, k);
else if (sub === "strength") blur.strength = OFF.has(v) || v === "" ? null : Number(raw);
else if (sub === "label") blur.label = v === "off" ? false : raw.trim() === "" ? null : raw;
- else blur.boxes = OFF.has(v) || v === "" ? null : raw.split(";").map((b) => b.split(",").map(Number));
+ else if (sub === "band" || sub === "style") {
+ if (OFF.has(v) || v === "") blur[sub] = null;
+ else {
+ const c = censorSpecOf(raw);
+ if (c.error || (sub === "band" && !c.band) || (sub === "style" && !c.style) || Object.keys(c).length !== 1) throw new CliError(`${k}= takes ${sub === "band" ? "an edge and its place (below:0.38, above:0.2, between:0.2,0.6, left:0.5, right:0.5)" : "blur, black or pixelate"}${c.error ? ` -- ${c.error}` : ""}`);
+ blur[sub] = c[sub];
+ }
+ } else blur.boxes = OFF.has(v) || v === "" ? null : raw.split(";").map((b) => b.split(",").map(Number));
if (typeof blur.strength === "number" && !Number.isFinite(blur.strength)) throw new CliError(`${k}= takes a number (1-10)`);
+ } else if (/^media\.\d+\.censor$/.test(k)) {
+ // A BAND CENSOR in one knob (post-censor.mjs censorSpecOf): the blur on, its band, its style, its strength --
+ // `off`: the censor off and its band and style cleared.
+ const i = k.split(".")[1];
+ const blur = (((out.media ??= {})[i] ??= {}).blur ??= {});
+ if (OFF.has(v)) Object.assign(blur, { on: false, band: null, style: null });
+ else {
+ const c = censorSpecOf(raw);
+ if (c.error) throw new CliError(`${k}=: ${c.error}`);
+ Object.assign(blur, { on: true, ...c });
+ }
} else {
const m = /^media\.(\d+)\.(start|end|mute|crop|push|trim)$/.exec(k);
- if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, redact=, follow=, follow.dim|ease=, thread=, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan=, media.<i>.start|end|mute|crop|push|trim=, media.<i>.blur[.strength|.label|.boxes]=, quoted.paraphrase=, parent.<i>.paraphrase=)`);
+ if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, redact=, scene=, follow=, follow.dim|ease=, thread=, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan=, media.<i>.start|end|mute|crop|push|trim=, media.<i>.blur[.strength|.label|.boxes|.band|.style]=, media.<i>.censor=, quoted.paraphrase=, parent.<i>.paraphrase=)`);
const media = (out.media ??= {});
const one = (media[m[1]] ??= {});
if (m[2] === "start" || m[2] === "end") one[m[2]] = OFF.has(v) || v === "" ? null : Number(raw);
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -222,6 +222,7 @@ import { dropMarks, redactEntry } from "./post-redact.mjs";
import { avatarUrls } from "./post-avatars.mjs";
import { applyPostCombo } from "./post-combo-render.mjs";
import { projectCombos } from "./post-combo-prints.mjs";
+import { mediaSceneById, sceneEntry } from "./post-media-scene.mjs";
export { snap };
// The lint a build runs before it renders, and the prune after its final mux.
import { lintManifest, lintManifestFile, narrationLengthErrors } from "./lint.mjs";
@@ -6314,9 +6315,9 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
if (only && !entries.length) throw new Error(`no timeline entry with id ${only}`);
// The combo counter (post-combo.mjs): each post item's repeat of an earlier one's attachment, counted
// over the WHOLE cut, so an `--only` rebuild draws the count the full build would.
- const postCombos = manifest.timeline.some((e) => e?.type === "post" && e.media?.length)
- ? (await projectCombos(manifestDir, manifest, { channelsDir })).combos
- : {};
+ const { combos: postCombos, groups: postGroups } = manifest.timeline.some((e) => e?.type === "post" && e.media?.length)
+ ? await projectCombos(manifestDir, manifest, { channelsDir })
+ : { combos: {}, groups: [] };
// Under the deck, the box every footage segment is framed into: the posts
// feed's when this cut is a feed -- decided on the cut's WHOLE timeline, so
// an `--only` rebuild frames a clip as the full build would.
@@ -6436,11 +6437,14 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
// The item before it in the cut (post-thread.mjs: a parent that is that item is carried in, not cut to) and
// the scene its run leaves on screen (post-conversation.mjs: one conversation played as one scene).
...planContextOf(manifest.timeline, entry.id, render),
+ // Its media scene (post-media-scene.mjs): neighbours with the same attachment, over the WHOLE cut's groups --
+ // its attachment always, its card only when the conversation has no scene (read-follow.mjs: that one wins).
+ mediaScene: mediaSceneById(manifest.timeline, entry.id, postGroups, render),
});
if (fr) await writeCutRecord(seg, { version: 1, id: entry.id, framing: fr });
// Its combo badge (post-combo-render.mjs): a pass over the segment when its attachment repeats an earlier one's.
if (postCombos[entry.id]) {
- await applyPostCombo(seg, entry, {
+ await applyPostCombo(seg, sceneEntry(entry, mediaSceneById(manifest.timeline, entry.id, postGroups, render)), {
combo: postCombos[entry.id], render, outDir, box: df ? df.box : { x: 0, y: 0, width: render.width, height: render.height },
encode: encodeArgs(render), exec: execFileP, ffmpeg: FFMPEG, emit: (ev, f) => EMIT(ev, f),
});
diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json
@@ -67,6 +67,7 @@
"./post-item": "./post-item.mjs",
"./post-narration": "./post-narration.mjs",
"./post-censor": "./post-censor.mjs",
+ "./post-media-scene": "./post-media-scene.mjs",
"./post-redact": "./post-redact.mjs",
"./post-redact-files": "./post-redact-files.mjs",
"./post-slurs": "./post-slurs.mjs",
diff --git a/umtool/report-to-video/post-censor.mjs b/umtool/report-to-video/post-censor.mjs
@@ -3,7 +3,8 @@
// played BLURRED -- the whole frame, or only some regions of it -- with a
// small label saying so. umtool/docs/knobs.md, "A post item".
//
-// media[i].blur = { on: true, strength?: 1–10 (7), boxes?: [[x, y, w, h], …], label?: "…" | false }
+// media[i].blur = { on: true, strength?: 1–10 (7), boxes?: [[x, y, w, h], …], label?: "…" | false,
+// band?: { below?|above?|between?: [a, b], left?|right? }, style?: "blur"|"black"|"pixelate" }
//
// `boxes` are fractions of the picture AS SHOWN (after its crop), held still
// over the clip; none blurs the whole frame. `label` is the caption drawn on
@@ -11,33 +12,118 @@
// one of its attachments for every project (posts-markup.json's `censor`,
// post-redact.mjs); the item's own `blur` wins.
//
+// A BAND (operator, 4 Nov: "I'd also like to be able to censor across a line
+// dividing the image e.g. censor everything neck down"): the region across the
+// picture on one side of a line -- `below: 0.38` everything under 38% of its
+// height, `above`, `between: [a, b]` -- and, optionally, on one side of an
+// upright line (`left: 0.5` everything left of the middle, `right`); both:
+// where they meet. It is one more region beside the boxes (none of either:
+// the whole frame), and the label sits at its corner. `style` is how a region
+// is censored: `blur` (the default, its `strength`), `black` (a solid fill) or
+// `pixelate` (blocks, coarser with the strength).
+//
+// A PRESENTATION choice, like the rest of the censor: it stays ON in an
+// uncensored cut (post-slurs.mjs toggles the slurs only).
+//
// NOTHING IS REWRITTEN: the attachment's file stays as it was captured. The
// blur is a real one (ffmpeg gblur, sigma grown with the strength and the
// picture's size), drawn where public output is made -- the render. Play and
-// the post bench preview it (a CSS blur, the boxes as backdrop blurs).
+// the post bench preview it (a CSS blur, the boxes as backdrop blurs; a black
+// fill; the pixels drawn coarse on a canvas).
//
// PURE and dependency-free.
-export const POST_BLUR_DEFAULTS = Object.freeze({ strength: 7, label: "Censored" });
+export const POST_BLUR_DEFAULTS = Object.freeze({ strength: 7, label: "Censored", style: "blur" });
export const POST_BLUR_BOXES_MAX = 8;
+/** How a censored region is drawn. */
+export const POST_BLUR_STYLES = Object.freeze(["blur", "black", "pixelate"]);
+/** A band's edges: one across (below, above, between) and, optionally, one upright (left, right). */
+export const POST_BAND_ACROSS = Object.freeze(["below", "above", "between"]);
+export const POST_BAND_UPRIGHT = Object.freeze(["left", "right"]);
+const BLUR_KEYS = ["on", "strength", "boxes", "label", "band", "style"];
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
const fin = (v) => typeof v === "number" && Number.isFinite(v);
const r3 = (v) => Math.round(v * 1000) / 1000;
+const r4 = (v) => Math.round(v * 10000) / 10000;
/** Is attachment `m` blurred? */
export const blurOn = (m) => isObj(m?.blur) && m.blur.on === true;
-/** Its blur with the defaults filled: `{ strength, boxes, label }` (label null: none), or null when it is not blurred. */
+/**
+ * THE BAND's BOX, pure: `[x, y, w, h]` as fractions of the picture as shown,
+ * or null when `band` names no edge (or the region is empty). `below: a` is
+ * y from a to the foot, `above: a` from the top to a, `between: [a, b]` a to
+ * b; `left: a` x from 0 to a, `right: a` from a to the right edge.
+ */
+export function bandBox(band) {
+ if (!isObj(band)) return null;
+ let y0 = 0, y1 = 1, x0 = 0, x1 = 1;
+ let any = false;
+ if (fin(band.below)) [y0, any] = [band.below, true];
+ else if (fin(band.above)) [y1, any] = [band.above, true];
+ else if (Array.isArray(band.between) && band.between.length === 2 && band.between.every(fin)) {
+ y0 = Math.min(...band.between);
+ y1 = Math.max(...band.between);
+ any = true;
+ }
+ if (fin(band.left)) [x1, any] = [band.left, true];
+ else if (fin(band.right)) [x0, any] = [band.right, true];
+ const c = (v) => Math.min(1, Math.max(0, v));
+ [x0, x1, y0, y1] = [c(x0), c(x1), c(y0), c(y1)];
+ if (!any || x1 - x0 < 0.01 || y1 - y0 < 0.01) return null;
+ return [r4(x0), r4(y0), r4(x1 - x0), r4(y1 - y0)];
+}
+
+/** Every reason a band is refused. */
+export function bandErrors(band, where) {
+ if (band === undefined) return [];
+ if (!isObj(band)) return [`${where} must be {below?|above?|between?, left?|right?} (fractions of the picture)`];
+ const errors = [];
+ for (const k of Object.keys(band)) if (![...POST_BAND_ACROSS, ...POST_BAND_UPRIGHT].includes(k)) errors.push(`${where}.${k} is not a band edge (${[...POST_BAND_ACROSS, ...POST_BAND_UPRIGHT].join(", ")})`);
+ const across = POST_BAND_ACROSS.filter((k) => band[k] !== undefined);
+ const upright = POST_BAND_UPRIGHT.filter((k) => band[k] !== undefined);
+ if (across.length > 1) errors.push(`${where}: one of ${POST_BAND_ACROSS.join(", ")} (not ${across.join(" and ")})`);
+ if (upright.length > 1) errors.push(`${where}: one of left, right (not both)`);
+ if (!across.length && !upright.length) errors.push(`${where} names no edge (below, above, between, left or right)`);
+ const frac = (v) => fin(v) && v > 0 && v < 1;
+ for (const k of ["below", "above", "left", "right"]) if (band[k] !== undefined && !frac(band[k])) errors.push(`${where}.${k} must be a fraction of the picture, between 0 and 1 (0.38: 38% of the way ${k === "left" || k === "right" ? "across" : "down"})`);
+ if (band.between !== undefined) {
+ const b = band.between;
+ if (!(Array.isArray(b) && b.length === 2 && b.every(frac) && b[1] - b[0] >= 0.01)) errors.push(`${where}.between must be [a, b], fractions of the picture's height with a < b`);
+ }
+ if (!errors.length && !bandBox(band)) errors.push(`${where} leaves no picture to censor`);
+ return errors;
+}
+
+/**
+ * Its blur with the defaults filled: `{ strength, boxes, band, label, style }`
+ * (label null: none; `band` the band's box, also the LAST of `boxes` -- the
+ * regions drawn; none of either: the whole frame), or null when it is not
+ * blurred.
+ */
export function blurOf(m) {
if (!blurOn(m)) return null;
const b = m.blur;
+ const band = bandBox(b.band);
+ const boxes = Array.isArray(b.boxes) ? b.boxes.filter((x) => Array.isArray(x) && x.length === 4) : [];
return {
strength: fin(b.strength) ? Math.min(10, Math.max(1, b.strength)) : POST_BLUR_DEFAULTS.strength,
- boxes: Array.isArray(b.boxes) ? b.boxes.filter((x) => Array.isArray(x) && x.length === 4) : [],
+ boxes: band ? [...boxes, band] : boxes,
+ band,
label: b.label === false ? null : typeof b.label === "string" && b.label.trim() ? b.label.trim() : POST_BLUR_DEFAULTS.label,
+ style: POST_BLUR_STYLES.includes(b.style) ? b.style : POST_BLUR_DEFAULTS.style,
};
}
+/** Where the label sits, as fractions of the picture: the band's corner, else the picture's. */
+export const labelBoxOf = (bl) => bl?.band ?? [0, 0, 1, 1];
+
+/** A pixelated region's blocks `[across, down]`: a block is 0.8% of the picture's width per step of strength (at 7, 5.6%). */
+export function pixelGrid(strength, rw, rh, width, height) {
+ const block = Math.max(0.005, strength * 0.008);
+ return [Math.max(1, Math.round(rw / block)), Math.max(1, Math.round((rh * (height / Math.max(1, width))) / block))];
+}
+
/** The blur's sigma on a picture `width` px wide: 0.4% of the width per step of strength (at 7, ~2.8%). */
export const blurSigma = (strength, width) => Math.max(2, Math.round(width * strength * 0.004 * 10) / 10);
/** The same as a share of the width, for a preview (CSS `cqw`). */
@@ -50,9 +136,9 @@ export const boxOk = (b) =>
/** Every reason `media[i].blur` is refused. */
export function blurErrors(blur, where) {
if (blur === undefined) return [];
- if (!isObj(blur)) return [`${where} must be {on, strength?, boxes?, label?}`];
+ if (!isObj(blur)) return [`${where} must be {on, strength?, boxes?, label?, band?, style?}`];
const errors = [];
- for (const k of Object.keys(blur)) if (!["on", "strength", "boxes", "label"].includes(k)) errors.push(`${where}.${k} is not a blur knob (on, strength, boxes, label)`);
+ for (const k of Object.keys(blur)) if (!BLUR_KEYS.includes(k)) errors.push(`${where}.${k} is not a blur knob (${BLUR_KEYS.join(", ")})`);
if (typeof blur.on !== "boolean") errors.push(`${where}.on must be true or false`);
if (blur.strength !== undefined && !(fin(blur.strength) && blur.strength >= 1 && blur.strength <= 10)) errors.push(`${where}.strength must be 1–10`);
if (blur.boxes !== undefined) {
@@ -60,6 +146,8 @@ export function blurErrors(blur, where) {
else blur.boxes.forEach((b, j) => !boxOk(b) && errors.push(`${where}.boxes[${j}] must be [x, y, w, h] as fractions of the picture (each 0–1, inside it)`));
}
if (blur.label !== undefined && blur.label !== false && !(typeof blur.label === "string" && blur.label.length <= 40)) errors.push(`${where}.label must be words (at most 40 characters) or false`);
+ errors.push(...bandErrors(blur.band, `${where}.band`));
+ if (blur.style !== undefined && !POST_BLUR_STYLES.includes(blur.style)) errors.push(`${where}.style must be one of ${POST_BLUR_STYLES.join(", ")}`);
return errors;
}
@@ -67,27 +155,46 @@ export function blurErrors(blur, where) {
const dtText = (s) => String(s).replace(/\\/g, "\\\\").replace(/'/g, "\u2019").replace(/:/g, "\\:").replace(/%/g, "\\%");
/**
- * The filters that blur attachment `m`, drawn `w` × `h` px: `[inLabel]` →
- * `[outLabel]`. The whole frame, or each box: split, cropped, blurred and laid
- * back over. A label is drawn by labelFilter, on the composed frame.
+ * The filters that censor attachment `m`, drawn `w` × `h` px: `[inLabel]` →
+ * `[outLabel]`. The whole frame, or each region (its boxes, its band) in its
+ * style: blurred (split, cropped, blurred and laid back over), black (a filled
+ * box) or pixelated (cropped, scaled down and back up without smoothing). A
+ * label is drawn by labelFilter, on the composed frame.
*/
export function blurFilters(inLabel, outLabel, m, { width, height }) {
const b = blurOf(m);
if (!b) return [`[${inLabel}]null[${outLabel}]`];
const sigma = blurSigma(b.strength, width);
- if (!b.boxes.length) return [`[${inLabel}]gblur=sigma=${sigma}:steps=3[${outLabel}]`];
+ const regions = b.boxes.length ? b.boxes : [[0, 0, 1, 1]];
+ const px = (box) => {
+ const x = Math.round(box[0] * width);
+ const y = Math.round(box[1] * height);
+ return { x, y, w: Math.max(2, Math.min(width - x, Math.round(box[2] * width))), h: Math.max(2, Math.min(height - y, Math.round(box[3] * height))) };
+ };
+ if (b.style === "black") {
+ const fills = regions.map((box) => {
+ const r = px(box);
+ return `drawbox=x=${r.x}:y=${r.y}:w=${r.w}:h=${r.h}:color=black@1:t=fill`;
+ });
+ return [`[${inLabel}]${fills.join(",")}[${outLabel}]`];
+ }
+ const fx = (box, r) => {
+ if (b.style === "pixelate") {
+ const [nx, ny] = pixelGrid(b.strength, box[2], box[3], width, height);
+ return `scale=${nx}:${ny}:flags=neighbor,scale=${r.w}:${r.h}:flags=neighbor`;
+ }
+ return `gblur=sigma=${sigma}:steps=3`;
+ };
+ if (!b.boxes.length) return [`[${inLabel}]${fx([0, 0, 1, 1], { w: width, h: height })}[${outLabel}]`];
const out = [];
let cur = inLabel;
b.boxes.forEach((box, j) => {
- const x = Math.round(box[0] * width);
- const y = Math.round(box[1] * height);
- const w = Math.max(2, Math.min(width - x, Math.round(box[2] * width)));
- const h = Math.max(2, Math.min(height - y, Math.round(box[3] * height)));
+ const r = px(box);
const base = `${outLabel}_k${j}`;
out.push(`[${cur}]split[${base}a][${base}b]`);
- out.push(`[${base}b]crop=${w}:${h}:${x}:${y},gblur=sigma=${sigma}:steps=3[${base}c]`);
+ out.push(`[${base}b]crop=${r.w}:${r.h}:${r.x}:${r.y},${fx(box, r)}[${base}c]`);
const next = j === b.boxes.length - 1 ? outLabel : `${base}o`;
- out.push(`[${base}a][${base}c]overlay=x=${x}:y=${y}[${next}]`);
+ out.push(`[${base}a][${base}c]overlay=x=${r.x}:y=${r.y}[${next}]`);
cur = next;
});
return out;
@@ -95,17 +202,21 @@ export function blurFilters(inLabel, outLabel, m, { width, height }) {
/**
* The label's drawtext on the frame `[inLabel]` → `[outLabel]`: the words at
- * the attachment's top-left corner (its box `b` on the frame) while it is up,
- * or null when it has none (or there is no face to draw it in).
+ * the censored region's top-left corner -- the band's, else the
+ * attachment's (its box `b` on the frame) -- while it is up, or null when it
+ * has none (or there is no face to draw it in).
*/
export function labelFilter(inLabel, outLabel, m, b, { from, to, fontfile, scale = 1 }) {
const bl = blurOf(m);
if (!bl?.label || !fontfile) return null;
const size = Math.max(12, Math.round(26 * scale));
const pad = Math.round(size * 0.5);
+ const at = labelBoxOf(bl);
+ const x = Math.round(b.x + at[0] * b.width) + pad;
+ const y = Math.round(b.y + at[1] * b.height) + pad;
return (
`[${inLabel}]drawtext=fontfile='${fontfile}':text='${dtText(bl.label)}':fontsize=${size}:fontcolor=white:box=1:boxcolor=black@0.7:boxborderw=${Math.round(size * 0.35)}:` +
- `x=${b.x + pad}:y=${b.y + pad}:enable='between(t,${r3(from)},${r3(to)})'[${outLabel}]`
+ `x=${x}:y=${y}:enable='between(t,${r3(from)},${r3(to)})'[${outLabel}]`
);
}
@@ -142,3 +253,41 @@ export function censorEntry(entry, red) {
});
return changed ? { ...entry, media } : entry;
}
+
+/**
+ * A CENSOR in the knob's words (`umtool posts set-item … media.<i>.censor=`):
+ * colon-separated parts -- an edge and its place (`below:0.38`, `above:0.2`,
+ * `between:0.2,0.6`, `left:0.5`, `right:0.5`), a style (`blur`, `black`,
+ * `pixelate`) and a strength (1–10) -- as `{ band?, style?, strength? }`, or
+ * `{ error }`. `below:0.38:blur`, `below:0.4:left:0.5:pixelate:8`.
+ */
+export function censorSpecOf(text) {
+ const parts = String(text ?? "").trim().split(":").map((x) => x.trim()).filter(Boolean);
+ if (!parts.length) return { error: "a censor is <edge>:<fraction>[:<style>][:<strength>] (below:0.38:blur)" };
+ const out = {};
+ const band = {};
+ for (let k = 0; k < parts.length; k += 1) {
+ const p = parts[k].toLowerCase();
+ if ([...POST_BAND_ACROSS, ...POST_BAND_UPRIGHT].includes(p)) {
+ const v = parts[k + 1];
+ k += 1;
+ if (v === undefined) return { error: `${p} takes a fraction of the picture (${p}:${p === "between" ? "0.2,0.6" : "0.38"})` };
+ band[p] = p === "between" ? v.split(",").map(Number) : Number(v);
+ } else if (POST_BLUR_STYLES.includes(p)) out.style = p;
+ else if (/^\d+(\.\d+)?$/.test(p)) out.strength = Number(p);
+ else return { error: `${parts[k]}: not an edge (${[...POST_BAND_ACROSS, ...POST_BAND_UPRIGHT].join(", ")}), a style (${POST_BLUR_STYLES.join(", ")}) or a strength (1–10)` };
+ }
+ if (Object.keys(band).length) out.band = band;
+ const errors = [...bandErrors(out.band, "the band"), ...(out.strength !== undefined && !(out.strength >= 1 && out.strength <= 10) ? ["the strength must be 1–10"] : [])];
+ if (!out.band && !out.style && out.strength === undefined) errors.push("a censor names an edge, a style or a strength");
+ return errors.length ? { error: errors.join("; ") } : out;
+}
+
+/** A band in the knob's words (`below:0.38`, `between:0.2,0.6:left:0.5`), the inverse of censorSpecOf's band. */
+export function bandText(band) {
+ if (!isObj(band)) return "";
+ const out = [];
+ for (const k of POST_BAND_ACROSS) if (band[k] !== undefined) out.push(`${k}:${Array.isArray(band[k]) ? band[k].join(",") : band[k]}`);
+ for (const k of POST_BAND_UPRIGHT) if (band[k] !== undefined) out.push(`${k}:${band[k]}`);
+ return out.join(":");
+}
diff --git a/umtool/report-to-video/post-censor.test.mjs b/umtool/report-to-video/post-censor.test.mjs
@@ -6,8 +6,10 @@ import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
import { after, test } from "node:test";
-import { blurErrors, blurFilters, blurOf, blurSigma, censorEntry } from "./post-censor.mjs";
-import { postItemPlan, postLayout, validatePostItem } from "./post-item.mjs";
+import { bandBox, bandErrors, bandText, blurErrors, blurFilters, blurOf, blurSigma, censorEntry, censorSpecOf, labelFilter, pixelGrid } from "./post-censor.mjs";
+import { postItemPlan, postLayout, stepBoxes, validatePostItem } from "./post-item.mjs";
+
+const stepBoxesOf = (e, layout) => stepBoxes(postItemPlan(e).steps[0], layout.slot)[0];
import { postSegmentArgs } from "./post-render.mjs";
import { validatePostsMarkup } from "./post-redact.mjs";
@@ -26,7 +28,7 @@ test("the knob: on, a strength 1-10, boxes of fractions, a label or false; valid
const bad = blurErrors({ on: "yes", strength: 11, boxes: [[0.8, 0, 0.5, 0.5]], label: 3, extra: 1 }, "b");
assert.equal(bad.length, 5, bad.join("; "));
assert.ok(validatePostItem(entry({ on: true, strength: 0 })).some((e) => e.includes("media[0].blur.strength must be 1–10")));
- assert.deepEqual(blurOf({ blur: { on: true } }), { strength: 7, boxes: [], label: "Censored" });
+ assert.deepEqual(blurOf({ blur: { on: true } }), { strength: 7, boxes: [], band: null, label: "Censored", style: "blur" });
assert.equal(blurOf({ blur: { on: false, strength: 3 } }), null, "off keeps its settings and blurs nothing");
});
@@ -58,6 +60,60 @@ test("a channel's markup censors an attachment in every project; the item's own
assert.equal(validatePostsMarkup({ "1": { censor: [{ media: 9 }, { media: 0, blur: { strength: 30 } }] } }).length, 2);
});
+
+test("THE BAND's geometry: below, above, between, left and right, as a box of fractions; their meeting; nothing to censor refused", () => {
+ assert.deepEqual(bandBox({ below: 0.38 }), [0, 0.38, 1, 0.62]);
+ assert.deepEqual(bandBox({ above: 0.2 }), [0, 0, 1, 0.2]);
+ assert.deepEqual(bandBox({ between: [0.2, 0.6] }), [0, 0.2, 1, 0.4]);
+ assert.deepEqual(bandBox({ left: 0.5 }), [0, 0, 0.5, 1]);
+ assert.deepEqual(bandBox({ right: 0.75 }), [0.75, 0, 0.25, 1]);
+ assert.deepEqual(bandBox({ below: 0.4, left: 0.5 }), [0, 0.4, 0.5, 0.6], "both: where they meet (the bottom-left)");
+ assert.equal(bandBox({}), null);
+ assert.equal(bandBox({ below: 0.999 }), null, "a sliver is no band");
+ assert.deepEqual(bandErrors({ below: 0.38 }, "b"), []);
+ assert.equal(bandErrors({ below: 0.3, above: 0.6 }, "b").length, 1, "one edge across");
+ assert.ok(bandErrors({ below: 1.2 }, "b").some((e) => e.includes("fraction of the picture")));
+ assert.ok(bandErrors({ between: [0.6, 0.2] }, "b").some((e) => e.includes("a < b")));
+ assert.ok(bandErrors({ top: 0.2 }, "b").some((e) => e.includes("not a band edge")));
+ assert.ok(bandErrors({}, "b").some((e) => e.includes("names no edge")));
+ // On the item: validated with it; the band is a region beside the boxes, the label at its corner.
+ assert.deepEqual(blurErrors({ on: true, strength: 9, band: { below: 0.38 }, style: "pixelate" }, "b"), []);
+ assert.ok(blurErrors({ on: true, style: "smudge" }, "b").some((e) => e.includes("style must be one of blur, black, pixelate")));
+ assert.ok(validatePostItem(entry({ on: true, band: { below: 2 } })).some((e) => e.includes("media[0].blur.band.below")));
+ const bl = blurOf({ blur: { on: true, strength: 9, boxes: [[0.1, 0.1, 0.2, 0.2]], band: { below: 0.38 } } });
+ assert.deepEqual(bl, { strength: 9, boxes: [[0.1, 0.1, 0.2, 0.2], [0, 0.38, 1, 0.62]], band: [0, 0.38, 1, 0.62], label: "Censored", style: "blur" });
+ assert.deepEqual(pixelGrid(7, 1, 1, 500, 280), [18, 10]);
+});
+
+test("the censor in the knob's words: an edge and its place, a style, a strength", () => {
+ assert.deepEqual(censorSpecOf("below:0.38:blur"), { band: { below: 0.38 }, style: "blur" });
+ assert.deepEqual(censorSpecOf("between:0.2,0.6:black"), { band: { between: [0.2, 0.6] }, style: "black" });
+ assert.deepEqual(censorSpecOf("below:0.4:left:0.5:pixelate:8"), { band: { below: 0.4, left: 0.5 }, style: "pixelate", strength: 8 });
+ assert.deepEqual(censorSpecOf("pixelate"), { style: "pixelate" });
+ assert.match(censorSpecOf("below").error, /takes a fraction/);
+ assert.match(censorSpecOf("below:0.3:smudge").error, /not an edge/);
+ assert.match(censorSpecOf("below:0.3:11").error, /strength must be 1–10/);
+ assert.equal(bandText({ between: [0.2, 0.6], left: 0.5 }), "between:0.2,0.6:left:0.5");
+});
+
+test("the encode of a band: blurred, black or pixelated under the line, the label at the band's corner", () => {
+ const blurred = graphOf(entry({ on: true, strength: 9, band: { below: 0.5 } }), "/f/bold.ttf");
+ assert.match(blurred, /\[m0_0r\]split\[m0_0_k0a\]\[m0_0_k0b\]/);
+ assert.equal((blurred.match(/gblur/g) ?? []).length, 1);
+ const black = graphOf(entry({ on: true, band: { below: 0.5 }, style: "black", label: false }));
+ assert.match(black, /drawbox=x=0:y=\d+:w=\d+:h=\d+:color=black@1:t=fill/);
+ assert.doesNotMatch(black, /gblur|split/);
+ const pix = graphOf(entry({ on: true, band: { above: 0.5 }, style: "pixelate" }));
+ assert.match(pix, /scale=\d+:\d+:flags=neighbor,scale=\d+:\d+:flags=neighbor/);
+ const whole = graphOf(entry({ on: true, style: "pixelate" }));
+ assert.match(whole, /\[m0_0r\]scale=\d+:\d+:flags=neighbor/);
+ // The label: at the band's top-left, not the attachment's.
+ const lf = labelFilter("a", "b", { blur: { on: true, band: { below: 0.5 } } }, { x: 100, y: 50, width: 400, height: 200 }, { from: 0, to: 3, fontfile: "/f.ttf" });
+ assert.match(lf, /x=113:y=163:/);
+ const lf0 = labelFilter("a", "b", { blur: { on: true } }, { x: 100, y: 50, width: 400, height: 200 }, { from: 0, to: 3, fontfile: "/f.ttf" });
+ assert.match(lf0, /x=113:y=63:/);
+});
+
const ROOT = mkdtempSync(path.join(tmpdir(), "post-censor-"));
after(() => rmSync(ROOT, { recursive: true, force: true }));
@@ -81,3 +137,26 @@ test("the encode runs: a blurred frame is smoother than the clean one (ffmpeg)",
assert.ok(Number.isFinite(clean) && Number.isFinite(blurred), `${clean} ${blurred}`);
assert.ok(blurred < clean * 0.6, `edges: clean ${clean}, blurred ${blurred}`);
});
+
+test("the encode runs: a band below the middle blurs the foot and leaves the head sharp (ffmpeg)", () => {
+ const src = path.join(ROOT, "vb.mp4");
+ execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=s=320x180:d=3:r=30", "-c:v", "libx264", "-pix_fmt", "yuv420p", src]);
+ const png = path.join(ROOT, "cardb.png");
+ execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "color=c=black:s=1440x810", "-frames:v", "1", png]);
+ const run = (blur, name) => {
+ const e = entry(blur);
+ const out = path.join(ROOT, `${name}.mp4`);
+ const layout = postLayout(e, box);
+ execFileSync("ffmpeg", postSegmentArgs({ entry: e, box, plan: postItemPlan(e), layout, cards: { read: png }, files: [src], render: { fps: 30 }, outPath: out, encode: ["-c:v", "libx264", "-preset", "ultrafast"] }));
+ return { out, b: stepBoxesOf(e, layout) };
+ };
+ const energy = ({ out, b }, half) => {
+ const y = half === "top" ? b.y : b.y + Math.floor(b.height / 2);
+ const r = spawnSync("ffmpeg", ["-v", "info", "-ss", "1", "-i", out, "-frames:v", "1", "-vf", `crop=${b.width}:${Math.floor(b.height / 2) - 4}:${b.x}:${y + 2},edgedetect,signalstats,metadata=print:key=lavfi.signalstats.YAVG`, "-f", "null", "-"], { encoding: "utf8" });
+ return Number(/YAVG=([\d.]+)/.exec(`${r.stdout}${r.stderr}`)?.[1] ?? NaN);
+ };
+ const clean = run(null, "clean-b");
+ const band = run({ on: true, strength: 9, band: { below: 0.5 }, label: false }, "band-b");
+ assert.ok(Math.abs(energy(band, "top") - energy(clean, "top")) < energy(clean, "top") * 0.15, "the head as sharp as the clean frame");
+ assert.ok(energy(band, "bottom") < energy(clean, "bottom") * 0.5, `the foot blurred (${energy(band, "bottom")} vs ${energy(clean, "bottom")})`);
+});
diff --git a/umtool/report-to-video/post-combo.mjs b/umtool/report-to-video/post-combo.mjs
@@ -418,8 +418,9 @@ export function validatePostComboRender(render) {
const p = render?.posts;
if (p === undefined || p === null) return [];
if (!isObj(p)) return ["render.posts must be an object (its `combo` knobs)"];
- // render.posts is shared: `redact` and `slurs` are post-redact.mjs's (validatePostsRender checks them).
- const errors = Object.keys(p).filter((k) => !["combo", "redact", "slurs"].includes(k)).map((k) => `render.posts.${k} is not a knob (combo, redact, slurs)`);
+ // render.posts is shared: `redact` and `slurs` are post-redact.mjs's (validatePostsRender checks them), `scene`
+ // post-media-scene.mjs's (validatePostSceneRender).
+ const errors = Object.keys(p).filter((k) => !["combo", "redact", "slurs", "scene"].includes(k)).map((k) => `render.posts.${k} is not a knob (combo, redact, slurs, scene)`);
if (p.combo === undefined) return errors;
if (!isObj(p.combo)) return [...errors, "render.posts.combo must be an object of knobs"];
return [...errors, ...knobErrors(p.combo, "render.posts.combo", Object.keys(COMBO_DEFAULTS))];
diff --git a/umtool/report-to-video/post-conversation.mjs b/umtool/report-to-video/post-conversation.mjs
@@ -278,7 +278,7 @@ function contextsOf(tl, render) {
for (const t of L.tiles) {
if (t.mode === "hidden") continue;
if (t.mode === "scene") {
- if (t.action === "keep") end.push({ id: t.scope.slice(6), ref: t.ref });
+ if (t.action === "keep") end.push({ id: t.scope.slice(5), ref: t.ref });
} else if (t.scope === "post" || t.scope.startsWith("parent:")) {
const ref = sceneRefOf(e, t.scope);
if (ref?.id && str(ref.text).trim()) end.push({ id: ref.id, ref });
diff --git a/umtool/report-to-video/post-conversation.test.mjs b/umtool/report-to-video/post-conversation.test.mjs
@@ -103,23 +103,23 @@ test("THE SCENE: each item opens on what its run left on screen -- an ancestor k
assert.equal(c.prev, A);
assert.deepEqual(c.scene.tiles.map((t) => [t.id, t.action, t.from]), [["771", "keep", "small"], ["776", "keep", "full"]]);
const Lc = threadLayout(C, render, c);
- assert.deepEqual(Lc.tiles.map((t) => [t.scope, t.mode]), [["scene:771", "scene"], ["parent:1", "carry"], ["parent:0", "full"], ["post", "full"]]);
+ assert.deepEqual(Lc.tiles.map((t) => [t.scope, t.mode]), [["conv:771", "scene"], ["parent:1", "carry"], ["parent:0", "full"], ["post", "full"]]);
// B after C: the root is B's own (context); C's branch (A, Fox, C) collapses -- in the tree's order, between the root and B's branch.
const b = planContext(tl, 2, render);
assert.deepEqual(b.scene.tiles.map((t) => [t.id, t.action, t.from]), [["771", "keep", "small"], ["776", "collapse", "small"], ["834", "collapse", "small"], ["848", "collapse", "full"]]);
const Lb = threadLayout(B, render, b);
- assert.deepEqual(Lb.tiles.map((t) => [t.scope, t.mode, t.action ?? null]), [["parent:1", "context", null], ["scene:776", "scene", "collapse"], ["scene:834", "scene", "collapse"], ["scene:848", "scene", "collapse"], ["parent:0", "full", null], ["post", "full", null]]);
+ assert.deepEqual(Lb.tiles.map((t) => [t.scope, t.mode, t.action ?? null]), [["parent:1", "context", null], ["conv:776", "scene", "collapse"], ["conv:834", "scene", "collapse"], ["conv:848", "scene", "collapse"], ["parent:0", "full", null], ["post", "full", null]]);
// Another conversation: no scene.
assert.equal(planContext(tl, 3, render).scene, null);
// The schedule: the branch collapses (scale 0, opacity 0) as the stranger's post is revealed, all at the first read's lead.
const plan = postItemPlan(B, render, b);
const th = plan.follow.thread;
const row = (sc) => th.tiles.find((t) => t.scope === sc);
- assert.deepEqual([row("scene:848").from, row("scene:848").to], [[1, 1], [0, 0]]);
- assert.deepEqual([row("scene:776").from, row("scene:776").to], [[THREAD_DEFAULTS.shrink, THREAD_DEFAULTS.dim], [0, 0]]);
+ assert.deepEqual([row("conv:848").from, row("conv:848").to], [[1, 1], [0, 0]]);
+ assert.deepEqual([row("conv:776").from, row("conv:776").to], [[THREAD_DEFAULTS.shrink, THREAD_DEFAULTS.dim], [0, 0]]);
assert.deepEqual([row("parent:0").from, row("parent:0").to], [[1, 0], [1, 1]]);
- assert.equal(row("scene:848").t0, row("parent:0").t0);
- assert.equal(row("scene:848").ref.handle, "subject");
+ assert.equal(row("conv:848").t0, row("parent:0").t0);
+ assert.equal(row("conv:848").ref.handle, "subject");
assert.deepEqual(threadReadErrors(B, render, b), []);
assert.deepEqual(validateThreadReads({ render, timeline: tl }), []);
});
@@ -139,7 +139,7 @@ function fakeGeo(plan, { H = 520, line = 44 } = {}) {
blocks[b.k] = { top: y, bottom: y + h };
y += h + line;
}
- tiles[t.scope] = { top, height: y - top, ...(t.scope.startsWith("scene:") ? { gap: 22 } : {}) };
+ tiles[t.scope] = { top, height: y - top, ...(t.scope.startsWith("conv:") ? { gap: 22 } : {}) };
y += 22;
}
return { H, C: y, blocks, tiles };
@@ -157,7 +157,7 @@ test("THE INVARIANT, in a scene: every part of each item's read is on screen whi
const settle = Math.max(THREAD_DEFAULTS.pan, THREAD_DEFAULTS.seconds) + plan.follow.ease / 2 + 0.02;
t.parts.forEach((p, k) => {
const blk = plan.follow.blocks.find((b) => b.part === k);
- assert.ok(blk && !blk.scope.startsWith("scene:"), `${e.id} part ${k + 1}: a block of its own`);
+ assert.ok(blk && !blk.scope.startsWith("conv:"), `${e.id} part ${k + 1}: a block of its own`);
const to = (t.parts[k + 1] ? plan.follow.blocks.find((b) => b.part === k + 1).start : plan.follow.readEnd) - 0.45;
for (let s = blk.start + settle; s <= to; s += 0.1) {
const st = followStateAt(plan.follow, path, s);
@@ -167,7 +167,7 @@ test("THE INVARIANT, in a scene: every part of each item's read is on screen whi
const bb = g.blocks[blk.k];
assert.ok(bb.top - st.offset >= -1 && bb.bottom - st.offset <= geo.H + 1, `${e.id} part ${k + 1} at ${s.toFixed(2)} s: in the window (${(bb.top - st.offset).toFixed(0)}–${(bb.bottom - st.offset).toFixed(0)})`);
// A collapsed branch is gone (scale 0), its gap closed.
- for (const [sc, v] of Object.entries(st.tiles)) if (sc.startsWith("scene:") && plan.follow.thread.tiles.find((x) => x.scope === sc).action === "collapse") assert.equal(v[0], 0, `${sc} collapsed`);
+ for (const [sc, v] of Object.entries(st.tiles)) if (sc.startsWith("conv:") && plan.follow.thread.tiles.find((x) => x.scope === sc).action === "collapse") assert.equal(v[0], 0, `${sc} collapsed`);
}
});
// The opening frame is the one the item before ended on: the post it ended on in full, at the top of the window.
@@ -187,16 +187,41 @@ test("the card page draws the scene's posts as they were -- in the tree's order,
const plan = postItemPlan(B, render, ctx);
const html = postCardHtml(B, { width: 1600, height: 900, follow: true, thread: plan.follow.thread });
const at = (sc) => html.indexOf(`data-thread-slot="${sc}"`);
- for (const sc of ["parent:1", "scene:776", "scene:834", "scene:848", "parent:0", "post"]) assert.ok(at(sc) > 0, sc);
- assert.ok(at("parent:1") < at("scene:776") && at("scene:776") < at("scene:834") && at("scene:834") < at("scene:848") && at("scene:848") < at("parent:0") && at("parent:0") < at("post"), "the tree's order");
- assert.match(html, /data-thread-slot="scene:848" data-thread-scene="collapse"/);
- const scene = html.slice(at("scene:848"), at("parent:0"));
+ for (const sc of ["parent:1", "conv:776", "conv:834", "conv:848", "parent:0", "post"]) assert.ok(at(sc) > 0, sc);
+ assert.ok(at("parent:1") < at("conv:776") && at("conv:776") < at("conv:834") && at("conv:834") < at("conv:848") && at("conv:848") < at("parent:0") && at("parent:0") < at("post"), "the tree's order");
+ assert.match(html, /data-thread-slot="conv:848" data-thread-scene="collapse"/);
+ const scene = html.slice(at("conv:848"), at("parent:0"));
assert.doesNotMatch(scene, /data-w=|data-post-block=/, "never read");
assert.match(scene, /worthless loser/);
// Redacted as published: a term of the project's, and a stranger (no badge) blurred by C's rule.
const red = postCardHtml(B, { width: 1600, height: 900, follow: true, thread: plan.follow.thread, redaction: { terms: [{ term: "worthless", wholeWord: true }] } });
- assert.doesNotMatch(red.slice(red.indexOf('data-thread-slot="scene:848"'), red.indexOf('data-thread-slot="parent:0"')), /worthless/);
- const fox = red.slice(red.indexOf('data-thread-slot="scene:834"'), red.indexOf('data-thread-slot="scene:848"'));
+ assert.doesNotMatch(red.slice(red.indexOf('data-thread-slot="conv:848"'), red.indexOf('data-thread-slot="parent:0"')), /worthless/);
+ const fox = red.slice(red.indexOf('data-thread-slot="conv:834"'), red.indexOf('data-thread-slot="conv:848"'));
assert.match(fox, /data-redacted=""/);
assert.doesNotMatch(fox, /fox_one/);
});
+
+test("A THREAD SCENE AND A MEDIA SCENE on one item: the conversation's scene wins the card; the media scene keeps only the attachment (post-media-scene.mjs's header)", async () => {
+ const { repeatGroups } = await import("./post-combo.mjs");
+ const { mediaSceneOf, sceneEntry } = await import("./post-media-scene.mjs");
+ const gif = (id) => [{ src: `posts-media/acct-x/${id}/${id}_1.mp4`, kind: "gif", seconds: 0.8, width: 500, height: 280 }];
+ // A and C, one conversation (its id snapshotted on both; C's card shows only the stranger it answers), carrying
+ // the same GIF (the same bytes): both scenes want C's card.
+ const a = { ...A, conversation: "771", media: gif("776") };
+ const c = { ...C, conversation: "771", parents: [FOX], media: gif("848") };
+ const tl = [a, c];
+ const groups = repeatGroups(tl, () => ({ sha256: "same" }));
+ const ms = mediaSceneOf(tl, 1, groups, render);
+ assert.ok(ms, "C is in a media scene with A");
+ const ctx = planContext(tl, 1, render);
+ assert.ok(ctx.scene, "and in A's conversation's run");
+ const shown = sceneEntry(c, ms);
+ assert.equal(shown.media[0].src, a.media[0].src, "the media scene keeps the attachment: the anchor's");
+ const plan = postItemPlan(shown, render, { ...ctx, mediaScene: ms });
+ const scopes = plan.follow.thread.tiles.map((t) => t.scope);
+ assert.ok(scopes.includes("conv:776"), "the conversation's scene draws the card (A's post, collapsing)");
+ assert.ok(!scopes.some((sc) => sc.startsWith("scene:")), "no media-scene tile on it");
+ // With no conversation scene, the media scene's column is drawn as before.
+ const alone = postItemPlan(shown, render, { prev: a, scene: null, mediaScene: ms });
+ assert.ok(alone.follow.thread.tiles.some((t) => t.scope.startsWith("scene:")), "the media scene's earlier message above it");
+});
diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs
@@ -11,7 +11,7 @@
// media?: [{ src, kind: "image"|"video"|"gif", seconds?, width?, height?, audio?,
// start?, end?, mute?, crop?: [x, y, w, h], push?, words?,
// blur?: { on, strength?, boxes?, label? } }], (post-censor.mjs)
-// mediaLayout?: "sequence"|"grid", hold?, redact?, onscreen?,
+// mediaLayout?: "sequence"|"grid", hold?, redact?, onscreen?, scene?: false|"join", (post-media-scene.mjs)
// fx?: [{ kind: "word-zoom", match, target?, occurrence?, at?, lead?, hold?, scale?, ease?, highlight? }] }
//
// (`fx`: the card pushed in on a word as it is read -- word-zoom.mjs.)
@@ -37,6 +37,7 @@ import { blurErrors } from "./post-censor.mjs";
import { WORD_ZOOM_HIGHLIGHT_ALPHA, cardTokens, cardWordsOf, findMatch, targetTextOf, validatePostFx } from "./word-zoom.mjs";
import { FOLLOW_MIN_SIZE, followBlocks, followSchedule, scopeBlocks, validatePostFollow } from "./read-follow.mjs";
import { validatePostThread } from "./post-thread.mjs";
+import { validatePostScene, validatePostSceneRender } from "./post-media-scene.mjs";
/** The platforms a post item may come from (deck.mjs POST_PLATFORMS). */
export const POST_ITEM_PLATFORMS = Object.freeze(["x", "bluesky", "web"]);
@@ -224,13 +225,21 @@ export function postItemSeconds(entry, render = undefined) {
*
* @param {Record<string, any>} entry
* @param {Record<string, any>} [render]
- * @param {{ prev?: Record<string, any> | null, scene?: Record<string, any> | null }} [o] the item before it in the cut (post-thread.mjs
- * carries a parent that is it) and the scene its run leaves on screen (post-conversation.mjs planContext)
+ * `mediaScene` (post-media-scene.mjs mediaSceneOf): its media scene -- the
+ * scene's earlier messages in its card's column (`follow.thread`). The entry
+ * is the one the scene plays (sceneEntry: the shared attachment the
+ * anchor's): the caller makes it, so a channel's markup is laid on first.
+ * `scene` (post-conversation.mjs planContext): the posts its conversation's
+ * run left on screen -- it wins the card over a media scene.
+ *
+ * @param {Record<string, any>} entry
+ * @param {Record<string, any>} [render]
+ * @param {{ prev?: Record<string, any> | null, scene?: Record<string, any> | null, mediaScene?: Record<string, any> | null }} [o] the item before it in the cut (post-thread.mjs carries a parent that is it)
* @returns {{ reading: number, total: number, steps: Array<Record<string, any>>, held: number, narration?: Record<string, any>, follow?: Record<string, any> }}
*/
-export function postItemPlan(entry, render = undefined, { prev = null, scene = null } = {}) {
+export function postItemPlan(entry, render = undefined, { prev = null, scene = null, mediaScene = null } = {}) {
const hold = fin(entry?.hold) && entry.hold > 0 ? round3(entry.hold) : null;
- return planOf(entry, render, hold, prev, scene);
+ return planOf(entry, render, hold, prev, scene, mediaScene);
}
/**
@@ -239,14 +248,15 @@ export function postItemPlan(entry, render = undefined, { prev = null, scene = n
* @param {number | null} hold
* @param {Record<string, any> | null} [prev]
* @param {Record<string, any> | null} [scene]
+ * @param {Record<string, any> | null} [mediaScene]
*/
-function planOf(entry, render, hold, prev = null, scene = null) {
+function planOf(entry, render, hold, prev = null, scene = null, mediaScene = null) {
const narrated = isNarrated(entry);
const k = postNarrationKnobs(entry, render);
const sch = narrated ? narrationSchedule(entry, render) : null;
// Its read-follow (read-follow.mjs): each block's start on the item's clock -- null when it is off. `prev`: the
// item before it in the cut (post-thread.mjs: a parent that is that item is carried in, not cut to).
- const follow = followSchedule(entry, render, { hold, narration: sch, prev, scene });
+ const follow = followSchedule(entry, render, { hold, narration: sch, prev, scene, mediaScene });
const extra = { ...(sch ? { narration: sch } : {}), ...(follow ? { follow } : {}) };
if (sch && k.attach === "after") {
const voiceOnly = round3(sch.at + sch.seconds + k.tail);
@@ -489,6 +499,8 @@ export function validatePostItem(e) {
errors.push(...validatePostFollow(e));
// Its thread read's knobs (post-thread.mjs): what each context post is on screen, the shrink and dim.
errors.push(...validatePostThread(e));
+ // Its media scene (post-media-scene.mjs): false (never in one) or "join".
+ errors.push(...validatePostScene(e));
return errors;
}
@@ -527,7 +539,7 @@ export function validatePostItems(manifest) {
const errors = [];
const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : [];
for (const e of tl) if (e?.type === "post") errors.push(...validatePostItem(e));
- errors.push(...validatePostsRender(manifest?.render));
+ errors.push(...validatePostsRender(manifest?.render), ...validatePostSceneRender(manifest?.render));
// A word zoom on a word the project's list blanks (the corpus's and a post's markup are checked by the build).
const own = { terms: projectRedactOf(manifest?.render) };
for (const e of tl) if (e?.type === "post") errors.push(...fxRedactionErrors(e, own));
@@ -912,6 +924,10 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
// Each tile's HTML by its scope, then drawn in the layout's order (the tree's: a scene's posts among his own).
const byScope = new Map();
const tileHtml = { push: (h) => byScope.set(/data-thread-slot="([^"]+)"/.exec(h)?.[1] ?? `x${byScope.size}`, h) };
+ // A MEDIA SCENE (post-media-scene.mjs): the scene's earlier messages, oldest first, each drawn as its own post tile was.
+ for (const t of tiles) {
+ if (t.scope.startsWith("scene:") && isObj(t.entry)) tileHtml.push(sceneTileHtml(t, { k, pal, size: (text) => sizeFor(text, innerW, innerH - 170 * k), redaction, avatars }));
+ }
for (let i = parents.length - 1; i >= 0; i -= 1) {
const scope = `parent:${i}`;
const mode = tmode(scope);
@@ -955,7 +971,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
const text = str(ref.text);
const tsize = sizeFor(text || " ", innerW - av - Math.round(16 * k), innerH - 90 * k);
tileHtml.push(
- `<div class="tslot" data-thread-slot="${esc(t.scope)}" data-thread-scene="${t.action === "keep" ? "keep" : "collapse"}"><div class="tile tparent tscene" data-thread-tile="${esc(t.scope)}" data-thread-mode="scene" data-post-scene="${esc(t.scope.slice(6))}"${r ? ' data-redacted=""' : ""}>${avatarHtml(ref, { redact: r, size: av, img: pic(ref) })}<div class="pbody"><div class="phead">${nameHtml(ref, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(ref.date).split(" · ")[0])}</span>${ref.paraphrased ? '<span class="plabel" data-post-paraphrased="">paraphrased</span>' : ""}</div><div class="ptext tt" style="font-size:${tsize}px">${wordsHtml(text, r && ref.handle ? [...blurred, ref.handle] : blurred)}</div></div></div></div>`,
+ `<div class="tslot" data-thread-slot="${esc(t.scope)}" data-thread-scene="${t.action === "keep" ? "keep" : "collapse"}"><div class="tile tparent tscene" data-thread-tile="${esc(t.scope)}" data-thread-mode="scene" data-post-scene="${esc(t.scope.slice(5))}"${r ? ' data-redacted=""' : ""}>${avatarHtml(ref, { redact: r, size: av, img: pic(ref) })}<div class="pbody"><div class="phead">${nameHtml(ref, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(ref.date).split(" · ")[0])}</span>${ref.paraphrased ? '<span class="plabel" data-post-paraphrased="">paraphrased</span>' : ""}</div><div class="ptext tt" style="font-size:${tsize}px">${wordsHtml(text, r && ref.handle ? [...blurred, ref.handle] : blurred)}</div></div></div></div>`,
);
}
const order = [...tiles.map((t) => t.scope).filter((sc) => byScope.has(sc)), ...[...byScope.keys()].filter((sc) => !tiles.some((t) => t.scope === sc))];
@@ -1057,3 +1073,34 @@ ${BAR_CSS(pal.fg)}
})();
</script></body></html>`;
}
+
+/**
+ * A MEDIA SCENE's earlier message as a tile of a later item's column
+ * (post-media-scene.mjs; postCardHtml's threaded card): drawn as its own post
+ * tile was while it was read -- the repost line, its author (under its own
+ * privacy rule), its words at the size that fits it alone, its counts --
+ * with its own redaction laid on. `t`: the tile (`scope`, `mode`, `entry`:
+ * its card).
+ *
+ * @param {{ scope: string, mode: string, entry: Record<string, any> }} t
+ * @param {{ k: number, pal: Record<string, string>, size: (text: string) => number, redaction?: any, avatars?: Record<string, string> }} o
+ */
+export function sceneTileHtml(t, { k, pal, size, redaction = null, avatars = {} }) {
+ const e = redactEntry(t.entry, redaction);
+ const authors = cardAuthors(e);
+ const blurred = authors.filter((a) => a.redact && a.handle).map((a) => a.handle);
+ const red = (where) => authors.find((a) => a.where === where)?.redact ?? false;
+ const ownRed = red("author");
+ const own = { author: e.author, handle: e.handle };
+ const words = cardText(e);
+ const n = e.engagement ?? {};
+ const counts = [["replies", n.replies], ["reposts", n.reposts], ["likes", n.likes], ["quotes", n.quotes]]
+ .filter(([, v]) => fin(v) && v > 0)
+ .map(([k2, v]) => `<span class="count"><b>${countText(v)}</b> ${v === 1 ? String(k2).replace(/ies$/, "y").replace(/s$/, "") : k2}</span>`)
+ .join("");
+ const repost = e.repostedBy ? `<div class="repost" data-post-repost="">↻ ${esc(str(e.repostedBy.author) || `@${e.repostedBy.handle}`)} reposted</div>` : "";
+ const to = parentsOf(e)[0]?.handle ?? e.replyingTo;
+ const replying = to ? `<div class="replying">Replying to ${red("parents[0]") || red("replyingTo") ? '<span class="redact">@xxxxxxxx</span>' : `<span class="mention">@${esc(String(to).replace(/^@/, ""))}</span>`}</div>` : "";
+ const head = `<div class="head"${ownRed ? ' data-redacted=""' : ""}>${avatarHtml(own, { redact: ownRed, size: Math.round(64 * k), accent: ownRed ? undefined : pal.accent, img: avatarUrlOf(avatars, own.handle) })}<div class="hwho">${nameHtml(own, { redact: ownRed, cls: "big" })}<div class="date">${esc(cardDate(e.date))}</div></div><div class="mark">${esc(PLATFORM_NAME[e.platform] ?? "")}</div></div>`;
+ return `<div class="tslot" data-thread-slot="${esc(t.scope)}"><div class="tile tpost" data-thread-tile="${esc(t.scope)}" data-thread-mode="${esc(t.mode)}" data-scene-post="${esc(e.id ?? "")}">${repost}${replying}${head}<div class="twords" style="font-size:${size(words)}px">${wordsHtml(words, blurred)}</div>${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div></div>`;
+}
diff --git a/umtool/report-to-video/post-media-scene.mjs b/umtool/report-to-video/post-media-scene.mjs
@@ -0,0 +1,382 @@
+// A MEDIA SCENE (umtool/docs/report-video.md, "Media scenes"; operator, 4 Nov,
+// on the Mr. Obvious cut: "show all these 'jiggle' messages in a way that makes
+// it obvious he's posted multiple different messages about this same
+// picture"): CONSECUTIVE post items of a cut that carry the same attachment
+// are one scene. The attachment is shown ONCE and stays put -- the same
+// picture in the same box from the scene's first frame to its last, never
+// pushed in, never crossfaded in again -- and each message about it stacks
+// in beside it: the one being read in full and lit, the ones before it shrunk
+// and dimmed above it, the one just read giving way as the next comes in
+// (the thread read's parent → reply motion, post-thread.mjs, on its knobs).
+//
+// WHAT IS "THE SAME ATTACHMENT" is the combo counter's question, answered by
+// its matcher (post-combo.mjs repeatGroups: X's media id, then the bytes,
+// then -- `match: "audio"` -- the sound): two items are in one scene when they
+// are next to each other in the cut and share a repeat group. The planner
+// takes those groups; it never matches files itself.
+//
+// render.posts.scene = { on } the cut's: scenes at all (default on)
+// timeline[i].scene = false this item is never in a scene (it breaks one)
+// | "join" this item, with no attachment of its own in
+// the group, joins the scene beside it (a post
+// that talks about the picture without carrying it)
+//
+// THE ATTACHMENT in the scene is the scene's ANCHOR's -- its first item that
+// carries it: its file, its crop, its censor (set them there; a later item's
+// own are not drawn while it is in the scene). A video or a GIF keeps each
+// item's own in and out point (its read is timed to it); an image is held.
+//
+// THE CARD: an item after the first is drawn as a column of tiles (the thread
+// read's: read-follow.mjs pans it, post-item.mjs draws it) -- the scene's
+// earlier messages oldest first, then its own (and, narrated, the posts it
+// answers and quotes, as its thread read draws them). The column rides on
+// read-follow (on by default): with it off, each card is drawn alone and only
+// the attachment carries the scene. A thread read's own tile for a post that
+// is also an earlier message of the scene (the post it answers, just before
+// it) is drawn once, as the thread's.
+//
+// A THREAD SCENE and a media scene on the same item: THE THREAD SCENE WINS. A
+// conversation drawn across items (lane/thread-tree's post-conversation.mjs
+// `planContext(timeline, i)` → `{ prev, scene }`) takes the card; the media
+// scene keeps only the attachment (sceneEntry). The call sites pass this
+// module's plan as its own option (`mediaScene`), beside `prev`, so the two
+// meet only where read-follow.mjs builds the column.
+//
+// PURE and dependency-free: the build, Play, the card's route, the bench, the
+// lint and `umtool posts scenes` read the same plan from here.
+
+export const SCENE_DEFAULTS = Object.freeze({ on: true });
+/** A post item's own `scene`: false (never in one) or "join" (joins the scene beside it). */
+export const SCENE_ITEM_VALUES = Object.freeze([false, "join"]);
+/** The card fields an earlier message of the scene is drawn from (its tile). */
+const CARD_KEYS = ["id", "post", "platform", "author", "handle", "badge", "date", "text", "url", "repostedBy", "parents", "replyingTo", "subjects", "redact", "engagement"];
+
+const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+const r3 = (v) => Math.round(v * 1000) / 1000;
+
+// ---------------------------------------------------------------------------
+// The knobs.
+// ---------------------------------------------------------------------------
+
+/** The cut's scene knobs, the defaults filled in. */
+export function sceneKnobs(render) {
+ const r = isObj(render?.posts) && isObj(render.posts.scene) ? render.posts.scene : {};
+ return { ...SCENE_DEFAULTS, ...(typeof r.on === "boolean" ? { on: r.on } : {}) };
+}
+
+/** Every reason `render.posts.scene` cannot be built. */
+export function validatePostSceneRender(render) {
+ const v = render?.posts?.scene;
+ if (v === undefined) return [];
+ if (!isObj(v)) return ["render.posts.scene must be { on } (media scenes: consecutive post items with the same attachment)"];
+ const errors = Object.keys(v).filter((k) => !(k in SCENE_DEFAULTS)).map((k) => `render.posts.scene.${k} is not a scene knob (${Object.keys(SCENE_DEFAULTS).join(", ")})`);
+ if (v.on !== undefined && typeof v.on !== "boolean") errors.push("render.posts.scene.on must be true or false");
+ return errors;
+}
+
+/** Every reason one post item's `scene` cannot be built. */
+export function validatePostScene(e) {
+ if (e?.scene === undefined) return [];
+ return SCENE_ITEM_VALUES.includes(e.scene) ? [] : [`timeline ${e?.id ?? "?"}.scene must be false (never in a media scene) or "join" (joins the scene beside it); absent: in one when it shares the attachment`];
+}
+
+// ---------------------------------------------------------------------------
+// THE SCENES of a cut.
+// ---------------------------------------------------------------------------
+
+/** One item's groups: `Map<groupKey, mediaIndex>` (the repeat groups it is a member of). */
+function groupsById(groups) {
+ const out = new Map();
+ for (const g of Array.isArray(groups) ? groups : []) {
+ for (const m of Array.isArray(g?.members) ? g.members : []) {
+ if (!out.has(m.id)) out.set(m.id, new Map());
+ if (!out.get(m.id).has(g.key)) out.get(m.id).set(g.key, m.i);
+ }
+ }
+ return out;
+}
+
+const MEMO = new WeakMap();
+
+/**
+ * THE SCENES, pure and memoised (per timeline, groups and the cut's `on`):
+ * `{ scenes: [{ key, group, at: [timeline indices], ids, anchor: { id, at,
+ * media }, members: [{ id, at, media }] }], byAt: Map<index, scene> }` -- each
+ * a run of at least two neighbouring post items sharing a repeat group (and
+ * the `join` items beside it), with at least one that carries the attachment.
+ * `groups`: post-combo.mjs repeatGroups' (its members' `id` and `i`).
+ *
+ * A run is broken by anything that is not a post item of the group: a clip, a
+ * post with another attachment, `scene: false`. A `join` item after a scene
+ * joins it; one before the first scene of a run joins the scene that follows.
+ *
+ * @param {Array<Record<string, any>>} timeline
+ * @param {Array<{ key: string, members: Array<{ id: string, i: number }> }>} groups
+ * @param {Record<string, any>} [render]
+ */
+export function mediaScenes(timeline, groups, render = undefined) {
+ const tl = Array.isArray(timeline) ? timeline : [];
+ const on = sceneKnobs(render).on;
+ const memo = MEMO.get(tl);
+ if (memo && memo.groups === groups && memo.on === on) return memo.value;
+ const value = planScenes(tl, groups, on);
+ MEMO.set(tl, { groups, on, value });
+ return value;
+}
+
+function planScenes(tl, groups, on) {
+ const byAt = new Map();
+ const scenes = [];
+ if (!on) return { scenes, byAt };
+ const gOf = groupsById(groups);
+ const order = (Array.isArray(groups) ? groups : []).map((g) => g.key);
+ /** null: breaks a run; "J": joins; else its groups. */
+ const label = (e) => {
+ if (!isObj(e) || e.type !== "post" || typeof e.id !== "string" || e.scene === false) return null;
+ const own = gOf.get(e.id);
+ if (own?.size) return own;
+ return e.scene === "join" ? "J" : null;
+ };
+ const labels = tl.map(label);
+ let run = null;
+ let pending = [];
+ const close = () => {
+ if (run && run.at.length >= 2 && run.at.some((k) => labels[k] !== "J")) {
+ const members = run.at.map((k) => ({ id: tl[k].id, at: k, media: labels[k] === "J" ? null : labels[k].get(run.group) }));
+ const a = members.find((m) => m.media !== null);
+ const scene = { key: `s${scenes.length + 1}`, group: run.group, at: [...run.at], ids: members.map((m) => m.id), anchor: { id: a.id, at: a.at, media: a.media }, members };
+ scenes.push(scene);
+ for (const k of run.at) byAt.set(k, scene);
+ }
+ run = null;
+ };
+ /** The group a run starting at `k` takes: the one it shares with the next item that carries one, else its first. */
+ const groupFrom = (k) => {
+ const mine = labels[k];
+ let j = k + 1;
+ while (j < labels.length && labels[j] === "J") j += 1;
+ const next = labels[j];
+ const shared = next instanceof Map ? order.filter((g) => mine.has(g) && next.has(g)) : [];
+ return shared[0] ?? order.find((g) => mine.has(g));
+ };
+ labels.forEach((lab, k) => {
+ if (lab === null) {
+ close();
+ pending = [];
+ return;
+ }
+ if (lab === "J") {
+ if (run) run.at.push(k);
+ else pending.push(k);
+ return;
+ }
+ if (run && lab.has(run.group)) {
+ run.at.push(k);
+ return;
+ }
+ close();
+ run = { group: groupFrom(k), at: [...pending, k] };
+ pending = [];
+ });
+ close();
+ return { scenes, byAt };
+}
+
+/** The card fields of an item (its tile in a later item's column). */
+export const sceneCardOf = (e) => Object.fromEntries(CARD_KEYS.filter((k) => e?.[k] !== undefined).map((k) => [k, e[k]]));
+
+/**
+ * ITEM `i`'s SCENE, pure (memoised through mediaScenes): `{ key, n, of, ids,
+ * media, anchor: { id, media, entry: { id, post, media } }, before: [cards] }`
+ * -- `n` its place (0: the first), `media` the index of the shared attachment
+ * in its own media (null: a join item), `before` the earlier messages' cards,
+ * oldest first. Null when the item is in no scene.
+ *
+ * @param {Array<Record<string, any>>} timeline
+ * @param {number} i
+ * @param {Array<Record<string, any>>} groups
+ * @param {Record<string, any>} [render]
+ */
+export function mediaSceneOf(timeline, i, groups, render = undefined) {
+ const tl = Array.isArray(timeline) ? timeline : [];
+ const s = mediaScenes(tl, groups, render).byAt.get(i);
+ if (!s) return null;
+ const n = s.at.indexOf(i);
+ const a = tl[s.anchor.at];
+ return {
+ key: s.key,
+ n,
+ of: s.at.length,
+ ids: s.ids,
+ media: s.members[n].media,
+ anchor: { id: a.id, media: s.anchor.media, entry: { id: a.id, post: a.post, media: a.media } },
+ before: s.at.slice(0, n).map((k) => sceneCardOf(tl[k])),
+ };
+}
+
+/**
+ * The scene of the item with id `id` in a timeline (mediaSceneOf by id).
+ *
+ * @param {Array<Record<string, any>>} timeline
+ * @param {string} id
+ * @param {Array<Record<string, any>>} groups
+ * @param {Record<string, any>} [render]
+ */
+export function mediaSceneById(timeline, id, groups, render = undefined) {
+ const tl = Array.isArray(timeline) ? timeline : [];
+ const at = tl.findIndex((e) => e?.id === id);
+ return at < 0 ? null : mediaSceneOf(tl, at, groups, render);
+}
+
+// ---------------------------------------------------------------------------
+// THE ITEM AS THE SCENE PLAYS IT.
+// ---------------------------------------------------------------------------
+
+/** An attachment's timing (its own in a scene: its read is timed to it). */
+const TIMING = ["start", "end", "mute", "words", "seconds", "audio"];
+
+/**
+ * ITEM `entry` AS ITS SCENE PLAYS IT, pure: the shared attachment drawn as
+ * the anchor's (its file, size, crop and censor), with the item's own timing
+ * (in and out, sound, words) and never pushed in; a join item gains it as its
+ * first attachment (the anchor's timing). `censor(entry)` lays a channel's
+ * markup on the anchor first (post-censor.mjs censorEntry). The entry itself
+ * when it is in no scene.
+ *
+ * @param {Record<string, any>} entry
+ * @param {ReturnType<typeof mediaSceneOf>} scene
+ * @param {{ censor?: (e: Record<string, any>) => Record<string, any> }} [o]
+ */
+export function sceneEntry(entry, scene, { censor = null } = {}) {
+ if (!scene || !isObj(entry)) return entry;
+ const anchor = censor ? censor(scene.anchor.entry) : scene.anchor.entry;
+ const am = Array.isArray(anchor?.media) ? anchor.media[scene.anchor.media] : null;
+ if (!isObj(am)) return entry;
+ const look = Object.fromEntries(Object.entries(am).filter(([k]) => !TIMING.includes(k) && k !== "push"));
+ const own = Array.isArray(entry.media) ? entry.media : [];
+ if (scene.media === null) {
+ const { push, ...m } = am;
+ void push;
+ return { ...entry, media: [m, ...own].slice(0, 4) };
+ }
+ if (!isObj(own[scene.media])) return entry;
+ const media = own.map((m, k) => {
+ if (k !== scene.media) return m;
+ const time = Object.fromEntries(Object.entries(m).filter(([kk]) => TIMING.includes(kk)));
+ return { ...look, ...time };
+ });
+ return { ...entry, media };
+}
+
+// ---------------------------------------------------------------------------
+// THE COLUMN: the scene's earlier messages as tiles over the card's own.
+// ---------------------------------------------------------------------------
+
+/** The archive id of an item's post (`<channel>/<postId>` → `<postId>`). */
+const postIdOf = (e) => String(e?.post ?? "").split("/")[1] ?? "";
+
+/**
+ * THE SCENE's TILES over item `entry`'s card, pure: `{ on, scene, tiles,
+ * roles }` -- the scene's earlier messages (`scene:<j>`, oldest first; the
+ * one just before it `carry`, in full as that item ended, the rest
+ * `context`), then the card's own tiles: `base` (post-thread.mjs threadLayout,
+ * a narrated item's: the posts it answers and quotes as its read draws them)
+ * or, without one, the posts it answers as `context`, its post in full, the
+ * post it quotes. Each scene tile carries its message's card (`entry`). A post
+ * the thread draws (the post it answers, carried) is not drawn twice. `base`
+ * itself when the item is the scene's first (nothing above it), or in none.
+ *
+ * @param {Record<string, any> | null} base
+ * @param {Record<string, any>} entry
+ * @param {ReturnType<typeof mediaSceneOf>} scene
+ */
+export function sceneLayout(base, entry, scene) {
+ if (!scene || scene.n === 0 || !scene.before.length) return base;
+ const parents = (Array.isArray(entry?.parents) ? entry.parents : []).filter(isObj).slice(0, 2);
+ const drawn = new Set();
+ if (base?.tiles) {
+ for (const t of base.tiles) {
+ const m = /^parent:(\d)$/.exec(t.scope);
+ if (m && t.mode !== "hidden" && parents[Number(m[1])]?.id) drawn.add(String(parents[Number(m[1])].id));
+ }
+ }
+ const baseCarries = !!base?.tiles?.some((t) => t.mode === "carry");
+ const scenes = [];
+ scene.before.forEach((card0, j) => {
+ if (drawn.has(postIdOf(card0))) return;
+ // A message answering the one drawn just above it says so by its place: no "Replying to" line (as its own
+ // thread read drew it, the post it answers a tile over it).
+ const above = j > 0 ? postIdOf(scene.before[j - 1]) : "";
+ const answers = (Array.isArray(card0.parents) ? card0.parents : [])[0]?.id;
+ const card = above && answers !== undefined && String(answers) === above ? (({ parents, replyingTo, ...rest }) => (void parents, void replyingTo, rest))(card0) : card0;
+ scenes.push({ scope: `scene:${j}`, mode: "context", read: false, entry: card });
+ });
+ if (!baseCarries && scenes.length && scene.before.length - 1 === Number(scenes[scenes.length - 1].scope.slice(6))) scenes[scenes.length - 1].mode = "carry";
+ let own;
+ if (base?.tiles) own = base.tiles;
+ else {
+ // Un-narrated: the posts it answers small and dim above its words (an earlier message carried is drawn once).
+ const carried = new Set(scene.before.map(postIdOf));
+ own = [];
+ for (let i = parents.length - 1; i >= 0; i -= 1) {
+ const p = parents[i];
+ const words = typeof p.paraphrase === "string" && p.paraphrase.trim() ? p.paraphrase : typeof p.text === "string" ? p.text : "";
+ if (!words.trim() || carried.has(String(p.id ?? ""))) continue;
+ own.push({ scope: `parent:${i}`, mode: "context", read: false });
+ }
+ own.push({ scope: "post", mode: "full", read: true });
+ if (isObj(entry?.quoted) && String(entry.quoted.paraphrase ?? entry.quoted.text ?? "").trim()) own.push({ scope: "quoted", mode: "full", read: false });
+ }
+ if (!scenes.length) return base;
+ return { on: true, scene: scene.key, tiles: [...scenes, ...own], roles: base?.roles ?? [] };
+}
+
+/**
+ * THE SCHEDULE of an UN-NARRATED item's column (a narrated one's is the thread
+ * read's, threadSchedule, over sceneLayout's tiles), pure, in the thread's
+ * shape (read-follow.mjs pans it, Play and the build draw it): the message
+ * before it in full as that item ended, shrinking and dimming (`knobs`: the
+ * thread read's shrink, dim, seconds) as its words come in under it -- from
+ * its first block's start, less `lead` -- the older ones small and dim.
+ *
+ * @param {{ shrink: number, dim: number, seconds: number, pan: number, reveal?: boolean }} knobs
+ * @param {{ layout: Record<string, any>, blocks: Array<{ start: number | null }>, lead?: number }} o
+ */
+export function sceneSchedule(knobs, { layout, blocks, lead = 0.4 }) {
+ if (!layout?.on) return null;
+ const starts = (blocks ?? []).map((b) => b.start).filter(fin);
+ const T = starts.length ? Math.min(...starts) : 0;
+ const t0 = r3(Math.max(0, T - lead));
+ const win = { t0, t1: r3(t0 + knobs.seconds) };
+ const small = [knobs.shrink, knobs.dim];
+ const tiles = [];
+ for (const t of layout.tiles) {
+ if (t.mode === "hidden") continue;
+ const row = { scope: t.scope, mode: t.mode, read: !!t.read, from: [1, 1], to: [1, 1], t0: 0, t1: 0 };
+ if (t.mode === "context") {
+ row.from = t.scope === "quoted" ? [1, knobs.dim] : small;
+ row.to = row.from;
+ } else if (t.mode === "carry") Object.assign(row, { to: small, ...win });
+ else if (t.scope === "post" && knobs.reveal !== false) Object.assign(row, { from: [1, 0], to: [1, 1], ...win });
+ tiles.push(row);
+ }
+ return { shrink: knobs.shrink, dim: knobs.dim, seconds: knobs.seconds, pan: knobs.pan, contextRoom: 0.3, tiles };
+}
+
+/** A schedule's rows with the scene's messages on them (`entry`: what a `scene:<j>` tile draws), and the scene's key. */
+export function sceneRows(thread, layout) {
+ if (!thread || !layout?.scene) return thread;
+ const cards = new Map(layout.tiles.filter((t) => t.entry).map((t) => [t.scope, t.entry]));
+ return { ...thread, scene: layout.scene, tiles: thread.tiles.map((r) => (cards.has(r.scope) ? { ...r, entry: cards.get(r.scope) } : r)) };
+}
+
+/** The scene's lines for a person (`umtool posts scenes`): each scene, its items, the anchor. */
+export function sceneLines(scenes, timeline) {
+ const tl = Array.isArray(timeline) ? timeline : [];
+ return scenes.map((s) => {
+ const items = s.members.map((m) => `${m.id}${m.media === null ? " (joins)" : ""}${m.id === s.anchor.id ? " (anchor)" : ""}`);
+ const a = tl[s.anchor.at]?.media?.[s.anchor.media];
+ return `${s.key}: ${items.join(" → ")}${a?.src ? ` -- ${a.src}` : ""}`;
+ });
+}
diff --git a/umtool/report-to-video/post-media-scene.test.mjs b/umtool/report-to-video/post-media-scene.test.mjs
@@ -0,0 +1,160 @@
+// post-media-scene.mjs: consecutive post items with the same attachment are one
+// scene -- the planner over the combo counter's groups, the item as the scene
+// plays it, the column's tiles and its schedule, the knobs' checks.
+import assert from "node:assert/strict";
+import { test } from "node:test";
+import { mediaSceneById, mediaSceneOf, mediaScenes, sceneEntry, sceneLayout, sceneRows, sceneSchedule, validatePostScene, validatePostSceneRender } from "./post-media-scene.mjs";
+import { repeatGroups } from "./post-combo.mjs";
+import { postCardHtml, postItemPlan, validatePostItem, validatePostItems } from "./post-item.mjs";
+import { followStateAt, followPath } from "./read-follow.mjs";
+import { threadKnobs } from "./post-thread.mjs";
+
+const gif = (id, o = {}) => [{ src: `posts-media/c-x/${id}/${id}_1.mp4`, kind: "gif", seconds: 0.8, width: 500, height: 280, ...o }];
+const post = (id, text, o = {}) => ({ type: "post", id, post: `c-x/${id.replace(/^p-/, "")}`, platform: "x", author: "Mr. Subject", handle: "subject", date: "2026-11-02T22:15:00.000Z", text, ...o });
+const clip = (id) => ({ type: "clip", id, video: "v", start: 0, end: 5 });
+
+/** The cut: a clip, the same GIF three times running (one a join with none), another GIF, the first GIF again apart. */
+function cut() {
+ return [
+ clip("c1"),
+ post("p-1", "Phat ass jiggle", { scene: "join" }),
+ post("p-2", "It jiggle.", { media: gif("2", { blur: { on: true, strength: 9, band: { below: 0.38 } }, push: true }) }),
+ post("p-3", "@Movail2 it jiggle", { media: gif("3", { start: 0.1 }), parents: [{ id: "77", handle: "Movail2", text: "Ready for more lessons?" }] }),
+ post("p-4", "Something else", { media: gif("4") }),
+ clip("c2"),
+ post("p-5", "The jiggle, once more", { media: gif("5") }),
+ ];
+}
+/** Prints as post-combo-prints.mjs makes them: 2, 3 and 5 the same bytes; 4 another. */
+const PRINTS = { "p-2:0": { sha256: "aa" }, "p-3:0": { sha256: "aa" }, "p-4:0": { sha256: "bb" }, "p-5:0": { sha256: "aa" } };
+const groupsOf = (tl) => repeatGroups(tl, (id, i) => PRINTS[`${id}:${i}`]);
+
+test("THE SCENES: neighbours sharing a repeat group (the combo counter's matcher), a join item joined, a clip or another attachment breaks them", () => {
+ const tl = cut();
+ const g = groupsOf(tl);
+ assert.equal(g.length, 1, "one repeat group: p-2, p-3, p-5");
+ const { scenes, byAt } = mediaScenes(tl, g);
+ assert.equal(scenes.length, 1);
+ assert.deepEqual(scenes[0].ids, ["p-1", "p-2", "p-3"], "p-5 is the same GIF, but a clip and another GIF stand between");
+ assert.deepEqual(scenes[0].anchor, { id: "p-2", at: 2, media: 0 }, "the anchor: its first to carry it");
+ assert.deepEqual(scenes[0].members.map((m) => m.media), [null, 0, 0]);
+ assert.equal(byAt.get(6), undefined);
+ assert.equal(mediaScenes(tl, g), mediaScenes(tl, g), "memoised: the same plan for the same timeline and groups");
+ // Off for the cut: none.
+ assert.equal(mediaScenes(tl, g, { posts: { scene: { on: false } } }).scenes.length, 0);
+ // One item out (scene: false) breaks it: p-1 and p-2 alone (a join and one carrier) are still a scene.
+ const out = cut();
+ out[3].scene = false;
+ assert.deepEqual(mediaScenes(out, groupsOf(out)).scenes.map((s) => s.ids), [["p-1", "p-2"]]);
+ // A join item with nothing to join is in no scene; one carrier alone is none either.
+ const lone = [post("p-1", "words", { scene: "join" }), post("p-4", "x", { media: gif("4") })];
+ assert.equal(mediaScenes(lone, []).scenes.length, 0);
+ // A join after a scene joins it.
+ const after = [post("p-2", "a", { media: gif("2") }), post("p-3", "b", { media: gif("3") }), post("p-9", "c", { scene: "join" })];
+ assert.deepEqual(mediaScenes(after, groupsOf(after)).scenes[0].ids, ["p-2", "p-3", "p-9"]);
+});
+
+test("an item's scene: its place, the earlier messages' cards, the anchor; the item as the scene plays it", () => {
+ const tl = cut();
+ const g = groupsOf(tl);
+ assert.equal(mediaSceneOf(tl, 0, g), null, "a clip");
+ const s1 = mediaSceneOf(tl, 1, g);
+ assert.deepEqual([s1.n, s1.of, s1.media, s1.anchor.id, s1.before.length], [0, 3, null, "p-2", 0]);
+ const s3 = mediaSceneById(tl, "p-3", g);
+ assert.deepEqual([s3.n, s3.of, s3.media, s3.before.map((b) => b.id)], [2, 3, 0, ["p-1", "p-2"]]);
+ assert.equal(s3.before[1].media, undefined, "a card, not the entry: no media, no narration");
+ // p-3 plays the ANCHOR's look (its file, its censor) with its OWN timing; never pushed in.
+ const e3 = sceneEntry(tl[3], s3);
+ assert.equal(e3.media[0].src, "posts-media/c-x/2/2_1.mp4");
+ assert.deepEqual(e3.media[0].blur, { on: true, strength: 9, band: { below: 0.38 } });
+ assert.equal(e3.media[0].start, 0.1, "its own in point");
+ assert.equal(e3.media[0].push, undefined);
+ assert.equal(tl[3].media[0].src, "posts-media/c-x/3/3_1.mp4", "the entry is never rewritten");
+ // The anchor itself: not pushed in either (the picture stays put through the scene).
+ assert.equal(sceneEntry(tl[2], mediaSceneOf(tl, 2, g)).media[0].push, undefined);
+ // A join item gains the attachment: a slot beside its words, the same picture.
+ const e1 = sceneEntry(tl[1], s1);
+ assert.equal(e1.media.length, 1);
+ assert.equal(e1.media[0].src, "posts-media/c-x/2/2_1.mp4");
+ assert.equal(postItemPlan(e1).steps.length, 1);
+ // A channel's markup on the anchor is laid on first (the build's censorEntry).
+ const marked = sceneEntry(tl[3], s3, { censor: (e) => ({ ...e, media: e.media.map((m) => ({ ...m, blur: { on: true, style: "black" } })) }) });
+ assert.deepEqual(marked.media[0].blur, { on: true, style: "black" });
+ assert.equal(sceneEntry(tl[4], null), tl[4]);
+});
+
+test("THE COLUMN: the earlier messages as tiles over the card -- the one just before carried, older ones context -- its own after", () => {
+ const tl = cut();
+ const g = groupsOf(tl);
+ const s3 = mediaSceneOf(tl, 3, g);
+ const L = sceneLayout(null, tl[3], s3);
+ assert.deepEqual(L.tiles.map((t) => `${t.scope}:${t.mode}`), ["scene:0:context", "scene:1:carry", "parent:0:context", "post:full"]);
+ assert.equal(L.tiles[1].entry.id, "p-2");
+ assert.equal(sceneLayout(null, tl[1], mediaSceneOf(tl, 1, g)), null, "the scene's first: nothing above it");
+ // A narrated item's thread layout is the base: its own tiles kept, the scene's above them.
+ const base = { on: true, roles: [{ role: "parent:0" }], tiles: [{ scope: "parent:0", mode: "full", read: true }, { scope: "post", mode: "full", read: true }] };
+ const N = sceneLayout(base, tl[3], s3);
+ assert.deepEqual(N.tiles.map((t) => `${t.scope}:${t.mode}`), ["scene:0:context", "scene:1:carry", "parent:0:full", "post:full"]);
+ assert.deepEqual(N.roles, base.roles);
+ // The post it answers IS an earlier message (carried by the thread read): drawn once, as the thread's.
+ const reply = cut();
+ reply[3].parents = [{ id: "2", handle: "subject", text: "It jiggle." }];
+ const carried = { on: true, roles: [], tiles: [{ scope: "parent:0", mode: "carry", read: false }, { scope: "post", mode: "full", read: true }] };
+ const C = sceneLayout(carried, reply[3], mediaSceneOf(reply, 3, groupsOf(reply)));
+ assert.deepEqual(C.tiles.map((t) => `${t.scope}:${t.mode}`), ["scene:0:context", "parent:0:carry", "post:full"]);
+});
+
+test("THE SCHEDULE (un-narrated): the message before in full, shrinking and dimming as its words come in; the older ones small; the plan carries it", () => {
+ const tl = cut();
+ const g = groupsOf(tl);
+ const s3 = mediaSceneOf(tl, 3, g);
+ const e3 = sceneEntry(tl[3], s3);
+ const k = threadKnobs(e3, undefined);
+ const L = sceneLayout(null, e3, s3);
+ const sch = sceneSchedule(k, { layout: L, blocks: [{ start: 1.2 }, { start: 2 }], lead: 0.4 });
+ const row = (sc) => sch.tiles.find((t) => t.scope === sc);
+ assert.deepEqual([row("scene:1").from, row("scene:1").to, row("scene:1").t0, row("scene:1").t1], [[1, 1], [0.62, 0.5], 0.8, 1.5]);
+ assert.deepEqual([row("scene:0").from, row("scene:0").to], [[0.62, 0.5], [0.62, 0.5]]);
+ assert.deepEqual([row("post").from, row("post").to], [[1, 0], [1, 1]], "his words revealed under it");
+ const rows = sceneRows(sch, L);
+ assert.equal(rows.tiles.find((t) => t.scope === "scene:0").entry.id, "p-1");
+ assert.equal(rows.scene, "s1");
+ // The plan: postItemPlan carries the column on its follow (read-follow on by default).
+ const plan = postItemPlan(e3, undefined, { mediaScene: s3 });
+ assert.deepEqual(plan.follow.thread.tiles.map((t) => t.scope), ["scene:0", "scene:1", "parent:0", "post"]);
+ assert.equal(plan.follow.thread.scene, "s1");
+ // Follow off: no column (each card alone), the attachment still the scene's.
+ assert.equal(postItemPlan({ ...e3, follow: false }, undefined, { mediaScene: s3 }).follow, undefined);
+ // The state on the clock: at 0 the one before in full and his post hidden; after, small and his post up.
+ const geo = { H: 900, C: 1400, blocks: {}, tiles: { "scene:0": { top: 0, height: 300 }, "scene:1": { top: 322, height: 300 }, "parent:0": { top: 644, height: 200 }, post: { top: 866, height: 300 } } };
+ const path = followPath(plan.follow, geo);
+ const at0 = followStateAt(plan.follow, path, 0).tiles;
+ const late = followStateAt(plan.follow, path, 5).tiles;
+ assert.deepEqual([at0["scene:1"][0], at0.post[1]], [1, 0]);
+ assert.deepEqual([late["scene:1"][0], late["scene:1"][1], late.post[1]], [0.62, 0.5, 1]);
+});
+
+test("the card draws the scene's messages as tiles above his own (redacted, their authors under their own rule)", () => {
+ const tl = cut();
+ const g = groupsOf(tl);
+ const s3 = mediaSceneOf(tl, 3, g);
+ const e3 = sceneEntry(tl[3], s3);
+ const plan = postItemPlan(e3, undefined, { mediaScene: s3 });
+ const html = postCardHtml(e3, { width: 1440, height: 810, follow: true, thread: plan.follow.thread, redaction: { terms: [{ term: "jiggle" }] } });
+ assert.match(html, /data-thread-slot="scene:0"/);
+ assert.match(html, /data-scene-post="p-2"[^>]*>|data-thread-tile="scene:1"[^>]*data-scene-post="p-2"/);
+ assert.match(html, /data-post-thread="4"/);
+ assert.match(html, /Phat ass/, "the earliest message's words drawn");
+ assert.doesNotMatch(html, /Phat ass jiggle/, "a redacted word in an earlier message is a bar too");
+ assert.ok(html.indexOf('data-thread-slot="scene:1"') < html.indexOf('data-thread-slot="post"'), "oldest first, his own last");
+});
+
+test("the knobs' checks: an item's scene false or join; the cut's { on }", () => {
+ assert.deepEqual(validatePostScene({ id: "p", scene: "join" }), []);
+ assert.deepEqual(validatePostScene({ id: "p", scene: false }), []);
+ assert.match(validatePostScene({ id: "p", scene: true })[0], /must be false .* or "join"/);
+ assert.ok(validatePostItem({ ...post("p-1", "x"), scene: "yes" }).some((e) => e.includes(".scene must be")));
+ assert.deepEqual(validatePostSceneRender({ posts: { scene: { on: false } } }), []);
+ assert.equal(validatePostSceneRender({ posts: { scene: { on: 1, x: 2 } } }).length, 2);
+ assert.ok(validatePostItems({ timeline: [], render: { posts: { scene: "no" } } }).some((e) => e.includes("render.posts.scene must be")));
+});
diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs
@@ -24,6 +24,7 @@ import { applyFollowState, followPath, followStateAt, followStateKey, measureFol
import { redactEntry, redactionOn, shownLine, termsFor } from "./post-redact.mjs";
import { bleepFilters, slursOn, takeBleeps } from "./post-slurs.mjs";
import { blurFilters, blurOn, censorEntry, labelFilter } from "./post-censor.mjs";
+import { sceneEntry } from "./post-media-scene.mjs";
import { WORD_ZOOM_DEFAULTS, findMatch, overlappingZooms, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomSpan, zoomTarget, zoompanExprs } from "./word-zoom.mjs";
const r3 = (v) => Math.round(v * 1000) / 1000;
@@ -440,21 +441,25 @@ export function postZoomPlan(entry, render, total = Infinity) {
* build-video's encode args and ffmpeg runner, the authors' pictures
* (`{ <handle>: absolute file }`, post-avatars.mjs), the redaction it is
* published with (`{ terms, markup }`, post-redact-files.mjs: its matches
- * drawn as bars, dropped from its captions), and `prev` the timeline entry
- * before it (post-thread.mjs carries a parent that is it) and `scene` the
- * posts its run left on screen (post-conversation.mjs planContext). Returns
- * the segment's path.
+ * drawn as bars, dropped from its captions), `prev` the timeline entry
+ * before it (post-thread.mjs carries a parent that is it), `scene` the posts
+ * its conversation's run left on screen (post-conversation.mjs planContext),
+ * and `mediaScene` its media scene (post-media-scene.mjs mediaSceneOf: the
+ * attachment the anchor's, the scene's earlier messages above its card -- not
+ * drawn when `scene` is). Returns the segment's path.
*/
-export async function buildPostSegment(entry, { render, outDir, manifestDir, box, place = [], encode = [], exec, ffmpeg = "ffmpeg", emit = () => {}, avatars = {}, redaction = null, prev = null, scene = null }) {
+export async function buildPostSegment(entry, { render, outDir, manifestDir, box, place = [], encode = [], exec, ffmpeg = "ffmpeg", emit = () => {}, avatars = {}, redaction = null, prev = null, scene = null, mediaScene = null }) {
// A channel's markup may censor an attachment for every project (post-censor.mjs); the item's own blur wins.
entry = censorEntry(entry, redaction);
+ // In a media scene (post-media-scene.mjs) the shared attachment is the anchor's -- its markup laid on too.
+ entry = sceneEntry(entry, mediaScene, { censor: (e) => censorEntry(e, redaction) });
// A word zoom on a redacted word is refused in the build's words (the corpus's terms and the markup included).
const fxRed = fxRedactionErrors(entry, redaction);
if (fxRed.length) throw new Error(fxRed.join("; "));
const seg = path.join(outDir, "segments", `${entry.id}.mp4`);
// `prev`: the item before it in the cut (post-thread.mjs: a parent that is that item is carried in); `scene`: what
- // its run left on screen (post-conversation.mjs) -- both in plan.follow, so in the segment's key.
- const plan = postItemPlan(entry, render, { prev, scene });
+ // its run left on screen (post-conversation.mjs) -- in plan.follow, so in the segment's key; a media scene too.
+ const plan = postItemPlan(entry, render, { prev, scene, mediaScene });
const layout = postLayout(entry, box);
const files = (entry.media ?? []).map((m) => path.resolve(manifestDir, m.src));
for (const [i, f] of files.entries()) {
diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs
@@ -250,7 +250,7 @@ export const shownIdOf = (e) => str(e?.originalId) || postIdOf(e);
* caller's to require). `prev`: the item before it in the cut (a parent that
* is that item is carried). `scene` (post-conversation.mjs planContext): the
* posts the run had on screen as the item before ended -- each a tile
- * `scene:<id>` (mode "scene", never read, `ref` what it draws), kept on top as
+ * `conv:<id>` (mode "scene", never read, `ref` what it draws), kept on top as
* context when it is an ancestor of this item, else collapsed away; one this
* item draws itself is its own tile. Every tile in the tree's order.
*
@@ -317,7 +317,7 @@ function sceneTiles(entry, tiles, scene, k) {
const extra = list
.filter((t) => isObj(t) && str(t.id) && isObj(t.ref) && !own.has(str(t.id)))
.map((t) => ({
- scope: `scene:${t.id}`,
+ scope: `conv:${t.id}`,
mode: "scene",
read: false,
action: t.action === "keep" ? "keep" : "collapse",
@@ -340,7 +340,7 @@ function sceneTiles(entry, tiles, scene, k) {
if (x.t.scope === "quoted") x.r = (mine.find((y) => y.t.scope === "post")?.r ?? x.r) + (x.t.above ? -0.0005 : 0.0005);
last = x.r;
});
- const theirs = extra.map((t, i) => ({ t, r: rankOf(t.scope.slice(6)) ?? 1e9 + i }));
+ const theirs = extra.map((t, i) => ({ t, r: rankOf(t.scope.slice(5)) ?? 1e9 + i }));
return [...mine, ...theirs].map((x, i) => ({ ...x, i })).sort((a, b) => a.r - b.r || a.i - b.i).map((x) => x.t);
}
@@ -549,7 +549,7 @@ export function threadGeoAt(geo, scales) {
if (y >= t.top + t.height - 0.5) d += (1 - t.s) * t.height;
else if (y > t.top) d += (1 - t.s) * (y - t.top);
// A scene tile collapsing away (post-conversation.mjs) closes the gap above it too.
- if (t.gap > 0 && t.scope.startsWith("scene:") && y >= t.top - 0.5) d += (1 - t.s) * t.gap;
+ if (t.gap > 0 && t.scope.startsWith("conv:") && y >= t.top - 0.5) d += (1 - t.s) * t.gap;
}
return y - d;
};
diff --git a/umtool/report-to-video/read-follow.mjs b/umtool/report-to-video/read-follow.mjs
@@ -46,7 +46,8 @@
import { cardText, contextReadSeconds, contextText, parentsOf, readSeconds } from "./post-item.mjs";
import { isNarrated, narrationSchedule, partStartOnItem, pickedTake, scriptParts } from "./post-narration.mjs";
import { cardTokens, easeOf, normWord, scriptWordsOf } from "./word-zoom.mjs";
-import { partRoles, threadGeoAt, threadLayout, threadSchedule, threadStateAt } from "./post-thread.mjs";
+import { partRoles, threadGeoAt, threadKnobs, threadLayout, threadSchedule, threadStateAt } from "./post-thread.mjs";
+import { sceneLayout, sceneRows, sceneSchedule } from "./post-media-scene.mjs";
export const FOLLOW_DEFAULTS = Object.freeze({ on: true, dim: 0.65, ease: 0.25 });
export const FOLLOW_LIMITS = Object.freeze({ dim: [0.2, 1], ease: [0, 2] });
@@ -313,9 +314,15 @@ const wordsIn = (t) => scriptWordsOf(t).length;
*
* @param {Record<string, any>} entry
* @param {Record<string, any>} [render]
- * @param {{ hold?: number | null, narration?: Record<string, any> | null, prev?: Record<string, any> | null, scene?: Record<string, any> | null }} [o]
+ * `o.mediaScene` (post-media-scene.mjs mediaSceneOf): the item's media scene --
+ * the scene's earlier messages drawn above the card as tiles of the column.
+ * `o.scene` (post-conversation.mjs planContext): the posts its conversation's
+ * run left on screen. A conversation scene WINS the card: with one, the media
+ * scene is not drawn (it keeps only the attachment, sceneEntry).
+ *
+ * @param {{ hold?: number | null, narration?: Record<string, any> | null, prev?: Record<string, any> | null, scene?: Record<string, any> | null, mediaScene?: Record<string, any> | null }} [o]
*/
-export function followSchedule(entry, render = undefined, { hold = null, narration = undefined, prev = null, scene = null } = {}) {
+export function followSchedule(entry, render = undefined, { hold = null, narration = undefined, prev = null, scene = null, mediaScene = null } = {}) {
const k = followKnobs(entry, render);
if (!k.on) return null;
const map = followBlocks(entry);
@@ -364,8 +371,14 @@ export function followSchedule(entry, render = undefined, { hold = null, narrati
// THREADED (post-thread.mjs): a narrated read of the post it answers or quotes -- the card a column of tiles,
// each shown in full while it is read, then shrunk and dimmed as the next piece comes in.
// `scene` (post-conversation.mjs planContext): the posts its run left on screen, kept on top or collapsed away.
- const layout = isNarrated(entry) ? threadLayout(entry, render, { prev, scene }) : null;
- const thread = layout?.on ? threadSchedule(entry, render, { layout, blocks, lead: FOLLOW_PAN.lead }) : null;
+ // THE THREAD SCENE WINS (post-media-scene.mjs's header): with one, no media scene is drawn on the card.
+ const ms = Array.isArray(scene?.tiles) && scene.tiles.length ? null : mediaScene;
+ const base = isNarrated(entry) ? threadLayout(entry, render, { prev, scene }) : null;
+ // A MEDIA SCENE (post-media-scene.mjs): the scene's earlier messages above the card's own tiles -- a narrated
+ // item's on its thread read's schedule, an un-narrated one's on the scene's.
+ const layout = ms ? sceneLayout(base, entry, ms) : base;
+ const own = !layout?.on ? null : base ? threadSchedule(entry, render, { layout, blocks, lead: FOLLOW_PAN.lead }) : sceneSchedule(threadKnobs(entry, render), { layout, blocks, lead: FOLLOW_PAN.lead });
+ const thread = ms ? sceneRows(own, layout) : own;
return { dim: k.dim, ease: k.ease, readEnd, source: map.source, blocks, ...(thread ? { thread } : {}) };
}
@@ -462,7 +475,12 @@ export function threadPath(follow, geo) {
const carry = (th.tiles ?? []).find((t) => t.mode === "carry") ?? (th.tiles ?? []).find((t) => t.mode === "scene" && t.wasPost);
const g0 = at(0);
let off;
- if (carry && g0.tiles[carry.scope]) off = placed(g0, g0.tiles[carry.scope].top - m);
+ if (carry && g0.tiles[carry.scope] && th.scene) {
+ // A MEDIA SCENE (post-media-scene.mjs): framed as the item before ended -- what is on screen (the column down
+ // to the carried message) centred, or its foot a margin above the window's when it runs past.
+ const vis = g0.tiles[carry.scope].bottom;
+ off = vis <= H ? Math.round(((vis - H) / 2) * 100) / 100 : placed(g0, vis - H + m);
+ } else if (carry && g0.tiles[carry.scope]) off = placed(g0, g0.tiles[carry.scope].top - m);
else if (read.length) {
const g = at(read[0].start - lead + span);
// The first post read, whole when it fits the window; else its first block a margin from the top.
@@ -572,7 +590,7 @@ export function followStateAt(follow, path, s) {
for (const [scope, [sc, o]] of Object.entries(ts)) {
const h = path?.tiles?.[scope]?.height ?? 0;
// A scene tile (post-conversation.mjs) collapsing away takes the gap above it with it.
- const gap = scope.startsWith("scene:") ? path?.tiles?.[scope]?.gap ?? 0 : 0;
+ const gap = scope.startsWith("conv:") ? path?.tiles?.[scope]?.gap ?? 0 : 0;
tiles[scope] = gap > 0 ? [sc, o, Math.round(h * 100) / 100, Math.round(gap * 100) / 100] : [sc, o, Math.round(h * 100) / 100];
if (sc < 0.9995 && gap > 0) C -= (1 - sc) * gap;
// A tile closes the flow up under it as it shrinks -- a quoted post inside his post never shrinks; one above it does.