commit a4b2b173ccc1f9c4dca0af6f10f7720ff6ecbadc
parent a06da009e93a34df2c00429de6b2f0ea83b61650
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 2 Nov 2026 01:20:49 -0500
umtool: tighten a clip to its sentence and snap an edge to its pause (UI notes item 4)
The bench's waveform tools gain "Tighten to this sentence" (both edges to the
sentence at the playhead -- a playhead parked on an edge does not count --
else the cut's sentences, else the whole ones in the window, each edge then
into its pause, inside the cached window) and "Snap edge to nearest pause"
(start / end). Both write at once through the bench's one window writer
(PUT /api/report/window: the token, the cite that follows the edge, a cut or
mute mark that no longer fits cleared and said) with an Undo that writes back
what moved.
No second detector: lib/report/tightWindow.mjs composes sentenceEdges.mjs (the
sentence, off the cues) and L1's report-to-video/pauses.mjs (pauseSpans,
snapEdge), the build's measured silences from the cut-points route and the
recording's timed words. The bench's zoom now draws a box per word and the
pauses as bands; the clip-editor route's zoom read falls back to the corpus's
words (report-to-video clip-words.mjs, now exported) when the project has no
words file for that recording.
The Cut tab's "Propose tight windows" (GET /api/report/tighten,
lib/report/tightPropose.mjs) lists before -> after per clip, the seconds
either way and why; nothing is written until a row's Apply, and an applied
row has an Undo. `umtool tighten <p> [--json] [--all] [--no-measure]` prints
the same list; `--apply <clip>[,...]` writes rows through the window writer.
A lock is not a refusal (it pins against resolve-windows, not a person).
Fixture tight-fixture and e2e/tighten.spec.ts; docs in knobs.md,
clip-bench.md, cli.md.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
19 files changed, 1471 insertions(+), 11 deletions(-)
diff --git a/umtool/app/api/report/tighten/route.ts b/umtool/app/api/report/tighten/route.ts
@@ -0,0 +1,30 @@
+import { projectRef } from "@/lib/projects";
+import { kindMakesTakes } from "@/lib/projects/kinds.mjs";
+import { proposeTightWindows } from "@/lib/report/tightPropose.mjs";
+
+export const dynamic = "force-dynamic";
+
+// PROPOSE TIGHT WINDOWS (UI notes 2026-10-30, item 4; lib/report/tightPropose.mjs):
+// every clip of the cut tightened to its sentence and each edge into its pause,
+// before and after, for review. READS ONLY -- nothing is fetched and nothing
+// is written; a row is applied by its own Apply, through the window writer
+// (PUT /api/report/window with the token this answers).
+//
+// GET ?project=<id>[&clip=<id>…][&measure=0]
+// -> { token, rows: [{ id, before, after, changed, how, said, why, fetched, locked, words, clear }], counts }
+// measure=0: no silences (the words alone) -- nothing is measured
+const headers = { "cache-control": "no-store" };
+
+export async function GET(request: Request) {
+ const url = new URL(request.url);
+ const project = await projectRef(String(url.searchParams.get("project") ?? ""));
+ if (!project) return Response.json({ error: "no such project" }, { status: 404, headers });
+ if (!kindMakesTakes(project.kind)) return Response.json({ error: "tight windows are a report video's" }, { status: 400, headers });
+ const clips = url.searchParams.getAll("clip").filter(Boolean);
+ try {
+ const got = await proposeTightWindows(project, { clips: clips.length ? clips : null, measure: url.searchParams.get("measure") !== "0" });
+ return Response.json(got, { headers });
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 422, headers });
+ }
+}
diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs
@@ -79,6 +79,8 @@
// umtool trailer-beats <project> [ls | add <clip> [<from>-<to>] | set <n> <from>-<to> | remove <n> | move <n> --to <m>
// | order | limit <s|m:ss|x> | xfade <s> | intro on|off | candidates [--add]] the trailer's beats
// (promo/trailer-beats.json): running length against the limit, beats outside their clip
+// umtool tighten <project> [--json] [--all] [--no-measure] | --apply <clip>[,<clip>…] each clip to its sentence,
+// each edge into its pause: before -> after for review; --apply writes the named rows
// umtool rulings <project> [import [--dry-run] | set <clip> <verdict> [--reason R] [--match M] | clear <clip>]
// the clip deck's montage rulings (release 34)
// umtool fetch <project> [--dry-run | --wait | --status | --body] [--reason R] the clip windows, asked of
@@ -892,6 +894,8 @@ function usage() {
" | remove <n> | move <n> --to <m> | order | limit <s|m:ss|x|instagram|shorts|tiktok> | xfade <s> | intro on|off",
" | candidates [--add] the trailer's beats (promo/trailer-beats.json, the Trailer page's file): each",
" beat's length, the running length against the platform limit (X 2:20), beats outside their clip",
+ " umtool tighten <project> [--json] [--all] [--no-measure] | --apply <clip>[,<clip>…] each clip to its sentence (its",
+ " cut's, else the whole ones in its window), each edge into its pause; before -> after; --apply writes",
" umtool rulings <project> [--json] | import [--dry-run] | set <clip> keep|cut|not-him|read-aloud [--reason R] [--match M] | clear <clip>",
" the clip deck's montage rulings (montage-rulings.json); a render leaves the ruled-out clips out",
" umtool fetch <project> [--dry-run | --wait | --status | --body] [--reason R] [--json]",
@@ -999,6 +1003,8 @@ const COMMANDS = {
links: async () => process.exit(await (await import("../lib/report/linksCli.mjs")).linksCommand(argv.slice(argv.indexOf("links") + 1))),
// A take patch's markers back on the cut (UI notes #6): lib/report/linksCli.mjs.
"patch-markers": async () => process.exit(await (await import("../lib/report/linksCli.mjs")).patchMarkersCommand(argv.slice(argv.indexOf("patch-markers") + 1))),
+ // Tight windows: each clip to its sentence and its pauses (UI notes item 4): lib/report/tightCli.mjs.
+ tighten: async () => process.exit(await (await import("../lib/report/tightCli.mjs")).tightenCommand(argv.slice(argv.indexOf("tighten") + 1))),
// The trailer's beats, edited (UI notes item 11): lib/report/trailerBeatsCli.mjs.
"trailer-beats": async () => process.exit(await (await import("../lib/report/trailerBeatsCli.mjs")).trailerBeatsCommand(argv.slice(argv.indexOf("trailer-beats") + 1))),
// The clip deck's rulings (release 34): lib/report/rulingsCli.mjs.
diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx
@@ -25,6 +25,7 @@ import EdgeStrip from "./bench/EdgeStrip";
import RenderGhosts, { useRenderEdges } from "./bench/RenderGhosts";
import { GapLayer, ZoomControls, ZoomOverview, ZoomRuler, useWaveZoom, type Span } from "./bench/GapsZoom";
import TakeWalkStrip from "./bench/TakeWalkStrip";
+import { TightenButtons, useEdgeTools, type BenchWord } from "./bench/TightenTools";
// The renderer's own line, imported rather than re-written. A preview that
// disagrees with the header by a character is worth less than no preview: you
// would only find out twenty minutes into a build.
@@ -1612,6 +1613,28 @@ export default function ClipBench({
[doSave],
);
+ // Tighten to the sentence, snap an edge to its pause (bench/TightenTools.tsx):
+ // written at once through `save`, with an Undo.
+ const readCues = useMemo(() => {
+ const seen = new Set<number>();
+ return [...cues, ...peek].filter((c) => (seen.has(c.start) ? false : (seen.add(c.start), true))).sort((a, b) => a.start - b.start);
+ }, [cues, peek]);
+ const edgeTools = useEdgeTools({
+ project: data.project,
+ clip,
+ video: clip.video,
+ sel,
+ playhead,
+ cues: readCues,
+ silences: renderEdges?.silences ?? null,
+ lo: fetchStart,
+ hi: clampTo,
+ save,
+ lastSaved,
+ play,
+ setNote,
+ });
+
/**
* Persist one attribution field, on blur or Enter, if it actually changed.
*
@@ -2004,7 +2027,7 @@ export default function ClipBench({
// whole window, today's view -- on every clip's arrival.
const zoom = useWaveZoom(view);
// Close in: the pauses between words, when the project has its words for this recording (the clip editor's).
- const [nearWords, setNearWords] = useState<{ key: string; words: { start: number; end: number }[] | null } | null>(null);
+ const [nearWords, setNearWords] = useState<{ key: string; words: BenchWord[] | null } | null>(null);
const close = zoom.vis.to - zoom.vis.from <= DETAIL_SPAN;
const wordsKey = close ? `${clip.id}|${Math.floor(zoom.vis.from / 10) * 10}|${Math.ceil(zoom.vis.to / 10) * 10}` : null;
useEffect(() => {
@@ -2013,7 +2036,7 @@ export default function ClipBench({
const [, a, b] = wordsKey.split("|");
const q = new URLSearchParams({ project: data.project, clip: clip.id, from: a, to: b, video: clip.video });
fetch(`/api/report/clip-editor?${q}`, { cache: "no-store" })
- .then((r) => (r.ok ? (r.json() as Promise<{ words?: { start: number; end: number }[] | null }>) : null))
+ .then((r) => (r.ok ? (r.json() as Promise<{ words?: BenchWord[] | null }>) : null))
.then((j) => {
if (live) setNearWords({ key: wordsKey, words: j?.words ?? null });
})
@@ -3820,6 +3843,7 @@ export default function ClipBench({
</button>
)}
</span>
+ <TightenButtons tools={edgeTools} busy={!!busy} />
<span className="micro max-md:hidden">
<kbd>z</kbd> <kbd>Z</kbd> zoom (or Ctrl/⌘ + wheel), <kbd>f</kbd> fit, <kbd>F</kbd> to the selection ·{" "}
<kbd>g</kbd> (or Alt + drag) select a gap, <kbd>g</kbd> cut it, <kbd>G</kbd> put back the one at the playhead
diff --git a/umtool/components/projects/bench/GapsZoom.tsx b/umtool/components/projects/bench/GapsZoom.tsx
@@ -5,6 +5,7 @@ import type { Peaks } from "@/components/Waveform";
import { buttonVariants } from "@/components/ui/button";
import { alpha, usePalette } from "@/components/ui/use-palette";
import { cn } from "@/lib/utils";
+import { pauseSpans } from "umtool-report-to-video/pauses";
import {
DETAIL_SPAN, ZOOM_STEP, centreOn, clampVis, isFit, panBy, quietPoints, rulerFor, tickLabel, wheelFactor, zoomAt, zoomTo,
} from "@/lib/report/benchZoom.mjs";
@@ -22,8 +23,11 @@ import {
// strip under it, which shows the whole cached window, what is
// shown in it, the selection and the gaps; a two-finger pinch on it.
// closer a ruler of round ticks, and at DETAIL_SPAN seconds or less the
-// measured silences (the cut-points route's, the build's own) and
-// the pauses between words, so a gap's edge goes between two words.
+// measured silences (the cut-points route's, the build's own), the
+// pauses (pauses.mjs pauseSpans: those silences and the gaps
+// between timed words, merged) as bands, and a box per WORD with
+// its text (a caption word's box runs to the next word's start),
+// so a gap's edge -- or a tightened edge -- goes between two words.
// gaps each a hatched band over the waveform, `cut` on it; a click on
// one removes it. A span for a new one is dragged with Alt held
// (or after `g` / Select a gap); Cut gap (or `g`) writes it.
@@ -193,7 +197,8 @@ export function GapLayer({
selection: Span | null;
picking: boolean;
silences: Span[] | null;
- words: { start: number; end: number }[] | null;
+ /** The recording's words (the clip-editor route's): timed (`end`), or a caption word's start only. */
+ words: { start: number; end?: number; w?: string }[] | null;
busy: boolean;
onRemove: (g: Span) => void;
onSelect: (s: Span, done: boolean) => void;
@@ -203,7 +208,14 @@ export function GapLayer({
const width = (a: number, b: number) => `calc(${pct(b)} - ${pct(a)})`;
const inView = (s: Span) => s.to > vis.from && s.from < vis.to;
const close = vis.to - vis.from <= DETAIL_SPAN;
- const quiet = close ? quietPoints({ words, silences }, vis.from, vis.to) : [];
+ const timed = (words ?? []).filter((w): w is { start: number; end: number; w?: string } => typeof w.end === "number");
+ const quiet = close ? quietPoints({ words: timed, silences }, vis.from, vis.to) : [];
+ const pauses = close ? pauseSpans({ words: timed, silences }, { from: vis.from, to: vis.to }) : [];
+ // A box per word in view: its own end, else (a caption's word) the next word's start, at most a second on.
+ const sorted = close ? [...(words ?? [])].sort((a, b) => a.start - b.start) : [];
+ const boxes = sorted
+ .map((w, i) => ({ text: w.w ?? "", from: w.start, to: typeof w.end === "number" ? w.end : Math.min(w.start + 1, sorted[i + 1]?.start ?? w.start + 1) }))
+ .filter((b) => b.to > b.from && inView(b));
const drag = useRef<{ id: number; at: number } | null>(null);
const tAt = (el: HTMLElement, clientX: number) => {
const r = el.getBoundingClientRect();
@@ -221,6 +233,28 @@ export function GapLayer({
style={{ left: pct(s.from), width: width(s.from, s.to) }}
/>
))}
+ {pauses.filter(inView).map((p) => (
+ <div
+ key={`pause-${p.from}`}
+ data-wave-pause={`${p.from.toFixed(2)}-${p.to.toFixed(2)}`}
+ aria-hidden
+ className="pointer-events-none absolute top-0 h-full bg-[color-mix(in_srgb,var(--color-meter)_10%,transparent)]"
+ style={{ left: pct(p.from), width: width(p.from, p.to) }}
+ />
+ ))}
+ {boxes.map((b) => (
+ <div
+ key={`word-${b.from}`}
+ data-wave-word={b.text}
+ data-wave-word-at={`${b.from.toFixed(2)}-${b.to.toFixed(2)}`}
+ title={`“${b.text}” ${b.from.toFixed(2)}–${b.to.toFixed(2)}`}
+ aria-hidden
+ className="pointer-events-none absolute top-0 h-3.5 overflow-hidden whitespace-nowrap rounded-sm border border-[color-mix(in_srgb,var(--color-text)_30%,transparent)] bg-[color-mix(in_srgb,var(--color-panel-2)_75%,transparent)] px-0.5 font-mono text-[9px] leading-3 text-[var(--color-text)]"
+ style={{ left: pct(b.from), width: width(b.from, b.to) }}
+ >
+ {b.text}
+ </div>
+ ))}
{quiet.map((t) => (
<div key={`q-${t}`} data-wave-quiet={t} aria-hidden className="pointer-events-none absolute top-0 h-full border-l border-dotted border-[color-mix(in_srgb,var(--color-meter)_55%,transparent)]" style={{ left: pct(t) }} />
))}
diff --git a/umtool/components/projects/bench/TightenTools.tsx b/umtool/components/projects/bench/TightenTools.tsx
@@ -0,0 +1,228 @@
+"use client";
+
+import { useCallback, useEffect, useState } from "react";
+import { buttonVariants } from "@/components/ui/button";
+import { HOW_SAID, nearestPause, snapSaid, tightWindow } from "@/lib/report/tightWindow.mjs";
+
+// ---------------------------------------------------------------------------
+// TIGHTEN TO THE SENTENCE, SNAP AN EDGE TO A PAUSE (UI notes 2026-10-30, item
+// 4), on the bench's waveform tools. lib/report/tightWindow.mjs decides where
+// the edges go -- the sentence from the cues (sentenceEdges.mjs), the pause
+// from the measured silences and the words (report-to-video/pauses.mjs) --
+// and the edit is WRITTEN AT ONCE through the bench's one window writer
+// (`save`: PUT /api/report/window, the token, the cite that follows the edge),
+// like Extend and the gaps, with an Undo that writes back what was there.
+// ---------------------------------------------------------------------------
+
+export type BenchWord = { w?: string; start: number; end?: number };
+type Span = { from: number; to: number };
+type Cue = { start: number; end: number; text: string };
+
+type ClipEdges = {
+ id: string;
+ start: number;
+ end: number;
+ cutStart: number | null;
+ cutEnd: number | null;
+ muteFrom: number | null;
+ cite: number | null;
+ citeUrl: string | null;
+};
+
+/** The words of [from, to] on this clip's recording (the clip-editor route's, the bench's zoom asks the same). */
+export async function benchWords(project: string, clip: string, video: string, from: number, to: number): Promise<BenchWord[] | null> {
+ const q = new URLSearchParams({ project, clip, video, from: String(Math.max(0, Math.floor(from))), to: String(Math.ceil(to)) });
+ try {
+ const r = await fetch(`/api/report/clip-editor?${q}`, { cache: "no-store" });
+ if (!r.ok) return null;
+ const j = (await r.json()) as { words?: BenchWord[] | null };
+ return j.words ?? null;
+ } catch {
+ return null;
+ }
+}
+
+const r2 = (n: number) => Number(n.toFixed(2));
+const toWords = (ws: BenchWord[] | null) => (ws ?? []).map((w) => ({ start: w.start, ...(typeof w.end === "number" ? { end: w.end } : {}), text: w.w ?? "" }));
+
+/**
+ * Tighten / snap / undo, over the bench's state. `save` is the bench's queued
+ * writer (it re-syncs the clip, the selection and the token, and says when
+ * the cite followed); `lastSaved` its last answer.
+ */
+export function useEdgeTools({
+ project,
+ clip,
+ video,
+ sel,
+ playhead,
+ cues,
+ silences,
+ lo,
+ hi,
+ save,
+ lastSaved,
+ play,
+ setNote,
+}: {
+ project: string;
+ clip: ClipEdges;
+ video: string;
+ sel: Span;
+ playhead: number | null;
+ cues: Cue[];
+ silences: Span[] | null;
+ lo: number;
+ hi: number;
+ save: (patch: Record<string, unknown>) => Promise<boolean>;
+ lastSaved: React.MutableRefObject<Record<string, unknown> | null>;
+ play: (from: number, to: number) => unknown;
+ setNote: (s: string | null) => void;
+}) {
+ const [undo, setUndo] = useState<{ patch: Record<string, unknown>; what: string } | null>(null);
+ const [working, setWorking] = useState<string | null>(null);
+ // Another clip: nothing to undo here.
+ useEffect(() => setUndo(null), [clip.id]);
+
+ /** Write new edges through the window writer, the cut and the mute mark cleared when they no longer fit -- as Save window does. */
+ const writeEdges = useCallback(
+ async (next: Span, what: string, moved: "start" | "end" | "both") => {
+ const start = r2(next.from);
+ const end = r2(next.to);
+ const patch: Record<string, unknown> = { start, end };
+ const cleared: string[] = [];
+ if (clip.cutStart != null && clip.cutEnd != null && (clip.cutStart < start - 0.02 || clip.cutEnd > end + 0.02)) {
+ patch.cutStart = "";
+ patch.cutEnd = "";
+ cleared.push("the cut");
+ }
+ if (clip.muteFrom != null && (clip.muteFrom < start - 0.02 || clip.muteFrom > end + 0.02)) {
+ patch.muteFrom = "";
+ cleared.push("the mute mark");
+ }
+ const before = clip;
+ const ok = await save(patch);
+ if (!ok) return false;
+ const followed = (lastSaved.current?.citeFollowed ?? null) as { cite?: unknown; citeUrl?: unknown } | null;
+ const back: Record<string, unknown> = {
+ start: before.start,
+ end: before.end,
+ ...(patch.cutStart !== undefined ? { cutStart: before.cutStart ?? "", cutEnd: before.cutEnd ?? "" } : {}),
+ ...(patch.muteFrom !== undefined ? { muteFrom: before.muteFrom ?? "" } : {}),
+ // The cite and the QR went with the edge: they come back with it.
+ ...(followed?.cite ? { cite: before.cite ?? "" } : {}),
+ ...(followed?.citeUrl ? { citeUrl: before.citeUrl ?? "" } : {}),
+ };
+ setUndo({ patch: back, what });
+ setNote(
+ `${what}${cleared.length ? ` — ${cleared.join(" and ")} no longer fitted and ${cleared.length > 1 ? "were" : "was"} cleared` : ""}` +
+ `${followed?.cite ? " — the cite followed the edge" : followed?.citeUrl ? " — the QR's t= followed the edge" : ""} · Undo puts it back`,
+ );
+ // Hear what moved.
+ if (moved === "end") play(Math.max(start, end - 4), end);
+ else play(start, Math.min(end, start + 4));
+ return true;
+ },
+ [clip, save, lastSaved, play, setNote],
+ );
+
+ const tighten = useCallback(async () => {
+ setWorking("tighten");
+ try {
+ // tightWindow decides whether the playhead is a place (not parked on an edge).
+ const at = playhead;
+ const words = await benchWords(project, clip.id, video, sel.from - 12, sel.to + 12);
+ const r = tightWindow({
+ clip: { start: sel.from, end: sel.to, cutStart: clip.cutStart, cutEnd: clip.cutEnd },
+ cues,
+ words: toWords(words),
+ silences,
+ at,
+ lo,
+ hi,
+ });
+ if (!r.ok) {
+ setNote(`not tightened: ${r.why}`);
+ return;
+ }
+ const span = `${r.start.toFixed(2)}–${r.end.toFixed(2)} (${(r.end - r.start).toFixed(2)} s, was ${(sel.to - sel.from).toFixed(2)} s)`;
+ if (!r.changed) {
+ setNote(`already tight: ${HOW_SAID[r.how]} is ${span}`);
+ return;
+ }
+ await writeEdges({ from: r.start, to: r.end }, `tightened to ${HOW_SAID[r.how]}: ${span}${r.said.length ? ` — ${r.said.join("; ")}` : ""}`, "both");
+ } finally {
+ setWorking(null);
+ }
+ }, [playhead, sel, project, clip, video, cues, silences, lo, hi, writeEdges, setNote]);
+
+ const snap = useCallback(
+ async (edge: "start" | "end") => {
+ setWorking(edge);
+ try {
+ const t = edge === "start" ? sel.from : sel.to;
+ const words = await benchWords(project, clip.id, video, t - 3, t + 3);
+ const other = edge === "start" ? sel.to : sel.from;
+ const s = nearestPause(t, {
+ words: toWords(words),
+ silences,
+ lo: edge === "start" ? lo : other + 0.5,
+ hi: edge === "start" ? other - 0.5 : hi,
+ });
+ const said = snapSaid(edge, s) ?? "";
+ if (!s.moved) {
+ setNote(`not moved: ${said}${!silences?.length && !words?.length ? " — no silences measured and no words for this recording" : ""}`);
+ return;
+ }
+ await writeEdges(edge === "start" ? { from: s.at, to: sel.to } : { from: sel.from, to: s.at }, said, edge);
+ } finally {
+ setWorking(null);
+ }
+ },
+ [sel, project, clip.id, video, silences, lo, hi, writeEdges, setNote],
+ );
+
+ const undoEdges = useCallback(async () => {
+ const u = undo;
+ if (!u) return;
+ const ok = await save(u.patch);
+ if (!ok) return;
+ setUndo(null);
+ setNote(`undone — ${u.what.split(":")[0]} is reversed`);
+ }, [undo, save, setNote]);
+
+ return { tighten, snap, undoEdges, undo, working };
+}
+
+const btn = buttonVariants({ variant: "outline", size: "sm" });
+
+/** The buttons, in the waveform's tools row. */
+export function TightenButtons({ tools, busy }: { tools: ReturnType<typeof useEdgeTools>; busy: boolean }) {
+ const off = busy || !!tools.working;
+ return (
+ <span data-edge-tools="" className="flex flex-wrap items-center gap-1.5">
+ <button
+ type="button"
+ data-tighten=""
+ className={btn}
+ disabled={off}
+ title="both edges to the sentence at the playhead (else the cut's, else the whole sentences in the window), each into its pause — saved at once, Undo puts it back"
+ onClick={() => void tools.tighten()}
+ >
+ {tools.working === "tighten" ? "Tightening…" : "Tighten to this sentence"}
+ </button>
+ <span className="micro">snap to nearest pause</span>
+ <button type="button" data-snap-edge="start" className={btn} disabled={off} title="the start into the middle of the nearest pause (a silence, or between two words) — at most a second" onClick={() => void tools.snap("start")}>
+ ← start
+ </button>
+ <button type="button" data-snap-edge="end" className={btn} disabled={off} title="the end into the middle of the nearest pause — at most a second" onClick={() => void tools.snap("end")}>
+ end →
+ </button>
+ {tools.undo && (
+ <button type="button" data-edge-undo="" className={btn} disabled={off} title={`undo: ${tools.undo.what}`} onClick={() => void tools.undoEdges()}>
+ Undo
+ </button>
+ )}
+ </span>
+ );
+}
diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx
@@ -12,6 +12,7 @@ import { clipBenchHref, clipDeckHref, clipEditorHref, mixHref as toolsMixHref, p
import { readTrailerBeats } from "@/lib/report/trailerBeats.mjs";
import { montageClipsOf, momentKeysOf, readRulingsState } from "@/lib/report/montageRulings.mjs";
import FetchUnfetchedButton from "../FetchUnfetchedButton";
+import TightWindowsPanel from "./TightWindowsPanel";
import { clipRecord, storedUrlOf } from "@/lib/clips/stored";
import { Fragment } from "react";
import { deckOn } from "umtool-report-to-video/deck";
@@ -442,6 +443,9 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor
</div>
</section>
+ {/* --- tight windows: each clip to its sentence, for review (UI notes item 4) --- */}
+ {clips.length > 0 && <TightWindowsPanel project={project.id} />}
+
{/* --- the walk's ★ clips: the trailer's candidates ------------------- */}
{candidates.length > 0 && (
<section
diff --git a/umtool/components/projects/report/TightWindowsPanel.tsx b/umtool/components/projects/report/TightWindowsPanel.tsx
@@ -0,0 +1,248 @@
+"use client";
+
+import Link from "next/link";
+import { useRouter } from "next/navigation";
+import { useCallback, useRef, useState } from "react";
+import { badgeVariants } from "@/components/ui/badge";
+import { buttonVariants } from "@/components/ui/button";
+import { clipBenchHref } from "@/lib/hrefs";
+
+// ---------------------------------------------------------------------------
+// PROPOSE TIGHT WINDOWS (UI notes 2026-10-30, item 4): every clip of the cut
+// tightened to its sentence and each edge into its pause
+// (lib/report/tightPropose.mjs, GET /api/report/tighten), as a review list --
+// before and after, the seconds either way, what moved and why. NOTHING
+// APPLIES WITHOUT A PRESS: each row's Apply is one window save (PUT
+// /api/report/window, the token, the cite that follows the edge), and an
+// applied row offers Undo, which writes back what was there.
+// ---------------------------------------------------------------------------
+
+type Edge = { start: number; end: number; seconds: number };
+type Row = {
+ id: string;
+ quote: string | null;
+ before: Edge;
+ after: Edge | null;
+ changed: boolean;
+ how: string | null;
+ said: string[];
+ why: string | null;
+ fetched: boolean;
+ locked: boolean;
+ words: string | null;
+ clear: { cut: boolean; mute: boolean };
+ prior: { cutStart: number | null; cutEnd: number | null; muteFrom: number | null; cite: number | null; citeUrl: string | null };
+};
+type Got = { token: string | null; rows: Row[]; counts: { clips: number; proposed: number; same: number; none: number } };
+type Applied = { k: "applying" } | { k: "applied"; undo: Record<string, unknown>; note: string } | { k: "undone" } | { k: "failed"; error: string };
+
+const hms = (t: number) => {
+ const s = Math.max(0, t);
+ const m = Math.floor(s / 60);
+ return `${m}:${(s - m * 60).toFixed(2).padStart(5, "0")}`;
+};
+const signed = (d: number) => `${d > 0 ? "+" : d < 0 ? "−" : "±"}${Math.abs(d).toFixed(2)} s`;
+
+export default function TightWindowsPanel({ project }: { project: string }) {
+ const router = useRouter();
+ const [got, setGot] = useState<Got | null>(null);
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const [all, setAll] = useState(false);
+ const [done, setDone] = useState<Record<string, Applied>>({});
+ const token = useRef<string | null>(null);
+ // One write at a time: each reads the token the last one was handed back.
+ const chain = useRef<Promise<unknown>>(Promise.resolve());
+
+ const propose = useCallback(async () => {
+ setLoading(true);
+ setError(null);
+ try {
+ const r = await fetch(`/api/report/tighten?${new URLSearchParams({ project })}`, { cache: "no-store" });
+ const j = (await r.json()) as Got & { error?: string };
+ if (!r.ok) {
+ setError(j.error ?? `HTTP ${r.status}`);
+ return;
+ }
+ token.current = j.token;
+ setGot(j);
+ setDone({});
+ } catch (e) {
+ setError(e instanceof Error ? e.message : String(e));
+ } finally {
+ setLoading(false);
+ }
+ }, [project]);
+
+ const put = useCallback(
+ async (clip: string, patch: Record<string, unknown>) => {
+ const r = await fetch("/api/report/window", {
+ method: "PUT",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ project, clip, token: token.current, ...patch }),
+ });
+ const j = (await r.json().catch(() => ({}))) as Record<string, unknown>;
+ if (r.ok) token.current = String(j.token ?? "");
+ return { ok: r.ok, j };
+ },
+ [project],
+ );
+
+ const apply = useCallback(
+ (row: Row) => {
+ if (!row.after) return;
+ setDone((d) => ({ ...d, [row.id]: { k: "applying" } }));
+ const after = row.after;
+ const patch: Record<string, unknown> = {
+ start: after.start,
+ end: after.end,
+ ...(row.clear.cut ? { cutStart: "", cutEnd: "" } : {}),
+ ...(row.clear.mute ? { muteFrom: "" } : {}),
+ };
+ chain.current = chain.current.then(async () => {
+ const { ok, j } = await put(row.id, patch);
+ if (!ok) {
+ setDone((d) => ({
+ ...d,
+ [row.id]: { k: "failed", error: j.stale ? "the manifest changed since these were proposed — Propose again" : String(j.error ?? "refused") },
+ }));
+ return;
+ }
+ const before = row.prior;
+ const followed = (j.citeFollowed ?? null) as { cite?: { from: number; to: number }; citeUrl?: unknown } | null;
+ const undo: Record<string, unknown> = {
+ start: row.before.start,
+ end: row.before.end,
+ ...(row.clear.cut ? { cutStart: before.cutStart ?? "", cutEnd: before.cutEnd ?? "" } : {}),
+ ...(row.clear.mute ? { muteFrom: before.muteFrom ?? "" } : {}),
+ ...(followed?.cite ? { cite: before.cite ?? "" } : {}),
+ ...(followed?.citeUrl ? { citeUrl: before.citeUrl ?? "" } : {}),
+ };
+ const note = followed?.cite ? `the cite followed: ${hms(followed.cite.from)} → ${hms(followed.cite.to)}${followed.citeUrl ? ", and the QR" : ""}` : "";
+ setDone((d) => ({ ...d, [row.id]: { k: "applied", undo, note } }));
+ router.refresh();
+ });
+ },
+ [put, router],
+ );
+
+ const undo = useCallback(
+ (row: Row) => {
+ const s = done[row.id];
+ if (s?.k !== "applied") return;
+ setDone((d) => ({ ...d, [row.id]: { k: "applying" } }));
+ chain.current = chain.current.then(async () => {
+ const { ok, j } = await put(row.id, s.undo);
+ setDone((d) => ({ ...d, [row.id]: ok ? { k: "undone" } : { k: "failed", error: j.stale ? "the manifest changed since — Propose again" : String(j.error ?? "refused") } }));
+ if (ok) router.refresh();
+ });
+ },
+ [done, put, router],
+ );
+
+ const rows = got ? got.rows.filter((r) => all || r.changed) : [];
+ return (
+ <section data-tight-windows={got ? got.counts.proposed : ""} className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2">
+ <div className="flex flex-wrap items-center gap-2">
+ <h2 className="micro">tight windows</h2>
+ <button type="button" data-action="propose-tight" className={buttonVariants({ variant: "outline", size: "sm" })} disabled={loading} onClick={() => void propose()}>
+ {loading ? "Proposing…" : got ? "Propose again" : "Propose tight windows"}
+ </button>
+ {got && (
+ <span data-tight-counts="" className="text-[11.5px] text-[var(--color-dim)]">
+ {got.counts.proposed} of {got.counts.clips} clips would change · {got.counts.same} already tight
+ {got.counts.none ? ` · ${got.counts.none} with nothing to go by` : ""}
+ {" · "}
+ <button type="button" data-action="tight-show-all" aria-pressed={all} className="ink-link" onClick={() => setAll((v) => !v)}>
+ {all ? "only the changes" : "show every clip"}
+ </button>
+ </span>
+ )}
+ {!got && !loading && (
+ <span className="text-[11.5px] text-[var(--color-dim)]">
+ each clip to its sentence (the cut’s, else the whole ones in its window), each edge into its pause — a list to review; nothing changes until you Apply a row
+ </span>
+ )}
+ </div>
+ {error && (
+ <p role="alert" className="mt-1 text-[12px] text-reject-text">
+ {error}
+ </p>
+ )}
+ {got && rows.length === 0 && <p className="mt-1 text-[12px] text-[var(--color-dim)]">every clip is already tight</p>}
+ {rows.length > 0 && (
+ <ul className="mt-2 space-y-1.5" aria-label="proposed tight windows">
+ {rows.map((r) => {
+ const s = done[r.id];
+ const d = r.after ? r.after.seconds - r.before.seconds : 0;
+ return (
+ <li key={r.id} data-tight-row={r.id} data-tight-state={s?.k ?? (r.changed ? "proposed" : r.after ? "same" : "none")} className="flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-[12px] leading-snug">
+ <Link href={clipBenchHref(project, r.id)} className="ink-link font-mono text-[11px]">
+ {r.id}
+ </Link>
+ <span className="num font-mono text-[11px] text-[var(--color-dim)]" data-tight-before={`${r.before.start}-${r.before.end}`}>
+ {hms(r.before.start)}–{hms(r.before.end)} ({r.before.seconds.toFixed(2)} s)
+ </span>
+ {r.after ? (
+ <>
+ <span aria-hidden>→</span>
+ <span className="num font-mono text-[11px]" data-tight-after={`${r.after.start}-${r.after.end}`}>
+ {hms(r.after.start)}–{hms(r.after.end)} ({r.after.seconds.toFixed(2)} s)
+ </span>
+ {r.changed && (
+ <span data-tight-delta={d.toFixed(2)} className={badgeVariants({ variant: d <= 0 ? "meter" : "state", size: "sm" })}>
+ {signed(d)}
+ </span>
+ )}
+ </>
+ ) : (
+ <span className="text-[var(--color-dim)]">{r.why}</span>
+ )}
+ {r.locked && <span className={badgeVariants({ variant: "state", size: "sm" })} title="locked against the widener (resolve-windows); Apply keeps the lock">locked</span>}
+ {!r.fetched && <span className={badgeVariants({ variant: "state", size: "sm" })} title="no cached window holds it: proposed from the cues and the words, no silences">not fetched</span>}
+ {r.clear.cut && <span className={badgeVariants({ variant: "state", size: "sm" })} title="the cut would no longer fit: Apply clears it">clears the cut</span>}
+ {r.changed && r.after && (
+ <span className="ml-auto flex items-center gap-1.5">
+ {s?.k === "applied" ? (
+ <>
+ <span data-tight-applied="" className="text-[11px] text-[var(--color-dim)]">
+ applied{s.note ? ` — ${s.note}` : ""}
+ </span>
+ <button type="button" data-action="tight-undo" className={buttonVariants({ variant: "outline", size: "sm" })} onClick={() => undo(r)}>
+ Undo
+ </button>
+ </>
+ ) : s?.k === "undone" ? (
+ <span className="text-[11px] text-[var(--color-dim)]">undone</span>
+ ) : (
+ <button type="button" data-action="tight-apply" className={buttonVariants({ size: "sm" })} disabled={s?.k === "applying"} onClick={() => apply(r)}>
+ {s?.k === "applying" ? "Applying…" : "Apply"}
+ </button>
+ )}
+ {s?.k === "failed" && (
+ <span role="alert" className="text-[11px] text-reject-text">
+ {s.error}
+ </span>
+ )}
+ </span>
+ )}
+ {(r.how || r.said.length > 0) && (
+ <span className="basis-full pl-6 text-[11px] text-[var(--color-dim)]">
+ {r.how}
+ {r.said.length ? ` — ${r.said.join("; ")}` : ""}
+ {r.words ? ` · words: ${r.words}` : ""}
+ </span>
+ )}
+ </li>
+ );
+ })}
+ </ul>
+ )}
+ {got && (
+ <p className="mt-2 text-[11px] text-[var(--color-dim)]">
+ <code className="font-mono">umtool tighten {project}</code> prints the same list; <code className="font-mono">--apply <clip>[,…]</code> applies rows.
+ </p>
+ )}
+ </section>
+ );
+}
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -26,6 +26,7 @@ Inbox cannot disagree about what is wrong with one.
| `window <project> <clip> --start S --end E --move-stamp first\|nearest\|<s>` · `--clear-stamp` · `--move-mute nearest` · `--clear-mute` | a window edit refused because a stamp's second (`claim.at`, a mark's `at`) or the mute mark would fall outside it, with the fix in the same write: the stamp to the first second that plays, the nearest, or `<s>`, or its `at` cleared; the mute mark to the nearest second, or cleared (never inside a gap). A refused `window` names these flags ([clip-bench.md](clip-bench.md#saving)) |
| `window <project> <clip> --verdict confirmed\|incorrect [--correction T]` · `window <project> <clip> --reject <why> [--note T]` | what the walk said: `--reject` is the walk's **Reject ▾** kept in place (`not-matching`/`wrong-speaker`: incorrect, the note its correction; `irrelevant`/`repeats`/`weak`/`privacy`/`other`: rejected, the note its `rejectNote`); `umtool timeline <p> reject` takes it out ([report-video.md](report-video.md#verdict--what-the-walk-said)) |
| `window <project> <clip> --walk-note T` · `--star` / `--no-star` · `--repeat-of <clip>` | what the walk said that is not a verdict: an editorial note (not a correction) and the ★ favourite, a trailer candidate (`trailer <project> --candidates [--json]` lists them as beats); a deliberate repeat ([knobs.md](knobs.md#a-clip)) |
+| `tighten <project> [--json] [--all] [--no-measure]` · `tighten <project> --apply <clip>[,<clip>…]` | the Cut tab's **Propose tight windows**: each clip to its sentence (the sentences its cut touches, else the whole ones inside its window) and each edge into its pause (the build's measured silences and the gaps between the recording's timed words, ≤ 1 s, inside the cached window) — before → after with the seconds, the clips that would change (`--all`: every clip); prints only. `--apply` writes the named rows through the window writer (the token, the cite that follows the edge); a lock is kept (it is against `resolve-windows`, not a person) ([knobs.md](knobs.md#tighten-to-the-sentence-snap-to-a-pause)) |
| `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`; **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)) |
| `patch-markers <project> [<file>.patch.json] [--fix] [--json]` | take patches whose deck markers name a clip not in the cut (a take made with one is refused); `--fix` gives each the `after` of the cut's marker of the same label; **exit 1** when one is left ([knobs.md](knobs.md#take-patches-follow-a-removal)) |
| `window <project> <clip> --take <take> …` | a **take's** clip (walk a take): the same fields, written into the take's patch (`takes/<take>/take.json`) with an undo point first; the project's manifest is untouched ([clip-bench.md](clip-bench.md#walking-a-take)) |
diff --git a/umtool/docs/clip-bench.md b/umtool/docs/clip-bench.md
@@ -475,6 +475,20 @@ uploads of the same event are two clocks). The bench shows them three ways:
*"already in the cut as c03"*, so reading ahead answers "is this missing?"
rather than only "what is out there?".
+## Tighten to the sentence, snap an edge to a pause
+
+Under the waveform, beside the gaps: **Tighten to this sentence** moves both edges to the sentence at the playhead (a
+playhead still parked on the start, where the bench puts it on arrival, is not a place: then every sentence the cut
+touches, else the whole sentences inside the window, else the one it is inside), each edge then into its pause — the
+start back into the quiet before its first word, the end forward into the quiet after its last — and never past the
+cached window. **Snap edge to nearest pause** (**start** / **end**) moves one edge to the middle of the closest pause,
+at most a second away. Both are WRITTEN AT ONCE through the one window writer, like Extend and the gaps — the cite and
+the QR follow the edge, a cut or mute mark the window no longer holds is cleared and said — the moved edge is heard, and
+**Undo** writes back what was there (the edges, and the cut, the mute mark, the cite and the QR when they moved). The
+words and pauses the snap reads are drawn in the zoom: a box per word, the pauses as bands
+([knobs.md](knobs.md#tighten-to-the-sentence-snap-to-a-pause)). The whole cut at once is the Cut tab's **Propose tight
+windows**: a review list, before → after per clip, each row applied by its own **Apply**.
+
## The cue rail
Every cue in view, positioned by time. Inside the selection in full contrast,
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -59,6 +59,30 @@ it wrote. The CLI prints *cite followed the edge*, the route answers `citeFollow
before this existed is the check's `clip-cite-off` row (open): *the clock and the QR point 78 s before
the clip*, with **Move to m:ss** (`umtool window <p> <clip> --cite N`).
+## Tighten to the sentence, snap to a pause
+
+What punchy tightening took by hand (silencedetect, en-orig word times read from a VTT) is two buttons on the bench and
+a review list on the Cut tab. Nothing new decides where a sentence or a pause is: the sentence is the phone walk's
+(`lib/report/sentenceEdges.mjs`, read off the cues), the pause is L1's (`report-to-video/pauses.mjs`: the build's
+measured silences, the cut-points route's, and the gaps between the recording's **timed** words — the corpus's
+`words.json`, a whisper `transcript.json`, else the en-orig captions' word starts, `report-to-video/clip-words.mjs`),
+composed in `lib/report/tightWindow.mjs`. Every write is the window writer's (`PUT /api/report/window`, the token, the
+cite and the QR that [follow the edge](#the-cite-follows-the-edge)); a cut or a mute mark the new window no longer holds
+is cleared in the same write, and said.
+
+| | In umtool | From a terminal | Route |
+|---|---|---|---|
+| both edges to the sentence: the one at the playhead (a playhead parked on an edge does not count), else every sentence the clip's cut (its quote) touches, else the whole sentences inside the window, else the one it is inside — then the start back into the pause before its first word and the end forward into the one after its last (0.1 s of quiet, ≤ 1 s away), inside the cached window | clip bench, under the waveform: **Tighten to this sentence**; **Undo** writes back the edges (and the cut, the mute mark, the cite, the QR) it moved | — | `PUT /api/report/window {project, clip, token, start, end}` |
+| one edge to the middle of its nearest pause (≤ 1 s) | **Snap edge to nearest pause**: **start** / **end**; **Undo** | — | same |
+| the words and the pauses, drawn | the bench's zoom, at 20 s or less shown: a box per word with its text (a caption word's box runs to the next word's start), the pauses as bands, the measured silences under them | — | `GET /api/report/clip-editor?project&clip&video&from&to` (`words`, `wordsFrom`, `timed`) |
+| every clip of the cut, proposed: before → after and the seconds either way, what moved and why; **nothing applies without a press** | the Cut tab's **Propose tight windows**: each row's **Apply**, then its **Undo**; **show every clip** lists the ones already tight | `umtool tighten <p> [--json] [--all] [--no-measure]` · `--apply <clip>[,<clip>…]` | `GET /api/report/tighten?project=<p>[&clip=…][&measure=0]`, each Apply a `PUT /api/report/window` |
+
+The batch has no playhead: the cut's sentences, else the whole ones in the window. A clip with nothing on disk is
+proposed from its cues and words (no silences) and says *not fetched*; one whose recording has no cues says so and is
+left. **A lock is not a refusal**: `lock`/`lockStart`/`lockEnd` pin an edge against `resolve-windows --write`, not
+against a person, so a locked clip is proposed like any other, its row says *locked*, and Apply keeps the lock. The batch
+is the project's cut; a take's clips are tightened on the take's bench (the take's patch, as every save there).
+
## Take patches follow a removal
A take patch beside the manifest (`*.patch.json`, the file `umtool take --patch` reads) that carries
@@ -138,8 +162,11 @@ second under it stays there; **−** / **+** / **Fit** / **Zoom to selection** (
selection); keys `z` in, `Z` out, `f` fit, `F` to the selection. Zoomed, the wheel pans (either axis), and an
**overview** strip under the waveform shows the whole cached window with what is shown, the selection and the gaps:
drag it to pan, click elsewhere to centre, pinch it with two fingers. A ruler of round ticks sits over a zoomed
-waveform; at 20 s across or closer it also draws the measured silences (the cut-points route's, the build's own) and
-the pauses between words (when the project's words file is this recording's), so a gap's edge goes between two words.
+waveform; at 20 s across or closer it also draws the measured silences (the cut-points route's, the build's own), the
+pauses (those silences and the gaps between timed words, merged) as bands, and a box per word with its text — the
+project's words file when it is this recording's, else the corpus's (`words.json`, a whisper transcript, the en-orig
+captions' word starts: `report-to-video/clip-words.mjs`) — so a gap's edge, or a tightened one
+([below](#tighten-to-the-sentence-snap-to-a-pause)), goes between two words.
At fit — the default, on every clip — the waveform is what it always was. The same zoom is on Play the cut's reel strip,
over cut seconds ([below](#the-reel-strip-zoom-and-reorder)).
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -798,6 +798,11 @@ const CUES = {
// widen every vid1 cache -- and the phone walk asserts where its cache ENDS
// (a sentence past it is offered as a fetch). Source isolation, as vid3/vid4.
CUES.walk1 = CUES.vid1.map((r) => [...r]);
+// The tighten spec's source (tighten.spec.ts): vid1's words under a name of its own, with a
+// words.json sidecar of TIMED words written below -- what the bench's word boxes draw and what the
+// pause snap reads (report-to-video clip-words.mjs) -- laid on the tone window's silences
+// (2.9-3.1, 5.9-6.1).
+CUES.tightvid = CUES.vid1.map((r) => [...r]);
for (const [vid, rows] of Object.entries(CUES)) {
const dir = path.join(CHANNELS, "testchan", "data", vid);
mkdirSync(dir, { recursive: true });
@@ -1890,6 +1895,31 @@ makeCutEditingFixture({ reports, manifest, deckManifest, cachedWindow: path.join
mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true });
copyFileSync(path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), path.join(dir, "out", "clips-raw", "gapvid_0.00-9.00.mp4"));
}
+// Tighten to the sentence, snap an edge to its pause, and the batch's proposals (tighten.spec.ts),
+// which WRITES (the spec puts the manifest back before each test): its own project on tightvid
+// (vid1's cues; sentences 0-3, 3-9, 9-12), the tone window cached as tightvid_0.00-9.00.mp4, and
+// the recording's timed words in the corpus (data/tightvid/words.json).
+// t01 tightvid 1.2-7.4 both edges mid-sentence: tightens to the sentence 3-9 (bounded by the cache's 9)
+// t02 tightvid 3.0-9.0 already the sentence: already tight
+// t03 tightvid 0.5-8.6 a cut 3.5-5.0 inside it (the quote): the cut's sentence, 3-9
+{
+ const g = manifest("tight-fixture", "The Tight Fixture", { siteOrigin: "https://archive.example" }, [
+ { type: "clip", id: "t01", video: "tightvid", start: 1.2, end: 7.4, cite: 1, section: 0, quote: "and this one runs on and because" },
+ { type: "clip", id: "t02", video: "tightvid", start: 3.0, end: 9.0, cite: 3, section: 0, quote: "and this one runs on and because of that it finishes here" },
+ { type: "clip", id: "t03", video: "tightvid", start: 0.5, end: 8.6, cutStart: 3.5, cutEnd: 5.0, cite: 0, section: 0, quote: "runs on and because" },
+ ]);
+ g.render.fetchPad = 0;
+ const dir = writeProject("tight-fixture", g);
+ mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true });
+ copyFileSync(path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), path.join(dir, "out", "clips-raw", "tightvid_0.00-9.00.mp4"));
+ const words = [
+ ["This", 0.2, 0.5], ["is", 0.55, 0.7], ["a", 0.75, 0.8], ["complete", 0.9, 1.6], ["sentence.", 1.7, 2.8],
+ ["And", 3.2, 3.5], ["this", 3.55, 3.8], ["one", 3.85, 4.1], ["runs", 4.15, 4.5], ["on", 4.55, 4.7], ["and", 4.75, 5], ["because", 5.1, 5.85],
+ ["of", 6.2, 6.4], ["that", 6.45, 6.8], ["it", 6.85, 7], ["finishes", 7.1, 7.9], ["here.", 8, 8.8],
+ ["Another", 9.2, 9.8], ["whole", 9.9, 10.3], ["sentence", 10.4, 11], ["entirely.", 11.1, 11.8],
+ ].map(([w, start, end]) => ({ w, start, end }));
+ writeFileSync(path.join(CHANNELS, "testchan", "data", "tightvid", "words.json"), JSON.stringify({ words }, null, 1));
+}
// A clip fetched PER KEPT PIECE (pieced.spec.ts, fetch-per-piece): no window holds its extent, the
// pieces do. READ-ONLY (the spec writes nothing), so one project serves it.
// pc01 pcvid 1-98, gap 8-91 (83 s out): both pieces on disk -- raw windows 0-9 and 90-99
diff --git a/umtool/e2e/tighten.spec.ts b/umtool/e2e/tighten.spec.ts
@@ -0,0 +1,126 @@
+import { test, expect, type Page } from "@playwright/test";
+import { readFileSync, writeFileSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// Tighten to the sentence, snap an edge to its pause, and Propose tight
+// windows (UI notes 2026-10-30, item 4; lib/report/tightWindow.mjs,
+// tightPropose.mjs, components/projects/bench/TightenTools.tsx,
+// report/TightWindowsPanel.tsx):
+//
+// - the bench's zoom draws a box per WORD (the corpus's words.json for the
+// recording) and the pauses (the silences and the gaps between words)
+// - Tighten to this sentence writes both edges through the window writer,
+// Undo puts them back; Snap edge (start / end) moves one edge to the
+// middle of its nearest pause
+// - the Cut tab's Propose tight windows lists before/after per clip and
+// writes NOTHING until a row's Apply; an applied row's Undo restores it
+//
+// Fixture: tight-fixture (make-fixture.mjs), which this spec WRITES and puts
+// back before each test: t01 tightvid 1.2-7.4, t02 3.0-9.0 (already the
+// sentence), t03 0.5-8.6 with a cut 3.5-5.0; vid1's cues (sentences 0-3, 3-9,
+// 9-12), the tone window cached as 0-9, timed words in the corpus.
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const PROJECT = "reports/tight-fixture";
+const MANIFEST = path.join(HERE, "..", ".e2e-song", "reports", "tight-fixture", "video.manifest.json");
+const SHOTS = process.env.U3_SHOTS ?? null;
+type Clip = { id: string; start: number; end: number; cutStart?: number; cutEnd?: number; cite?: number };
+const clipOf = (id: string) => (JSON.parse(readFileSync(MANIFEST, "utf8")) as { timeline: Clip[] }).timeline.find((e) => e.id === id)!;
+
+let PRISTINE = "";
+test.beforeAll(() => {
+ PRISTINE = readFileSync(MANIFEST, "utf8");
+});
+test.beforeEach(() => {
+ test.setTimeout(120_000);
+ writeFileSync(MANIFEST, PRISTINE);
+});
+
+const shot = async (page: Page, name: string) => {
+ await page.screenshot({ path: test.info().outputPath(name) });
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, name) });
+};
+
+const openBench = async (page: Page, clip = "t01") => {
+ await page.setViewportSize({ width: 1440, height: 1000 });
+ await page.goto(urls.clipBenchHref(PROJECT, clip));
+ await page.locator("[data-wave-box]").scrollIntoViewIfNeeded();
+ await expect(page.locator("[data-wave-box]")).toBeInViewport();
+};
+
+test("the zoom draws the recording's words as boxes and its pauses", async ({ page }) => {
+ await openBench(page);
+ // A 9 s window is close enough at fit: the words and the pauses are drawn.
+ const word = page.locator("[data-wave-word='because']");
+ await expect(word).toHaveCount(1, { timeout: 20_000 });
+ await expect(word).toHaveAttribute("data-wave-word-at", "5.10-5.85");
+ expect(await page.locator("[data-wave-word]").count()).toBeGreaterThanOrEqual(10);
+ // The pause between "sentence." and "And" (the words' gap, 2.80-3.20, merged with the measured silence).
+ await expect(page.locator("[data-wave-pause]").first()).toBeAttached();
+ const pauses = await page.locator("[data-wave-pause]").evaluateAll((els) => els.map((e) => e.getAttribute("data-wave-pause")));
+ expect(pauses.some((p) => { const [a, b] = String(p).split("-").map(Number); return a <= 2.81 && b >= 3.19; })).toBe(true);
+ await page.locator("[data-zoom-in]").click();
+ await page.locator("[data-wave-box]").scrollIntoViewIfNeeded();
+ await expect(word).toBeVisible();
+ await shot(page, "u3-1-word-boxes-and-pauses.png");
+});
+
+test("Tighten to this sentence writes both edges through the window writer; Undo puts them back", async ({ page }) => {
+ await openBench(page);
+ await page.locator("[data-tighten]").click();
+ // No playhead: the window 1.2-7.4 holds no whole sentence, so the one it is inside (3-9), the end at the cache's 9.
+ await expect.poll(() => [clipOf("t01").start, clipOf("t01").end]).toEqual([3, 9]);
+ await expect(page.locator("body")).toContainText("tightened to the sentence the window is inside");
+ await page.locator("[data-edge-undo]").click();
+ await expect.poll(() => [clipOf("t01").start, clipOf("t01").end]).toEqual([1.2, 7.4]);
+ await expect(page.locator("body")).toContainText("undone");
+});
+
+test("Snap edge: the start, then the end, each to the middle of its nearest pause", async ({ page }) => {
+ await openBench(page);
+ await page.locator("[data-snap-edge='start']").click();
+ // 1.2 sits between "a" (…0.8) / "complete" (0.9…) and "complete" (…1.6) / "sentence." (1.7…): the nearer pause is 0.8-0.9.
+ await expect.poll(() => clipOf("t01").start).toBe(0.85);
+ await expect(page.locator("[data-edge-undo]")).toBeVisible();
+ await page.locator("[data-snap-edge='end']").click();
+ // 7.4: "it" (…7.0) / "finishes" (7.1…) is nearer than "finishes" (…7.9) / "here." (8.0…).
+ await expect.poll(() => clipOf("t01").end).toBe(7.05);
+ expect(clipOf("t01").start).toBe(0.85);
+});
+
+test("Propose tight windows: a review list, nothing written until Apply; Apply and Undo per row", async ({ page }) => {
+ await page.setViewportSize({ width: 1440, height: 1100 });
+ await page.goto(urls.section(PROJECT, "cut"));
+ const panel = page.locator("[data-tight-windows]");
+ await panel.scrollIntoViewIfNeeded();
+ await panel.locator("[data-action='propose-tight']").click();
+ const t01 = panel.locator("[data-tight-row='t01']");
+ await expect(t01).toBeVisible({ timeout: 60_000 });
+ await expect(t01.locator("[data-tight-before]")).toHaveAttribute("data-tight-before", "1.2-7.4");
+ await expect(t01.locator("[data-tight-after]")).toHaveAttribute("data-tight-after", "3-9");
+ await expect(t01.locator("[data-tight-delta]")).toHaveAttribute("data-tight-delta", "-0.20");
+ // t03's cut (its quote, 3.5-5.0) anchors it: the sentence 3-9.
+ await expect(panel.locator("[data-tight-row='t03'] [data-tight-after]")).toHaveAttribute("data-tight-after", "3-9");
+ // t02 is already the sentence: not listed until every clip is shown.
+ await expect(panel.locator("[data-tight-row='t02']")).toHaveCount(0);
+ await expect(panel.locator("[data-tight-counts]")).toContainText("2 of 3 clips would change · 1 already tight");
+ // Proposing wrote nothing.
+ expect(readFileSync(MANIFEST, "utf8")).toBe(PRISTINE);
+ await shot(page, "u3-2-propose-tight-review.png");
+
+ await t01.locator("[data-action='tight-apply']").click();
+ await expect(t01).toHaveAttribute("data-tight-state", "applied");
+ await expect.poll(() => [clipOf("t01").start, clipOf("t01").end]).toEqual([3, 9]);
+ // Only that row: t03 is as it was.
+ expect([clipOf("t03").start, clipOf("t03").end]).toEqual([0.5, 8.6]);
+ await t01.locator("[data-action='tight-undo']").click();
+ await expect(t01).toHaveAttribute("data-tight-state", "undone");
+ await expect.poll(() => [clipOf("t01").start, clipOf("t01").end]).toEqual([1.2, 7.4]);
+
+ await panel.locator("[data-action='tight-show-all']").click();
+ await expect(panel.locator("[data-tight-row='t02']")).toHaveAttribute("data-tight-state", "same");
+});
diff --git a/umtool/lib/report/clipEditor.mjs b/umtool/lib/report/clipEditor.mjs
@@ -25,7 +25,7 @@
import { readFile, stat } from "node:fs/promises";
import path from "node:path";
import { clipMomentKey } from "umtool-report-to-video/montage-rulings";
-import { channelFor, clipsOf, cuesInWindow, readManifest } from "../projects/report.mjs";
+import { channelFor, channelsDirFor, clipsOf, cuesInWindow, hasShadowChannels, readManifest } from "../projects/report.mjs";
import {
StaleToken,
StructureRefused,
@@ -263,7 +263,22 @@ const overlapping = (list, from, to) =>
export async function clipNeighbourhood(project, { clip, from, to, video = null }) {
if (!fin(from) || !fin(to) || to <= from) throw new Error("from and to must be seconds, from < to");
const { doc } = await readReactions(project.dir);
- const words = video && doc?.source?.video !== video ? null : await readWords(project.dir, doc);
+ let words = video && doc?.source?.video !== video ? null : await readWords(project.dir, doc);
+ // The bench, zoomed in, on a recording the project has no words file for:
+ // the corpus's words for it (report-to-video clip-words.mjs -- a words
+ // sidecar, a whisper transcript, else the en-orig captions' word starts),
+ // the same ones the trailer's pause snap reads. Never a cue spread by its
+ // characters: a box drawn there would be a made-up place.
+ let wordsFrom = words?.length ? "project" : null;
+ let timed = words?.length ? true : null;
+ if (video && !words?.length && clip) {
+ const corpus = await corpusWords(project.dir, clip, video, from, to).catch(() => null);
+ if (corpus?.words?.length) {
+ words = corpus.words.map((w) => ({ w: w.text, start: w.start, ...(fin(w.end) ? { end: w.end } : {}) }));
+ wordsFrom = corpus.from;
+ timed = corpus.timed;
+ }
+ }
const turns = overlapping(doc?.turns, from, to).map((t) => ({ start: t.start, end: t.end, speaker: t.speaker }));
const laughs = overlapping(doc?.laughs, from, to).map((l) => ({ start: l.start, end: l.end, score: fin(l.score) ? l.score : null, speaker: fin(l.speaker) ? l.speaker : null }));
let cues = null;
@@ -278,12 +293,33 @@ export async function clipNeighbourhood(project, { clip, from, to, video = null
to,
turns,
laughs,
- words: words?.length ? words.filter((w) => w.end >= from && w.start <= to).map((w) => ({ w: String(w.w ?? w.word ?? w.text ?? ""), start: w.start, end: w.end })) : null,
+ words: words?.length
+ ? words
+ .filter((w) => (fin(w.end) ? w.end : w.start) >= from && w.start <= to)
+ .map((w) => ({ w: String(w.w ?? w.word ?? w.text ?? ""), start: w.start, ...(fin(w.end) ? { end: w.end } : {}) }))
+ : null,
+ // Where the words came from (the project's words file, words.json /
+ // transcript.json / captions in the corpus), and whether they carry their
+ // ends (captions' words have only their starts).
+ ...(video ? { wordsFrom, timed } : {}),
cues,
duration,
};
}
+/**
+ * A recording's words from the corpus (clip-words.mjs), for the bench's zoom:
+ * the clip named, on THAT recording.
+ */
+async function corpusWords(dir, clipId, video, from, to) {
+ const manifest = await readManifest(dir);
+ const entry = clipsOf(manifest).find((e) => e.id === clipId);
+ if (!entry || entry.video !== video) return null;
+ const { clipWords } = await import("umtool-report-to-video/clip-words");
+ const channelsDir = channelsDirFor(dir, manifest, { shadowExists: await hasShadowChannels(dir) });
+ return clipWords(entry, manifest.provenance, from, to, { channelsDir });
+}
+
/** The words of a span around one clip (for a quote), from words or cues. */
async function quoteFor(project, clipId, from, to) {
const n = await clipNeighbourhood(project, { clip: clipId, from: Math.max(0, from - 1), to: to + 1 }).catch(() => null);
diff --git a/umtool/lib/report/tightCli.mjs b/umtool/lib/report/tightCli.mjs
@@ -0,0 +1,92 @@
+// `umtool tighten <project> [--json] [--no-measure] [--all] [--apply <clip>[,<clip>…]]`:
+// the Cut tab's "Propose tight windows" (lib/report/tightPropose.mjs) from a
+// terminal -- every clip of the cut tightened to its sentence and each edge
+// into its pause, before and after. Prints only; `--apply` writes the named
+// rows through the window writer (the token, the cite that follows the edge,
+// an edit note on a generated manifest), re-proposed first.
+//
+// Plain ESM: the CLI runs it under bare node.
+import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs";
+import { kindMakesTakes } from "../projects/kinds.mjs";
+import { applyTightWindows, proposeTightWindows } from "./tightPropose.mjs";
+
+export const TIGHTEN_USAGE = [
+ "usage: umtool tighten <project> [--json] [--all] [--no-measure]",
+ " umtool tighten <project> --apply <clip>[,<clip>…]",
+ "",
+ "Each clip of the cut to its sentence -- the sentences its cut (its quote) touches, else the whole",
+ "sentences inside its window -- and each edge into its pause (the build's measured silences and the",
+ "gaps between the recording's timed words, at most 1 s away, inside the cached window). Prints the",
+ "clips that would change, before -> after with the seconds (--all: every clip). --no-measure skips",
+ "the silences (the words alone). --apply writes those rows through the window writer; a locked edge",
+ "is proposed like any other (a lock is against resolve-windows) and the lock is kept.",
+].join("\n");
+
+class CliError extends Error {}
+
+const hms = (t) => {
+ const m = Math.floor(t / 60);
+ return `${m}:${(t - m * 60).toFixed(2).padStart(5, "0")}`;
+};
+
+/** One row as a line. */
+export function tightLine(r) {
+ const b = `${hms(r.before.start)}–${hms(r.before.end)} (${r.before.seconds.toFixed(2)} s)`;
+ if (!r.after) return `${r.id.padEnd(8)} ${b} — ${r.why}`;
+ const a = `${hms(r.after.start)}–${hms(r.after.end)} (${r.after.seconds.toFixed(2)} s)`;
+ const d = r.after.seconds - r.before.seconds;
+ const marks = [r.locked ? "locked" : null, r.fetched ? null : "not fetched", r.clear.cut ? "clears the cut" : null].filter(Boolean);
+ return `${r.id.padEnd(8)} ${b} → ${a} ${r.changed ? `${d > 0 ? "+" : "−"}${Math.abs(d).toFixed(2)} s` : "already tight"}${marks.length ? ` [${marks.join(", ")}]` : ""}` +
+ (r.changed ? `\n ${r.how}${r.said.length ? ` — ${r.said.join("; ")}` : ""}` : "");
+}
+
+/**
+ * @param {string[]} args the words after `tighten`
+ * @param {{ root?: string, out?: (s: string) => void, err?: (s: string) => void }} [opts]
+ * @returns {Promise<number>}
+ */
+export async function tightenCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s) } = {}) {
+ try {
+ const flags = new Set();
+ const words = [];
+ let apply = null;
+ for (let i = 0; i < args.length; i += 1) {
+ const a = args[i];
+ if (a === "--apply") {
+ apply = String(args[i + 1] ?? "").split(",").map((s) => s.trim()).filter(Boolean);
+ i += 1;
+ if (!apply.length) throw new CliError("--apply names clips: --apply c01,c02");
+ } else if (a.startsWith("--")) {
+ if (!["--json", "--all", "--no-measure", "--help"].includes(a)) throw new CliError(`unknown flag ${a}`);
+ flags.add(a);
+ } else words.push(a);
+ }
+ if (!words[0] || flags.has("--help")) {
+ (flags.has("--help") ? out : err)(TIGHTEN_USAGE);
+ return flags.has("--help") ? 0 : 2;
+ }
+ const r = await resolveProject(words[0], root);
+ if (r.ambiguous) throw new CliError(`"${words[0]}" is the name of ${r.ambiguous.length} projects — pass its id`);
+ if (!r.project) throw new CliError(`no project matches "${words[0]}"`);
+ const project = r.project;
+ if (!kindMakesTakes(project.kind)) throw new CliError(`${project.id} is a ${project.kind}, not a report video`);
+ if (apply) {
+ const done = await applyTightWindows(project, apply);
+ if (flags.has("--json")) out(JSON.stringify({ applied: done }, null, 2));
+ else for (const d of done) out(`${d.ok ? "applied" : "NOT applied"} ${d.id}: ${d.said}`);
+ return done.every((d) => d.ok) ? 0 : 1;
+ }
+ const got = await proposeTightWindows(project, { measure: !flags.has("--no-measure") });
+ if (flags.has("--json")) {
+ out(JSON.stringify(got, null, 2));
+ return 0;
+ }
+ out(`${got.counts.proposed} of ${got.counts.clips} clips would change · ${got.counts.same} already tight${got.counts.none ? ` · ${got.counts.none} with nothing to go by` : ""}`);
+ for (const row of got.rows) if (flags.has("--all") || row.changed) out(tightLine(row));
+ if (got.counts.proposed) out(`\napply: umtool tighten ${project.id} --apply ${got.rows.filter((x) => x.changed).map((x) => x.id).join(",")}`);
+ return 0;
+ } catch (e) {
+ err(e instanceof Error ? e.message : String(e));
+ return e instanceof CliError ? 2 : 1;
+ }
+}
diff --git a/umtool/lib/report/tightCli.test.mjs b/umtool/lib/report/tightCli.test.mjs
@@ -0,0 +1,41 @@
+// The pure halves of the batch: the window patch an Apply writes
+// (tightPropose.mjs applyPatchOf) and a row as `umtool tighten` prints it.
+//
+// Run with: node --test lib/report/tightCli.test.mjs
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { tightLine } from "./tightCli.mjs";
+import { applyPatchOf } from "./tightPropose.mjs";
+
+const row = (o = {}) => ({
+ id: "t01",
+ quote: "and because of that",
+ section: 0,
+ before: { start: 1.2, end: 7.4, seconds: 6.2 },
+ after: { start: 3.0, end: 9.0, seconds: 6 },
+ changed: true,
+ how: "the sentences the cut (its quote) touches",
+ said: ["start 3.00 → 3.01, into the pause before “And”"],
+ why: null,
+ fetched: true,
+ locked: false,
+ words: "words.json",
+ clear: { cut: false, mute: false },
+ prior: { cutStart: null, cutEnd: null, muteFrom: null, cite: null, citeUrl: null },
+ ...o,
+});
+
+test("applyPatchOf: the edges, and the cut / mute mark cleared only when they no longer fit", () => {
+ assert.deepEqual(applyPatchOf(row()), { start: 3, end: 9 });
+ assert.deepEqual(applyPatchOf(row({ clear: { cut: true, mute: true } })), { start: 3, end: 9, cutStart: "", cutEnd: "", muteFrom: "" });
+ assert.equal(applyPatchOf(row({ after: null })), null);
+});
+
+test("tightLine: before → after with the seconds, the marks, and why", () => {
+ const l = tightLine(row({ locked: true, fetched: false }));
+ assert.match(l, /^t01 +0:01\.20–0:07\.40 \(6\.20 s\) → 0:03\.00–0:09\.00 \(6\.00 s\) {2}−0\.20 s {2}\[locked, not fetched\]/);
+ assert.match(l, /into the pause before/);
+ assert.match(tightLine(row({ after: null, changed: false, why: "no cues" })), /— no cues$/);
+ assert.match(tightLine(row({ changed: false, after: { start: 1.2, end: 7.4, seconds: 6.2 } })), /already tight/);
+});
diff --git a/umtool/lib/report/tightPropose.mjs b/umtool/lib/report/tightPropose.mjs
@@ -0,0 +1,211 @@
+// PROPOSE TIGHT WINDOWS for a cut (UI notes 2026-10-30, item 4: "a batch
+// 'propose tight windows' that shows before/after durations for review").
+//
+// For every clip of the project's cut, lib/report/tightWindow.mjs over what
+// this machine already has -- nothing is fetched, nothing is written:
+//
+// cues the recording's cue file (projects/report.mjs cuesInWindow),
+// 60 s either side, for where a sentence starts and ends
+// words the project's words file when it is THAT recording's, else the
+// corpus's (report-to-video clip-words.mjs: a words sidecar, a
+// whisper transcript, the en-orig captions' starts)
+// silences the build's own, measured on the build's own file and cached
+// (lib/report/cutPoints.mjs -- the bench's ghosts and Play read the
+// same); a clip with nothing on disk goes by its words alone
+// the bound the cached window holding the clip, when there is one: a
+// proposal never reaches past what the bench could play
+//
+// with no playhead: the cut's sentences when the clip has a cut (its quote),
+// else the whole sentences inside the window. Each row is before and after,
+// what moved and why; the review list (the Cut tab) applies a row only when
+// its Apply is pressed -- PUT /api/report/window, the token, the cite that
+// follows the edge -- and `umtool tighten <p> --apply <clip>` does the same
+// through the same writer.
+//
+// A LOCK IS NOT A REFUSAL HERE. `lock`/`lockStart`/`lockEnd` pin an edge
+// against `resolve-windows --write` (the widener), not against a person: five
+// of six real cuts are fully locked. A locked clip is proposed like any other
+// and its row says it is locked; Apply leaves the locks as they are.
+
+import { clipWords } from "umtool-report-to-video/clip-words";
+import { hasLocalMedia } from "umtool-report-to-video/local-media";
+import { channelsDirFor, clipsOf, cuesInWindow, hasShadowChannels, readManifest } from "../projects/report.mjs";
+import { readWords } from "./clipEditor.mjs";
+import { readReactions } from "./clipEditorBridge.mjs";
+import { withEditNotes } from "./edit-guard.mjs";
+import { manifestToken, updateClip } from "./manifest.mjs";
+import { projectCache, windowsFor } from "./serve.mjs";
+import { HOW_SAID, tightWindow } from "./tightWindow.mjs";
+
+/** How far either side of a clip its cues are read (seconds). */
+const CUE_REACH = 60;
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+const r2 = (v) => Math.round(v * 100) / 100;
+
+/**
+ * @typedef {{
+ * id: string, quote: string | null, section: unknown,
+ * before: { start: number, end: number, seconds: number },
+ * after: { start: number, end: number, seconds: number } | null,
+ * changed: boolean, how: string | null, said: string[], why: string | null,
+ * fetched: boolean, locked: boolean, words: string | null,
+ * clear: { cut: boolean, mute: boolean },
+ * prior: { cutStart: number | null, cutEnd: number | null, muteFrom: number | null, cite: number | null, citeUrl: string | null },
+ * }} TightRow
+ */
+
+/**
+ * The proposals for a project's cut (or the named clips).
+ *
+ * @param {{ id: string, dir: string }} project
+ * @param {{ clips?: string[] | null, measure?: boolean }} [opts]
+ * `measure: false` skips the silences (the words alone), for a cut whose sources are not on disk
+ * @returns {Promise<{ token: string | null, rows: TightRow[], counts: { clips: number, proposed: number, same: number, none: number } }>}
+ */
+export async function proposeTightWindows(project, { clips = null, measure = true } = {}) {
+ const manifest = await readManifest(project.dir);
+ if (!manifest) throw new Error("no manifest");
+ const want = clips ? new Set(clips) : null;
+ const entries = clipsOf(manifest).filter((e) => fin(e.start) && fin(e.end) && typeof e.video === "string" && !hasLocalMedia(e) && (!want || want.has(e.id)));
+ const token = await manifestToken(project.dir);
+ const channelsDir = channelsDirFor(project.dir, manifest, { shadowExists: await hasShadowChannels(project.dir) });
+ const { doc: reactions } = await readReactions(project.dir);
+ const projectWords = await readWords(project.dir, reactions).catch(() => null);
+ const cache = await projectCache(project, manifest);
+
+ // The build's silences per clip (cached on disk; the first read measures).
+ /** @type {Map<string, Array<{ from: number, to: number }>>} */
+ const silences = new Map();
+ if (measure && entries.length) {
+ try {
+ const { cutPointsFor } = await import("./cutPoints.mjs");
+ const got = await cutPointsFor(project, { clips: entries.map((e) => e.id) });
+ for (const row of got.clips ?? []) {
+ if (!row || row.missing || row.error || !Array.isArray(row.silences) || !fin(row.fetchStart)) continue;
+ silences.set(row.id, row.silences.map((x) => ({ from: row.fetchStart + x.s, to: row.fetchStart + x.e })));
+ }
+ } catch {
+ /* the words alone */
+ }
+ }
+
+ /** @type {TightRow[]} */
+ const rows = [];
+ for (const e of entries) {
+ const before = { start: e.start, end: e.end, seconds: r2(e.end - e.start) };
+ const base = {
+ id: e.id,
+ quote: typeof e.quote === "string" ? e.quote : null,
+ section: e.section ?? null,
+ before,
+ locked: !!(e.lock || e.lockStart || e.lockEnd),
+ // What an Undo of an applied row writes back besides the edges (the writer answers only the edges' `before`).
+ prior: {
+ cutStart: fin(e.cutStart) ? e.cutStart : null,
+ cutEnd: fin(e.cutEnd) ? e.cutEnd : null,
+ muteFrom: fin(e.muteFrom) ? e.muteFrom : null,
+ cite: fin(e.cite) ? e.cite : null,
+ citeUrl: typeof e.citeUrl === "string" ? e.citeUrl : null,
+ },
+ };
+ const wins = /** @type {Array<{ from: number, to: number }>} */ (await windowsFor(project, e, cache).catch(() => []));
+ const holds = wins.find((w) => w.from <= e.start + 0.02 && w.to >= e.end - 0.02) ?? null;
+ const c = await cuesInWindow(project.dir, e.id, e.start - CUE_REACH, e.end + CUE_REACH, { manifest }).catch(() => null);
+ let words = null;
+ let wordsFrom = null;
+ if (projectWords?.length && reactions?.source?.video === e.video) {
+ words = projectWords.filter((w) => w.end >= e.start - CUE_REACH && w.start <= e.end + CUE_REACH).map((w) => ({ start: w.start, end: w.end, text: String(w.w ?? w.word ?? w.text ?? "") }));
+ wordsFrom = "project";
+ } else {
+ const cw = await clipWords(e, manifest.provenance, e.start - CUE_REACH, e.end + CUE_REACH, { channelsDir }).catch(() => null);
+ if (cw?.words?.length) {
+ words = cw.words;
+ wordsFrom = cw.from;
+ }
+ }
+ const r = tightWindow({
+ clip: { start: e.start, end: e.end, cutStart: fin(e.cutStart) ? e.cutStart : null, cutEnd: fin(e.cutEnd) ? e.cutEnd : null },
+ cues: c?.cues ?? [],
+ words,
+ silences: silences.get(e.id) ?? null,
+ at: null,
+ ...(holds ? { lo: holds.from, hi: holds.to } : { lo: 0 }),
+ });
+ if (!r.ok) {
+ rows.push({ ...base, after: null, changed: false, how: null, said: [], why: r.why, fetched: !!holds, words: wordsFrom, clear: { cut: false, mute: false } });
+ continue;
+ }
+ const cutOut = fin(e.cutStart) && fin(e.cutEnd) && (e.cutStart < r.start - 0.02 || e.cutEnd > r.end + 0.02);
+ const muteOut = fin(e.muteFrom) && (e.muteFrom < r.start - 0.02 || e.muteFrom > r.end + 0.02);
+ rows.push({
+ ...base,
+ after: { start: r.start, end: r.end, seconds: r2(r.end - r.start) },
+ changed: r.changed,
+ how: HOW_SAID[r.how],
+ said: r.said,
+ why: null,
+ fetched: !!holds,
+ words: wordsFrom,
+ clear: { cut: !!cutOut, mute: !!muteOut },
+ });
+ }
+ const proposed = rows.filter((x) => x.changed).length;
+ const none = rows.filter((x) => !x.after).length;
+ return { token, rows, counts: { clips: rows.length, proposed, same: rows.length - proposed - none, none } };
+}
+
+/**
+ * The window patch that applies one row: its edges, and the cut / the mute
+ * mark cleared when they no longer fit (as the bench's Save window does).
+ *
+ * @param {TightRow} row
+ */
+export function applyPatchOf(row) {
+ if (!row.after) return null;
+ return {
+ start: row.after.start,
+ end: row.after.end,
+ ...(row.clear.cut ? { cutStart: "", cutEnd: "" } : {}),
+ ...(row.clear.mute ? { muteFrom: "" } : {}),
+ };
+}
+
+/**
+ * Apply proposals by clip id through the window writer (the terminal's
+ * `umtool tighten <p> --apply <ids>`), one write each, re-proposed first so a
+ * row is never applied from a stale reading.
+ *
+ * @param {{ id: string, dir: string, kind: string }} project
+ * @param {string[]} ids
+ * @returns {Promise<Array<{ id: string, ok: boolean, said: string }>>}
+ */
+export async function applyTightWindows(project, ids) {
+ const { rows } = await proposeTightWindows(project, { clips: ids });
+ const out = [];
+ for (const id of ids) {
+ const row = rows.find((x) => x.id === id);
+ if (!row) {
+ out.push({ id, ok: false, said: "not a clip of the cut with a window" });
+ continue;
+ }
+ const patch = applyPatchOf(row);
+ if (!patch || !row.changed) {
+ out.push({ id, ok: false, said: row.why ?? "already tight" });
+ continue;
+ }
+ try {
+ const token = await manifestToken(project.dir);
+ const { result: res } = await withEditNotes(project, () => updateClip(project.dir, id, patch, { token }));
+ const f = res.citeFollowed;
+ out.push({
+ id,
+ ok: true,
+ said: `${row.before.start}–${row.before.end} → ${row.after?.start}–${row.after?.end} (${row.before.seconds} s → ${row.after?.seconds} s)` +
+ `${f?.cite ? `; cite ${f.cite.from} → ${f.cite.to}` : ""}${f?.citeUrl ? "; the QR's t= with it" : ""}`,
+ });
+ } catch (e) {
+ out.push({ id, ok: false, said: e instanceof Error ? e.message : String(e) });
+ }
+ }
+ return out;
+}
diff --git a/umtool/lib/report/tightWindow.mjs b/umtool/lib/report/tightWindow.mjs
@@ -0,0 +1,198 @@
+// TIGHTEN A CLIP TO ITS SENTENCE, and an edge into the nearest pause (UI notes
+// 2026-10-30, item 4: "punchy tightening meant silencedetect by hand and
+// en-orig word times read from VTT").
+//
+// Two existing rules, composed -- nothing here detects a pause or a sentence
+// of its own:
+//
+// the sentence lib/report/sentenceEdges.mjs (the phone walk's strip, the
+// pre-cut's rule): a start edge lands on a sentence START,
+// an end edge on a sentence END, read off the cues;
+// the pause report-to-video/pauses.mjs (L1's helper, the trailer's
+// snap): the measured silences and the gaps between timed
+// words, and `snapEdge` -- a start back into the pause
+// before its first word, an end forward into the one after
+// its last, "nearest" to the middle of the closest one.
+//
+// WHICH SENTENCE ("the sentence around the playhead or the current window"):
+//
+// at the playhead, when it is inside the clip (more than AT_MARGIN from
+// either edge: a playhead parked on the start, where the bench puts it
+// on arrival, is not a place somebody chose): the one sentence it is in
+// cut else the clip's cut (the quote's span): every sentence it touches,
+// whole -- the quote finished, nothing more
+// window else the whole sentences inside the window: a partial sentence at
+// either edge is dropped
+// middle a window inside one sentence: that sentence
+//
+// then each edge into its pause (a hard cut's SNAP_HARD_ROOM of quiet, at most
+// SNAP_MAX_SHIFT away, never past `lo`/`hi`: the cached window on the bench).
+// What moved and why comes back to be said; nothing here writes. The bench
+// writes through the window writer (PUT /api/report/window, the token, the cite
+// that follows the edge), and so does each Apply of the batch's proposals
+// (tightPropose.mjs).
+//
+// PURE: no fs, no DOM -- the bench imports it.
+
+import { sentenceBoundaries } from "./sentenceEdges.mjs";
+import { pauseSpans, snapEdge } from "umtool-report-to-video/pauses";
+
+/** Two seconds closer than this are the same boundary (sentenceEdges' SAME). */
+const SAME = 0.05;
+/** A playhead this close to an edge is parked there, not placed (seconds). */
+export const AT_MARGIN = 0.25;
+/** How far past the sentence the pauses are read (seconds): a snap moves at most SNAP_MAX_SHIFT. */
+const PAUSE_REACH = 2;
+
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+const r2 = (v) => Math.round(v * 100) / 100;
+
+/**
+ * The sentence(s) around the span [a, b]: the last sentence start at or
+ * before `a` and the first sentence end at or after `b`. null when the cues
+ * hold no such boundary on either side.
+ *
+ * @param {Array<{ start: number, end: number, text: string }>} cues
+ * @param {number} a
+ * @param {number} b
+ * @returns {{ start: number, end: number } | null}
+ */
+export function sentenceAround(cues, a, b) {
+ const { starts, ends } = sentenceBoundaries(cues);
+ let start = null;
+ for (const s of starts) if (s <= a + SAME) start = s;
+ const end = ends.find((e) => e >= b - SAME && e > (start ?? -Infinity) + SAME) ?? null;
+ return start !== null && end !== null ? { start, end } : null;
+}
+
+/**
+ * The whole sentences inside [from, to]: the first sentence start at or after
+ * `from`, the last sentence end at or before `to`. null when no whole sentence
+ * fits.
+ *
+ * @param {Array<{ start: number, end: number, text: string }>} cues
+ * @param {number} from
+ * @param {number} to
+ */
+export function sentencesInside(cues, from, to) {
+ const { starts, ends } = sentenceBoundaries(cues);
+ const start = starts.find((s) => s >= from - SAME) ?? null;
+ let end = null;
+ for (const e of ends) if (e <= to + SAME) end = e;
+ return start !== null && end !== null && end > start + SAME ? { start, end } : null;
+}
+
+/**
+ * The pauses around [from, to] (pauses.mjs pauseSpans): the measured silences
+ * and the gaps between timed words.
+ *
+ * @param {{ words?: Array<{ start: number, end?: number }> | null, silences?: Array<{ from: number, to: number }> | null }} o
+ * @param {number} from
+ * @param {number} to
+ */
+export function pausesNear({ words = null, silences = null }, from, to) {
+ return pauseSpans({ words, silences }, { from: from - PAUSE_REACH, to: to + PAUSE_REACH });
+}
+
+/** One snap in words: "start 12.40 → 12.95, into the pause before “So”". */
+export function snapSaid(edge, snap) {
+ if (!snap) return null;
+ if (!snap.moved) {
+ const why = snap.reason === "fits" ? "already in a pause" : snap.reason === "far" ? "the nearest pause is more than a second away" : snap.reason === "bound" ? "the pause is past the cached window" : "no pause near it";
+ return `${edge} stays at ${snap.at.toFixed(2)} (${why})`;
+ }
+ const word = snap.word ? ` ${snap.side === "start" ? "before" : snap.side === "end" ? "after" : "by"} “${snap.word}”` : "";
+ return `${edge} ${snap.from.toFixed(2)} → ${snap.at.toFixed(2)}, into the pause${word}${snap.bounded ? " (as far as the cached window)" : ""}`;
+}
+
+/**
+ * An edge into the pause nearest it (pauses.mjs snapEdge "nearest"): what the
+ * bench's "Snap edge to nearest pause" does.
+ *
+ * @param {number} t
+ * @param {{ words?: Array<{ start: number, end?: number, text?: string }> | null, silences?: Array<{ from: number, to: number }> | null, lo?: number, hi?: number }} o
+ */
+export function nearestPause(t, { words = null, silences = null, lo = -Infinity, hi = Infinity }) {
+ const pauses = pausesNear({ words, silences }, t, t);
+ return snapEdge(t, "nearest", { pauses, words, lo, hi });
+}
+
+/**
+ * Tighten a clip to its sentence (see the header).
+ *
+ * @param {{
+ * clip: { start: number, end: number, cutStart?: number | null, cutEnd?: number | null },
+ * cues: Array<{ start: number, end: number, text: string }>,
+ * words?: Array<{ start: number, end?: number, text?: string }> | null,
+ * silences?: Array<{ from: number, to: number }> | null,
+ * at?: number | null,
+ * lo?: number, hi?: number,
+ * snap?: boolean,
+ * }} o
+ * @returns {{ ok: true, start: number, end: number, how: "at" | "cut" | "window" | "middle",
+ * sentence: { start: number, end: number }, snaps: { start: any, end: any } | null, changed: boolean, said: string[] }
+ * | { ok: false, why: string }}
+ */
+export function tightWindow({ clip, cues, words = null, silences = null, at = null, lo = -Infinity, hi = Infinity, snap = true }) {
+ if (!clip || !fin(clip.start) || !fin(clip.end)) return { ok: false, why: "the clip has no window" };
+ const cs = (cues ?? []).filter((c) => c && fin(c.start) && fin(c.end));
+ if (!cs.length) return { ok: false, why: "no cues for this recording: nothing says where a sentence is" };
+ const hasCut = fin(clip.cutStart) && fin(clip.cutEnd);
+ /** @type {"at" | "cut" | "window" | "middle"} */
+ let how;
+ let s = null;
+ if (fin(at) && at > clip.start + AT_MARGIN && at < clip.end - AT_MARGIN) {
+ how = "at";
+ s = sentenceAround(cs, /** @type {number} */ (at), /** @type {number} */ (at));
+ } else if (hasCut) {
+ how = "cut";
+ s = sentenceAround(cs, /** @type {number} */ (clip.cutStart), /** @type {number} */ (clip.cutEnd));
+ } else {
+ how = "window";
+ s = sentencesInside(cs, clip.start, clip.end);
+ if (!s) {
+ how = "middle";
+ const mid = (clip.start + clip.end) / 2;
+ s = sentenceAround(cs, mid, mid);
+ }
+ }
+ if (!s) return { ok: false, why: "the cues around it hold no sentence boundary" };
+ // The cached window bounds the sentence itself, not only the snap: an edge
+ // past it is clamped to it (and said).
+ const said = [];
+ let start = s.start;
+ let end = s.end;
+ if (start < lo - 1e-6) {
+ said.push(`the sentence starts at ${start.toFixed(2)}, before the cached window: from ${lo.toFixed(2)}`);
+ start = lo;
+ }
+ if (end > hi + 1e-6) {
+ said.push(`the sentence ends at ${end.toFixed(2)}, past the cached window: to ${hi.toFixed(2)}`);
+ end = hi;
+ }
+ let snaps = null;
+ if (snap) {
+ const pauses = pausesNear({ words, silences }, start, end);
+ if (pauses.length) {
+ const a = snapEdge(start, "start", { pauses, words, lo, hi: end });
+ const b = snapEdge(end, "end", { pauses, words, lo: start, hi });
+ snaps = { start: a, end: b };
+ if (a.moved) start = a.at;
+ if (b.moved) end = b.at;
+ for (const [edge, x] of /** @type {const} */ ([["start", a], ["end", b]])) if (x.moved) said.push(/** @type {string} */ (snapSaid(edge, x)));
+ }
+ }
+ start = r2(start);
+ end = r2(end);
+ if (!(end - start >= 0.5)) return { ok: false, why: "the sentence is shorter than half a second" };
+ const changed = Math.abs(start - clip.start) > 0.02 || Math.abs(end - clip.end) > 0.02;
+ return { ok: true, start, end, how, sentence: { start: r2(s.start), end: r2(s.end) }, snaps, changed, said };
+}
+
+/** What the anchor was, in words. */
+export const HOW_SAID = Object.freeze({
+ at: "the sentence at the playhead",
+ cut: "the sentences the cut (its quote) touches",
+ window: "the whole sentences inside the window",
+ middle: "the sentence the window is inside",
+});
diff --git a/umtool/lib/report/tightWindow.test.mjs b/umtool/lib/report/tightWindow.test.mjs
@@ -0,0 +1,109 @@
+// tightWindow.mjs: a clip tightened to its sentence (sentenceEdges.mjs) and
+// each edge into its pause (report-to-video/pauses.mjs) -- which sentence (the
+// playhead's, the cut's, the whole ones inside the window, the one it is
+// inside), the cache as a bound, and an edge to the nearest pause.
+//
+// Run with: node --test lib/report/tightWindow.test.mjs
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { HOW_SAID, nearestPause, pausesNear, sentenceAround, sentencesInside, snapSaid, tightWindow } from "./tightWindow.mjs";
+
+// The e2e fixture's vid1 cues (e2e/fixtures/make-fixture.mjs): sentences 0-3, 3-9, 9-12, 12-15, 15-21.
+const VID1 = [
+ [0, 3, "This is a complete sentence."],
+ [3, 6, "And this one runs on and because"],
+ [6, 9, "of that it finishes here."],
+ [9, 12, "Another whole sentence entirely."],
+ [12, 15, "A fourth one, done."],
+ [15, 18, "trailing off and then"],
+ [18, 21, "it lands at last."],
+].map(([start, end, text]) => ({ start, end, text }));
+
+// Timed words over it (the tight fixture's words.json), with the silences of the fixture's tone window.
+const WORDS = [
+ ["This", 0.2, 0.5], ["is", 0.55, 0.7], ["a", 0.75, 0.8], ["complete", 0.9, 1.6], ["sentence.", 1.7, 2.8],
+ ["And", 3.2, 3.5], ["this", 3.55, 3.8], ["one", 3.85, 4.1], ["runs", 4.15, 4.5], ["on", 4.55, 4.7], ["and", 4.75, 5], ["because", 5.1, 5.85],
+ ["of", 6.2, 6.4], ["that", 6.45, 6.8], ["it", 6.85, 7], ["finishes", 7.1, 7.9], ["here.", 8, 8.8],
+ ["Another", 9.2, 9.8], ["whole", 9.9, 10.3], ["sentence", 10.4, 11], ["entirely.", 11.1, 11.8],
+].map(([text, start, end]) => ({ text, start, end }));
+const SILENCES = [{ from: 2.9, to: 3.11 }, { from: 5.92, to: 6.11 }, { from: 8.85, to: 9.15 }];
+
+test("sentenceAround: the last start at or before, the first end at or after", () => {
+ assert.deepEqual(sentenceAround(VID1, 4.5, 4.5), { start: 3, end: 9 });
+ assert.deepEqual(sentenceAround(VID1, 1, 10), { start: 0, end: 12 });
+ // On a boundary: the sentence that starts there.
+ assert.deepEqual(sentenceAround(VID1, 3, 3), { start: 3, end: 9 });
+ assert.equal(sentenceAround([{ start: 0, end: 3, text: "no end" }], 1, 1), null);
+});
+
+test("sentencesInside: partial sentences at either edge are dropped", () => {
+ assert.deepEqual(sentencesInside(VID1, 1.2, 12.4), { start: 3, end: 12 });
+ assert.equal(sentencesInside(VID1, 3.5, 8), null, "inside one sentence: nothing whole");
+});
+
+test("at the playhead: that sentence, each edge into its pause", () => {
+ const r = tightWindow({ clip: { start: 1.2, end: 10.5 }, cues: VID1, words: WORDS, silences: SILENCES, at: 4.4 });
+ assert.equal(r.ok, true);
+ if (!r.ok) return;
+ assert.equal(r.how, "at");
+ assert.deepEqual(r.sentence, { start: 3, end: 9 });
+ // The start goes back into the 2.9-3.2 pause (the hard cut's 0.1 s of quiet before "And");
+ // the end is already in the pause after "here." (8.8-9.2), and stays.
+ assert.ok(r.start >= 2.9 && r.start <= 3.2, `start ${r.start}`);
+ assert.ok(r.end >= 8.8 && r.end <= 9.2, `end ${r.end}`);
+ assert.equal(r.changed, true);
+});
+
+test("the cut anchors it when the playhead is elsewhere: every sentence the quote touches", () => {
+ const r = tightWindow({ clip: { start: 0.5, end: 11.9, cutStart: 4, cutEnd: 7.5 }, cues: VID1, at: null, snap: false });
+ assert.equal(r.ok && r.how, "cut");
+ assert.equal(r.ok && r.start, 3);
+ assert.equal(r.ok && r.end, 9);
+});
+
+test("no playhead, no cut: the whole sentences inside the window, else the one it is inside", () => {
+ const a = tightWindow({ clip: { start: 1.2, end: 12.4 }, cues: VID1, snap: false });
+ assert.equal(a.ok && a.how, "window");
+ assert.deepEqual(a.ok && [a.start, a.end], [3, 12]);
+ const b = tightWindow({ clip: { start: 3.5, end: 8 }, cues: VID1, snap: false });
+ assert.equal(b.ok && b.how, "middle");
+ assert.deepEqual(b.ok && [b.start, b.end], [3, 9]);
+ assert.match(HOW_SAID.middle, /inside/);
+});
+
+test("the cached window bounds it, and says so", () => {
+ const r = tightWindow({ clip: { start: 1.2, end: 7.4 }, cues: VID1, at: 4, lo: 0, hi: 7.5, snap: false });
+ assert.equal(r.ok, true);
+ if (!r.ok) return;
+ assert.equal(r.end, 7.5);
+ assert.match(r.said.join(" "), /past the cached window/);
+});
+
+test("already tight: unchanged", () => {
+ const r = tightWindow({ clip: { start: 3, end: 9 }, cues: VID1, snap: false });
+ assert.equal(r.ok && r.changed, false);
+});
+
+test("refusals: no cues, no boundary, a window with no edges", () => {
+ assert.equal(tightWindow({ clip: { start: 1, end: 2 }, cues: [] }).ok, false);
+ assert.equal(tightWindow({ clip: { start: 1, end: 2 }, cues: [{ start: 0, end: 3, text: "no end" }] }).ok, false);
+ assert.equal(tightWindow({ clip: /** @type {any} */ ({}), cues: VID1 }).ok, false);
+});
+
+test("nearestPause: the middle of the closest pause, within a second; bounded; said", () => {
+ const n = nearestPause(5.7, { words: WORDS, silences: SILENCES });
+ assert.equal(n.moved, true);
+ assert.ok(n.at > 5.85 && n.at < 6.2, `at ${n.at}`);
+ assert.match(String(snapSaid("end", n)), /^end 5\.70 → 6\.\d\d, into the pause/);
+ const far = nearestPause(20, { words: WORDS, silences: SILENCES });
+ assert.equal(far.moved, false);
+ assert.match(String(snapSaid("start", far)), /stays/);
+ assert.ok(pausesNear({ words: WORDS, silences: SILENCES }, 4, 5).length >= 1);
+});
+
+test("a playhead parked on an edge is not the place: the window decides", () => {
+ const r = tightWindow({ clip: { start: 1.2, end: 7.4 }, cues: VID1, at: 1.2, snap: false });
+ assert.equal(r.ok && r.how, "middle");
+ assert.deepEqual(r.ok && [r.start, r.end], [3, 9]);
+});
diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json
@@ -27,6 +27,7 @@
"./claims": "./claims.mjs",
"./clip-audio": "./clip-audio.mjs",
"./clip-blur": "./clip-blur.mjs",
+ "./clip-words": "./clip-words.mjs",
"./compose-chrome": "./compose-chrome.mjs",
"./counter": "./counter.mjs",
"./cues": "./cues.mjs",