commit 7deb11a1b5e6ee399301b8f768cb854dabcdd9dc
parent dce267bc408a5759d7ec15b2f6d27b363645b8c7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 20 Nov 2026 14:18:00 -0500
umtool: set the gap mark on the bench and see it while playing (gap cue, slice 1b)
The operator: "I should be able to adjust these effects and settings on gaps
that we've added while playing/editing in umtool."
- The clip bench: a click on a gap's hatched band now picks the gap (an
outline on the band) and a row under the waveform shows it: its seconds,
how it shows (skip; fast-forward is said not built yet, no control), its
own mark (as the clip's, on, off), what it was cut for (not said, dead
air, other) and Remove. `G` still puts back the gap at the playhead. A
reel beat's band keeps its old click (it puts the gap back): a beat's gap
has no settings.
- Beside it, the clip's own mark settings: the mark at its joins (as the
project's, on, off), the shortest gap marked, the corner, the label. Each
"as the project's" names the project's value.
- Every control writes through the window route the CLI twins use: a gap's
through gapEdit (an undo point, and the bench's Undo), the clip's through
gapCue. A clip's gapCue and the project's render.gapCue (umtool look, the
Media tab's Modules panel) now leave an undo point too (auto-before-gaps),
as a gap write does.
- The Modules panel already listed the gap mark; a field cleared there did
not clear (render.gapCue is merged by its writer, and the panel sent the
block without the key). panelWrite now sends a cleared field as null for a
merged look key.
- The mark while playing: Play the cut draws it over the footage (the deck's
footage box, the plain picture) and the bench over its picture, at the
same seconds, with the same text and fade as the render. Both read
lib/report/gapCueView.mjs, which only lays out the joins on the page's
clock and asks common gapCue.mjs's gapCues / gapCueAlpha / gapCueText, the
functions the build's gap-mark.mjs uses. A test checks the bench's marks
equal the build's for the same clip. The page does not move the mark off a
hidden region or a code as the build does; auto is the layout's corner.
- Tests: gapCueView.test.mjs (6), gaps-writer (undo points), config-loader
(the panel's gap mark row and a cleared field). gaps-zoom.spec's band click
now picks the gap and Remove puts it back.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
17 files changed, 742 insertions(+), 42 deletions(-)
diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx
@@ -35,7 +35,11 @@ import { attributionLine } from "umtool-report-to-video/attribution";
import { DETAIL_SPAN } from "@/lib/report/benchZoom.mjs";
// Gaps inside a clip: the rule (the writer's and the build's) and the pieces that play.
import { gapSpan, gapWalls, gappedLength, validateGaps } from "umtool-report-to-video/gaps";
-import { useGapEditor } from "./bench/useGapEditor";
+import { useGapEditor, type SavedGap } from "./bench/useGapEditor";
+import GapCueTools from "./bench/GapCueTools";
+import GapMarkChip from "./review/GapMarkChip";
+import { clipGapMarks, clipPlayClock, gapMarkAt, gapMarkCorner } from "@/lib/report/gapCueView.mjs";
+import { clipGapCueOf, gapCueOf, type GapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
import { BenchWaveBox, GapTools } from "./bench/BenchWave";
import { CutEdges } from "./bench/CutEdges";
import { sourceWindowMedia } from "./bench/benchMedia";
@@ -142,9 +146,12 @@ type Clip = {
/**
* GAPS: source seconds cut out of the clip's middle (gaps.mjs), so it plays
* as one segment of jump cuts. Written at once (Cut gap, a click on a band),
- * not drafted like the edges; every playback here skips them.
+ * not drafted like the edges; every playback here skips them. Each with
+ * its own `mark` and `why` when it says (common gapCue.mjs).
*/
- gaps: Span[];
+ gaps: SavedGap[];
+ /** The mark at its gaps' joins, its own settings over the project's (common gapCue.mjs); absent: none. */
+ gapCue?: Partial<GapCue> | null;
/**
* The seconds no gap may cover (lane/clip-fixes): each claim mark's or
* stamp's `at` (`claims`, else `claim`; gaps.mjs gapWalls), read so the
@@ -252,7 +259,8 @@ const fromEntry = (prev: Clip, e: Record<string, unknown>): Clip => ({
cutEnd: e.cutEnd == null ? null : Number(e.cutEnd),
lockCut: !!e.lockCut,
muteFrom: e.muteFrom == null ? null : Number(e.muteFrom),
- gaps: Array.isArray(e.gaps) ? (e.gaps as Span[]) : [],
+ gaps: Array.isArray(e.gaps) ? (e.gaps as SavedGap[]) : [],
+ gapCue: e.gapCue && typeof e.gapCue === "object" ? (e.gapCue as Partial<GapCue>) : null,
marks: Array.isArray(e.marks) ? (e.marks as Clip["marks"]) : marksOf(e),
verdict: e.verdict === "confirmed" || e.verdict === "incorrect" || e.verdict === "rejected" ? e.verdict : null,
walkNote: (e.walkNote as string) ?? null,
@@ -320,6 +328,8 @@ export type ClipBenchData = {
deckOn: boolean;
/** Every region the cut hides on this clip (clip-censor.mjs censorRegionsOf): drawn over the raw window. */
hidden?: CensorRegion[];
+ /** The project's `render.gapCue` as the build reads it (the look preset under it): the mark at gaps' joins. */
+ gapCue?: Record<string, unknown> | null;
/** The manifest's `generatedBy`: edits here are noted for the agent that runs it. */
generatedBy?: string | null;
/**
@@ -1375,7 +1385,8 @@ export default function ClipBench({
// of jump cuts rather than as two clips with a crossfade, a second pip and a
// second card. A span is dragged on the waveform with Alt held (or after `g`
// / Select a gap) and written by Cut gap (or `g`); a click on a gap's band
- // puts it back. Unlike the edges these are WRITTEN AT ONCE, through the one
+ // picks it -- its mark, its why and Remove under the waveform (bench/GapCueTools.tsx)
+ // -- and `G` puts back the one at the playhead. Unlike the edges these are WRITTEN AT ONCE, through the one
// window writer (`gapAdd` / `gapRemove`), which refuses what the build would
// -- and leaves an undo point (auto-before-gaps) -- and Undo here writes the
// list back as it was. The rule is checked here first, with the same
@@ -1419,12 +1430,20 @@ export default function ClipBench({
gaps: clip.gaps ?? [],
span: gapsSpan,
refusal: gapRefusal,
+ // A clip's gap has settings of its own (its mark, its why): a click on its band picks it (bench/GapCueTools.tsx).
+ settings: true,
write: async (op, _next) => {
// A moved edge rides along: the gap was checked against the edges as drafted.
const win = windowMoved || muteMoved ? windowPatch() : null;
const ok = await save({
...(win ?? {}),
- ...("add" in op ? { gapAdd: op.add } : "remove" in op ? { gapRemove: (op.remove.from + op.remove.to) / 2 } : { gaps: op.set }),
+ ...("add" in op
+ ? { gapAdd: op.add }
+ : "remove" in op
+ ? { gapRemove: (op.remove.from + op.remove.to) / 2 }
+ : "edit" in op
+ ? { gapEdit: op.edit }
+ : { gaps: op.set }),
});
return ok;
},
@@ -1446,6 +1465,27 @@ export default function ClipBench({
: `stopped at the start of what plays (${hms(at)}) — drag the start handle out first${atStartEdge ? ", past the cache: Fetch more" : ""}`,
});
+ // ---- the mark at the gaps' joins (lane gap-cue; common gapCue.mjs, lib/report/gapCueView.mjs) ----------------
+ //
+ // The project's settings (the look preset under them), the clip's over them, and the marks what plays draws:
+ // on the clock of what plays (the cut, else the extent, as drafted -- the gaps' span), the render's own rule.
+ const projectCue = useMemo(() => gapCueOf({ gapCue: data.gapCue ?? undefined }), [data.gapCue]);
+ const clipCue = useMemo(() => clipGapCueOf({ gapCue: data.gapCue ?? undefined }, { gapCue: clip.gapCue ?? undefined }), [data.gapCue, clip.gapCue]);
+ const benchMarks = useMemo(
+ () => clipGapMarks({ cue: clipCue, gaps: clip.gaps ?? [], from: gapsSpan.from, to: gapsSpan.to }),
+ [clipCue, clip.gaps, gapsSpan.from, gapsSpan.to],
+ );
+ const benchMark = benchMarks.length ? gapMarkAt(benchMarks, clipPlayClock({ gaps: clip.gaps ?? [], from: gapsSpan.from, to: gapsSpan.to }, playhead)) : null;
+ const benchMarkCorner = gapMarkCorner(clipCue.corner, { deck: data.deckOn });
+ const writeGapCue = useCallback(
+ async (patch: Record<string, unknown>) => {
+ const ok = await save({ gapCue: patch });
+ if (ok) setNote(`the mark at this clip's joins: ${Object.entries(patch).map(([k, v]) => `${k} ${v === null ? "as the project's" : JSON.stringify(v)}`).join(", ")}`);
+ return ok;
+ },
+ [save],
+ );
+
// ---- the cut, cleared and put back -------------------------------------------
//
// Use the whole clip (and Clear cut) clears the cut -- what plays becomes the
@@ -2938,7 +2978,7 @@ export default function ClipBench({
>
{placeBar}
<div className="flex md:contents">
- {cached && (data.hidden?.length ?? 0) > 0 ? (
+ {cached && ((data.hidden?.length ?? 0) > 0 || benchMarks.length > 0) ? (
// With hidden regions the picture sits in a box of its own, the regions drawn over it (an editing
// surface: outlined, a Peek toggle off by default). Without, the <video> is the flex item as before.
<div
@@ -2959,7 +2999,9 @@ export default function ClipBench({
onTimeUpdate={(e) => setBenchAt((cached?.from ?? 0) + e.currentTarget.currentTime)}
onSeeked={(e) => setBenchAt((cached?.from ?? 0) + e.currentTarget.currentTime)}
/>
- <CensorOverlay regions={data.hidden ?? []} at={benchAt} aspect={benchAspect} mode="edit" testId="bench-censor" />
+ {(data.hidden?.length ?? 0) > 0 && <CensorOverlay regions={data.hidden ?? []} at={benchAt} aspect={benchAspect} mode="edit" testId="bench-censor" />}
+ {/* The mark at a gap's join, as the render draws it (lane gap-cue): up while what plays crosses a marked join. */}
+ {benchMarks.length > 0 && <GapMarkChip mark={benchMark} corner={benchMarkCorner} aspect={benchAspect} testId="bench-gap-mark" />}
</div>
) : cached ? (
<video
@@ -3398,6 +3440,17 @@ export default function ClipBench({
</span>
<ZoomControls zoom={zoom} whole={view} selection={gap.sel ?? sel} playhead={playhead} />
</div>
+ {/* ---- the mark at the gaps' joins: the picked gap's own, the clip's (bench/GapCueTools.tsx) ---- */}
+ <GapCueTools
+ gap={gap}
+ cue={clipCue}
+ project={projectCue}
+ own={clip.gapCue ?? null}
+ busy={!!busy}
+ fmt={hms}
+ writeCue={writeGapCue}
+ hasGaps={(clip.gaps ?? []).length > 0}
+ />
</div>
{/* Offered at the edge of the cache, as always -- and also whenever
diff --git a/umtool/components/projects/bench/BenchWave.tsx b/umtool/components/projects/bench/BenchWave.tsx
@@ -6,7 +6,7 @@ import { buttonVariants } from "@/components/ui/button";
import { GAP_LIMITS, gappedLength } from "umtool-report-to-video/gaps";
import { GapLayer, type GapWallsView, type WaveZoom } from "./GapsZoom";
import type { Span } from "./benchMedia";
-import type { GapEditor } from "./useGapEditor";
+import type { GapEditor, SavedGap } from "./useGapEditor";
// ---------------------------------------------------------------------------
// THE BENCH'S WAVEFORM AND ITS GAPS (lifted out of ClipBench.tsx; shared with
@@ -46,7 +46,7 @@ export function BenchWaveBox({
playhead: number | null;
onSel: (next: Span, dragging: boolean, edge?: "start" | "end" | null) => void;
gap: GapEditor;
- gaps: Span[];
+ gaps: SavedGap[];
silences: Span[] | null;
words: { start: number; end?: number; w?: string }[] | null;
busy: boolean;
@@ -118,8 +118,10 @@ export function BenchWaveBox({
silences={silences}
words={words}
busy={busy}
- onRemove={gap.remove}
+ onRemove={gap.band}
onSelect={gap.select}
+ picked={gap.picked}
+ pickable={gap.settings}
/>
{children}
</div>
diff --git a/umtool/components/projects/bench/GapCueTools.tsx b/umtool/components/projects/bench/GapCueTools.tsx
@@ -0,0 +1,200 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { buttonVariants } from "@/components/ui/button";
+import { GAP_CUE_CORNERS, GAP_CUE_MIN, gapMarkOn, type GapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import type { GapEditor } from "./useGapEditor";
+
+// ---------------------------------------------------------------------------
+// THE MARK AT A GAP'S JOIN, SET ON THE BENCH (lane gap-cue, slice 1b; common
+// lib/report/gapCue.mjs is the rule). Under the gaps' tools, in Cut mode:
+//
+// the picked gap (a click on its band) its seconds, how it shows (a skip:
+// fast-forward is not built yet), its own mark (as the
+// clip's, on, off), what it was cut for, Remove
+// the clip's the mark at its joins (as the project's, on, off), the
+// shortest gap marked, the corner, the label
+//
+// Every control writes at once through the window writer -- `gapEdit` for the
+// gap (useGapEditor's editPicked: an undo point, and the bench's Undo),
+// `gapCue` for the clip (an undo point) -- the same writes as their CLI twins,
+// named on each control.
+// ---------------------------------------------------------------------------
+
+const sel =
+ "rounded border border-[var(--color-line)] bg-[var(--color-panel-2)] px-1 py-0.5 text-[11px] text-[var(--color-text)] disabled:opacity-60";
+const onOff = (v: boolean) => (v ? "on" : "off");
+const CORNER_WORDS: Record<string, string> = { auto: "the layout's", tl: "top left", tr: "top right", bl: "bottom left", br: "bottom right" };
+
+export default function GapCueTools({
+ gap,
+ cue,
+ project,
+ own,
+ busy,
+ fmt,
+ writeCue,
+ hasGaps,
+}: {
+ gap: GapEditor;
+ /** The clip's settings, its own over the project's (clipGapCueOf). */
+ cue: GapCue;
+ /** The project's (gapCueOf(render), the look preset under it): what the clip's "as the project's" means. */
+ project: GapCue;
+ /** The clip's own `gapCue` block, as saved (null: none). */
+ own: Partial<GapCue> | null;
+ busy: boolean;
+ fmt: (t: number) => string;
+ /** Write the clip's `gapCue` patch (a key null drops it); resolves whether it was written. */
+ writeCue: (patch: Record<string, unknown>) => Promise<boolean>;
+ hasGaps: boolean;
+}) {
+ const g = gap.picked;
+ // The two typed fields: drafted, written on Enter or leaving them.
+ const [min, setMin] = useState(own?.min === undefined ? "" : String(own.min));
+ const [label, setLabel] = useState(own?.label ?? "");
+ useEffect(() => setMin(own?.min === undefined ? "" : String(own.min)), [own?.min]);
+ useEffect(() => setLabel(own?.label ?? ""), [own?.label]);
+ if (!hasGaps) return null;
+
+ const commitMin = () => {
+ const v = min.trim();
+ const was = own?.min === undefined ? "" : String(own.min);
+ if (v === was) return;
+ void writeCue({ min: v === "" ? null : Number(v) });
+ };
+ const commitLabel = () => {
+ if (label === (own?.label ?? "")) return;
+ void writeCue({ label: label === "" ? null : label });
+ };
+ const len = g ? g.to - g.from : 0;
+ return (
+ <div data-gap-settings="" className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[12px]">
+ {g && (
+ <span data-gap-picked-row={`${g.from}-${g.to}`} className="flex flex-wrap items-center gap-1.5 rounded border border-[var(--color-sel)] px-1.5 py-0.5">
+ <span className="num text-[var(--color-text)]">
+ gap {fmt(g.from)}–{fmt(g.to)} <span className="text-[var(--color-dim)]">({len.toFixed(2)} s)</span>
+ </span>
+ <span data-gap-show="skip" className="text-[var(--color-dim)]" title="how the gap plays: a jump cut (fast-forward through it is a later slice)">
+ shows as <span className="text-[var(--color-text)]">skip</span> · fast-forward: not built yet
+ </span>
+ <label className="flex items-center gap-1">
+ <span className="micro">mark</span>
+ <select
+ data-gap-mark-select=""
+ className={sel}
+ disabled={busy}
+ value={typeof g.mark === "boolean" ? onOff(g.mark) : ""}
+ title={`umtool set <p> <clip> gap.mark=${((g.from + g.to) / 2).toFixed(2)}:on|off|default`}
+ onChange={(e) => void gap.editPicked({ mark: e.target.value === "" ? null : e.target.value === "on" })}
+ >
+ <option value="">as the clip’s ({onOff(cue.mark)})</option>
+ <option value="on">on</option>
+ <option value="off">off</option>
+ </select>
+ </label>
+ <label className="flex items-center gap-1">
+ <span className="micro">why</span>
+ <select
+ data-gap-why-select=""
+ className={sel}
+ disabled={busy}
+ value={g.why ?? ""}
+ title={`umtool set <p> <clip> gap.why=${((g.from + g.to) / 2).toFixed(2)}:dead-air|other|default`}
+ onChange={(e) => void gap.editPicked({ why: e.target.value === "" ? null : (e.target.value as "dead-air" | "other") })}
+ >
+ <option value="">not said</option>
+ <option value="dead-air">dead air</option>
+ <option value="other">other</option>
+ </select>
+ </label>
+ {gapMarkOn(cue, g) && len < cue.min && (
+ <span data-gap-under-min="" className="text-[var(--color-dim)]">
+ under {cue.min} s: no mark
+ </span>
+ )}
+ <button
+ type="button"
+ data-gap-remove=""
+ className={buttonVariants({ variant: "outline", size: "sm" })}
+ disabled={busy}
+ title={`put these seconds back in the clip (G at the playhead; umtool set <p> <clip> gap.remove=${((g.from + g.to) / 2).toFixed(2)})`}
+ onClick={() => gap.remove(g)}
+ >
+ Remove
+ </button>
+ </span>
+ )}
+ <span data-gap-cue-clip="" className="flex flex-wrap items-center gap-1.5">
+ <span className="micro">mark at joins</span>
+ <select
+ data-gap-cue-mark=""
+ className={sel}
+ disabled={busy}
+ value={typeof own?.mark === "boolean" ? onOff(own.mark) : ""}
+ title="this clip's, over the project's (umtool set <p> <clip> gapCue.mark=true|false; gapCue.mark= as the project's)"
+ onChange={(e) => void writeCue({ mark: e.target.value === "" ? null : e.target.value === "on" })}
+ >
+ <option value="">as the project’s ({onOff(project.mark)})</option>
+ <option value="on">on</option>
+ <option value="off">off</option>
+ </select>
+ <label className="flex items-center gap-1">
+ <span className="micro">from</span>
+ <input
+ data-gap-cue-min=""
+ type="number"
+ min={GAP_CUE_MIN.min}
+ max={GAP_CUE_MIN.max}
+ step={0.5}
+ className={`${sel} w-14`}
+ disabled={busy}
+ value={min}
+ placeholder={String(project.min)}
+ title="the shortest gap marked, in seconds (umtool set <p> <clip> gapCue.min=<s>)"
+ onChange={(e) => setMin(e.target.value)}
+ onBlur={commitMin}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") commitMin();
+ }}
+ />
+ <span className="micro">s</span>
+ </label>
+ <label className="flex items-center gap-1">
+ <span className="micro">corner</span>
+ <select
+ data-gap-cue-corner=""
+ className={sel}
+ disabled={busy}
+ value={own?.corner ?? ""}
+ title="umtool set <p> <clip> gapCue.corner=auto|tl|tr|bl|br"
+ onChange={(e) => void writeCue({ corner: e.target.value === "" ? null : e.target.value })}
+ >
+ <option value="">as the project’s ({CORNER_WORDS[project.corner] ?? project.corner})</option>
+ {GAP_CUE_CORNERS.map((c) => (
+ <option key={c} value={c}>
+ {CORNER_WORDS[c] ?? c}
+ </option>
+ ))}
+ </select>
+ </label>
+ <label className="flex items-center gap-1">
+ <span className="micro">label</span>
+ <input
+ data-gap-cue-label=""
+ className={`${sel} w-24 font-mono`}
+ disabled={busy}
+ value={label}
+ placeholder={project.label}
+ title="{s} is the time skipped (umtool set <p> <clip> gapCue.label='» {s}')"
+ onChange={(e) => setLabel(e.target.value)}
+ onBlur={commitLabel}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") commitLabel();
+ }}
+ />
+ </label>
+ </span>
+ </div>
+ );
+}
diff --git a/umtool/components/projects/bench/GapsZoom.tsx b/umtool/components/projects/bench/GapsZoom.tsx
@@ -202,9 +202,15 @@ export function GapLayer({
onSelect,
live = null,
walls = null,
+ picked = null,
+ pickable = false,
}: {
vis: Span;
- gaps: Span[];
+ gaps: Array<Span & { mark?: boolean; why?: string }>;
+ /** The gap whose settings are shown (useGapEditor's `picked`): outlined. */
+ picked?: Span | null;
+ /** A click on a band picks the gap (its settings) rather than putting it back (useGapEditor's `settings`). */
+ pickable?: boolean;
selection: Span | null;
/** What the selection would do, checked on every move (useGapEditor's GapLive). */
live?: { why: string | null; wall: string | null; merged: { from: number; to: number } | null; short: boolean } | null;
@@ -280,21 +286,37 @@ export function GapLayer({
<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) }} />
))}
{walls && <GapWallsLayer walls={walls} vis={vis} pct={pct} width={width} full={picking || !!selection} />}
- {gaps.filter(inView).map((g) => (
- <button
- key={`gap-${g.from}`}
- type="button"
- data-gap-band={`${g.from}-${g.to}`}
- disabled={busy}
- title={`a gap: ${g.from.toFixed(2)}–${g.to.toFixed(2)} (${(g.to - g.from).toFixed(2)} s) is cut out of the clip — click to put it back`}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={() => onRemove(g)}
- className="absolute top-0 z-[5] h-full cursor-pointer overflow-hidden border-x border-[var(--color-dirty)] p-0 text-left [background:repeating-linear-gradient(45deg,color-mix(in_srgb,var(--color-ground)_70%,transparent)_0_5px,color-mix(in_srgb,var(--color-dirty)_22%,transparent)_5px_9px)]"
- style={{ left: pct(g.from), width: width(g.from, g.to) }}
- >
- <span className="pointer-events-none absolute left-1 top-0.5 rounded bg-[var(--color-panel-2)] px-1 font-mono text-[9px] leading-tight text-[var(--color-dirty)]">cut</span>
- </button>
- ))}
+ {gaps.filter(inView).map((g) => {
+ const on = !!picked && picked.from === g.from && picked.to === g.to;
+ return (
+ <button
+ key={`gap-${g.from}`}
+ type="button"
+ data-gap-band={`${g.from}-${g.to}`}
+ data-gap-picked={on ? "" : undefined}
+ data-gap-own-mark={typeof g.mark === "boolean" ? (g.mark ? "on" : "off") : undefined}
+ data-gap-why={g.why}
+ aria-pressed={pickable ? on : undefined}
+ disabled={busy}
+ title={
+ pickable
+ ? `a gap: ${g.from.toFixed(2)}–${g.to.toFixed(2)} (${(g.to - g.from).toFixed(2)} s) is cut out of the clip — click for its settings and Remove`
+ : `a gap: ${g.from.toFixed(2)}–${g.to.toFixed(2)} (${(g.to - g.from).toFixed(2)} s) is cut out of the clip — click to put it back`
+ }
+ onPointerDown={(e) => e.stopPropagation()}
+ onClick={() => onRemove(g)}
+ className={cn(
+ "absolute top-0 z-[5] h-full cursor-pointer overflow-hidden border-x border-[var(--color-dirty)] p-0 text-left [background:repeating-linear-gradient(45deg,color-mix(in_srgb,var(--color-ground)_70%,transparent)_0_5px,color-mix(in_srgb,var(--color-dirty)_22%,transparent)_5px_9px)]",
+ on && "outline outline-2 -outline-offset-2 outline-[var(--color-sel)]",
+ )}
+ style={{ left: pct(g.from), width: width(g.from, g.to) }}
+ >
+ <span className="pointer-events-none absolute left-1 top-0.5 rounded bg-[var(--color-panel-2)] px-1 font-mono text-[9px] leading-tight text-[var(--color-dirty)]">
+ cut
+ </span>
+ </button>
+ );
+ })}
{selection && inView(selection) && (
<div
data-gap-selection={`${selection.from.toFixed(2)}-${selection.to.toFixed(2)}`}
diff --git a/umtool/components/projects/bench/useGapEditor.ts b/umtool/components/projects/bench/useGapEditor.ts
@@ -9,14 +9,23 @@ import type { Span } from "./benchMedia";
// out of the middle of a span (umtool-report-to-video gaps.mjs), so it plays
// as one run of jump cuts. A span is dragged on the waveform with Alt held
// (or after `g` / Select a gap) and written by Cut gap (or `g`); a click on a
-// gap's band puts it back; Undo writes the list back as it was. Written AT
+// gap's band puts it back -- or, where a gap has settings of its own (a
+// clip's: its mark and why, lane gap-cue), picks it, its settings and Remove
+// shown under the waveform; Undo writes the list back as it was. Written AT
// ONCE, through the caller's writer -- a clip's window writer (`gapAdd` /
// `gapRemove`) or a reel's beat writer -- which refuses what the build would;
// the rule is checked here first (`refusal`), with the same sentences, so a
// refusal is said before anything is sent.
// ---------------------------------------------------------------------------
-export type GapOp = { add: Span } | { remove: Span } | { set: Span[] };
+/** A gap's own settings (common gapCue.mjs): its mark over the clip's, what it was cut for. */
+export type GapOwn = { mark?: boolean; why?: "dead-air" | "other" };
+/** A gap as saved: its seconds and its own settings. */
+export type SavedGap = Span & GapOwn;
+/** One gap's own settings changed, its seconds as they are (the window writer's `gapEdit`; null drops a key). */
+export type GapEdit = { at: number; mark?: boolean | null; why?: "dead-air" | "other" | null };
+
+export type GapOp = { add: Span } | { remove: Span } | { set: Span[] } | { edit: GapEdit };
/**
* What the span being dragged for a gap would do, said WHILE it is dragged
@@ -40,11 +49,12 @@ export function useGapEditor({
setNote,
fmt,
wall,
+ settings = false,
}: {
/** What the gaps belong to: another one starts with nothing selected and nothing to undo. */
key: string;
- /** The gaps as saved. */
- gaps: Span[];
+ /** The gaps as saved (a clip's with their own settings). */
+ gaps: SavedGap[];
/** Where a gap may go (the clip's cut or extent; a beat's span). */
span: Span;
/** Why `next` cannot be written, or null. */
@@ -57,6 +67,11 @@ export function useGapEditor({
fmt: (t: number) => string;
/** The sentence for a drag stopped at `span`'s edge (the clip's cut, a beat's end); a plain one without. */
wall?: (side: "start" | "end", at: number) => string;
+ /**
+ * A gap has settings of its own (a clip's: its mark, its why; lane gap-cue): a click on its band PICKS it --
+ * its settings and Remove under the waveform -- instead of putting it back. A reel beat's has none.
+ */
+ settings?: boolean;
}) {
const [sel, setSelState] = useState<Span | null>(null);
const [live, setLive] = useState<GapLive | null>(null);
@@ -66,11 +81,19 @@ export function useGapEditor({
}, []);
const [pick, setPick] = useState(false);
const [undo, setUndo] = useState<{ gaps: Span[]; what: string } | null>(null);
+ // The saved gap whose settings are shown (a click on its band, `settings` only): by its seconds.
+ const [picked, setPicked] = useState<Span | null>(null);
useEffect(() => {
setSel(null);
setPick(false);
setUndo(null);
+ setPicked(null);
}, [key, setSel]);
+ // The gap picked as it is saved now; none once it is gone (put back, merged into another).
+ const pickedGap = picked ? (gaps.find((g) => g.from === picked.from && g.to === picked.to) ?? null) : null;
+ useEffect(() => {
+ if (picked && !pickedGap) setPicked(null);
+ }, [picked, pickedGap]);
const run = useCallback(
async (op: GapOp, next: Span[], what: string) => {
@@ -123,6 +146,45 @@ export function useGapEditor({
[gaps, run, fmt],
);
+ /**
+ * A click on a gap's band: with `settings`, it picks the gap (again: lets it go) and says so; without,
+ * it puts the gap back, as it always has.
+ */
+ const band = useCallback(
+ (g: Span) => {
+ if (!settings) {
+ remove(g);
+ return;
+ }
+ setSel(null);
+ setPick(false);
+ setPicked((p) => (p && p.from === g.from && p.to === g.to ? null : { from: g.from, to: g.to }));
+ },
+ [settings, remove, setSel],
+ );
+
+ /** One of the picked gap's own settings changed (its mark, its why): one write, an undo point, Undo here. */
+ const editPicked = useCallback(
+ (change: Omit<GapEdit, "at">) => {
+ const g = pickedGap;
+ if (!g) return Promise.resolve(false);
+ const edit: GapEdit = { at: Number(((g.from + g.to) / 2).toFixed(3)), ...change };
+ let next: Span[];
+ try {
+ next = editGaps(gaps, { edit });
+ } catch (e) {
+ setNote(e instanceof Error ? e.message : String(e));
+ return Promise.resolve(false);
+ }
+ const said = [
+ "mark" in change ? `its mark ${change.mark === true ? "on" : change.mark === false ? "off" : "as the clip's"}` : null,
+ "why" in change ? `cut for ${change.why === "dead-air" ? "dead air" : change.why ?? "no reason given"}` : null,
+ ].filter(Boolean).join(", ");
+ return run({ edit }, next, `the gap ${fmt(g.from)}–${fmt(g.to)}: ${said}`);
+ },
+ [pickedGap, gaps, run, setNote, fmt],
+ );
+
/** `G`: the gap the playhead is in (or at the edge of). */
const removeAt = useCallback(
(t: number | null) => {
@@ -197,7 +259,7 @@ export function useGapEditor({
[span.from, span.to, gaps, refusal, setNote, fmt, wall, setSel],
);
- return { sel, setSel, live, pick, setPick, undo, cut, remove, removeAt, undoLast, select };
+ return { sel, setSel, live, pick, setPick, undo, cut, remove, removeAt, undoLast, select, settings, picked: pickedGap, setPicked, band, editPicked };
}
export type GapEditor = ReturnType<typeof useGapEditor>;
diff --git a/umtool/components/projects/review/GapMarkChip.tsx b/umtool/components/projects/review/GapMarkChip.tsx
@@ -0,0 +1,76 @@
+"use client";
+
+import { useEffect, useRef, useState } from "react";
+
+// THE GAP MARK OVER A PLAYER (lane gap-cue, slice 1b): "» 27 s" at a clip gap's join, drawn where the render
+// draws it -- Play the cut over its footage, the clip bench over its picture -- at the second
+// lib/report/gapCueView.mjs says (common gapCue.mjs's timing, the build's own). The look is gap-mark.mjs's, in
+// the frame's proportions: Plex Mono Bold at 2.4 % of the frame's short side, the box's border 0.35 of that, the
+// inset 2.6 %, light text on a dark box at 55 %, the text and its box faded together. Nothing to press.
+//
+// box where the mark stands inside the frame (Play's deck: the footage's rect, in % of the frame); the whole
+// frame when absent
+// aspect the picture is fitted inside this element (object-contain: the bench's <video>): its rect is measured,
+// and the picture is the frame
+
+export type GapMarkCorner = "tl" | "tr" | "bl" | "br";
+
+export default function GapMarkChip({
+ mark,
+ corner,
+ box = null,
+ aspect = null,
+ testId = "gap-mark",
+}: {
+ mark: { text: string; alpha: number } | null;
+ corner: GapMarkCorner;
+ box?: { left: string; top: string; width: string; height: string } | null;
+ aspect?: number | null;
+ testId?: string;
+}) {
+ const el = useRef<HTMLDivElement | null>(null);
+ const [size, setSize] = useState<{ w: number; h: number } | null>(null);
+ useEffect(() => {
+ const node = el.current;
+ if (!node || !aspect) return;
+ const ro = new ResizeObserver(() => setSize({ w: node.clientWidth, h: node.clientHeight }));
+ ro.observe(node);
+ setSize({ w: node.clientWidth, h: node.clientHeight });
+ return () => ro.disconnect();
+ }, [aspect]);
+ // The picture's rect in a fitted player, as CensorOverlay measures it.
+ let frame: React.CSSProperties = { inset: 0 };
+ if (aspect && size && size.w > 0 && size.h > 0) {
+ const k = Math.min(size.w / aspect, size.h);
+ frame = { left: (size.w - k * aspect) / 2, top: (size.h - k) / 2, width: k * aspect, height: k };
+ }
+ const inset = "2.6cqmin";
+ const at: React.CSSProperties = {
+ [corner.startsWith("t") ? "top" : "bottom"]: inset,
+ [corner.endsWith("l") ? "left" : "right"]: inset,
+ };
+ return (
+ <div ref={el} data-testid={testId} data-gap-mark-layer={corner} aria-hidden className="pointer-events-none absolute inset-0 z-[4] overflow-hidden">
+ <div className="absolute" style={{ ...frame, containerType: "size" }}>
+ <div className="absolute" style={box ?? { inset: 0 }}>
+ {mark && (
+ <span
+ data-gap-mark-chip={mark.text}
+ data-gap-mark-alpha={mark.alpha.toFixed(2)}
+ className="absolute whitespace-nowrap font-mono font-bold leading-[1.2] text-white"
+ style={{
+ ...at,
+ fontSize: "max(9px, 2.4cqmin)",
+ padding: "max(3px, 0.84cqmin)",
+ background: "rgba(0, 0, 0, 0.55)",
+ opacity: mark.alpha,
+ }}
+ >
+ {mark.text}
+ </span>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx
@@ -117,8 +117,10 @@ export type PlayEntry = {
end?: number;
cutStart?: number | null;
cutEnd?: number | null;
- /** Seconds taken out of its middle (gaps.mjs): one item of jump cuts. */
- gaps?: { from: number; to: number }[];
+ /** Seconds taken out of its middle (gaps.mjs): one item of jump cuts; each with its own mark and why when it says. */
+ gaps?: { from: number; to: number; mark?: boolean; why?: string }[];
+ /** The mark at its gaps' joins (common gapCue.mjs clipGapCueOf), only when a gap of it is marked. */
+ gapCue?: { mark: boolean; min: number; corner: string; label: string };
blur?: { on?: boolean; caption?: string; strength?: number; from?: number; to?: number } | null;
/** Its hidden regions (clip-censor.mjs censorRegionsOf): drawn over the picture as the cut hides them. */
censor?: CensorRegion[];
diff --git a/umtool/components/projects/review/playCore.tsx b/umtool/components/projects/review/playCore.tsx
@@ -3,7 +3,9 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { footageAt } from "@/lib/report/footage-move.mjs";
import { finaleUp, stampAt, tallyAt } from "@/lib/report/liveClock.mjs";
-import { chromeTime, playPlan, skipEntries } from "@/lib/report/playCut.mjs";
+import { chromeTime, gapJoins, playPlan, skipEntries } from "@/lib/report/playCut.mjs";
+import { gapMarkAt, gapMarkCorner, playGapMarks } from "@/lib/report/gapCueView.mjs";
+import GapMarkChip from "./GapMarkChip";
import { tallyCellsFrom, VERDICTS } from "umtool-report-to-video/factcheck";
import { fullFrameItems, layerOffOver } from "umtool-report-to-video/full-frame";
import { DeckFrame, FeedOverlay, ModuleLayers, PostsOverlay, postsWindowAt, type DeckPreviewDoc, type FullFrameTraits, type Rect } from "../OnscreenSection";
@@ -376,6 +378,14 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC
const footageCanvas = (style: React.CSSProperties | undefined, w: number, h: number) => (
<canvas ref={engine.canvasRef} data-play-footage="" data-play-move={move ? move.segment : ""} width={w} height={h} className="absolute" style={style} />
);
+ // The mark at a gap's join (lane gap-cue): the render's, at Play's joins on the cut's clock (lib/report/gapCueView.mjs).
+ const cueEntry = item?.clip ? entryOf.get(item.id) : null;
+ const gapMarks = useMemo(
+ () => (item?.clip && cueEntry?.gapCue ? playGapMarks(gapJoins(item), { cue: cueEntry.gapCue, entryGaps: cueEntry.gaps ?? [], playEnd: item.clip.playEnd }) : []),
+ [item, cueEntry],
+ );
+ const gapMark = gapMarks.length ? gapMarkAt(gapMarks, t) : null;
+ const gapCorner = gapMarkCorner(cueEntry?.gapCue?.corner, { deck: !!doc });
const sideNow = item && sideEntry ? <SidePostOverlay project={project} take={take} clipId={item.id} side={sideEntry} s={Math.max(0, t - item.start)} published={asPublished} /> : null;
const postPlayer = (box2: { width: number; height: number }) =>
postNow ? (
@@ -498,6 +508,9 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC
{introCard}
{placeholderCard}
{sideNow && rect && <div className="pointer-events-none absolute" style={{ left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H) }}>{sideNow}</div>}
+ {gapMarks.length > 0 && rect && (
+ <GapMarkChip mark={gapMark} corner={gapCorner} box={{ left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H) }} testId="play-gap-mark" />
+ )}
{/* Over a full-frame item (full-frame.mjs) a layer that keeps no time of its own is not drawn (layerOff):
kept mounted, transparent, so its page is ready and seeked when the item after it comes up. The feed
follows the deck (followsDeck), as the deck's own page does: off over a video entry or an analysis item. */}
@@ -539,6 +552,7 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC
{!basic && introCard}
{!basic && placeholderCard}
{!basic && sideNow}
+ {!basic && gapMarks.length > 0 && <GapMarkChip mark={gapMark} corner={gapCorner} testId="play-gap-mark" />}
</div>
)}
{dipVeil}
diff --git a/umtool/e2e/gaps-zoom.spec.ts b/umtool/e2e/gaps-zoom.spec.ts
@@ -13,7 +13,7 @@ import * as urls from "./urls";
// silences; at fit it is what it always was
// - a span selected on the waveform (Select a gap, or Alt + drag) is cut out
// of the clip through the window writer; Undo puts the list back; a click
-// on a gap's band removes it; a span the build would refuse is refused here
+// on a gap's band picks it, its Remove puts it back; a span the build would refuse is refused here
// - the bench's playback skips a gap, as the cut will
// - Play the cut plays the clip as ONE item of jump cuts: the render's
// footage less the gap, one sound node per kept piece, the picture past
@@ -204,8 +204,10 @@ test("a gap: selected on the waveform, cut, undone; Alt + drag and g; a click on
await expect.poll(() => clipOf("g01").gaps?.length ?? 0).toBe(1);
expect(clipOf("g01").gaps![0].from).toBeCloseTo(4, 1);
- // A click on the band puts the seconds back.
+ // A click on the band picks the gap (its settings, lane gap-cue); its Remove puts the seconds back.
await page.locator("[data-gap-band]").click();
+ await expect(page.locator("[data-gap-picked-row]")).toBeVisible();
+ await page.locator("[data-gap-remove]").click();
await expect.poll(() => clipOf("g01").gaps).toBeUndefined();
// Too close to the clip's start: said, and nothing written.
diff --git a/umtool/lib/report/benchData.ts b/umtool/lib/report/benchData.ts
@@ -17,6 +17,7 @@ import { deckOn } from "umtool-report-to-video/deck";
import { censorRegionsOf } from "umtool-report-to-video/clip-censor";
import { pieceHrefOfProject } from "@/lib/pieces/article";
import { readWorkingCut } from "@/lib/report/workingCut.mjs";
+import { effectiveManifest } from "@/lib/report/manifest.mjs";
import type { ProjectRef } from "@/lib/project-types";
// THE CLIP BENCH'S DATA, in one place: what `/projects/<p>/clip/<id>` renders
@@ -134,10 +135,16 @@ export async function clipBenchData(
muteFrom:
((manifest.timeline ?? []) as { id: string; muteFrom?: number }[]).find((e) => e.id === clipId)
?.muteFrom ?? null,
- // Seconds cut out of its middle (gaps.mjs), likewise from the manifest's own entry.
+ // Seconds cut out of its middle (gaps.mjs), likewise from the manifest's own entry -- each with its own
+ // mark and why when it says (common gapCue.mjs).
gaps:
((manifest.timeline ?? []) as { id: string; gaps?: { from: number; to: number }[] }[]).find((e) => e.id === clipId)
?.gaps ?? [],
+ // The mark at its gaps' joins, the clip's own settings (lane gap-cue), from the manifest's own entry.
+ gapCue: (() => {
+ const v = ((manifest.timeline ?? []) as { id: string; gapCue?: unknown }[]).find((e) => e.id === clipId)?.gapCue;
+ return v && typeof v === "object" && !Array.isArray(v) ? (v as NonNullable<ClipBenchData["clip"]["gapCue"]>) : null;
+ })(),
// The seconds no gap may cover (claim marks, a stamp), from the manifest's own entry.
marks: gapWalls({ ...(((manifest.timeline ?? []) as { id: string }[]).find((e) => e.id === clipId) ?? {}), type: "clip", muteFrom: null })
.marks.map((m) => ({ id: m.id, at: m.at })),
@@ -166,6 +173,17 @@ export async function clipBenchData(
// bench composes a preview of it; the fields are there either way.
deckOn: deckOn(manifest.render ?? {}),
// Every region the cut hides on it (clip-censor.mjs): the bench draws them over the raw window.
+ // The project's mark at gaps' joins (render.gapCue) as the build reads it: the look preset under it.
+ gapCue: (() => {
+ let render = (manifest.render ?? {}) as Record<string, unknown>;
+ try {
+ render = ((effectiveManifest(manifest) as { render?: Record<string, unknown> }).render ?? {}) as Record<string, unknown>;
+ } catch {
+ // An unknown preset: the manifest's own word (the build says what is wrong).
+ }
+ const v = render.gapCue;
+ return v && typeof v === "object" && !Array.isArray(v) ? (v as Record<string, unknown>) : null;
+ })(),
hidden: censorRegionsOf(((manifest.timeline ?? []) as { id: string }[]).find((e) => e.id === clipId) ?? {}, manifest.render ?? {}, manifest.provenance ?? {}),
generatedBy: typeof manifest.generatedBy === "string" ? manifest.generatedBy : null,
view,
diff --git a/umtool/lib/report/gapCueView.mjs b/umtool/lib/report/gapCueView.mjs
@@ -0,0 +1,110 @@
+// THE GAP MARK ON umtool's PAGES (lane gap-cue, slice 1b): the clip bench and
+// Play the cut draw the mark the render draws at a gap's join ("» 27 s"), at
+// the same seconds, with the same text and the same fade. Nothing here times
+// a mark: the rule is common lib/report/gapCue.mjs's (gapCues, gapCueAlpha,
+// gapCueText -- the build's gap-mark.mjs reads the same three), and the clocks
+// are gaps.mjs's (offsetIn). This file only says which joins a page has, on
+// the clock the page plays, and which mark is up at a second of it.
+//
+// PURE and dependency-free beyond those two: the client bundle takes it.
+import { GAP_CUE_MOTION, gapCueAlpha, gapCueText, gapCues, gapMarkOn } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { gappedLength, gapsWithin, offsetIn } from "umtool-report-to-video/gaps";
+
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+/** How far a clip's own gap may sit from the one the render took out (the frame grid) and still be it. */
+const NEAR = 0.05;
+
+/**
+ * The corner a page draws the mark at: the clip's `corner`, or for `auto` the
+ * layout's own (gap-mark.mjs's `prefer`): the deck's footage bottom left, a
+ * plain cut's picture top left.
+ *
+ * @param {string | null | undefined} corner
+ * @param {{ deck: boolean }} layout
+ * @returns {"tl" | "tr" | "bl" | "br"}
+ */
+export function gapMarkCorner(corner, { deck }) {
+ if (corner === "tl" || corner === "tr" || corner === "bl" || corner === "br") return corner;
+ return deck ? "bl" : "tl";
+}
+
+/**
+ * Is one of the clip's own gaps (`own`, with their `mark`) the one a page
+ * plays from `from`–`to`: the same seconds, give or take the frame grid.
+ */
+const ownOf = (own, from, to) => (own ?? []).filter((c) => fin(c?.from) && fin(c?.to) && c.to > from - NEAR && c.from < to + NEAR);
+
+/**
+ * The marks of a clip played from `from` to `to` (source seconds) with its
+ * `gaps` (the clip's own, each with its `mark`), on the clock of what PLAYS:
+ * seconds from `from`, the gaps taken out -- the segment's clock, which is the
+ * render's. `cue` is the clip's settings (common gapCue.mjs clipGapCueOf).
+ * Each mark is `{ at, until, seconds, count, text }`; [] when nothing is
+ * marked.
+ *
+ * @param {{ cue: { mark: boolean, min: number, label: string }, gaps: Array<{ from: number, to: number, mark?: boolean }> | null | undefined,
+ * from: number, to: number }} o
+ * @returns {Array<{ at: number, until: number, seconds: number, count: number, text: string }>}
+ */
+export function clipGapMarks({ cue, gaps, from, to }) {
+ if (!fin(from) || !fin(to) || to <= from) return [];
+ const inside = gapsWithin(gaps ?? [], from, to).sort((a, b) => a.from - b.from);
+ const joins = inside.map((g) => {
+ const own = ownOf(gaps, g.from, g.to);
+ return { at: offsetIn(g.from, from, inside), seconds: g.to - g.from, mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark };
+ });
+ return gapCues(joins, { min: cue.min, seconds: gappedLength(from, to, inside) }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label) }));
+}
+
+/**
+ * Source second `src` on clipGapMarks's clock (a page whose playhead is in
+ * source seconds: the bench), or null outside `from`–`to`. A second inside a
+ * gap is its join, where no mark is up yet.
+ *
+ * @param {{ gaps: Array<{ from: number, to: number }> | null | undefined, from: number, to: number }} o
+ * @param {number | null | undefined} src
+ */
+export function clipPlayClock({ gaps, from, to }, src) {
+ if (!fin(src) || !fin(from) || !fin(to) || /** @type {number} */ (src) < from - 1e-6 || /** @type {number} */ (src) > to + 1e-6) return null;
+ return offsetIn(/** @type {number} */ (src), from, gapsWithin(gaps ?? [], from, to).sort((a, b) => a.from - b.from));
+}
+
+/**
+ * The marks of one of Play's clip items, on the CUT's clock: its joins as
+ * Play lays them (playCut.mjs gapJoins: `{ at, from, to }`, the render's gaps
+ * when it said, so the join is where Play jumps), each marked as the clip's
+ * own gap there says (`entryGaps`), under the clip's settings (`cue`). A
+ * mark never outlives the clip's footage (`playEnd`).
+ *
+ * @param {Array<{ at: number, from: number, to: number }>} joins
+ * @param {{ cue: { mark: boolean, min: number, label: string }, entryGaps?: Array<{ from: number, to: number, mark?: boolean }> | null,
+ * playEnd: number }} o
+ */
+export function playGapMarks(joins, { cue, entryGaps = [], playEnd }) {
+ const marked = (joins ?? []).map((j) => {
+ const own = ownOf(entryGaps, j.from, j.to);
+ return { at: j.at, seconds: j.to - j.from, mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark };
+ });
+ return gapCues(marked, { min: cue.min, seconds: fin(playEnd) ? playEnd : Infinity }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label) }));
+}
+
+/**
+ * The mark up at `t` (the marks' clock) and its opacity (gapCueAlpha), or
+ * null when none is. `peak` is its opacity at full, for a page that fades the
+ * text and its box together, as drawtext's alpha does.
+ *
+ * @param {Array<{ at: number, until: number, text: string }>} marks
+ * @param {number | null | undefined} t
+ * @returns {{ text: string, alpha: number, at: number, until: number } | null}
+ */
+export function gapMarkAt(marks, t) {
+ if (!fin(t)) return null;
+ for (const m of marks ?? []) {
+ const alpha = gapCueAlpha(/** @type {number} */ (t), m);
+ if (alpha > 0) return { text: m.text, alpha, at: m.at, until: m.until };
+ }
+ return null;
+}
+
+/** The mark's opacity at full (common gapCue.mjs GAP_CUE_MOTION.peak). */
+export const GAP_MARK_PEAK = GAP_CUE_MOTION.peak;
diff --git a/umtool/lib/report/gapCueView.test.mjs b/umtool/lib/report/gapCueView.test.mjs
@@ -0,0 +1,82 @@
+// gapCueView.mjs (lane gap-cue, slice 1b): the mark as umtool's pages draw it --
+// the bench on its source clock, Play on the cut's -- is the build's mark: the
+// same joins, the same seconds up, the same text, the same fade.
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { GAP_CUE_LIFE, GAP_CUE_MOTION, clipGapCueOf } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { segmentGapJoins, segmentGapMarks } from "../../report-to-video/gap-mark.mjs";
+import { clipGapMarks, clipPlayClock, gapMarkAt, gapMarkCorner, playGapMarks } from "./gapCueView.mjs";
+import { gapJoins } from "./playCut.mjs";
+
+const near = (a, b, what, tol = 1e-3) => assert.ok(Math.abs(a - b) <= tol, `${what}: ${a} vs ${b}`);
+
+test("clipGapMarks: the build's marks for the same clip (segmentGapJoins + segmentGapMarks), at the same seconds with the same text", () => {
+ // A clip played 100–160 with gaps 110–137 (27 s, marked by the project), 150–151 (under min) and 154–157 (its own off).
+ const render = { gapCue: { mark: true, label: "{s} later" } };
+ const entry = { type: "clip", gaps: [{ from: 110, to: 137 }, { from: 150, to: 151 }, { from: 154, to: 157, mark: false }] };
+ const page = clipGapMarks({ cue: clipGapCueOf(render, entry), gaps: entry.gaps, from: 100, to: 160 });
+ const segGaps = entry.gaps.map((g) => ({ from: g.from - 100, to: g.to - 100 }));
+ const seconds = 60 - 27 - 1 - 3;
+ const build = segmentGapMarks({ render, entry, seconds, joins: segmentGapJoins({ segGaps, clipGaps: entry.gaps, segStart: 100, cue: clipGapCueOf(render, entry) }) });
+ assert.deepEqual(page, build);
+ assert.deepEqual(page.map((m) => [m.at, m.text]), [[10, "27 s later"]]);
+ near(page[0].until - page[0].at, GAP_CUE_LIFE, "a mark's life");
+});
+
+test("clipGapMarks: nothing marked is no mark; a gap's own on over the clip's off; joins inside a life are one mark", () => {
+ const gaps = [{ from: 3.5, to: 5.5 }, { from: 6, to: 9, mark: true }];
+ assert.deepEqual(clipGapMarks({ cue: clipGapCueOf({}, { gaps }), gaps: [{ from: 3.5, to: 5.5 }], from: 0.5, to: 12 }), [], "off by default");
+ const own = clipGapMarks({ cue: clipGapCueOf({}, { gaps }), gaps, from: 0.5, to: 12 });
+ assert.deepEqual(own.map((m) => [m.at, m.text]), [[3.5, "» 3 s"]], "only the gap that says so");
+ // Both marked: 3.5–5.5 joins at 3, 6–9 at 3.5 (0.5 s later): one mark, both gaps' seconds.
+ const both = clipGapMarks({ cue: clipGapCueOf({ gapCue: { mark: true } }, { gaps }), gaps, from: 0.5, to: 12 });
+ assert.equal(both.length, 1);
+ assert.deepEqual([both[0].at, both[0].count, both[0].text], [3, 2, "» 5 s"]);
+ near(both[0].until, 3.5 + GAP_CUE_LIFE, "a life after the last join");
+ // A gap outside what plays draws nothing.
+ assert.deepEqual(clipGapMarks({ cue: clipGapCueOf({ gapCue: { mark: true } }, {}), gaps: [{ from: 20, to: 30 }], from: 0, to: 12 }), []);
+});
+
+test("clipPlayClock: a source second on the marks' clock; inside a gap its join; outside what plays null", () => {
+ const o = { gaps: [{ from: 3.5, to: 5.5 }], from: 0.5, to: 8.5 };
+ assert.equal(clipPlayClock(o, 2), 1.5);
+ assert.equal(clipPlayClock(o, 4.2), 3, "inside the gap: its join");
+ assert.equal(clipPlayClock(o, 6), 3.5);
+ assert.equal(clipPlayClock(o, 0.2), null);
+ assert.equal(clipPlayClock(o, null), null);
+});
+
+test("gapMarkAt: up over `in`, held at the peak, down over `out`; none before the join or after the life", () => {
+ const marks = [{ at: 3, until: 3 + GAP_CUE_LIFE, seconds: 2, count: 1, text: "» 2 s" }];
+ assert.equal(gapMarkAt(marks, 2.9), null);
+ assert.equal(gapMarkAt(marks, 3), null, "at the join itself it is still 0");
+ near(gapMarkAt(marks, 3 + GAP_CUE_MOTION.in / 2).alpha, GAP_CUE_MOTION.peak / 2, "half way up");
+ near(gapMarkAt(marks, 3.5).alpha, GAP_CUE_MOTION.peak, "held");
+ assert.equal(gapMarkAt(marks, 3.5).text, "» 2 s");
+ assert.equal(gapMarkAt(marks, 3 + GAP_CUE_LIFE + 0.01), null);
+});
+
+test("playGapMarks: on the cut's clock at Play's joins, each marked as the clip's own gap says, never past the footage", () => {
+ // g01 0.5–8.5 with 3.5–5.5 out, starting at cut second 10: the join at 13, the footage to 16.
+ const item = { id: "g01", start: 10, clip: { sourceFrom: 0.5, sourceTo: 8.5, playEnd: 16, hold: 0, gaps: [{ from: 3.5, to: 5.5 }] } };
+ const joins = gapJoins(item);
+ assert.deepEqual(joins, [{ at: 13, from: 3.5, to: 5.5 }]);
+ const on = playGapMarks(joins, { cue: clipGapCueOf({ gapCue: { mark: true } }, {}), entryGaps: [{ from: 3.5, to: 5.5 }], playEnd: 16 });
+ assert.deepEqual(on.map((m) => [m.at, m.text]), [[13, "» 2 s"]]);
+ near(on[0].until, 13 + GAP_CUE_LIFE, "a mark's life");
+ // The clip's own gap off (the render's gap a frame off the manifest's: still it).
+ assert.deepEqual(playGapMarks(joins, { cue: clipGapCueOf({ gapCue: { mark: true } }, {}), entryGaps: [{ from: 3.53, to: 5.47, mark: false }], playEnd: 16 }), []);
+ // A join near the footage's end: clamped to it.
+ const late = playGapMarks([{ at: 15.5, from: 3.5, to: 5.5 }], { cue: clipGapCueOf({ gapCue: { mark: true } }, {}), playEnd: 16 });
+ assert.equal(late[0].until, 16);
+});
+
+test("gapMarkCorner: a clip's corner as it says; auto the layout's (the deck's footage bottom left, a plain cut's top left)", () => {
+ assert.equal(gapMarkCorner("br", { deck: true }), "br");
+ assert.equal(gapMarkCorner("auto", { deck: true }), "bl");
+ assert.equal(gapMarkCorner("auto", { deck: false }), "tl");
+ assert.equal(gapMarkCorner(undefined, { deck: false }), "tl");
+});
diff --git a/umtool/lib/report/gaps-writer.test.mjs b/umtool/lib/report/gaps-writer.test.mjs
@@ -99,6 +99,24 @@ test("updateClip: a gap edit leaves an undo point (auto-before-gaps); another ed
assert.ok(r.snapshot, "the answer names it");
});
+test("the bench's mark settings leave an undo point, as a gap write does: a clip's gapCue (window route), the project's (look / Modules)", async () => {
+ const { updateRender } = await import("./manifest.mjs");
+ const count = async (d) => (await readdir(path.join(d, "revisions")).catch(() => [])).filter((f) => f.includes("auto-before-gaps")).length;
+ const dir = await project();
+ const r = await updateClip(dir, "c01", { gapCue: { mark: true } });
+ assert.ok(r.snapshot, "the clip's: an undo point first");
+ assert.equal(await count(dir), 1);
+ const dir2 = await project();
+ const l = await updateRender(dir2, { gapCue: { mark: true, label: "{s} later" } });
+ assert.ok(l.snapshot, "the project's: an undo point first");
+ assert.equal(await count(dir2), 1);
+ // Another look key leaves none.
+ const dir3 = await project();
+ const o = await updateRender(dir3, { headerHeight: 0 });
+ assert.equal(o.snapshot, undefined);
+ assert.equal(await count(dir3), 0);
+});
+
test("updateMarks: a mark's second inside a gap is refused", async () => {
const dir = await project();
await updateClip(dir, "c01", { gapAdd: "15-17" });
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -299,7 +299,8 @@ export async function updateClip(dir, clipId, patch, { token = null, edit = "tri
// A gap cut or removed (gaps.mjs) changes what the clip IS in the cut, as a
// split does, and so does a moved edge (one undo stack, L3 S5): an undo point
// first (`umtool timeline <p> undo`, the Cut tab's Undo).
- const gaps = GAP_PATCH_KEYS.some((k) => patch[k] !== undefined);
+ // The mark at its gaps' joins (`gapCue`, lane gap-cue) is the gaps' too: the bench writes it as it writes a gap.
+ const gaps = GAP_PATCH_KEYS.some((k) => patch[k] !== undefined) || patch.gapCue !== undefined;
const moved = !!before && (entry.start !== before.start || entry.end !== before.end);
const snapshot = gaps ? await autoSnapshot(dir, "gaps") : moved ? await autoSnapshot(dir, "trim") : null;
const nextToken = await writeManifestAtomic(dir, manifest);
@@ -1948,8 +1949,10 @@ export async function updateRender(dir, patch, { token = null } = {}) {
if ("censor" in patch) errors.push(...renderCensorErrors(render.censor));
if (errors.length) throw new RenderRefused(errors);
manifest.render = render;
+ // The mark at the gaps' joins (render.gapCue, lane gap-cue) leaves an undo point, as a gap's write does.
+ const snapshot = "gapCue" in patch ? await autoSnapshot(dir, "gaps") : null;
const nextToken = await writeManifestAtomic(dir, manifest);
- return { look: lookOf(render), token: nextToken };
+ return { look: lookOf(render), token: nextToken, ...(snapshot ? { snapshot } : {}) };
});
}
diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs
@@ -26,7 +26,8 @@ import { playableTakes, resolveTakeManifest } from "./takeManifest.mjs";
import { draftLine, readWorkingCut } from "./workingCut.mjs";
import { listTakes, previewFile } from "./takes.mjs";
import { sectionModel } from "./sectionEdit.mjs";
-import { manifestToken } from "./manifest.mjs";
+import { effectiveManifest, manifestToken } from "./manifest.mjs";
+import { clipGapCueOf, gapCueWanted } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
import { projectCombos } from "umtool-report-to-video/post-combo-prints";
import { mediaSceneOf, sceneEntry } from "umtool-report-to-video/post-media-scene";
import { videoAudio, videoEnter, videoFit, videoHidesChrome, videoLead, videoSeconds, videoSpan } from "umtool-report-to-video/video-entry";
@@ -186,6 +187,13 @@ export async function playViewWith(project, { take = null, bare = false, postFor
(manifest.timeline ?? []).forEach((e, i) => e && typeof e === "object" && sourceAt.set(e, i));
const selected = selectVariant(manifest, DEFAULT_VARIANT);
const render = selected.render ?? {};
+ // The mark at the gaps' joins (lane gap-cue) as the build reads it: the look preset under the cut's own render.
+ let cueRender = render;
+ try {
+ cueRender = effectiveManifest(selected).render ?? render;
+ } catch {
+ // An unknown preset: the manifest's own word.
+ }
// THE BASIC OUTPUT MODE (render.mode, report-to-video basic.mjs): Play plays what the basic render cuts --
// the clips alone, their spans exactly (no lead-in), hard cuts, nothing drawn over the footage.
const basic = basicOn(render);
@@ -233,6 +241,9 @@ export async function playViewWith(project, { take = null, bare = false, postFor
cutEnd: fin(e.cutEnd) ? e.cutEnd : null,
// Seconds taken out of its middle (gaps.mjs): the plan plays it as one item of jump cuts.
...(Array.isArray(e.gaps) && e.gaps.length ? { gaps: e.gaps } : {}),
+ // The mark at those gaps' joins (common gapCue.mjs): its settings, the clip's over the project's -- only when a
+ // gap of it is marked (lib/report/gapCueView.mjs draws it at Play's joins, on the render's timing).
+ ...(!basic && Array.isArray(e.gaps) && e.gaps.length && gapCueWanted(cueRender, e) ? { gapCue: clipGapCueOf(cueRender, e) } : {}),
blur: e.blur && typeof e.blur === "object" ? e.blur : null,
// Its hidden regions (report-to-video clip-censor.mjs): Play draws them over the picture as the cut hides them.
censor: censorRegionsOf(e, render, selected.provenance ?? {}),
diff --git a/umtool/report-to-video/modules/config-loader.test.mjs b/umtool/report-to-video/modules/config-loader.test.mjs
@@ -173,3 +173,19 @@ test("the panel: a module's fields from its descriptor, a save as the writers ta
assert.throws(() => panelWrite(m, "qr", { enabled: false }), /not switched on and off/);
assert.deepEqual(setPath({ a: { b: 1 } }, "a.b", null), {});
});
+
+test("the panel: the gap mark (an input module, a look key the writer merges) is listed, and a field cleared is sent as null", async () => {
+ const { applyLookPatch } = await import("yt-dlp-transcript-common/lib/report/look.mjs");
+ const m = { ...manifest(), render: { ...manifest().render, gapCue: { mark: true, min: 4 } } };
+ const row = panelState(m, m, {}).find((r) => r.id === "gap-cue");
+ assert.ok(row, "the gap mark is in the panel");
+ assert.equal(row.base, "render.gapCue");
+ assert.deepEqual(row.fields, { mark: true, min: 4 });
+ assert.deepEqual(row.ui.map((f) => f.key), ["mark", "min", "corner", "label"]);
+ // min cleared, the label set: min goes as null, so the merging writer drops it.
+ const w = panelWrite(m, "gap-cue", { fields: { min: null, label: "{s} later" } });
+ assert.deepEqual(w.render, { gapCue: { min: null, mark: true, label: "{s} later" } });
+ assert.deepEqual(applyLookPatch(m, w.render).render.gapCue, { mark: true, label: "{s} later" });
+ // Every field cleared: the block goes.
+ assert.deepEqual(panelWrite(m, "gap-cue", { fields: { mark: null, min: null } }).render, { gapCue: null });
+});
diff --git a/umtool/report-to-video/modules/panel.mjs b/umtool/report-to-video/modules/panel.mjs
@@ -18,6 +18,8 @@
import { MODULES } from "./index.mjs";
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
+/** Look keys whose writer merges a patch into what it holds (common look.mjs applyLookPatch): the gap mark's. */
+const MERGED_LOOK_KEYS = new Set(["gapCue"]);
/** Where a module's ui keys are rooted. */
export function uiBase(m) {
@@ -159,7 +161,14 @@ export function panelWrite(manifest, id, { fields = {}, enabled } = {}) {
const patch = {};
for (const k of new Set([...Object.keys(render), ...Object.keys(next)])) {
if (k === "chrome") continue;
- if (JSON.stringify(render[k]) !== JSON.stringify(next[k])) patch[k] = next[k] === undefined ? null : next[k];
+ if (JSON.stringify(render[k]) === JSON.stringify(next[k])) continue;
+ if (next[k] === undefined) patch[k] = null;
+ else if (MERGED_LOOK_KEYS.has(k) && isObj(next[k])) {
+ // A look key the writer MERGES (applyLookPatch: each key over what it holds, null drops one): a field
+ // cleared here is sent as null, or it would stay.
+ const was = isObj(render[k]) ? render[k] : {};
+ patch[k] = { ...Object.fromEntries(Object.keys(was).filter((x) => !(x in next[k])).map((x) => [x, null])), ...next[k] };
+ } else patch[k] = next[k];
}
return { render: patch };
}