Archilyzer · Source

archilyzer

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

commit f59903970404e91d7e4e78ac78d0d500249cf5e4
parent 3b969412f00f60a88db950eabfd7322a728ee8eb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 23 Oct 2026 01:44:01 -0400

umtool: the clip editor's Marks box on every clip -- add at the playhead (Shift+M), Shift+S on the selected mark

Count & stamp becomes Marks: a row per mark (this cut's verdicts, lands at,
Set at playhead, hold, draw the stamp, count, label, Remove, where it stamps
when elsewhere), one selected; Add mark at playhead with a verdict picker;
Clear. The box owns Shift+S and Shift+M (S and M alone stay Split and Merge),
and they work with focus on a select or a checkbox. e2e: marks.spec.ts on its
own fixture; knobs.spec.ts follows the box's new selectors.

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

Diffstat:
Mumtool/components/projects/review/ClipEditor.tsx | 49++++++++++++++++++-------------------------------
Mumtool/components/projects/review/ClipKnobs.tsx | 355++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------
Mumtool/e2e/fixtures/make-fixture.mjs | 3+++
Aumtool/e2e/fixtures/marks-fixture.mjs | 34++++++++++++++++++++++++++++++++++
Mumtool/e2e/knobs.spec.ts | 14++++++++------
Aumtool/e2e/marks.spec.ts | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 449 insertions(+), 103 deletions(-)

diff --git a/umtool/components/projects/review/ClipEditor.tsx b/umtool/components/projects/review/ClipEditor.tsx @@ -14,7 +14,7 @@ import { cn } from "@/lib/utils"; import { ROOM, roomShade } from "umtool-report-to-video/room"; import { startTakeJob } from "../NewTakePanel"; import AssistBox from "../report/AssistBox"; -import { AudioBox, CountStampBox } from "./ClipKnobs"; +import { AudioBox, MarksBox } from "./ClipKnobs"; // Release 36 lane D: the assistant's labels, Suggest, Ask and Apply (all optional). import type { ReplyProposal } from "@/lib/annotations/types"; import { proposalWords, ReplyProposalRow, SuggestLabel, SuggestPanel, SuggestWhy, useClipSuggest, type ClipSuggest } from "./ClipSuggest"; @@ -38,9 +38,10 @@ import { proposalWords, ReplyProposalRow, SuggestLabel, SuggestPanel, SuggestWhy // the short (release 36) a 9:16 box dragged on the player (the clip's // `vertical.crop`), Make a short (a job: shorts/<clip>.mp4); // a speaker's name for the captions in the Speakers list -// the knobs (video knobs) Count & stamp on a claimed clip -- the stamp's +// the knobs (video knobs) Marks on every clip -- each mark's verdict, // second (Set at playhead, Shift+S), hold, on/off, count, -// label -- and Audio: sync nudge, gain, fades (./ClipKnobs.tsx) +// label; Add mark at playhead (Shift+M) -- and Audio: sync +// nudge, gain, fades (./ClipKnobs.tsx) // // Every write is one POST to /api/report/clip-editor; the answer is the whole // view again, so the page never guesses what the server did. Edge edits are @@ -355,14 +356,7 @@ export default function ClipEditor({ setPlayhead(t); player.current?.seek(t); }; - // The video knobs: the claim's stamp at the playhead (Shift+S), and the 3 s around it, heard. - const stampAtPlayhead = () => { - if (playhead === null) { - setError("put the playhead where the stamp should land first"); - return; - } - void flush().then(() => write({ op: "claim", clip: clip.id, knobs: { at: r2(playhead) } }, `The stamp lands at ${edgeClock(playhead)}`)); - }; + // The video knobs: the 3 s around the playhead, heard. (The marks' keys are the Marks box's.) const listen = () => { if (playhead === null) return; player.current?.listen(playhead); @@ -374,13 +368,9 @@ export default function ClipEditor({ if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey) return; const t = e.target as HTMLElement | null; if (t?.closest?.(TYPING) || t?.closest?.("dialog[open]")) return; - // Shift+S: the claim's stamp lands at the playhead (S alone splits). - if (e.shiftKey && e.key.toLowerCase() === "s") { - if (!clip.claim) return; - e.preventDefault(); - stampAtPlayhead(); - return; - } + // Shift+S and Shift+M are the Marks box's (a mark's moment at the + // playhead, a mark added there); S and M alone split and merge. + if (e.shiftKey && (e.key.toLowerCase() === "s" || e.key.toLowerCase() === "m")) return; const k = e.key.length === 1 ? e.key.toLowerCase() : e.key; const act: Record<string, () => void> = { " ": () => player.current?.toggle(), @@ -596,19 +586,16 @@ export default function ClipEditor({ )} {/* ---- the knobs (video knobs) -------------------------------------- */} - {clip.claim && ( - <CountStampBox - clipId={clip.id} - claim={clip.claim} - stampsOn={clip.stampsOn ?? null} - defaults={view.knobs} - playhead={playhead} - span={{ start: clip.start, end: clip.end, cutStart: cut.cutStart, cutEnd: cut.cutEnd }} - busy={busy} - write={write} - onGo={choose} - /> - )} + <MarksBox + clipId={clip.id} + marks={clip.marks ?? (clip.claim ? [{ ...clip.claim, stampsOn: clip.stampsOn ?? null }] : [])} + defaults={view.knobs} + playhead={playhead} + span={{ start: clip.start, end: clip.end, cutStart: cut.cutStart, cutEnd: cut.cutEnd }} + busy={busy} + write={(body, done) => flush().then(() => write(body, done))} + onGo={choose} + /> <AudioBox clipId={clip.id} audio={clip.audio ?? null} busy={busy} write={write} canListen={playhead !== null} onListen={listen} /> {/* ---- the decisions ----------------------------------------------- */} diff --git a/umtool/components/projects/review/ClipKnobs.tsx b/umtool/components/projects/review/ClipKnobs.tsx @@ -1,24 +1,27 @@ "use client"; -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { buttonVariants } from "@/components/ui/button"; import { edgeClock } from "@/lib/report/clipEditorModel.mjs"; -import type { ClaimKnobs, ClipAudio, KnobDefaults } from "@/lib/report/clipEditorTypes"; +import type { ClipAudio, KnobDefaults, MarkVerdict, MarkView } from "@/lib/report/clipEditorTypes"; // THE CLIP'S KNOBS (video knobs, plans/video-knobs-ui.md), in the clip editor: // -// Count & stamp on a clip that carries a claim: the source second its stamp -// lands and the tally steps (`claim.at`, Set at playhead, -// Shift+S), how long it stays (`hold`), whether it is drawn -// (`stamp`), how much it counts (`count`), what it says -// (`label`) +// Marks on every clip (plans/clip-marks.md): its marks, each its +// own stamp and tally step -- the verdict (this cut's words), +// the source second it lands and the tally steps (`at`, Set +// at playhead, Shift+S for the selected mark), how long it +// stays (`hold`), whether it is drawn (`stamp`), how much it +// counts (`count`), what it says (`label`), remove; Add mark +// at playhead (Shift+M); Clear (every mark) // Audio the clip's sound at the encode: a sync nudge in ms (+ = // later), gain in dB, fades in s; "listen" replays the 3 s // around the playhead // // Every field shows the default it gets when its key is absent; Clear removes // the key (the default again). Each change is one write through the clip -// editor's route (op claim / op audio), the same writer `umtool set` uses. +// editor's route (op marks / op claim / op audio), the same writers `umtool +// set` uses. const input = "num w-[6em] rounded border border-seam-2 bg-ground px-1.5 py-0.5 font-mono text-[12px] text-text outline-none focus:border-signal"; const box = "space-y-1.5 rounded-[3px] border border-seam bg-panel p-2 text-[12px] text-text-2"; @@ -93,10 +96,120 @@ function KnobField({ const numOrNull = (s: string) => (s === "" ? null : Number(s)); -export function CountStampBox({ +/** + * Where a key is typing, not a command: the clip editor's rule, less a select + * and a checkbox -- Shift+S / Shift+M still work just after a verdict is + * picked or the stamp toggled (the word buttons never take the focus). + */ +const TYPING = "input:not([type='checkbox']), textarea, [contenteditable=''], [contenteditable='true']"; +const r2 = (n: number) => Math.round(n * 100) / 100; + +/** A verdict's words for the picker: this cut's label, and the verdict's name when the label is not it. */ +const verdictText = (v: MarkVerdict) => (v.label.toUpperCase().replace(/[\s-]+/g, "_") === v.verdict ? v.label : `${v.label} (${v.verdict})`); + +function VerdictPicker({ + name, + value, + verdicts, + busy, + onPick, +}: { + name: string; + value: string; + verdicts: MarkVerdict[]; + busy: boolean; + onPick: (v: string) => unknown; +}) { + const stock = verdicts.filter((v) => v.stock); + const other = verdicts.filter((v) => !v.stock); + const known = verdicts.some((v) => v.verdict === value); + // The choice shows at once until the view comes back with it (or does not). + const [draft, setDraft] = useState<string | null>(null); + useEffect(() => setDraft(null), [value]); + return ( + <select + data-mark-verdict={name} + value={draft ?? value} + disabled={busy} + onChange={(e) => { + const v = e.target.value; + setDraft(v); + const r = onPick(v); + if (r instanceof Promise) void r.finally(() => setDraft(null)); + else setDraft(null); + }} + className="rounded border border-seam-2 bg-ground px-1 py-0.5 text-[12px] text-text outline-none focus:border-signal" + > + {!known && <option value={value}>{value}</option>} + {stock.length > 0 && other.length > 0 ? ( + <> + <optgroup label="this cut's"> + {stock.map((v) => ( + <option key={v.verdict} value={v.verdict}> + {verdictText(v)} + </option> + ))} + </optgroup> + <optgroup label="other verdicts"> + {other.map((v) => ( + <option key={v.verdict} value={v.verdict}> + {verdictText(v)} + </option> + ))} + </optgroup> + </> + ) : ( + verdicts.map((v) => ( + <option key={v.verdict} value={v.verdict}> + {verdictText(v)} + </option> + )) + )} + </select> + ); +} + +/** "draw the stamp": shows the choice at once (a draft) until the view comes back with it. */ +function StampToggle({ on, busy, onSet }: { on: boolean; busy: boolean; onSet: (on: boolean) => Promise<unknown> }) { + const [draft, setDraft] = useState<boolean | null>(null); + useEffect(() => setDraft(null), [on]); + return ( + <label className="inline-flex items-center gap-1.5 text-text"> + <input + type="checkbox" + data-knob="stamp" + checked={draft ?? on} + disabled={busy} + onChange={(e) => { + const next = e.target.checked; + setDraft(next); + void onSet(next).finally(() => setDraft(null)); + }} + /> + draw the stamp + </label> + ); +} + +/** The verdicts when the view names none (an older server): the five, by name. */ +const FALLBACK_VERDICTS: MarkVerdict[] = ["CORROBORATED", "PARTLY", "CONTRADICTED", "NOT_FOUND", "UNTESTABLE"].map((v) => ({ + verdict: v, + label: v, + stampLabel: v, + color: "currentColor", + stock: false, +})); + +/** + * THE MARKS of one clip (plans/clip-marks.md): a list, each mark its own stamp + * and tally step. One mark is selected (click its row): Shift+S puts its + * moment at the playhead. Shift+M adds a mark at the playhead with the + * verdict beside "Add mark at playhead". The box keeps its own keys (the + * editor's own key handler leaves Shift+S and Shift+M to it). + */ +export function MarksBox({ clipId, - claim, - stampsOn, + marks, defaults, playhead, span, @@ -105,8 +218,7 @@ export function CountStampBox({ onGo, }: { clipId: string; - claim: ClaimKnobs; - stampsOn: string | null; + marks: MarkView[]; defaults: KnobDefaults | undefined; playhead: number | null; span: { start: number; end: number; cutStart: number; cutEnd: number }; @@ -114,76 +226,187 @@ export function CountStampBox({ write: Write; onGo: (id: string) => void; }) { - const set = (knobs: Record<string, unknown>, done: string) => void write({ op: "claim", clip: clipId, knobs }, done); + const verdicts = defaults?.verdicts?.length ? defaults.verdicts : FALLBACK_VERDICTS; const hold = defaults?.hold ?? 3; - const word = defaults?.labels?.[claim.verdict] ?? claim.verdict; - // The box shows the choice at once (stampDraft) until the view comes back with it. - const [stampDraft, setStampDraft] = useState<boolean | null>(null); - useEffect(() => setStampDraft(null), [claim.stamp, clipId]); - const stampOn = stampDraft ?? claim.stamp !== false; - const outsideCut = typeof claim.at === "number" && (claim.at < span.cutStart || claim.at > span.cutEnd); + const [selected, setSelected] = useState<string | null>(marks[0]?.id ?? null); + const [hint, setHint] = useState<string | null>(null); + // A new clip: its first mark selected. A selected mark removed: the first. + useEffect(() => { + setSelected(marks[0]?.id ?? null); + setHint(null); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [clipId]); + useEffect(() => { + if (selected !== null && !marks.some((m) => m.id === selected)) setSelected(marks[0]?.id ?? null); + if (selected === null && marks.length) setSelected(marks[0].id); + }, [marks, selected]); + const current = marks.find((m) => m.id === selected) ?? null; + const [addVerdict, setAddVerdict] = useState<string>(verdicts.find((v) => v.stock)?.verdict ?? verdicts[0].verdict); + // The verdict a new mark takes follows the selected mark's. + useEffect(() => { + if (current) setAddVerdict(current.verdict); + }, [current?.verdict]); // eslint-disable-line react-hooks/exhaustive-deps + + const setKnobs = (id: string, knobs: Record<string, unknown>, done: string) => void write({ op: "claim", clip: clipId, mark: id, knobs }, done); + const addAtPlayhead = () => { + if (playhead === null) { + setHint("put the playhead where the mark should land first (play, or click the strip)"); + return; + } + if (marks.length >= 8) { + setHint("a clip carries at most 8 marks"); + return; + } + setHint(null); + const at = r2(playhead); + void write({ op: "marks", clip: clipId, add: { verdict: addVerdict, at } }, `Mark added at ${edgeClock(at)}`).then((r) => { + const added = (r as { result?: { added?: string } } | null)?.result?.added; + if (added) setSelected(added); + }); + }; + const atPlayhead = () => { + if (!current) { + setHint("no mark to move: add one at the playhead first (⇧M)"); + return; + } + if (playhead === null) { + setHint("put the playhead where the stamp should land first"); + return; + } + setHint(null); + setKnobs(current.id, { at: r2(playhead) }, `${current.id} lands at ${edgeClock(playhead)}`); + }; + + // Shift+S (the selected mark's moment at the playhead) and Shift+M (a mark + // added at the playhead). S and M alone stay Split and Merge. + const keys = useRef<(e: KeyboardEvent) => void>(() => {}); + keys.current = (e: KeyboardEvent) => { + if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey || !e.shiftKey) return; + const t = e.target as HTMLElement | null; + if (t?.closest?.(TYPING) || t?.closest?.("dialog[open]")) return; + const k = e.key.toLowerCase(); + if (k === "s") { + e.preventDefault(); + atPlayhead(); + } else if (k === "m") { + e.preventDefault(); + addAtPlayhead(); + } + }; + useEffect(() => { + const on = (e: KeyboardEvent) => keys.current(e); + document.addEventListener("keydown", on); + return () => document.removeEventListener("keydown", on); + }, []); + + const timedAny = marks.some((m) => typeof m.at === "number"); return ( - <section id="clip-stamp" data-count-stamp={clipId} data-claim-id={claim.id} className={box}> - <div className="flex flex-wrap items-baseline gap-2"> - <h2 className="micro m-0">Count &amp; stamp</h2> - <span className="font-mono text-[11.5px]"> - {claim.id} · {claim.verdict} - </span> - {stampsOn && stampsOn !== clipId && ( - <span data-stamps-on={stampsOn} className="text-muted"> - this claim stamps on{" "} - <button type="button" onClick={() => onGo(stampsOn)} className="underline"> - {stampsOn} - </button>{" "} - (the last clip carrying it) — its knobs are read there - </span> - )} - </div> - <div className="flex flex-wrap items-center gap-x-3 gap-y-1.5"> - <span className="inline-flex items-center gap-1.5" data-knob-at={claim.at ?? ""}> - <span className="micro">lands at</span> - <span className="num font-mono">{typeof claim.at === "number" ? edgeClock(claim.at) : "default (before the clip leaves)"}</span> + <section id="clip-stamp" data-marks={clipId} data-mark-count={marks.length} className={box}> + <div className="flex flex-wrap items-center gap-2"> + <h2 className="micro m-0">Marks</h2> + <span className="text-muted">{marks.length ? "each its own stamp and count" : "none: this clip stamps nothing and counts nothing"}</span> + <span className="ml-auto inline-flex flex-wrap items-center gap-1.5"> + <VerdictPicker name="add" value={addVerdict} verdicts={verdicts} busy={busy} onPick={setAddVerdict} /> <button type="button" - data-claim-at-playhead="" - disabled={busy || playhead === null} + data-mark-add="" + disabled={busy || marks.length >= 8} onMouseDown={(e) => e.preventDefault()} - onClick={() => playhead !== null && set({ at: Math.round(playhead * 100) / 100 }, `The stamp lands at ${edgeClock(playhead)}`)} + onClick={addAtPlayhead} className={buttonVariants({ size: "sm" })} - title="the stamp lands and the count steps at the playhead (a source second inside the clip)" + title="a new mark, landing at the playhead (a source second inside the clip)" > - Set at playhead <kbd>⇧S</kbd> + Add mark at playhead <kbd>⇧M</kbd> </button> - {typeof claim.at === "number" && ( - <button type="button" data-knob-clear="at" disabled={busy} onClick={() => set({ at: null }, "The stamp lands at its default")} className={buttonVariants({ variant: "quiet", size: "sm" })}> + {marks.length > 0 && ( + <button type="button" data-marks-clear="" disabled={busy} onClick={() => write({ op: "marks", clip: clipId, set: null }, "No marks on this clip")} className={buttonVariants({ variant: "quiet", size: "sm" })} title="remove every mark on this clip"> Clear </button> )} </span> - <KnobField name="hold" label="hold" unit="s" step={0.5} value={claim.hold} placeholder={String(hold)} busy={busy} onSave={(v) => set({ hold: numOrNull(v) }, v ? `The stamp stays ${v} s` : "The stamp stays the cut's default")} /> - <label className="inline-flex items-center gap-1.5 text-text"> - <input type="checkbox" data-knob="stamp" checked={stampOn} disabled={busy} onChange={(e) => { - const on = e.target.checked; - setStampDraft(on); - void write({ op: "claim", clip: clipId, knobs: { stamp: on ? null : false } }, on ? "Stamp drawn" : "Counts, no stamp").finally(() => setStampDraft(null)); - }} - /> - draw the stamp - </label> - <KnobField name="count" label="count" step={1} value={claim.count} placeholder={String(defaults?.count ?? 1)} busy={busy} onSave={(v) => set({ count: numOrNull(v) }, v ? `Counts ${v}` : "Counts 1")} /> - <KnobField name="label" label="label" kind="text" maxLength={20} value={claim.label} placeholder={word} busy={busy} onSave={(v) => set({ label: v || null }, v ? `The stamp says “${v}”` : "The stamp says the verdict's word")} /> </div> - {typeof claim.at === "number" && ( - <p data-knob-at-hint="" className="m-0 text-muted"> - The On-screen preview places this second from the last build&rsquo;s cut of the clip: it is approximate until the next build. + {marks.map((m, i) => { + const on = m.id === selected; + const word = m.label ?? defaults?.labels?.[m.verdict] ?? m.verdict; + const outsideCut = typeof m.at === "number" && (m.at < span.cutStart || m.at > span.cutEnd); + return ( + <div + key={m.id} + data-mark={m.id} + data-mark-at={m.at ?? ""} + data-claim-id={m.id} + aria-selected={on} + onClick={() => setSelected(m.id)} + className={`space-y-1 rounded-[3px] border px-1.5 py-1 ${on ? "border-signal" : "border-seam"}`} + > + <div className="flex flex-wrap items-center gap-x-3 gap-y-1.5"> + <span className="num font-mono text-[11.5px] text-muted">{i + 1}</span> + <VerdictPicker name={m.id} value={m.verdict} verdicts={verdicts} busy={busy} onPick={(v) => write({ op: "marks", clip: clipId, mark: m.id, verdict: v }, `${m.id} is ${verdicts.find((x) => x.verdict === v)?.label ?? v}`)} /> + <span className="font-mono text-[11.5px]" title="the mark's id: the same id on another clip is the same event, counted once"> + {m.id} + </span> + <span className="inline-flex items-center gap-1.5" data-knob-at={m.at ?? ""}> + <span className="micro">lands at</span> + <span className="num font-mono">{typeof m.at === "number" ? edgeClock(m.at) : i < marks.length - 1 ? "default (before the next)" : "default (before the clip leaves)"}</span> + <button + type="button" + data-claim-at-playhead={m.id} + disabled={busy || playhead === null} + onMouseDown={(e) => e.preventDefault()} + onClick={(e) => { + e.stopPropagation(); + setSelected(m.id); + if (playhead !== null) setKnobs(m.id, { at: r2(playhead) }, `${m.id} lands at ${edgeClock(playhead)}`); + }} + className={buttonVariants({ size: "sm" })} + title="this mark's stamp lands and the count steps at the playhead (a source second inside the clip)" + > + Set at playhead{on && <kbd>⇧S</kbd>} + </button> + {typeof m.at === "number" && ( + <button type="button" data-knob-clear="at" disabled={busy} onClick={() => setKnobs(m.id, { at: null }, `${m.id} lands at its default`)} className={buttonVariants({ variant: "quiet", size: "sm" })}> + Clear + </button> + )} + </span> + <button type="button" data-mark-remove={m.id} disabled={busy} onClick={(e) => { e.stopPropagation(); void write({ op: "marks", clip: clipId, remove: m.id }, `${m.id} removed`); }} className={`${buttonVariants({ variant: "quiet", size: "sm" })} ml-auto`} title="remove this mark"> + Remove + </button> + </div> + <div className="flex flex-wrap items-center gap-x-3 gap-y-1.5"> + <KnobField name="hold" label="hold" unit="s" step={0.5} value={m.hold} placeholder={String(hold)} busy={busy} onSave={(v) => setKnobs(m.id, { hold: numOrNull(v) }, v ? `${m.id}'s stamp stays ${v} s` : `${m.id}'s stamp stays the cut's default`)} /> + <StampToggle on={m.stamp !== false} busy={busy} onSet={(on) => write({ op: "claim", clip: clipId, mark: m.id, knobs: { stamp: on ? null : false } }, on ? `${m.id}: stamp drawn` : `${m.id}: counts, no stamp`)} /> + <KnobField name="count" label="count" step={1} value={m.count} placeholder={String(defaults?.count ?? 1)} busy={busy} onSave={(v) => setKnobs(m.id, { count: numOrNull(v) }, v ? `${m.id} counts ${v}` : `${m.id} counts 1`)} /> + <KnobField name="label" label="label" kind="text" maxLength={20} value={m.label} placeholder={word} busy={busy} onSave={(v) => setKnobs(m.id, { label: v || null }, v ? `${m.id}'s stamp says “${v}”` : `${m.id}'s stamp says the verdict's word`)} /> + </div> + {m.stampsOn && m.stampsOn !== clipId && ( + <p data-stamps-on={m.stampsOn} className="m-0 text-muted"> + {m.id} stamps on{" "} + <button type="button" onClick={() => onGo(m.stampsOn as string)} className="underline"> + {m.stampsOn} + </button>{" "} + (the last clip carrying it) — its knobs are read there + </p> + )} + {outsideCut && ( + <p data-knob-warning="" className="m-0 text-reject-text"> + {edgeClock(m.at as number)} is outside the cut ({edgeClock(span.cutStart)}–{edgeClock(span.cutEnd)}): the stamp would land on footage the cut does not play. + </p> + )} + </div> + ); + })} + {hint && ( + <p data-marks-hint="" className="m-0 text-reject-text"> + {hint} </p> )} - {defaults && !defaults.stampShown && <p className="m-0 text-muted">The cut draws no stamps (the fact-check's stamp effect is off): the count still steps here.</p>} - {outsideCut && ( - <p data-knob-warning="" className="m-0 text-reject-text"> - {edgeClock(claim.at as number)} is outside the cut ({edgeClock(span.cutStart)}–{edgeClock(span.cutEnd)}): the stamp would land on footage the cut does not play. + {timedAny && ( + <p data-knob-at-hint="" className="m-0 text-muted"> + The On-screen preview places a mark&rsquo;s second from the last build&rsquo;s cut of the clip: it is approximate until the next build. </p> )} + {marks.length > 0 && defaults && !defaults.stampShown && <p className="m-0 text-muted">The cut draws no stamps (the fact-check&rsquo;s stamp effect is off): the counts still step here.</p>} </section> ); } diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -39,6 +39,7 @@ import { makeRunTraceFixture } from "./run-trace-fixture.mjs"; import { makeClipsSuggestFixture } from "./clips-suggest-fixture.mjs"; import { makeVideoAssistFixture } from "./video-assist-fixture.mjs"; import { makeKnobsFixture } from "./knobs-fixture.mjs"; +import { makeMarksFixture } from "./marks-fixture.mjs"; const CODE = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "song"); const dest = path.resolve(process.argv[2] ?? path.join(process.cwd(), ".e2e-song")); @@ -1825,6 +1826,8 @@ makeClipsSuggestFixture({ reports, manifest, cachedWindow: path.join(REPORT, "ou makeVideoAssistFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); // Video knobs (plans/video-knobs-ui.md): Count & stamp, Audio, Make variants, Sync and the Markers editor (knobs.spec.ts). makeKnobsFixture({ reports, manifest, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); +// Marks (plans/clip-marks.md): the clip editor's Marks box -- add at the playhead, verdict, Shift+S/M, remove (marks.spec.ts). +makeMarksFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); // TWO MORE cached windows for vid1, and they are the regression rather than // decoration. diff --git a/umtool/e2e/fixtures/marks-fixture.mjs b/umtool/e2e/fixtures/marks-fixture.mjs @@ -0,0 +1,34 @@ +// What marks.spec.ts edits (plans/clip-marks.md): the clip editor's three clips +// (clip-editor-fixture.mjs, its own copy) with the fact-check relabelled as +// the Huck cut's (CORROBORATED "Episodes", CONTRADICTED "Grift"), the stamp's +// seconds at 1, and ONE mark on r001 (`claim`, at 1.2) -- the Marks box: add a +// mark at the playhead (button and Shift+M), its verdict, hold, Shift+S on the +// selected mark, remove, Clear. +// +// Synthetic, like every fixture. +import { readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { makeClipEditorFixture } from "./clip-editor-fixture.mjs"; + +/** + * @param {{ reports: string, manifest: Function, cachedWindow: string, cues: Array<[number, number, string]> }} o + */ +export function makeMarksFixture({ reports, manifest, cachedWindow, cues }) { + const { dir } = makeClipEditorFixture({ reports, manifest, cachedWindow, cues, name: "marks-fixture", title: "The Marks Fixture" }); + const file = path.join(dir, "video.manifest.json"); + const m = JSON.parse(readFileSync(file, "utf8")); + m.render.chrome = { + engine: "hyperframes", + layout: "deck", + factcheck: { + verdicts: { + CORROBORATED: { label: "Episodes", stampLabel: "Seizure" }, + CONTRADICTED: { label: "Grift", stampLabel: "Grift" }, + }, + stamp: { seconds: 1 }, + }, + }; + for (const e of m.timeline) if (e.id === "r001") e.claim = { id: "r001", verdict: "CORROBORATED", at: 1.2 }; + writeFileSync(file, JSON.stringify(m, null, 2) + "\n"); + return { dir }; +} diff --git a/umtool/e2e/knobs.spec.ts b/umtool/e2e/knobs.spec.ts @@ -6,9 +6,10 @@ import * as urls from "./urls"; // --------------------------------------------------------------------------- // The video knobs (plans/video-knobs-ui.md): -// - the clip editor's Count & stamp box: Set at playhead (and Shift+S) writes -// claim.at, count / label / stamp on-off write and Clear removes; a clip -// that carries the claim but does not stamp it says where it stamps +// - the clip editor's Marks box (was Count & stamp) on a clip with one mark: +// Set at playhead (and Shift+S) writes claim.at, count / label / stamp +// on-off write and Clear removes; a clip that carries the claim but does +// not stamp it says where it stamps (marks.spec.ts: two marks and more) // - the Audio box: a sync nudge, the gain, Clear all // - an agent's token on a manifest-write route: right one writes, a wrong one is 401 // - the On-screen Markers editor: add, label, colour, align, re-order, the @@ -37,7 +38,7 @@ test("Count & stamp and Audio in the clip editor; an agent's token on the route" await expect(page.locator("[data-clip-editor]")).toHaveAttribute("data-clip-editor", "r003"); await expect(page.locator("[data-editor-player]")).not.toHaveAttribute("data-editor-player", "looking", { timeout: 15_000 }); - const box = page.locator('[data-count-stamp="r003"]'); + const box = page.locator('[data-marks="r003"]'); await expect(box).toBeVisible(); // The defaults show where a key is absent: the cut's stamp seconds, a count of 1. await expect(box.locator('[data-knob="hold"]')).toHaveAttribute("placeholder", "3"); @@ -82,9 +83,10 @@ test("Count & stamp and Audio in the clip editor; an agent's token on the route" // r002 carries the claim but r003 stamps it: the box says so; r001 has none. await page.locator('[data-editor-row="r002"]').click(); - await expect(page.locator('[data-count-stamp="r002"] [data-stamps-on="r003"]')).toBeVisible(); + await expect(page.locator('[data-marks="r002"] [data-stamps-on="r003"]')).toBeVisible(); await page.locator('[data-editor-row="r001"]').click(); - await expect(page.locator("[data-count-stamp]")).toHaveCount(0); + await expect(page.locator('[data-marks="r001"]')).toHaveAttribute("data-mark-count", "0"); + await expect(page.locator("[data-mark]")).toHaveCount(0); // An agent's token writes through the same route; a wrong one is refused. const view = await (await request.get(`/api/report/clip-editor?project=${encodeURIComponent(PROJECT)}`)).json(); diff --git a/umtool/e2e/marks.spec.ts b/umtool/e2e/marks.spec.ts @@ -0,0 +1,97 @@ +import { test, expect } from "@playwright/test"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// Marks (plans/clip-marks.md): the clip editor's Marks box, on every clip. +// - Add mark at playhead (the button, and Shift+M): a second mark on a clip +// with one makes `claims`, under a NEW id (<clip>.2) +// - the verdicts offered are this cut's words ("Episodes", "Grift") +// - a mark that would sit on another's stamp is refused, the file unchanged +// - a mark's verdict, its hold, Shift+S on the selected mark +// - Remove back to one mark (`claim` again), Clear (none) +// - a clip with no marks shows the box, empty +// Fixture: e2e/fixtures/marks-fixture.mjs (r001 carries one mark, at 1.2; the +// stamp stays 1 s). +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const DIR = path.join(HERE, "..", ".e2e-song", "reports", "marks-fixture"); +const PROJECT = "reports/marks-fixture"; + +type Mark = { id: string; verdict: string; at?: number; hold?: number }; +type Entry = { id: string; type: string; claim?: Mark; claims?: Mark[] }; +const entry = (id: string): Entry | null => + (JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")).timeline as Entry[]).find((e) => e.id === id) ?? null; + +test("the Marks box: add at the playhead, this cut's verdicts, Shift+M / Shift+S, overlap refused, remove, clear", async ({ page }) => { + test.setTimeout(150_000); + await page.setViewportSize({ width: 1366, height: 900 }); + await page.goto(urls.clipEditorHref(PROJECT, { clip: "r001", mode: "edit" })); + await expect(page.locator("[data-clip-editor]")).toHaveAttribute("data-clip-editor", "r001"); + await expect(page.locator("[data-editor-player]")).not.toHaveAttribute("data-editor-player", "looking", { timeout: 15_000 }); + + const box = page.locator('[data-marks="r001"]'); + await expect(box).toHaveAttribute("data-mark-count", "1"); + await expect(box.locator('[data-mark="r001"]')).toHaveAttribute("aria-selected", "true"); + // This cut's words for the verdicts, its own first. + const options = await box.locator('[data-mark-verdict="add"] option').allTextContents(); + expect(options.slice(0, 2)).toEqual(["Episodes (CORROBORATED)", "Grift (CONTRADICTED)"]); + + // The button: a second mark at the playhead (the word at 2.4 s), a NEW id. + await page.locator('[data-word-t="2.4"]').click(); + await box.locator("[data-mark-add]").click(); + await expect.poll(() => entry("r001")?.claims?.map((m) => [m.id, m.verdict, m.at])).toEqual([ + ["r001", "CORROBORATED", 1.2], + ["r001.2", "CORROBORATED", 2.4], + ]); + expect(entry("r001")?.claim).toBeUndefined(); + await expect(box).toHaveAttribute("data-mark-count", "2"); + await expect(box.locator('[data-mark="r001.2"]')).toHaveAttribute("aria-selected", "true"); + + // Its verdict, from this cut's words. + await box.locator('[data-mark-verdict="r001.2"]').selectOption("CONTRADICTED"); + await expect.poll(() => entry("r001")?.claims?.[1]?.verdict).toBe("CONTRADICTED"); + + // Shift+M at 1.8: on the first's stamp (it stays 1 s) -- refused, nothing written. + await page.locator('[data-word-t="1.8"]').click(); + await page.keyboard.press("Shift+M"); + await expect(page.locator("[data-editor-error]")).toContainText("overlap"); + expect(entry("r001")?.claims?.length).toBe(2); + + // A shorter hold on the first, then Shift+S moves the SELECTED mark (the first) to 1.8. + await box.locator('[data-mark="r001"]').click(); + await expect(box.locator('[data-mark="r001"]')).toHaveAttribute("aria-selected", "true"); + const hold = box.locator('[data-mark="r001"] [data-knob="hold"]'); + await expect(async () => { + await hold.fill("0.5"); + await hold.press("Enter"); + await expect.poll(() => entry("r001")?.claims?.[0]?.hold, { timeout: 2000 }).toBe(0.5); + }).toPass({ timeout: 15_000 }); + await page.locator('[data-word-t="1.8"]').click(); + await page.keyboard.press("Shift+S"); + await expect.poll(() => entry("r001")?.claims?.[0]?.at).toBe(1.8); + // S and M alone are still Split and Merge: Shift did neither. + expect((JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")).timeline as Entry[]).filter((e) => e.type === "clip").map((e) => e.id)).toEqual(["r001", "r002", "r003"]); + + // Remove the second: one mark, written as `claim` again. + await box.locator('[data-mark-remove="r001.2"]').click(); + await expect.poll(() => entry("r001")?.claim).toEqual({ id: "r001", verdict: "CORROBORATED", at: 1.8, hold: 0.5 }); + expect(entry("r001")?.claims).toBeUndefined(); + + // Shift+M on a clip with no marks: its first, under the clip's id. + await page.locator('[data-editor-row="r002"]').click(); + const box2 = page.locator('[data-marks="r002"]'); + await expect(box2).toHaveAttribute("data-mark-count", "0"); + await page.locator('[data-word-t="4.71"]').click(); + await box2.locator('[data-mark-verdict="add"]').selectOption("CONTRADICTED"); + await page.keyboard.press("Shift+M"); + await expect.poll(() => entry("r002")?.claim).toEqual({ id: "r002", verdict: "CONTRADICTED", at: 4.71 }); + + // Clear: no marks. + await box2.locator("[data-marks-clear]").click(); + await expect.poll(() => entry("r002")?.claim ?? entry("r002")?.claims ?? null).toBeNull(); + await expect(box2).toHaveAttribute("data-mark-count", "0"); +});