Archilyzer · Source

archilyzer

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

commit 3f2bae3dcbaa92d6a00640e3f1f04e9e040a125d
parent f72e3355a9f7c99b8842ff72702959fd0b2135f7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 30 Oct 2026 12:20:11 -0400

umtool walk: Reject ▾ with explicit reasons — doesn't match is one of seven

The walk rejected a clip only as "incorrect" (doesn't match), but walkers
mostly cut clips that are accurate and just irrelevant. Rejection now says why
(lib/report/rejectReasons.mjs, one vocabulary for the writer, the bench, Play
the cut, the CLI and umtool check):

- FACT reasons stay the incorrect verdict, as before: not-matching (the bare
  incorrect + correction, so every old manifest reads unchanged) and
  wrong-speaker. A correction for the report; clip-incorrect blocks.
- CUT reasons are verdict "rejected" + reason (irrelevant, repeats, weak,
  privacy, other) + an optional rejectNote (required for other). Never a
  correction; still in the cut it is an open check row, clip-rejected.

rejectClip (manifest.mjs) rejects and removes in one structural write, on
record in removed.json with the reason and note; removeWrongSpeaker is it with
its reason preset. POST /api/report/timeline op "reject"; the window route
takes reason and rejectNote for "Reject, keep in place".

UI: RejectClip replaces WrongSpeaker on the clip bench and in Play the cut —
Reject ▾ (x, then 1–7), asked in the page, Remove or keep in place, Undo;
Wrong speaker keeps its one-click button. The bench asks "Keep c04 in the
cut?", its phone dock opens the reasons in a sheet. Play skips every rejected
clip and says why ("rejected — irrelevant"; Show rejected clips). The
AuditionDeck's cut chips use the same words.

CLI: umtool window --reject <why> [--note], umtool timeline <p> reject <id>
<why> [--note], umtool set verdict=<why> rejectNote=…; walk, timeline ls,
corrections and check say the reason.

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

Diffstat:
Mumtool/app/api/report/timeline/route.ts | 8+++++++-
Mumtool/app/api/report/window/route.ts | 7+++++--
Mumtool/bin/umtool.mjs | 47++++++++++++++++++++++++++++++++++++++++-------
Mumtool/components/projects/ClipBench.tsx | 218++++++++++++++++++++++++++++++++++++-------------------------------------------
Mumtool/components/projects/ClipBenchPage.tsx | 10+++++++++-
Mumtool/components/projects/DeliverSection.tsx | 8++++----
Mumtool/components/projects/TakeWalkPage.tsx | 10+++++++---
Mumtool/components/projects/report/CutTab.tsx | 7++++---
Mumtool/components/projects/review/AuditionDeck.tsx | 6+++++-
Mumtool/components/projects/review/ClipDeck.tsx | 2+-
Mumtool/components/projects/review/PlayCut.tsx | 82++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Mumtool/components/projects/review/ReelStrip.tsx | 16++++++++--------
Aumtool/components/projects/review/RejectClip.tsx | 430+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dumtool/components/projects/review/WrongSpeaker.tsx | 161-------------------------------------------------------------------------------
Mumtool/docs/cli.md | 3++-
Mumtool/docs/clip-bench.md | 49++++++++++++++++++++++++++++++++++++++-----------
Mumtool/docs/inbox.md | 1+
Mumtool/docs/knobs.md | 29+++++++++++++++++------------
Mumtool/docs/piece.md | 2+-
Mumtool/docs/report-video.md | 60+++++++++++++++++++++++++++++++++++++++++++-----------------
Mumtool/e2e/bench-shell.spec.ts | 12++++++------
Mumtool/e2e/clip-bench.spec.ts | 85++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Mumtool/e2e/fixtures/make-fixture.mjs | 5++++-
Mumtool/e2e/phone-walk.spec.ts | 11++++++++---
Mumtool/e2e/play-modules.spec.ts | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Mumtool/e2e/take-walk.spec.ts | 8+++++---
Mumtool/lib/inbox/groups.mjs | 1+
Mumtool/lib/inbox/what.mjs | 1+
Mumtool/lib/projects/report.mjs | 36+++++++++++++++++++++++++++++++++---
Mumtool/lib/report/deliver.mjs | 7++++++-
Mumtool/lib/report/knobsCli.mjs | 23++++++++++++++++-------
Mumtool/lib/report/manifest.mjs | 104+++++++++++++++++++++++++++++++-------------------------------------------------
Mumtool/lib/report/playView.mjs | 18+++++++++++++++---
Aumtool/lib/report/reject-reasons.test.mjs | 181+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/report/rejectReasons.mjs | 197+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/timelineCli.mjs | 33++++++++++++++++++++++++++++-----
Mumtool/lib/report/walkCli.mjs | 5++++-
Mumtool/lib/report/walkData.mjs | 9++++++++-
38 files changed, 1458 insertions(+), 524 deletions(-)

diff --git a/umtool/app/api/report/timeline/route.ts b/umtool/app/api/report/timeline/route.ts @@ -8,6 +8,7 @@ import { manifestToken, moveEntry, removeEntry, + rejectClip, removeWrongSpeaker, removePost, undoStructural, @@ -33,6 +34,8 @@ export const dynamic = "force-dynamic"; // POST { project, token, op, ... } one op: // move { id, at?, toIndex } toIndex is the index AFTER the move // remove { id, at? } +// reject { id, at?, reason, note? } rejected (rejectReasons.mjs) and removed, on record +// wrong-speaker { id, at?, correction? } reject with the reason wrong-speaker // duplicate { id, at? } // insert { afterId: id | null, at?, entry: "<channel>/<video>@<start>-<end>" | { type, … } } // teaser { id, at?, patch: { lines?, beat?, dip?, tail?, tailWait? } } @@ -108,6 +111,9 @@ export async function POST(request: Request) { case "wrong-speaker": // Marked incorrect (wrong speaker) and removed in one write, on the record (removed.json). return removeWrongSpeaker(dir, id, { token, at, correction: typeof body.correction === "string" ? body.correction : null }); + case "reject": + // Rejected for `reason` (rejectReasons.mjs) and removed in one write, on the record (removed.json). + return rejectClip(dir, id, String(body.reason ?? ""), { token, at, note: typeof body.note === "string" ? body.note : null }); case "duplicate": return duplicateEntry(dir, id, { token, at }); case "insert": @@ -123,7 +129,7 @@ export async function POST(request: Request) { case "undo": return undoStructural(dir, { token }); default: - throw new Error("op must be move, remove, wrong-speaker, duplicate, insert, teaser, post, post-remove, factcheck or undo"); + throw new Error("op must be move, remove, reject, wrong-speaker, duplicate, insert, teaser, post, post-remove, factcheck or undo"); } }; diff --git a/umtool/app/api/report/window/route.ts b/umtool/app/api/report/window/route.ts @@ -59,9 +59,12 @@ export async function PUT(request: Request) { // plays on, in source seconds; empty or null clears it. Checked by the // writer against the clip's window, like the cut. "muteFrom", - // Whether the walk has looked at this clip: "confirmed", or empty to clear - // it. A non-empty `correction` is the other answer and needs no value. + // Whether the walk has looked at this clip: "confirmed", "incorrect" (a + // fact error, with its correction), "rejected" (with its `reason` and an + // optional `rejectNote`), or empty to clear it (lib/report/rejectReasons.mjs). "verdict", + "reason", + "rejectNote", // What the deck says over this clip: { title?, subtitle? }, or null to // clear it. Normalised and checked by the writer, like the date. "onscreen", diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -22,6 +22,7 @@ // umtool window <project> <clip> [--start S] [--end E] [--lock] [--lock-end] // [--title T] [--date YYYY-MM-DD] [--cite S] [--cite-url U] [--quote Q] // [--correction TEXT] [--verdict confirmed|incorrect|''] +// [--reject not-matching|wrong-speaker|irrelevant|repeats|weak|privacy|other [--note TEXT]] // [--cut-start S] [--cut-end E] [--lock-cut] the cut inside the extent // [--take <id>] a take's clip: the edit goes into the take's patch (walk a take) // umtool walk <project> [--take <id>] [--all] [--json] the walk: clips in walk order, verdicts, fetched @@ -114,7 +115,14 @@ import { EXPORT_FORMATS, exportProject } from "../lib/report/export.mjs"; import path from "node:path"; import { updateArticleLink, updateClip, updateStorage } from "../lib/report/manifest.mjs"; import { withEditNotes } from "../lib/report/edit-guard.mjs"; +import { rejectionOf } from "../lib/report/rejectReasons.mjs"; import { hms } from "umtool-report-to-video/attribution"; + +/** What the walk said about a clip, with why when it was rejected: "rejected (irrelevant: covered in c07)". */ +const reviewWords = (e) => { + const r = rejectionOf(e); + return r ? `${clipVerdict(e)} (${r.label}${!r.fact && r.note ? `: ${r.note}` : ""})` : clipVerdict(e); +}; import { buildSteps, checkSourcesSteps, PRESETS } from "../lib/report/driver.mjs"; import { sourceCountOf } from "umtool-report-to-video/manifest-sources"; import { runBuildOverHttp, umtoolBase } from "../lib/report/buildRun.mjs"; @@ -734,6 +742,9 @@ function usage() { " attribution too: --title, --date YYYY-MM-DD, --cite, --cite-url, --quote", " --correction TEXT what the REPORT got wrong here (never rendered)", " --verdict confirmed|incorrect what the walk said; incorrect needs --correction", + " --reject <why> [--note TEXT] rejected on the walk, kept in place (`umtool timeline <p> reject`", + " takes it out, on record): not-matching|wrong-speaker (fact errors: incorrect, the note its", + " correction) or irrelevant|repeats|weak|privacy|other (rejected; other needs --note)", " --cut-start S --cut-end E --lock-cut the cut the video renders", " an empty value (--title '') deletes the field", " --take <id> a take's clip (walk a take): the edit goes into takes/<id>/take.json's", @@ -1015,6 +1026,23 @@ async function cmdWindow() { ]) { if (val(flag) !== undefined) patch[key] = val(flag); } + // --reject <why>: the walk's Reject, kept in place (lib/report/rejectReasons.mjs). + // A fact reason (not-matching, wrong-speaker) is `incorrect` and its note is + // the correction; a cut reason is `rejected` and its note the rejectNote. + // `--note` is the rejection's note here, not the entry's. + const reject = val("--reject"); + if (reject !== undefined) { + if (patch.verdict !== undefined) die("--reject and --verdict are two verdicts: give one"); + const { rejectPatch, rejectReasonOf } = await import("../lib/report/rejectReasons.mjs"); + const fact = !!rejectReasonOf(String(reject).trim())?.fact; + const note = val("--note") ?? (fact ? val("--correction") : undefined); + delete patch.note; + try { + Object.assign(patch, rejectPatch(String(reject), note)); + } catch (e) { + die(e?.message ?? String(e)); + } + } if (!Object.keys(patch).length) die("nothing to change"); // --take <id>: the clip is the TAKE's (walk a take), and the edit goes into @@ -1028,7 +1056,7 @@ async function cmdWindow() { if (json) return out({ ok: true, take, ...res }); console.log(`${clipId} (take ${take}): ${res.before.start}–${res.before.end} -> ${res.entry.start}–${res.entry.end}`); if (res.entry.cutStart != null) console.log(` cut: ${res.entry.cutStart}–${res.entry.cutEnd}`); - if (patch.verdict !== undefined || patch.correction !== undefined) console.log(` review: ${clipVerdict(res.entry)}`); + if (patch.verdict !== undefined || patch.correction !== undefined) console.log(` review: ${reviewWords(res.entry)}`); if (res.entry.correction) console.log(` correction: ${res.entry.correction}`); console.log(` undo point: takes/${take}/${res.revision.rel} (umtool timeline ${p.id} --take ${take} undo)`); return; @@ -1071,7 +1099,10 @@ async function cmdWindow() { console.log(res.entry.correction ? ` correction: ${res.entry.correction}` : " correction cleared"); } if (patch.verdict !== undefined || patch.correction !== undefined) { - console.log(` review: ${clipVerdict(res.entry)}`); + console.log(` review: ${reviewWords(res.entry)}`); + } + if (reject !== undefined) { + console.log(` still in the cut: umtool timeline ${p.id} reject ${clipId} ${String(reject).trim()} takes it out, on the record (removed.json)`); } if (editNotes) { const n = editNotes.added + editNotes.updated; @@ -1142,7 +1173,7 @@ async function cmdCorrections() { // different when sixty clips have never been looked at. const review = reviewOf(manifest); - // Taken out of the cut on the record (Wrong speaker: manifest.mjs + // Taken out of the cut on the record (Reject: manifest.mjs rejectClip, // removed.json) and not back in it -- an undo puts a clip back. const inCut = new Set((manifest.timeline ?? []).map((e) => e?.id)); const { readRemoved } = await import("../lib/report/manifest.mjs"); @@ -1152,6 +1183,7 @@ async function cmdCorrections() { const summary = `${review.total} clips: ${review.incorrect} incorrect, ` + + (review.rejected ? `${review.rejected} rejected (not corrections), ` : "") + `${review.confirmed} confirmed (${review.confirmedWithNote} with a note), ` + `${review.unreviewed} not yet reviewed` + (review.unreviewedIds.length ? ` (ids: ${review.unreviewedIds.join(", ")})` : ""); @@ -1174,13 +1206,14 @@ async function cmdCorrections() { console.log(`\n## Taken out of the cut\n`); for (const r of removed) { const where = `${r.channel ?? manifest.provenance?.channelSlug ?? "?"}/${r.video ?? "?"} ${r.start ?? "?"}–${r.end ?? "?"}`; - console.log(`- **${r.id}** · ${where} · ${r.reason}${r.correction ? ` — ${r.correction}` : ""} · ${r.when}`); + console.log(`- **${r.id}** · ${where} · ${r.reason}${r.correction ? ` — ${r.correction}` : ""}${r.note ? ` — ${r.note}` : ""} · ${r.when}`); } } if (notes.length) { - console.log(`\n## Notes on confirmed clips\n`); - console.log(`These clips are RIGHT. The note says why the window moved, or what a`); - console.log(`reader should know -- not what to fix.\n`); + console.log(`\n## Notes on clips the report got right\n`); + console.log(`These clips are RIGHT (confirmed, or rejected from the cut for a reason that is`); + console.log(`not a fact error). The note says why the window moved, or what a reader should`); + console.log(`know -- not what to fix.\n`); for (const c of notes) bullet(c); } } diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx @@ -1,6 +1,7 @@ "use client"; -import WrongSpeaker from "./review/WrongSpeaker"; +import RejectClip, { type RejectClipControl } from "./review/RejectClip"; +import { rejectionOf } from "@/lib/report/rejectReasons.mjs"; import AnchoredNotes, { notesOn } from "@/components/notes/AnchoredNotes"; import GeneratedBanner from "@/components/notes/GeneratedBanner"; import { useSharedNotes, wroteNotes } from "@/components/notes/NotesProvider"; @@ -133,8 +134,12 @@ type Clip = { * before a finale's ending sound. Absent means the clip plays with its sound. */ muteFrom: number | null; - /** "confirmed" / "incorrect", or null for "nobody has looked at this yet". */ - verdict: "confirmed" | "incorrect" | null; + /** "confirmed" / "incorrect" / "rejected", or null for "nobody has looked at this yet". */ + verdict: "confirmed" | "incorrect" | "rejected" | null; + /** Why it was rejected (lib/report/rejectReasons.mjs): wrong-speaker under incorrect, a cut reason under rejected. */ + reason: string | null; + /** The rejection's note (a cut reason's; a fact reason's note is the correction). */ + rejectNote: string | null; /** What the on-screen panel says over this clip. Absent means the auto text. */ onscreen: Onscreen | null; }; @@ -152,8 +157,8 @@ const sameOs = (a: OsDraft, b: OsDraft) => a.title.trim() === b.title.trim() && * a `correction` with no verdict was written before `incorrect` existed and * means exactly that. */ -const verdictOf = (c: Clip): "incorrect" | "confirmed" | "unreviewed" => { - if (c.verdict === "confirmed" || c.verdict === "incorrect") return c.verdict; +const verdictOf = (c: Clip): "incorrect" | "confirmed" | "rejected" | "unreviewed" => { + if (c.verdict === "confirmed" || c.verdict === "incorrect" || c.verdict === "rejected") return c.verdict; return (c.correction ?? "").trim() ? "incorrect" : "unreviewed"; }; @@ -167,7 +172,10 @@ const verdictOf = (c: Clip): "incorrect" | "confirmed" | "unreviewed" => { const verdictLabel = (c: Clip): string => { const v = verdictOf(c); if (v === "confirmed") return (c.correction ?? "").trim() ? "confirmed · with note" : "confirmed"; - return v === "incorrect" ? "incorrect" : "not yet reviewed"; + // A rejection says WHY: "incorrect — wrong speaker" is a fact error, "rejected — irrelevant" is not. + const r = rejectionOf(c); + if (v === "incorrect") return `incorrect — ${r?.label ?? "doesn't match"}`; + return v === "rejected" ? `rejected — ${r?.label ?? "other"}` : "not yet reviewed"; }; /** The five fields that decide the burned-in header and the QR. */ @@ -177,7 +185,7 @@ const ATTRIB = [ ["cite", "cite", "The second the header prints, in absolute source seconds. Empty uses the clip's start."], ["citeUrl", "citeUrl", "Where the QR points. Empty derives it from the archive. Set it when the clip is cut from a mirror that reads better."], ["quote", "quote", "The words this clip exists for. Not drawn on screen — it is what the cut is checked against."], - ["correction", "correction", "On an incorrect clip: what the report got wrong — wrong speaker, wrong addressee, wrong date, read by the next report pass. On a confirmed one it is just a note: why the window moved, or something a reader should know. Never rendered."], + ["correction", "correction", "On an incorrect clip (rejected as doesn't match or wrong speaker): what the report got wrong — wrong speaker, wrong addressee, wrong date, read by the next report pass. On a confirmed or rejected-as-irrelevant one it is just a note: why the window moved, or something a reader should know. Never rendered."], ] as const; type AttribKey = (typeof ATTRIB)[number][0]; @@ -214,7 +222,9 @@ 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), - verdict: e.verdict === "confirmed" || e.verdict === "incorrect" ? e.verdict : null, + verdict: e.verdict === "confirmed" || e.verdict === "incorrect" || e.verdict === "rejected" ? e.verdict : null, + reason: (e.reason as string) ?? null, + rejectNote: (e.rejectNote as string) ?? null, onscreen: (e.onscreen as Onscreen | undefined) ?? null, }); @@ -531,10 +541,8 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { const [busy, setBusy] = useState<string | null>(null); const [dirty, setDirty] = useState(false); const [draft, setDraft] = useState<Record<AttribKey, string>>(() => emptyDraft(data.clip)); - // `x` was pressed and nothing has been typed yet: the box is REQUIRED until - // it has something in it. An incorrect verdict with no note is a complaint - // nobody can act on, so the bench asks for the note before it writes one. - const [needNote, setNeedNote] = useState(false); + // Reject ▾ (RejectClip): the verdict bar's button and `x` open its reasons. + const rejectCtl = useRef<RejectClipControl | null>(null); // The window an Extend (the verdict bar's) saved over, so Reset can put it // back: Extend saves at once -- its button names its result -- and Reset is // its undo. Null once undone, or after any other window save. @@ -569,8 +577,6 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { const token = useRef(data.token); // And they must not interleave: same read-modify-write, one clip. const saving = useRef<Promise<boolean>>(Promise.resolve(true)); - // `x` answers "no" by putting the cursor in the note, which is the answer. - const correctionBox = useRef<HTMLTextAreaElement | null>(null); const segVideo = useRef<HTMLVideoElement | null>(null); const transcriptBox = useRef<HTMLDivElement | null>(null); // One auto-audition per clip, keyed by id: `canplay` fires again after a @@ -1470,29 +1476,22 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { * note on a clip nobody has confirmed IS saying the clip is wrong, so the * verdict rides along in the SAME patch -- one write, one token, and never a * moment where the manifest holds a complaint with no verdict. On a clip - * already confirmed it is just a note and the verdict is left alone. + * already confirmed -- or rejected for a cut reason (irrelevant, weak, …), + * whose facts are right -- it is just a note and the verdict is left alone. */ const commit = useCallback( (k: AttribKey) => { if (draft[k] === attribValue(clip, k)) return; if (k === "correction") { const text = draft.correction.trim(); - // Armed and still empty: keep the cue and write nothing. Blurring out - // of a box you were asked to fill is not an answer. - if (!text && needNote && clip.verdict !== "incorrect") return; - // `needNote` is the "no" button having been pressed: on a confirmed clip - // the note is only a note UNLESS the walk just said no, in which case - // the verdict flips with it. - if (text && (clip.verdict !== "confirmed" || needNote)) { - void save({ correction: draft.correction, verdict: "incorrect" }).then((ok) => { - if (ok) setNeedNote(false); - }); + if (text && clip.verdict !== "confirmed" && clip.verdict !== "rejected") { + void save({ correction: draft.correction, verdict: "incorrect" }); return; } } void save({ [k]: draft[k] }); }, - [draft, clip, save, needNote], + [draft, clip, save], ); /** Persist the on-screen pair, on blur or Enter, if either field changed. */ @@ -1537,11 +1536,11 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { // ---- the walk's verdict --------------------------------------------------- // - // "Is this clip what the report says it is" is the question the walk exists - // to answer, and it has two answers: yes, or a note saying what is wrong. - // Confirming ADVANCES, because the next clip is what you want in the yes - // case; saying no stays put, because the note has to be typed -- and then - // re-read, which is why it still stays put once it is saved. + // "Is this clip right for the cut" is the question the walk exists to + // answer, and it has two answers: yes, or Reject ▾ with the reason (doesn't + // match, wrong speaker, irrelevant, repeats, weak, privacy, other -- + // RejectClip). Confirming ADVANCES, because the next clip is what you want + // in the yes case; rejecting stays put, with its Undo and a Next link. const confirmClip = useCallback(async () => { // A MOVED WINDOW RIDES ALONG. Confirming a clip whose edges you just nudged // is a judgement about THAT window, and the advance would otherwise walk @@ -1551,7 +1550,6 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { // A note survives a confirmation. It stops being a complaint and becomes // what it now says it is: why this clip is here in the shape it is in. const ok = await save({ verdict: "confirmed", ...(win ?? {}) }); - if (ok) setNeedNote(false); if (ok && win) setNote( win.cutStart !== undefined @@ -1654,28 +1652,14 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { router.push(to); }, [data.fromPlay, dirty, muteMoved, save, windowPatch, router]); + /** Reject ▾: the reasons (RejectClip) -- on a phone in a sheet, keyboard up; on the desk where the answer sits. */ const rejectClip = useCallback(() => { - setNeedNote(true); - // A confirmed clip that already carries a note (a "confirmed · with note") - // has its answer written: "no" flips the verdict NOW, rather than waiting - // for an edit to a note that may already say everything. Otherwise saying - // no and changing your mind on a yes would be impossible. - if (clip.verdict === "confirmed" && (clip.correction ?? "").trim()) { - void save({ verdict: "incorrect" }).then((ok) => { - if (ok) setNeedNote(false); - }); - } - // On a phone the note is written in a sheet, keyboard up, not in a box - // folded away under Attribution. if (isPhoneNow()) { setSheet(true); return; } - const el = correctionBox.current; - if (!el) return; - el.focus(); - el.setSelectionRange(el.value.length, el.value.length); - }, [clip, save]); + rejectCtl.current?.open(); + }, []); // ---- the mute mark --------------------------------------------------------- // @@ -2306,7 +2290,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { sentenceEnd != null ? ( <>Extend {clip.id} to the end of the sentence?</> ) : ( - <>Is {clip.id} what the report says it is?</> + <>Keep {clip.id} in the cut?</> ) } consequence={ @@ -2318,13 +2302,11 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { ? `, overlapping ${covered.map((sb) => sb.id).join(", ")}` : "") + (pastCache ? " — past what is fetched." : ".") - : needNote && !draft.correction.trim() - ? "The note is the answer — type it, then blur or Enter." - : verdict === "unreviewed" - ? data.next - ? `Confirming saves it${windowMoved || muteMoved ? " with the window you moved" : ""} and opens ${data.next}.` - : `Confirming saves it${windowMoved || muteMoved ? " with the window you moved" : ""}; it is the walk's last.` - : undefined + : verdict === "unreviewed" + ? data.next + ? `Confirming saves it${windowMoved || muteMoved ? " with the window you moved" : ""} and opens ${data.next}.` + : `Confirming saves it${windowMoved || muteMoved ? " with the window you moved" : ""}; it is the walk's last.` + : undefined } > {sentenceEnd != null && @@ -2370,15 +2352,21 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { > Yes, confirmed <kbd>y</kbd> </button> - <button type="button" data-verdict-no="" className={buttonVariants({ size: "md" })} onClick={rejectClip}> - No, note what is wrong <kbd>x</kbd> + <button + type="button" + data-verdict-no="" + className={buttonVariants({ size: "md" })} + onClick={rejectClip} + title="take it out, and say why: doesn't match, wrong speaker, irrelevant, repeats, weak, privacy, other" + > + Reject ▾ <kbd>x</kbd> </button> <span data-verdict-state="" className={ verdict === "confirmed" ? "text-[12px] text-[var(--color-good)]" - : verdict === "incorrect" + : verdict === "incorrect" || verdict === "rejected" ? "text-[12px] text-[var(--color-dirty)]" : "text-[12px] text-[var(--color-dim)]" } @@ -2665,7 +2653,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { {note} </span> )} - <span data-walk-verdict={verdict} className={cn("ml-auto", verdict === "confirmed" ? "text-kept-text" : verdict === "incorrect" ? "text-doubt-text" : "text-muted")}> + <span data-walk-verdict={verdict} className={cn("ml-auto", verdict === "confirmed" ? "text-kept-text" : verdict === "incorrect" || verdict === "rejected" ? "text-doubt-text" : "text-muted")}> {verdictLabel(clip)} </span> </div> @@ -2699,10 +2687,45 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { )} </> ); - const closeSheet = () => { - setSheet(false); - if (!draft.correction.trim()) setNeedNote(false); - }; + const closeSheet = () => setSheet(false); + /** + * Reject ▾ (RejectClip) on this clip: the bench's own writer for a keep in + * place (its token, its state), the project's structural write for a + * removal -- and on a take's walk, a keep only (a take's timeline is a patch). + */ + const rejectPanel = (className: string, opened = false) => ( + <RejectClip + project={data.project} + take={takeId ?? null} + hotkey={opened ? false : "digits"} + control={opened ? undefined : rejectCtl} + initialOpen={opened} + write={(patch) => save(patch)} + clip={{ + id: clip.id, + video: clip.video, + channel: clip.channel, + start: clip.start, + end: clip.end, + verdict: clip.verdict, + reason: clip.reason, + correction: clip.correction, + rejectNote: clip.rejectNote, + }} + className={className} + after={ + hrefOf("next") ? ( + <a href={hrefOf("next")!} data-reject-next="" className="ink-link"> + Next clip › + </a> + ) : data.fromPlay ? ( + <a href={data.fromPlay.href} className="ink-link"> + ‹ Back to the cut + </a> + ) : null + } + /> + ); const phoneDock = ( <> {undo && ( @@ -2751,7 +2774,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { onClick={rejectClip} className={cn(buttonVariants({ variant: "outline", size: "md" }), "h-12 min-w-0 flex-1 whitespace-normal px-2 text-[13.5px] leading-tight")} > - Note what&rsquo;s wrong + Reject… </button> <button type="button" @@ -2778,7 +2801,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { <div role="dialog" aria-modal="true" - aria-label="Note what's wrong" + aria-label={`Reject ${clip.id}`} data-walk-sheet="" className="fixed inset-0 z-50 flex flex-col justify-end bg-[color-mix(in_srgb,var(--ground)_70%,transparent)] md:hidden" onClick={closeSheet} @@ -2789,35 +2812,15 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { > <div aria-hidden className="mx-auto mb-2 h-1 w-10 rounded-full bg-seam-2" /> <p className="m-0 text-[15px] text-text"> - What is wrong with <span className="font-mono">{clip.id}</span>? + Reject <span className="font-mono">{clip.id}</span> — why? </p> <p className="m-0 mt-0.5 text-[12.5px] text-muted"> - Speaker, addressee, date, wording… Saving marks it incorrect, and the walk stays on it. + Doesn&rsquo;t match and wrong speaker are corrections for the report; the rest say the clip just does not belong in this cut. </p> - <textarea - autoFocus - rows={4} - data-walk-note-field="" - aria-label={`what is wrong with ${clip.id}`} - value={draft.correction} - onChange={(e) => setDraft((d) => ({ ...d, correction: e.target.value }))} - className="mt-2 w-full rounded-[3px] border border-seam-2 bg-ground px-2 py-2 text-[16px] text-text outline-none focus:border-signal" - /> + {rejectPanel("text-[14px] mt-2", true)} <div className="mt-2 flex gap-2"> - <button - type="button" - data-walk-note-save="" - disabled={!draft.correction.trim() || !!busy} - onClick={() => { - commit("correction"); - setSheet(false); - }} - className={cn(buttonVariants({ variant: "go", size: "md" }), "h-12 flex-1 text-[14px]")} - > - Save note - </button> - <button type="button" onClick={closeSheet} className={cn(buttonVariants({ variant: "quiet", size: "md" }), "h-12 px-4 text-[14px]")}> - Cancel + <button type="button" data-walk-sheet-close="" onClick={closeSheet} className={cn(buttonVariants({ variant: "quiet", size: "md" }), "h-12 px-4 text-[14px]")}> + Close </button> </div> </div> @@ -3783,25 +3786,8 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { <span className="text-[var(--color-text)]">{data.uploadDate || "—"}</span> </div> - {/* Wrong speaker: this clip out of the cut, on record, with an undo (the project's cut, not a take's walk). */} - {!takeId && ( - <WrongSpeaker - project={data.project} - clip={{ id: clip.id, video: clip.video, channel: clip.channel, start: clip.start, end: clip.end }} - className={secBody("attribution", "max-md:order-[81]")} - after={ - hrefOf("next") ? ( - <a href={hrefOf("next")!} data-wrong-speaker-next="" className="ink-link"> - Next clip › - </a> - ) : data.fromPlay ? ( - <a href={data.fromPlay.href} className="ink-link"> - ‹ Back to the cut - </a> - ) : null - } - /> - )} + {/* Reject ▾: this clip out of the cut for a reason, on record, with an undo (a take's walk: kept in place). */} + {!sheet && rejectPanel(secBody("attribution", "max-md:order-[81]"))} {/* ---- the six fields that decide the header ---- Each field's reason is a tooltip now rather than a paragraph: the @@ -3812,9 +3798,6 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { return ( <label key={k} className="block" title={why}> <span className="font-mono text-[11px] text-[var(--color-text)]">{label}</span> - {k === "correction" && needNote && !draft.correction.trim() && ( - <span className="ml-2 text-[11px] text-[var(--color-dirty)]">required</span> - )} {changed && ( <span className="ml-2 text-[11px] text-[var(--color-dirty)]"> unsaved — was {attribValue(clip, k) || "(empty)"} @@ -3824,7 +3807,6 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { <textarea data-attrib-field={k} name={k} - ref={k === "correction" ? correctionBox : undefined} rows={3} value={draft[k]} placeholder={ @@ -3834,11 +3816,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) { } onChange={(e) => setDraft((d) => ({ ...d, [k]: e.target.value }))} onBlur={() => commit(k)} - className={`mt-0.5 w-full rounded border bg-[var(--color-panel-2)] px-2 py-1 text-[12px] ${ - k === "correction" && needNote && !draft.correction.trim() - ? "border-[var(--color-dirty)]" - : "border-[var(--color-line)]" - }`} + className="mt-0.5 w-full rounded border border-[var(--color-line)] bg-[var(--color-panel-2)] px-2 py-1 text-[12px]" /> ) : ( <input diff --git a/umtool/components/projects/ClipBenchPage.tsx b/umtool/components/projects/ClipBenchPage.tsx @@ -109,7 +109,15 @@ export default async function ClipBenchPage({ ((manifest.timeline ?? []) as { id: string; muteFrom?: number }[]).find((e) => e.id === clipId) ?.muteFrom ?? null, verdict: - entry.verdict === "confirmed" || entry.verdict === "incorrect" ? entry.verdict : null, + entry.verdict === "confirmed" || entry.verdict === "incorrect" || entry.verdict === "rejected" ? entry.verdict : null, + // Why it was rejected (lib/report/rejectReasons.mjs), from the manifest's own entry. + ...(() => { + const own = ((manifest.timeline ?? []) as { id: string; reason?: unknown; rejectNote?: unknown }[]).find((e) => e.id === clipId); + return { + reason: typeof own?.reason === "string" ? own.reason : null, + rejectNote: typeof own?.rejectNote === "string" ? own.rejectNote : null, + }; + })(), // From the manifest's own entry: what the on-screen panel says over this // clip, when somebody has written it. onscreen: diff --git a/umtool/components/projects/DeliverSection.tsx b/umtool/components/projects/DeliverSection.tsx @@ -32,12 +32,12 @@ type Section = { type State = { sections: Section[]; - review: { total: number; confirmed: number; incorrect: number; unreviewed: number }; + review: { total: number; confirmed: number; incorrect: number; rejected?: number; unreviewed: number }; cut: number; needCut: { id: string; seconds: number }[]; notFetched: string[]; batches: { name: string; label: string; count: number; hasList: boolean }[]; - excluded: { shared: string[]; incorrect: string[] }; + excluded: { shared: string[]; incorrect: string[]; rejected?: string[] }; candidates: { id: string; section: string; file: string }[]; nextName: string; variants: { file: string; module: string; out: string }[]; @@ -87,7 +87,7 @@ export default async function DeliverSection({ <div className="mb-1.5 flex flex-wrap items-baseline gap-3"> <h2 className="micro">deliver</h2> <span className="num text-[11px] text-[var(--color-dim)]"> - {review.confirmed} confirmed · {review.incorrect} incorrect · {review.unreviewed} not yet + {review.confirmed} confirmed · {review.incorrect} incorrect{review.rejected ? ` · ${review.rejected} rejected` : ""} · {review.unreviewed} not yet judged · {state.cut} of {review.confirmed} cut </span> </div> @@ -317,7 +317,7 @@ export default async function DeliverSection({ The next one ships {state.candidates.length} clip {state.candidates.length === 1 ? "" : "s"}: every confirmed clip with a file, minus the{" "} {state.excluded.shared.length} already shared and the {state.excluded.incorrect.length}{" "} - ruled incorrect. + ruled incorrect{state.excluded.rejected?.length ? ` and the ${state.excluded.rejected.length} rejected` : ""}. </p> {state.variants.length > 0 && ( diff --git a/umtool/components/projects/TakeWalkPage.tsx b/umtool/components/projects/TakeWalkPage.tsx @@ -17,7 +17,7 @@ import TakeActions from "./TakeActions"; // (`…/takes/<take>/clip/<id>`), whose saves go into the take's patch. // `umtool walk <project> --take <take>` prints the same reading. -const VERDICT_TONE = { confirmed: "on", incorrect: "meter", unreviewed: "state" } as const; +const VERDICT_TONE = { confirmed: "on", incorrect: "meter", rejected: "meter", unreviewed: "state" } as const; export default async function TakeWalkPage({ project, @@ -110,8 +110,12 @@ export default async function TakeWalkPage({ </td> <td className="num py-1 pr-2 text-right">{c.seconds.toFixed(1)}</td> <td className="py-1 pr-2"> - <span className={badgeVariants({ variant: VERDICT_TONE[c.verdict as keyof typeof VERDICT_TONE] ?? "state", size: "sm" })}>{c.verdict}</span> - {c.correction && <span className="block text-[11px] text-doubt-text">{c.correction}</span>} + <span className={badgeVariants({ variant: VERDICT_TONE[c.verdict as keyof typeof VERDICT_TONE] ?? "state", size: "sm" })}> + {c.rejected ? `${c.verdict} — ${c.rejected.label}` : c.verdict} + </span> + {(c.rejected?.fact ? c.correction : (c.rejected?.why ?? c.correction)) && ( + <span className="block text-[11px] text-doubt-text">{c.rejected?.fact ? c.correction : c.rejected ? c.rejected.why : c.correction}</span> + )} </td> <td className="py-1 pr-2 text-text-2">{c.quote}</td> </tr> diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx @@ -34,7 +34,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor at: number; href: string; text: string; - verdict: "confirmed" | "incorrect" | "unreviewed"; + verdict: "confirmed" | "incorrect" | "rejected" | "unreviewed"; }[]; const clips = entries.filter((e) => e.kind === "clip"); // How much of the cut has been walked. One definition, shared with the bench @@ -151,6 +151,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor <span className="text-[11px] text-[var(--color-dim)]" data-walk-progress=""> <kbd>p</kbd> / <kbd>n</kbd> move between clips · {review.reviewed} of {review.total}{" "} reviewed{review.incorrect > 0 ? ` · ${review.incorrect} incorrect` : ""} + {review.rejected > 0 ? ` · ${review.rejected} rejected` : ""} {" · "} <span data-ready-count=""> ready {readiness.ready} of {readiness.needing} needing judgement @@ -410,7 +411,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor corrections for the next pass —{" "} {corrections.filter((c) => c.verdict === "incorrect").length} {corrections.some((c) => c.verdict !== "incorrect") && - ` · ${corrections.filter((c) => c.verdict !== "incorrect").length} notes on confirmed clips`} + ` · ${corrections.filter((c) => c.verdict !== "incorrect").length} notes on clips the report got right`} </h2> <ul className="space-y-1.5"> {corrections.map((c) => ( @@ -423,7 +424,7 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor {/* A note on a CONFIRMED clip is not a defect, and a reader who cannot tell the two apart goes off to fix a clip nobody complained about. */} - {c.verdict !== "incorrect" && <Pill>note · confirmed</Pill>}{" "} + {c.verdict !== "incorrect" && <Pill>note · {c.verdict === "rejected" ? "rejected, facts right" : "confirmed"}</Pill>}{" "} <Link href={clipBenchHref(project.id, c.id)} className="ink-link font-mono text-[11px]" diff --git a/umtool/components/projects/review/AuditionDeck.tsx b/umtool/components/projects/review/AuditionDeck.tsx @@ -7,6 +7,7 @@ import { buttonVariants } from "@/components/ui/button"; import { awaitingReview } from "@/lib/inbox/drafts.mjs"; import { editTextOf, isEditableField } from "@/lib/report/draftEdit.mjs"; import { litCount, spokenWords } from "@/lib/clips/words"; +import { REJECT_REASONS } from "@/lib/report/rejectReasons.mjs"; import { cn } from "@/lib/utils"; import { useDrafts, type DraftRow, type DraftsView } from "../drafts"; import type { FieldEvidence, FieldProvenance } from "../MediaDrafts"; @@ -34,7 +35,10 @@ import type { FieldEvidence, FieldProvenance } from "../MediaDrafts"; type Decision = "kept" | "cut" | "edited"; type Undo = { address: string; kind: "kept" | "cut" | "skip"; prev: { verdict: DraftRow["verdict"]; note: string } }; -const CUT_REASONS = ["misheard", "wrong moment", "says something else", "too long", "wrong speaker"]; +// The walk's reject vocabulary (lib/report/rejectReasons.mjs: doesn't match, wrong speaker, irrelevant, +// repeats, weak, privacy), with the two a drafted MOMENT can also be wrong by, and "too long". A chip +// is words in the note, never a verdict on the clip. +const CUT_REASONS = ["misheard", "wrong moment", ...REJECT_REASONS.filter((r) => r.id !== "other").map((r) => r.label), "too long"]; const THRESHOLD = 0.3; const FLICK = 0.6; const UNDO_DEPTH = 20; diff --git a/umtool/components/projects/review/ClipDeck.tsx b/umtool/components/projects/review/ClipDeck.tsx @@ -40,7 +40,7 @@ type Plan = { kept: { id: string; n: number | null; of: number | null; match: st const VERDICT_OF: Record<Dir, Verdict> = { right: "keep", left: "cut", down: "not-him", up: "read-aloud" }; const STAMP: Record<Verdict, string> = { keep: "KEEP", cut: "CUT", "not-him": "NOT HIM", "read-aloud": "READ ALOUD" }; const WORDS: Record<Verdict, string> = { keep: "kept", cut: "cut", "not-him": "not him", "read-aloud": "read aloud" }; -const REASONS = ["co-host", "guest", "a clip played", "a post read out", "chat read out", "wrong moment", "says something else"]; +const REASONS = ["co-host", "guest", "a clip played", "a post read out", "chat read out", "wrong moment", "doesn't match"]; const SHOWS: { show: ClipDeckShow; label: string }[] = [ { show: "unruled", label: "Unruled" }, { show: "doubtful", label: "Doubtful first" }, diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -21,7 +21,7 @@ import { usePlayEngine } from "./playEngine/usePlayEngine"; import { useRenderCuts, type RenderCuts } from "./playEngine/useRenderCuts"; import type { EngineInfo, MediaRef } from "./playEngine/engine"; import ReelStrip, { type StripCounter } from "./ReelStrip"; -import WrongSpeaker from "./WrongSpeaker"; +import RejectClip from "./RejectClip"; // --------------------------------------------------------------------------- // THE PLAY VIEW (umtool/docs/knobs.md, "Play the cut"): a screening room. The @@ -101,8 +101,10 @@ export type PlayEntry = { cutEnd?: number | null; blur?: { on?: boolean; caption?: string; strength?: number; from?: number; to?: number } | null; media?: (MediaRef & { from: number; to: number }) | null; - /** Ruled incorrect by the walk: its correction (skipped unless "Show clips marked incorrect"). */ - incorrect?: string | null; + /** Rejected by the walk -- a fact error or a cut reason -- and why (skipped unless "Show rejected clips"). */ + rejected?: { reason: string; label: string; fact: boolean; why: string } | null; + /** The verdict's fields as written (Reject prefills from them; its keep-in-place Undo writes them back). */ + review?: { verdict: string | null; reason: string | null; correction: string | null; rejectNote: string | null }; }; export type PlayViewData = { @@ -137,8 +139,9 @@ const SKIP_S = 5; /** The player is as wide as leaves the strip and Now on screen under it (never under 480 px). */ const PLAYER_MAX_W = "max(480px, min(1100px, calc((100dvh - 430px) * 16 / 9)))"; const PAUSE_KEY = "umtool.play.pauseWhileWriting"; -/** "on": play the clips ruled incorrect too (for re-review); absent or "off": skip them. */ -const SHOW_INCORRECT_KEY = "umtool.play.showIncorrect"; +/** "on": play the clips the walk rejected too (for re-review); absent or "off": skip them. */ +// The key keeps its old name: a browser that chose "show" before rejections had reasons still has. +const SHOW_REJECTED_KEY = "umtool.play.showIncorrect"; /** The dailies' kinds of note: what it asks for, and its key (with Alt, in the composer). */ const ASKS: { id: CutAsk; label: string; key: string }[] = [ @@ -160,6 +163,7 @@ const KEYS: { keys: string; what: string }[] = [ { keys: "[ ]", what: "previous / next note" }, { keys: "M", what: "note at the playhead" }, { keys: "E", what: "edit this clip on the bench (Back returns here)" }, + { keys: "X then 1–7", what: "reject this clip, and why (doesn't match, wrong speaker, irrelevant, repeats, weak, privacy, other)" }, { keys: "Alt+T C M F L O", what: "the note's kind, while writing" }, { keys: "Enter", what: "save the note (Shift+Enter: a new line)" }, { keys: "Esc", what: "close the note, or this" }, @@ -259,21 +263,23 @@ export default function PlayCut({ // The render's edges (useRenderCuts: the build's snap), asked again when an entry's edges change. const edgesKey = useMemo(() => JSON.stringify(view.entries.map((e) => [e.id, e.start, e.end, e.cutStart, e.cutEnd])), [view.entries]); const edges = useRenderCuts(project, take, edgesKey); - // Clips ruled incorrect (the walk's verdict) are SKIPPED unless asked for: - // the cut the operator means to ship does not hold them (umtool check - // blocks on them, a take refuses them). Remembered per browser. - const [showIncorrect, setShowIncorrect] = useState(false); + // Clips the walk REJECTED (a fact error, or irrelevant, weak, …) are SKIPPED + // unless asked for: the cut the operator means to ship does not hold them + // (umtool check blocks on a fact error and lists the rest). Remembered per browser. + const [showRejected, setShowRejected] = useState(false); useEffect(() => { try { // The URL first (Back from the bench lands on the URL Play left), then this browser's choice. - const u = new URLSearchParams(window.location.search).get("incorrect"); - if (u === "1" || (u === null && window.localStorage.getItem(SHOW_INCORRECT_KEY) === "on")) setShowIncorrect(true); + const q = new URLSearchParams(window.location.search); + // `incorrect=1`: a link written before rejections had reasons. + const u = q.get("rejected") ?? q.get("incorrect"); + if (u === "1" || (u === null && window.localStorage.getItem(SHOW_REJECTED_KEY) === "on")) setShowRejected(true); } catch { // No storage: skipped, the default. } }, []); - const incorrect = useMemo(() => view.entries.filter((e) => e.incorrect), [view.entries]); - const skipIds = useMemo(() => new Set(showIncorrect ? [] : incorrect.map((e) => e.id)), [showIncorrect, incorrect]); + const rejected = useMemo(() => view.entries.filter((e) => e.rejected), [view.entries]); + const skipIds = useMemo(() => new Set(showRejected ? [] : rejected.map((e) => e.id)), [showRejected, rejected]); const plan = useMemo( () => skipEntries(playPlan(segments, view.entries, { leadIn, cuts: edges.cuts }), skipIds), [segments, view.entries, leadIn, edges.cuts, skipIds], @@ -309,7 +315,7 @@ export default function PlayCut({ // Let go once both have settled. A card keeps its offset. const anchor = useRef<{ clip: string; at: number; src?: number; t?: number } | null>(initialAt); // THE PLACE IN THE URL: Play keeps where it is -- the clip, the offset into - // it, the cut second and the incorrect-clips toggle -- in its own URL + // it, the cut second and the rejected-clips toggle -- in its own URL // (replaceState, at most once a second, never a history entry of its own), // so the browser's Back from the clip bench (one push, Edit this clip) // lands here, paused at the same place. A page restored without the @@ -349,7 +355,7 @@ export default function PlayCut({ } }, [plan, composeState, edges.state, seekTo]); - // A structural write landed (Wrong speaker, its undo): the view and the chrome are read again. + // A structural write landed (Reject, its undo): the view and the chrome are read again. const afterStructure = useCallback(() => { setPlaying(false); router.refresh(); @@ -456,10 +462,11 @@ export default function PlayCut({ u.searchParams.set("at", (Math.round(Math.max(0, e.t - it.from) * 100) / 100).toFixed(2)); u.searchParams.set("t", (Math.round(e.t * 100) / 100).toFixed(2)); } - if (showIncorrect) u.searchParams.set("incorrect", "1"); - else u.searchParams.delete("incorrect"); + u.searchParams.delete("incorrect"); + if (showRejected) u.searchParams.set("rejected", "1"); + else u.searchParams.delete("rejected"); return `${u.pathname}${u.search}${u.hash}`; - }, [now, showIncorrect]); + }, [now, showRejected]); const editHere = useCallback(() => { const h = editHref(); if (!h) return; @@ -480,7 +487,7 @@ export default function PlayCut({ const wait = ui.playing ? 1000 - (performance.now() - lastPlace.current) : 150; const id = setTimeout(due, Math.max(0, wait)); return () => clearTimeout(id); - }, [ui.t, ui.cur, ui.playing, showIncorrect, placeHref]); + }, [ui.t, ui.cur, ui.playing, showRejected, placeHref]); // ---- the keys ---------------------------------------------------------------------- const [help, setHelp] = useState(false); @@ -810,13 +817,19 @@ export default function PlayCut({ </button> </p> )} - {/* Wrong speaker: the clip on screen out of the cut, on record, with an undo (the project's cut: not on a take). */} + {/* Reject ▾ (x): the clip on screen out of the cut for a reason, on record, with an undo (the project's cut: not on a take). */} {!take && ( - <WrongSpeaker + <RejectClip project={project} - clip={item?.clip && entry ? { id: item.id, video: entry.video ?? null, channel: entry.channel ?? null, start: entry.start ?? null, end: entry.end ?? null } : null} + hotkey + clip={ + item?.clip && entry + ? { id: item.id, video: entry.video ?? null, channel: entry.channel ?? null, start: entry.start ?? null, end: entry.end ?? null, ...(entry.review ?? {}) } + : null + } onRemoved={afterStructure} onUndone={afterStructure} + onKept={afterStructure} /> )} {composeState === "error" && ( @@ -840,38 +853,39 @@ export default function PlayCut({ timecode={timecode} onSeek={seekTo} onSeekItem={(i) => seekTo(startOf(planRef.current, i))} - skipped={plan.skipped.map((x) => ({ ...x, correction: entryOf.get(x.id)?.incorrect ?? "" }))} + skipped={plan.skipped.map((x) => ({ ...x, why: entryOf.get(x.id)?.rejected?.why ?? "" }))} /> - {incorrect.length > 0 && ( - <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px] text-muted" data-play-incorrect={incorrect.map((e) => e.id).join(" ")}> + {rejected.length > 0 && ( + <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px] text-muted" data-play-rejected={rejected.map((e) => e.id).join(" ")}> <span> - {showIncorrect ? "Playing" : "Skipping"} {incorrect.length} clip{incorrect.length === 1 ? "" : "s"} marked incorrect:{" "} - {incorrect.map((e, k) => ( + {showRejected ? "Playing" : "Skipping"} {rejected.length} rejected clip{rejected.length === 1 ? "" : "s"}:{" "} + {rejected.map((e, k) => ( <span key={e.id}> {k > 0 ? ", " : ""} - <s className="font-mono" title={`${e.id}: ${e.incorrect}`} data-play-incorrect-id={e.id}> + <s className="font-mono" title={`${e.id}: rejected — ${e.rejected?.why ?? ""}`} data-play-rejected-id={e.id} data-play-rejected-reason={e.rejected?.reason ?? ""}> {e.id} </s> + <span className="text-muted-2"> ({e.rejected?.label})</span> </span> ))} - {!showIncorrect && <span title="the deck's pages are composed from the whole cut, so the tally still counts their marks"> · the deck still counts their marks</span>} + {!showRejected && <span title="the deck's pages are composed from the whole cut, so the tally still counts their marks"> · the deck still counts their marks</span>} </span> <label className="inline-flex items-center gap-1.5 text-text-2"> <input type="checkbox" - data-play-show-incorrect="" - checked={showIncorrect} + data-play-show-rejected="" + checked={showRejected} onChange={(ev) => { const on = ev.target.checked; - setShowIncorrect(on); + setShowRejected(on); try { - window.localStorage.setItem(SHOW_INCORRECT_KEY, on ? "on" : "off"); + window.localStorage.setItem(SHOW_REJECTED_KEY, on ? "on" : "off"); } catch { // A preference, not state. } }} /> - Show clips marked incorrect + Show rejected clips </label> </div> )} diff --git a/umtool/components/projects/review/ReelStrip.tsx b/umtool/components/projects/review/ReelStrip.tsx @@ -18,7 +18,7 @@ type PlayItem = ReturnType<typeof playPlan>["items"][number]; // counts the minutes. // --------------------------------------------------------------------------- -export type StripEntry = { id: string; type: string; heading: string; dateKey?: number | null; dateLabel?: string | null; media?: unknown; incorrect?: string | null }; +export type StripEntry = { id: string; type: string; heading: string; dateKey?: number | null; dateLabel?: string | null; media?: unknown; rejected?: { why: string } | null }; export type StripCounter = { id: string; label: string; steps: Array<{ t: number; n: number }> }; export type StripPin = { id: string; t: number; text: string; open: boolean }; export type StripSeam = { before: string; index: number; date: string | null; label: string | null }; @@ -53,8 +53,8 @@ export default function ReelStrip({ timecode: (t: number) => string; onSeek: (t: number) => void; onSeekItem: (i: number) => void; - /** Entries left out of the plan (clips ruled incorrect): a struck-through marker at the seam, the correction on hover. */ - skipped?: { id: string; at: number; correction: string }[]; + /** Entries left out of the plan (clips the walk rejected): a struck-through marker at the seam, why on hover. */ + skipped?: { id: string; at: number; why: string }[]; }) { const cells = useRef<HTMLDivElement | null>(null); const [hover, setHover] = useState<number | null>(null); @@ -159,7 +159,7 @@ export default function ReelStrip({ const e = entries.get(it.id); const f = ramp.get(it.id); const missing = noMedia(it); - const wrong = e?.incorrect ?? null; + const wrong = e?.rejected?.why ?? null; const base = it.clip ? `color-mix(in srgb, var(--seam-2) ${Math.round(30 + 60 * (f ?? 0.5))}%, var(--ground))` : "var(--panel)"; @@ -171,9 +171,9 @@ export default function ReelStrip({ data-play-row={it.id} aria-current={i === cur ? "true" : undefined} aria-label={`${it.id}${e?.dateLabel ? `, ${e.dateLabel}` : ""}, ${shownSeconds(it).toFixed(1)} seconds${missing ? ", no media" : ""}`} - title={wrong ? `${it.id}: marked incorrect — ${wrong}` : missing ? `${it.id}: no media — fetch it` : undefined} + title={wrong ? `${it.id}: rejected — ${wrong}` : missing ? `${it.id}: no media — fetch it` : undefined} data-play-row-missing={missing ? "" : undefined} - data-play-row-incorrect={wrong ? "" : undefined} + data-play-row-rejected={wrong ? "" : undefined} onClick={(ev) => { // A pointer's click scrubbed on pointerdown; a key's (Enter) jumps to the entry's start. if (ev.detail === 0) onSeekItem(i); @@ -198,12 +198,12 @@ export default function ReelStrip({ ); })} - {/* the entries skipped (ruled incorrect): a greyed, struck-through tag where they would play */} + {/* the entries skipped (rejected on the walk): a greyed, struck-through tag where they would play */} {skipped.map((x) => ( <span key={`skip:${x.id}`} data-play-skipped={x.id} - title={`${x.id} skipped — marked incorrect${x.correction ? `: ${x.correction}` : ""}`} + title={`${x.id} skipped — rejected${x.why ? ` — ${x.why}` : ""}`} className="absolute bottom-0 z-[1] -translate-x-1/2 rounded-[2px] bg-ground/90 px-0.5 font-mono text-[9px] leading-3 text-muted line-through opacity-80" style={{ left: pctOf(x.at, total) }} > diff --git a/umtool/components/projects/review/RejectClip.tsx b/umtool/components/projects/review/RejectClip.tsx @@ -0,0 +1,430 @@ +"use client"; + +import { useCallback, useEffect, useImperativeHandle, useRef, useState } from "react"; +import { buttonVariants } from "@/components/ui/button"; +import { REJECT_REASONS, rejectPatch, rejectReasonOf } from "@/lib/report/rejectReasons.mjs"; +import { cn } from "@/lib/utils"; +import { announceManifestChanged, refusalOf, timelineOp } from "../timelineApi"; + +// --------------------------------------------------------------------------- +// REJECT ▾: the walk's "this clip comes out", with the reason it comes out +// (operator, 2026-10-30: "non-matching being one reason among others"). +// lib/report/rejectReasons.mjs is the vocabulary: doesn't match and wrong +// speaker are FACT errors (verdict incorrect, a correction for the report); +// irrelevant, repeats, weak, privacy and other are CUT reasons (verdict +// rejected -- the report is right, the clip just does not belong here). +// +// `x` (when `hotkey`) opens the reasons, a digit picks one; Wrong speaker +// keeps its one-click button (the same flow, its reason preset). Asked in the +// page, never window.confirm: the reason, a note (required for doesn't match +// and other), then +// Remove <id> one structural write (POST /api/report/timeline +// `reject`, manifest.mjs rejectClip): marked, taken out +// of the cut, on record in removed.json; Undo is the +// structural undo (the clip back where it was). +// Reject, keep in place the verdict only (the clip writer), for removal +// later; Undo writes the verdict back as it was. +// A take's walk (`take`) only keeps in place: a take's timeline is a patch. +// --------------------------------------------------------------------------- + +export type RejectClipTarget = { + id: string; + video?: string | null; + channel?: string | null; + start?: number | null; + end?: number | null; + /** The verdict fields as they are now: prefill the note, and what a keep-in-place Undo writes back. */ + verdict?: string | null; + reason?: string | null; + correction?: string | null; + rejectNote?: string | null; +}; + +export type RejectClipControl = { open: () => void }; + +type Patch = Record<string, unknown>; +type Phase = + | { k: "idle" } + | { k: "menu" } + | { k: "asking"; reason: string } + | { k: "busy"; reason: string; removing: boolean } + | { k: "removed"; reason: string; notes: string[] } + | { k: "kept"; reason: string; prev: Patch } + | { k: "undone"; what: "removed" | "kept" }; + +const secs = (n: number | null | undefined) => (typeof n === "number" && Number.isFinite(n) ? `${n.toFixed(2)} s` : "?"); +const TYPING = "input, textarea, select, [contenteditable=''], [contenteditable='true']"; + +/** The clip writer's default: the clip's token, then PUT /api/report/window (a take's patch with `take`). */ +async function writeClip(project: string, clip: string, take: string | null, patch: Patch): Promise<string | null> { + const tq = take ? `&take=${encodeURIComponent(take)}` : ""; + const r = await fetch(`/api/report/clip?project=${encodeURIComponent(project)}&clip=${encodeURIComponent(clip)}${tq}`, { cache: "no-store" }); + if (!r.ok) return `could not read ${clip}: HTTP ${r.status}`; + const token = ((await r.json()) as { token?: string }).token ?? null; + const w = await fetch("/api/report/window", { + method: "PUT", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ project, clip, ...(take ? { take } : {}), token, ...patch }), + }); + if (w.ok) return null; + const j = (await w.json().catch(() => ({}))) as { error?: string; stale?: boolean }; + return j.stale ? "the manifest changed since — reload and try again" : String(j.error ?? `HTTP ${w.status}`); +} + +export default function RejectClip({ + project, + clip, + take = null, + hotkey = false, + initialOpen = false, + control, + write, + onRemoved, + onUndone, + onKept, + after, + className, +}: { + project: string; + /** The clip on screen; null (a card, nothing) shows only a removal still to undo. */ + clip: RejectClipTarget | null; + /** A take's walk: the verdict goes into the take's patch, and nothing is removed. */ + take?: string | null; + /** `x` opens the reasons, a digit picks one, Escape closes. "digits": the page's own `x` opens them (control). */ + hotkey?: boolean | "digits"; + /** Arrive with the reasons open (the phone's sheet). */ + initialOpen?: boolean; + /** For a page's own button (the verdict bar's) to open the reasons. */ + control?: React.Ref<RejectClipControl>; + /** The page's own clip writer (the bench's save: its token, its state); resolves true when it landed. */ + write?: (patch: Patch) => Promise<boolean>; + /** After the removal landed (the page re-reads what it plays). */ + onRemoved?: (id: string) => void; + /** After an undo landed (a removal's or a keep's). */ + onUndone?: (id: string) => void; + /** After a keep-in-place landed. */ + onKept?: (id: string) => void; + /** What follows the "removed" line (the bench's Next clip link). */ + after?: React.ReactNode; + className?: string; +}) { + const [phase, setPhase] = useState<Phase>(() => (initialOpen && clip ? { k: "menu" } : { k: "idle" })); + const [note, setNote] = useState(""); + const [error, setError] = useState<string | null>(null); + const [doneId, setDoneId] = useState<string | null>(null); + const noteBox = useRef<HTMLInputElement | null>(null); + const root = useRef<HTMLDivElement | null>(null); + + // A different clip on screen: whatever was being asked about the last one is dropped + // (a removal or a keep stays, with its Undo). + const clipId = clip?.id ?? null; + const lastClip = useRef(clipId); + useEffect(() => { + if (lastClip.current === clipId) return; + lastClip.current = clipId; + setPhase((p) => (p.k === "menu" || p.k === "asking" ? { k: "idle" } : p)); + setError(null); + }, [clipId]); + + const open = useCallback(() => { + if (!clip) return; + setError(null); + // A new rejection supersedes the last one's Undo line. + setDoneId(null); + setPhase({ k: "menu" }); + root.current?.scrollIntoView?.({ block: "nearest" }); + }, [clip]); + useImperativeHandle(control, () => ({ open }), [open]); + + const pick = useCallback( + (reason: string) => { + if (!clip) return; + const r = rejectReasonOf(reason); + // A fact reason's note is the correction; prefill what is already written. + setNote(r?.fact ? (clip.correction ?? "") : clip.verdict === "rejected" && clip.reason === reason ? (clip.rejectNote ?? "") : ""); + setError(null); + setDoneId(null); + setPhase({ k: "asking", reason }); + }, + [clip], + ); + useEffect(() => { + if (phase.k === "asking") noteBox.current?.focus(); + }, [phase]); + + const remove = async (reason: string) => { + if (!clip) return; + setPhase({ k: "busy", reason, removing: true }); + setError(null); + const res = await timelineOp(project, null, "reject", { id: clip.id, reason, ...(note.trim() ? { note: note.trim() } : {}) }); + if (!res.ok) { + setError(refusalOf(res)); + setPhase({ k: "asking", reason }); + return; + } + setDoneId(clip.id); + setNote(""); + setPhase({ k: "removed", reason, notes: Array.isArray(res.json.reanchored) ? (res.json.reanchored as string[]) : [] }); + announceManifestChanged(project); + onRemoved?.(clip.id); + }; + + const patchClip = async (id: string, patch: Patch): Promise<string | null> => { + if (write) return (await write(patch)) ? null : "not saved"; + const err = await writeClip(project, id, take, patch); + if (!err) announceManifestChanged(project); + return err; + }; + + const keep = async (reason: string) => { + if (!clip) return; + let patch: Patch; + try { + patch = rejectPatch(reason, note); + } catch (e) { + setError(e instanceof Error ? e.message : String(e)); + return; + } + // What a keep's Undo writes back: the verdict fields as they were. + const prev: Patch = { verdict: clip.verdict ?? "", reason: clip.reason ?? "", rejectNote: clip.rejectNote ?? "", correction: clip.correction ?? "" }; + setPhase({ k: "busy", reason, removing: false }); + setError(null); + const err = await patchClip(clip.id, patch); + if (err) { + setError(err); + setPhase({ k: "asking", reason }); + return; + } + setDoneId(clip.id); + setNote(""); + setPhase({ k: "kept", reason, prev }); + onKept?.(clip.id); + }; + + const undo = async () => { + const id = doneId ?? clip?.id ?? ""; + const was = phase; + if (was.k !== "removed" && was.k !== "kept") return; + setPhase({ k: "busy", reason: was.reason, removing: was.k === "removed" }); + setError(null); + if (was.k === "removed") { + const res = await timelineOp(project, null, "undo"); + if (!res.ok) { + setError(refusalOf(res)); + setPhase(was); + return; + } + announceManifestChanged(project); + } else { + // The previous verdict's own fields only: a rejectNote goes with `rejected` alone. + const back: Patch = { ...was.prev }; + if (back.verdict !== "rejected") delete back.rejectNote; + const err = await patchClip(id, back); + if (err) { + setError(`could not undo: ${err}`); + setPhase(was); + return; + } + } + setDoneId(null); + setPhase({ k: "undone", what: was.k }); + onUndone?.(id); + }; + + // ---- the keys: x opens, a digit picks, Escape closes ---- + const phaseRef = useRef(phase); + phaseRef.current = phase; + useEffect(() => { + if (!hotkey) return; + const onKey = (ev: KeyboardEvent) => { + const tgt = ev.target as HTMLElement | null; + if (ev.metaKey || ev.ctrlKey || ev.altKey) return; + const p = phaseRef.current; + if (ev.key === "Escape" && (p.k === "menu" || p.k === "asking")) { + setPhase({ k: "idle" }); + ev.preventDefault(); + return; + } + if (tgt?.closest(TYPING)) return; + if (hotkey === true && (ev.key === "x" || ev.key === "X") && clip && p.k !== "busy") { + if (p.k === "menu") setPhase({ k: "idle" }); + else open(); + ev.preventDefault(); + ev.stopImmediatePropagation(); + return; + } + if (p.k === "menu" && /^[1-9]$/.test(ev.key)) { + const r = REJECT_REASONS[Number(ev.key) - 1]; + if (!r) return; + pick(r.id); + ev.preventDefault(); + ev.stopImmediatePropagation(); + } + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [hotkey, clip, open, pick]); + + const shown = doneId ?? clip?.id ?? ""; + const asking = phase.k === "asking" || (phase.k === "busy" && !doneId) ? phase.reason : null; + const r = asking ? rejectReasonOf(asking) : null; + const doneReason = phase.k === "removed" || phase.k === "kept" || (phase.k === "busy" && doneId) ? rejectReasonOf(phase.reason) : null; + if (!clip && !doneId && phase.k !== "undone") return null; + const needNote = r?.note === "required" && !note.trim(); + return ( + <div ref={root} className={cn("text-[12px] text-text-2", className)} data-reject={shown} data-reject-phase={phase.k}> + {(phase.k === "idle" || phase.k === "undone" || phase.k === "menu") && ( + <div className="flex flex-wrap items-center gap-2"> + {clip && ( + <button + type="button" + data-reject-open="" + aria-expanded={phase.k === "menu"} + onClick={() => (phase.k === "menu" ? setPhase({ k: "idle" }) : open())} + className={cn(buttonVariants({ variant: "outline", size: "sm" }))} + title="take this clip out, and say why: doesn't match, wrong speaker, irrelevant, repeats, weak, privacy, other" + > + Reject ▾{hotkey ? <kbd className="ml-1">x</kbd> : null} + </button> + )} + {clip && ( + <button + type="button" + data-wrong-speaker-start="" + onClick={() => pick("wrong-speaker")} + className={cn(buttonVariants({ variant: "quiet", size: "sm" }))} + title="somebody else is talking: reject it as wrong speaker (a correction for the report) and take it out of the cut, with an undo" + > + Wrong speaker + </button> + )} + {phase.k === "undone" && ( + <span data-reject-undone="">{phase.what === "removed" ? "Undone: the clip is back in the cut." : "Undone: the verdict is as it was."}</span> + )} + </div> + )} + {clip && phase.k === "menu" && ( + <div role="menu" aria-label={`Reject ${clip.id} — why?`} data-reject-menu="" className="mt-1.5 flex flex-wrap gap-1.5"> + {REJECT_REASONS.map((x, i) => ( + <button + key={x.id} + type="button" + role="menuitem" + data-reject-reason={x.id} + title={x.hint} + onClick={() => pick(x.id)} + className={cn( + "rounded-[3px] border px-1.5 py-0.5 text-[11.5px]", + x.fact ? "border-seam-2 text-text" : "border-seam-2 text-text-2", + "hover:border-signal hover:text-text", + )} + > + <kbd className="mr-1 text-muted">{i + 1}</kbd> + {x.label} + </button> + ))} + </div> + )} + {clip && asking && r && ( + <div role="group" aria-label={`Reject ${clip.id}: ${r.label}`} data-reject-ask={asking} className="space-y-1.5 rounded-[3px] border border-seam-2 bg-panel p-2"> + <p className="m-0 text-text" data-reject-what=""> + Reject <span className="font-mono">{clip.id}</span> + {clip.video ? ( + <> + {" "} + ({clip.channel ? `${clip.channel}/` : ""} + {clip.video} {secs(clip.start)}–{secs(clip.end)}) + </> + ) : null}{" "} + as <strong>{r.label}</strong>?{" "} + <span className="text-text-2"> + {r.fact + ? `${r.hint}: marked incorrect, read by the next report pass.` + : `${r.hint[0].toUpperCase()}${r.hint.slice(1)} — the report is right; nothing here is a correction.`} + </span> + </p> + <input + ref={noteBox} + type="text" + data-reject-note="" + value={note} + onChange={(e) => setNote(e.target.value)} + onKeyDown={(e) => { + if (e.key === "Enter" && !needNote) { + e.preventDefault(); + void (take ? keep(asking) : remove(asking)); + } + }} + placeholder={r.placeholder} + aria-label={r.fact ? `what the report got wrong (${r.label})` : `why it comes out (${r.label})`} + maxLength={300} + className={cn( + "w-full rounded border bg-ground px-1.5 py-1 text-[12px] text-text outline-none focus:border-signal", + needNote ? "border-[var(--color-dirty)]" : "border-seam-2", + )} + /> + <div className="flex flex-wrap gap-2"> + {!take && ( + <button + type="button" + data-reject-remove="" + disabled={phase.k === "busy" || needNote} + onClick={() => void remove(asking)} + className={cn(buttonVariants({ variant: "go", size: "sm" }))} + title="out of the cut, on record (removed.json); Undo puts it back" + > + Remove {clip.id} + </button> + )} + <button + type="button" + data-reject-keep="" + disabled={phase.k === "busy" || needNote} + onClick={() => void keep(asking)} + className={cn(buttonVariants({ variant: take ? "go" : "outline", size: "sm" }))} + title={take ? "the verdict goes into the take's patch" : "the verdict only: the clip stays in the cut for now (umtool check lists it; Play the cut skips it)"} + > + Reject, keep in place + </button> + <button type="button" data-reject-cancel="" disabled={phase.k === "busy"} onClick={() => setPhase({ k: "idle" })} className={cn(buttonVariants({ variant: "quiet", size: "sm" }))}> + Cancel + </button> + </div> + </div> + )} + {doneId && doneReason && (phase.k === "removed" || phase.k === "kept" || phase.k === "busy") && ( + <div role="status" data-reject-done={shown} data-reject-done-as={phase.k === "busy" ? (phase.removing ? "removed" : "kept") : phase.k} className="space-y-1 rounded-[3px] border border-seam-2 bg-panel p-2"> + <div className="flex flex-wrap items-center gap-2"> + <span className="text-text" data-reject-said=""> + {phase.k === "kept" || (phase.k === "busy" && !phase.removing) ? ( + <> + Rejected <span className="font-mono">{shown}</span> ({doneReason.label}), still in the cut. + </> + ) : ( + <> + Removed <span className="font-mono">{shown}</span> from the cut ({doneReason.label}). + </> + )} + </span> + <button type="button" data-reject-undo="" disabled={phase.k === "busy"} onClick={() => void undo()} className={cn(buttonVariants({ variant: "outline", size: "sm" }))}> + Undo + </button> + {after} + </div> + {phase.k === "removed" && phase.notes.length > 0 && ( + <ul className="m-0 list-disc pl-5 text-[11.5px] text-muted" data-reject-reanchored=""> + {phase.notes.map((n) => ( + <li key={n}>{n}</li> + ))} + </ul> + )} + </div> + )} + {error && ( + <p role="alert" className="m-0 mt-1 text-[11.5px] text-reject-text"> + {error} + </p> + )} + </div> + ); +} diff --git a/umtool/components/projects/review/WrongSpeaker.tsx b/umtool/components/projects/review/WrongSpeaker.tsx @@ -1,161 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { buttonVariants } from "@/components/ui/button"; -import { cn } from "@/lib/utils"; -import { announceManifestChanged, refusalOf, timelineOp } from "../timelineApi"; - -// --------------------------------------------------------------------------- -// WRONG SPEAKER: the walk's one-click "this is somebody else talking". One -// structural write (POST /api/report/timeline `wrong-speaker`, -// manifest.mjs removeWrongSpeaker) marks the clip incorrect with the reason -// "wrong-speaker" and takes it out of the cut -- an undo point first, what -// named it re-anchored, the removal on record in removed.json. Asked in the -// page first (what will be removed, an optional note), never window.confirm; -// afterwards an Undo (the structural undo: the clip back where it was). -// -// The clip bench and Play the cut both carry it. -// --------------------------------------------------------------------------- - -export type WrongSpeakerClip = { id: string; video?: string | null; channel?: string | null; start?: number | null; end?: number | null }; - -type Phase = { k: "idle" } | { k: "asking" } | { k: "busy" } | { k: "removed"; notes: string[] } | { k: "undone" }; - -const secs = (n: number | null | undefined) => (typeof n === "number" && Number.isFinite(n) ? `${n.toFixed(2)} s` : "?"); - -export default function WrongSpeaker({ - project, - clip, - onRemoved, - onUndone, - after, - className, -}: { - project: string; - /** The clip on screen; null (a card, nothing) shows only a removal still to undo. */ - clip: WrongSpeakerClip | null; - /** After the removal landed (the page re-reads what it plays). */ - onRemoved?: (id: string) => void; - /** After the undo landed. */ - onUndone?: (id: string) => void; - /** What follows the "removed" line (the bench's Next clip link). */ - after?: React.ReactNode; - className?: string; -}) { - const [phase, setPhase] = useState<Phase>({ k: "idle" }); - const [note, setNote] = useState(""); - const [error, setError] = useState<string | null>(null); - const [removedId, setRemovedId] = useState<string | null>(null); - - const remove = async () => { - setPhase({ k: "busy" }); - setError(null); - if (!clip) return; - const res = await timelineOp(project, null, "wrong-speaker", { id: clip.id, ...(note.trim() ? { correction: note.trim() } : {}) }); - if (!res.ok) { - setError(refusalOf(res)); - setPhase({ k: "asking" }); - return; - } - setRemovedId(clip.id); - setNote(""); - setPhase({ k: "removed", notes: Array.isArray(res.json.reanchored) ? (res.json.reanchored as string[]) : [] }); - announceManifestChanged(project); - onRemoved?.(clip.id); - }; - const undo = async () => { - const id = removedId ?? clip?.id ?? ""; - setPhase({ k: "busy" }); - setError(null); - const res = await timelineOp(project, null, "undo"); - if (!res.ok) { - setError(refusalOf(res)); - setPhase({ k: "removed", notes: [] }); - return; - } - setRemovedId(null); - setPhase({ k: "undone" }); - announceManifestChanged(project); - onUndone?.(id); - }; - - const shown = removedId ?? clip?.id ?? ""; - if (!clip && (phase.k === "idle" || phase.k === "asking")) return null; - return ( - <div className={cn("text-[12px] text-text-2", className)} data-wrong-speaker={shown} data-wrong-speaker-phase={phase.k}> - {(phase.k === "idle" || phase.k === "undone") && ( - <div className="flex flex-wrap items-center gap-2"> - {clip && ( - <button - type="button" - data-wrong-speaker-start="" - onClick={() => setPhase({ k: "asking" })} - className={cn(buttonVariants({ variant: "outline", size: "sm" }))} - title="somebody else is talking: mark it incorrect (wrong speaker) and take it out of the cut, with an undo" - > - Wrong speaker - </button> - )} - {phase.k === "undone" && <span data-wrong-speaker-undone="">Undone: the clip is back in the cut.</span>} - </div> - )} - {clip && (phase.k === "asking" || (phase.k === "busy" && !removedId)) && ( - <div role="group" aria-label="Wrong speaker" data-wrong-speaker-ask="" className="space-y-1.5 rounded-[3px] border border-seam-2 bg-panel p-2"> - <p className="m-0 text-text" data-wrong-speaker-what=""> - Remove <span className="font-mono">{clip.id}</span> - {clip.video ? ( - <> - {" "} - ({clip.channel ? `${clip.channel}/` : ""} - {clip.video} {secs(clip.start)}–{secs(clip.end)}) - </> - ) : null}{" "} - from the cut as <strong>wrong speaker</strong>? It is marked incorrect and put on record; Undo puts it back. - </p> - <input - type="text" - data-wrong-speaker-note="" - value={note} - onChange={(e) => setNote(e.target.value)} - placeholder="who it is, if you know (optional)" - maxLength={300} - className="w-full rounded border border-seam-2 bg-ground px-1.5 py-1 text-[12px] text-text outline-none focus:border-signal" - /> - <div className="flex gap-2"> - <button type="button" data-wrong-speaker-remove="" disabled={phase.k === "busy"} onClick={() => void remove()} className={cn(buttonVariants({ variant: "go", size: "sm" }))}> - Remove {clip.id} - </button> - <button type="button" data-wrong-speaker-cancel="" disabled={phase.k === "busy"} onClick={() => setPhase({ k: "idle" })} className={cn(buttonVariants({ variant: "quiet", size: "sm" }))}> - Cancel - </button> - </div> - </div> - )} - {(phase.k === "removed" || (phase.k === "busy" && removedId)) && ( - <div role="status" data-wrong-speaker-removed={shown} className="space-y-1 rounded-[3px] border border-seam-2 bg-panel p-2"> - <div className="flex flex-wrap items-center gap-2"> - <span className="text-text"> - Removed <span className="font-mono">{shown}</span> from the cut (wrong speaker). - </span> - <button type="button" data-wrong-speaker-undo="" disabled={phase.k === "busy"} onClick={() => void undo()} className={cn(buttonVariants({ variant: "outline", size: "sm" }))}> - Undo - </button> - {after} - </div> - {phase.k === "removed" && phase.notes.length > 0 && ( - <ul className="m-0 list-disc pl-5 text-[11.5px] text-muted" data-wrong-speaker-reanchored=""> - {phase.notes.map((n) => ( - <li key={n}>{n}</li> - ))} - </ul> - )} - </div> - )} - {error && ( - <p role="alert" className="m-0 mt-1 text-[11.5px] text-reject-text"> - {error} - </p> - )} - </div> - ); -} diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -23,6 +23,7 @@ Inbox cannot disagree about what is wrong with one. | `inbox [--all] [--json]` | the decisions grouped and ranked by piece (`a:<site>/<report>`, `p:<project>`): Your call, Review, Blocking, Notes, Open, Ready to finish, Quiet — one card per piece and kind, and how many sit hidden on parked or done pieces (`--all` lists them). Every decision, songs' and articles' included; runs `bin/inbox.ts` through tsx | | `folders [--json]` · `kinds [--json]` | the tree, the registry | | `window <project> <clip> [--start S] [--end E] [--lock] [--lock-end] [--no-lock-end] [--note …]` | edit a window | +| `window <project> <clip> --verdict confirmed\|incorrect [--correction T]` · `window <project> <clip> --reject <why> [--note T]` | what the walk said: `--reject` is the walk's **Reject ▾** kept in place (`not-matching`/`wrong-speaker`: incorrect, the note its correction; `irrelevant`/`repeats`/`weak`/`privacy`/`other`: rejected, the note its `rejectNote`); `umtool timeline <p> reject` takes it out ([report-video.md](report-video.md#verdict--what-the-walk-said)) | | `window <project> <clip> --take <take> …` | a **take's** clip (walk a take): the same fields, written into the take's patch (`takes/<take>/take.json`) with an undo point first; the project's manifest is untouched ([clip-bench.md](clip-bench.md#walking-a-take)) | | `walk <project> [--take <take>] [--all] [--json]` | the clip bench's **walk**: every clip in walk order with its window, verdict and whether a fetched file holds it, and (→) the ones the walk visits — fetched and needing a verdict; `--all` every fetched one; `--take` walks a take (a draft too); the bench's address to start at | | `link <project> <site>/<report>` · `link <project> --clear` | the manifest names the article it is the video of (settles `link-ambiguous`) | @@ -59,7 +60,7 @@ Inbox cannot disagree about what is wrong with one. | `phrases "<phrase>" ["<phrase>" …] --channels a,b [--prefer c] [--exclude RE] [--words \| --regex] [--samples N] [--no-cache] [--json \| --full]` | the phrase finder's search ([tools.md](tools.md#the-phrase-finder-toolsphrases)): every phrase in one pass, each with its count once folded, by year, the preferred channel's share or Rumble's, speaker changes, sample contexts. Plain words become a tolerant pattern unless the phrase holds a regular expression's characters. `--json` the numbers, `--full` every instance; `--spec FILE --out FILE --progress` is the page's job form. **Exit 1** on a bad phrase | | `voice-match <project> [--reference auto\|rulings\|recordings] [--reference-video <channel>/<id> …] [--reference-channel <slug> …] [--instances FILE] [--span phrase\|cut] [--pad S] [--likely X --unlikely Y] [--out FILE] [--dry] [--json] [--progress ndjson]` | who is speaking, per montage clip: a local speaker-similarity score (TitaNet-small) against the host's voice → `<project>/voice-match.json` (the Cut tab's **Score the voices**); `--instances` also scores a phrase scan's instances not in the manifest; `--dry` prints the plan ([report-video.md](report-video.md#who-is-speaking-the-voice-match)) | | `clips analyze <project> [--from <channel>/<id>] [--rescan] [--no-laughs] [--no-voices] [params] [--words FILE] [--progress ndjson] [--json]` · `clips propose <project> [--from <channel>/<id>] [--host N] [params] [--words FILE] [--dry] [--json]` · `clips show <project> [--json]` · `clips segments <project> [--json]` | the **clip finder** on a long recording ([report-video.md](report-video.md#highlights-the-clip-finder)): `analyze` runs the laugh scan (CED-mini) and a voice centroid per speaker on the recording's sound (cached in `<project>/scans/`), then proposes; `propose` proposes again from what is there (after a role flip, a param change, new words); `show` prints the speakers, laughs and the cut. Params `--target S` (600) `--laugh-min X` (0.25) `--merge-gap S` (6) `--setup-max S` (20) `--clip-max S` (75) and the scope `--scope FROM:TO` (either side may be empty; `all` clears it) or `--from S --to S` with numbers (a `--from` that is a `<channel>/<id>` names the recording), kept in `reactions.json`; `--host N` is your word on the host, kept. `--keep-cut` proposes without touching the cut (nothing moved, removed or added; the proposals are listed). **`--scope auto`** reads the narrated video auto-scope finds in the speaker turns (`--segment sN` names one, else the longest); `segments` lists them. A chat replay beside the recording (`live_chat.cues.json`) adds chat-burst moments and the log names the chat's lag. A channel on no site gets each clip linked to its platform page (`citeUrl`). A clip you edited, ruled, locked or added is never moved. **Exit 2** with no `diarization.json` (the message names the `archilyzer diarize backfill` to run) | -| `timeline <project> [ls] [--json]` · `timeline <project> insert --after <id\|-> <channel>/<video>@<start>-<end> [--id ID] [--section N] [--lock] [--lock-end] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` · `timeline <project> move <id> --to <index>` · `remove <id>` · `wrong-speaker <id> [--correction T]` · `duplicate <id>` (`--at <index>` names one of an id's twins) · `post <json\|@file>` · `post-remove <id>` · `teaser <id> <patch-json\|@file>` · `undo` | the **structure** of the cut (the Cut tab's timeline, the On-screen section's teasers and posts) through the writers `POST /api/report/timeline` runs: `ls` prints index, id, type, video, start–end, date and title (`--json` adds the token and the posts); an insert's attribution is a second write through `window`'s writer, its date checked before anything is written; it is written in the manifest's own convention — under the deck `--title` is the deck's title (`onscreen.title`, `--stream-title` the stream's), a cut whose deck titles are dates gets `--date` as one in their format, and the clip takes the section of the clip it goes after (`--section N` names another) and, from the same recording, its deck title and its citation link. A removal re-anchors what named the clip (a marker to the clip before, a chapter to the next in its section; a pair, a status reference or a deck claim dropped) and prints each `re-anchored:` line; `wrong-speaker` marks the clip incorrect (reason `wrong-speaker`) and removes it, on record in `removed.json` ([report-video.md](report-video.md#verdict--what-the-walk-said)). Every write snapshots the manifest first (`revisions/…-auto-before-<op>`), is refused only for what it breaks in the build's own words (**exit 1**), and on a generated manifest leaves an `edit` note ([report-video.md](report-video.md#structural-edits)) | +| `timeline <project> [ls] [--json]` · `timeline <project> insert --after <id\|-> <channel>/<video>@<start>-<end> [--id ID] [--section N] [--lock] [--lock-end] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` · `timeline <project> move <id> --to <index>` · `remove <id>` · `reject <id> <why> [--note T]` · `wrong-speaker <id> [--correction T]` · `duplicate <id>` (`--at <index>` names one of an id's twins) · `post <json\|@file>` · `post-remove <id>` · `teaser <id> <patch-json\|@file>` · `undo` | the **structure** of the cut (the Cut tab's timeline, the On-screen section's teasers and posts) through the writers `POST /api/report/timeline` runs: `ls` prints index, id, type, video, start–end, date and title (`--json` adds the token and the posts); an insert's attribution is a second write through `window`'s writer, its date checked before anything is written; it is written in the manifest's own convention — under the deck `--title` is the deck's title (`onscreen.title`, `--stream-title` the stream's), a cut whose deck titles are dates gets `--date` as one in their format, and the clip takes the section of the clip it goes after (`--section N` names another) and, from the same recording, its deck title and its citation link. A removal re-anchors what named the clip (a marker to the clip before, a chapter to the next in its section; a pair, a status reference or a deck claim dropped) and prints each `re-anchored:` line; `reject` rejects the clip for `<why>` — `not-matching` or `wrong-speaker` (fact errors: `incorrect`, the note its correction) or `irrelevant`, `repeats`, `weak`, `privacy`, `other` (`rejected`, never a correction) — and removes it, on record in `removed.json` with the reason and the note; `wrong-speaker <id>` is `reject <id> wrong-speaker`; `ls` marks a clip rejected but still in the cut (`[rejected — irrelevant]`) ([report-video.md](report-video.md#verdict--what-the-walk-said)). Every write snapshots the manifest first (`revisions/…-auto-before-<op>`), is refused only for what it breaks in the build's own words (**exit 1**), and on a generated manifest leaves an `edit` note ([report-video.md](report-video.md#structural-edits)) | | `timeline <project> --take <take> [ls \| move <id> --to <index> \| remove <id> \| undo]` | a **take's** timeline (walk a take): the same structure checks, written into the take's patch, each write with an undo point of the take's own (`takes/<take>/revisions/`); `undo` takes the take's newest edit back, whichever writer made it | | `scenes <project> <clip> [--black-min 0.05] [--threshold 8] [--pix-th 0.10] [--pad 30 \| --from S --to S] [--json]` | the picture's **scene cuts** (ffmpeg `scdet`, score ≥ threshold) and **black spans** (`blackdetect`) in the clip's fetched window, in SOURCE seconds — for `blur.from`/`blur.to` and trims ([knobs.md](knobs.md#a-clips-picture-blurred)). The window is the one the build would cut from (the project's `out/clips-raw`, the editor's `channels/<slug>/data/<id>/clips/`, a saved source); the extent ± `--pad` inside it is scanned. Nothing is fetched: **exit 1** with no window on disk (`fetch` first) | | `posts set <project> <post> thread=on\|off [hide=on\|off] [attach=<clipId>\|auto] [--json]` | the Posts table's writer (`updatePosts`, `PUT /api/report/posts`) from a terminal: `<post>` is the manifest's id (`x-<postId>`) or the bare `<postId>`; `thread=on` draws a reply with the post it answers above it (`shot-thread.png` beside its `shot`, taken by `capture-posts` `"thread": true`; its own shot while there is none), `off` removes the key. Refused in the build's words (a post with no `shot`, an `attach` that is not a clip) — **exit 1** | diff --git a/umtool/docs/clip-bench.md b/umtool/docs/clip-bench.md @@ -302,20 +302,45 @@ open before it gets there is cut by the bench as before; a cut already running in the other process is waited for, not repeated. `UMTOOL_BENCH_PREP=0` queues nothing (`umtool prep --wait` still runs). -### Is this accurate? +### Keep it in the cut? A clip is a **claim** — the report said somebody said this, here — so the right column opens with what this clip is *supposed to be* (its `quote`, and its `note`: why it is in the cut) and then asks the one question the walk exists to -answer. +answer: **Keep c04 in the cut?** <kbd>y</kbd> confirms and **advances** — to the next clip on the walk, which is the next one that needs an answer and has something to play — because in the yes -case that clip is what you want and a walk of sixty clips should be one finger. <kbd>x</kbd> puts -the cursor in the `correction` box and marks it **required**, because the note -*is* the no answer — and saving it stays put, so it can be read back against the -clip. That save is ONE patch, `{correction, verdict: "incorrect"}`, so the -manifest never holds a complaint with no verdict. +case that clip is what you want and a walk of sixty clips should be one finger. + +<kbd>x</kbd> is **Reject ▾**: the reasons a clip comes out, and *doesn't match* is +only one of them (operator, 2026-10-30: "I tend to want to reject clips not +because they don't match, but are irrelevant"). A digit picks one: + +| key | reason | what it means | stored | +|---|---|---|---| +| <kbd>1</kbd> | doesn't match | what is said doesn't match the quote or claim | `incorrect` + `correction` (required) | +| <kbd>2</kbd> | wrong speaker | somebody else is talking | `incorrect`, `reason: "wrong-speaker"` | +| <kbd>3</kbd> | irrelevant | accurate, but not relevant to this cut | `rejected`, `reason: "irrelevant"` | +| <kbd>4</kbd> | repeats | covered by an earlier clip (the note: which) | `rejected`, `reason: "repeats"` | +| <kbd>5</kbd> | weak | accurate and relevant, not strong enough | `rejected`, `reason: "weak"` | +| <kbd>6</kbd> | privacy | holds something that must not be published | `rejected`, `reason: "privacy"` | +| <kbd>7</kbd> | other | anything else (the note is required) | `rejected`, `reason: "other"` | + +The first two are FACT errors — corrections for the next report pass, blocking in +`umtool check`; the rest say the report is right and the clip just does not belong +here, and are never read as a correction. Picking one asks in the page — the clip, +the reason, a note — and then **Remove c04** takes it out of the cut in one write +(an undo point first, on record in `removed.json` with the reason and the note, +**Undo** and **Next clip ›** after), or **Reject, keep in place** writes the +verdict only, for removal later. **Wrong speaker** beside **Reject ▾** is the same +flow with its reason preset. On a phone the dock's **Reject…** opens the same +choice in a sheet. On a take's walk only *keep in place* is offered: a take's +timeline is a patch. + +Typing a `correction` on a clip nobody has judged still marks it **incorrect** in +the same patch (`{correction, verdict: "incorrect"}`), so the manifest never holds +a complaint with no verdict. An edge you nudged but never saved is confirmed WITH the clip: if the selection differs from the stored window, <kbd>y</kbd> carries `start`/`end` (and clears a @@ -324,8 +349,10 @@ walking on never loses the window you just chose. A note on a clip that is already **confirmed** is just a note — why its window moved, a caveat for the writers — and writing one there leaves the verdict -alone. The state line reads *not yet reviewed*, *confirmed*, *confirmed · with -note* or *incorrect*, and the header counts how much of the cut has been +alone — as it does on a clip rejected for a cut reason, whose facts are right. +The state line reads *not yet reviewed*, *confirmed*, *confirmed · with note*, +*incorrect — doesn't match* / *incorrect — wrong speaker* or *rejected — irrelevant* +(and the rest), and the header counts how much of the cut has been reviewed. See [report-video.md](report-video.md#verdict--what-the-walk-said) for what is stored and what the writer refuses. @@ -343,7 +370,7 @@ a new fetch. `/projects/<project>/takes/<take>/clip/<id>` is this bench on the take's clip. Everything works as on the project's cut, and **every save goes into the take's patch** (`takes/<take>/take.json`), -never the project's manifest: the verdict (`y`, `x`), the edges, the attribution, the mute mark, +never the project's manifest: the verdict (`y`, `x` — kept in place), the edges, the attribution, the mute mark, cut to quote, a wider fetch (the job is pointed at the take's manifest, written beside the project's; the bytes land where every fetch's do). A strip at the top says **walking take `<take>` — edits go to the take, not the cut**, with **← earlier**, **later →**, **Remove from @@ -418,7 +445,7 @@ cannot disagree). Clicking a cue snaps the nearer edge to it. `[` `]` move the start · `,` `.` move the end · shift for 0.5 s instead of 0.05 · `space` auditions the whole selection · `R` resets to the saved window · -`p` `n` walk · `y` confirm · `x` note what is wrong · `-` `=` playback speed · +`p` `n` walk · `y` confirm · `x` reject, then `1`–`7` the reason (Esc closes) · `-` `=` playback speed · `a` auto-audition. Audition happens on pointer-**up**, never during a drag — the Deck's rule, because diff --git a/umtool/docs/inbox.md b/umtool/docs/inbox.md @@ -75,6 +75,7 @@ on (`decisionTab`, `songTabOfSection`). | `storage-mismatch` | open | a storage move that was cut, with the command that finishes it | Settle the storage | | `clip-cut-outside` | blocking | a `cutStart`/`cutEnd` without its pair, under half a second, or outside its window | Fix the cut | | `clip-incorrect` | blocking | a clip whose verdict is `incorrect` (or a legacy `correction` with no verdict) still in the timeline: "e01 is marked incorrect: … — remove it, fix it and re-confirm, or clear the verdict". A take of a cut holding one refuses with the same sentence; Play the cut skips it | Remove or fix the clip | +| `clip-rejected` | open | a clip the walk REJECTED for a cut reason (`verdict: "rejected"` — irrelevant, repeats, weak, privacy, other; not a fact error) that was kept in place: "c07 is rejected (irrelevant) but still in the cut — remove it (umtool timeline <p> reject c07 irrelevant), or clear the verdict". Play the cut skips it; a take does not refuse it | Take the clip out | **song** — `unjudged-variant` (Judge variant), `missing-cut` (Ship the cut), `no-recipe` / `stale-recipe` (Record the recipe), `spec-problem` (Fix the spec), `no-plan` (Name the plan), `unattributed` (Attribute variant), diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -236,18 +236,23 @@ own patch (a take's own `timeline` included), from `takes/<id>/take.json` or — names it; its pages are composed under `takes/<id>/out/`, never over the project's. `render.blur: "off"` on the take plays its blurred clips as recorded. -**A clip ruled incorrect is skipped.** A clip whose walk verdict is `incorrect` (or that carries a legacy -`correction` and no verdict) is left out of what Play plays — its neighbours meet at the seam — and the reel strip -shows it struck through where it would be, its correction on hover. **Show clips marked incorrect** (under the strip, -remembered by this browser) plays them again, greyed and struck through, for re-review. The deck's pages are still -composed from the whole cut, so its tally counts their marks. `umtool check` calls such a clip **blocking** -(`clip-incorrect`) and a take refuses it by name ([report-video.md](report-video.md)). - -**Wrong speaker** (under the transport; on the clip bench too) takes the clip on screen out of the project's cut in -one write — asked in the page first, with an **Undo** after, on record in `removed.json` -([report-video.md](report-video.md#verdict--what-the-walk-said)). Not on a take. - -**Play keeps its place in its URL** (`?clip=&at=&t=` and `incorrect=1`, replaced at most once a second, never a +**A rejected clip is skipped.** A clip the walk rejected — a fact error (`incorrect`: doesn't match, wrong speaker; +or a legacy `correction` and no verdict) or a cut reason (`rejected`: irrelevant, repeats, weak, privacy, other) — is +left out of what Play plays — its neighbours meet at the seam — and the reel strip shows it struck through where it +would be, **why** on hover ("c03 skipped — rejected — irrelevant"; under the strip each id carries its reason). +**Show rejected clips** (under the strip, remembered by this browser) plays them again, greyed and struck through, +for re-review. The deck's pages are still composed from the whole cut, so its tally counts their marks. `umtool +check` calls a fact error **blocking** (`clip-incorrect`, and a take refuses it by name) and a cut reason kept in +place **open** (`clip-rejected`) ([report-video.md](report-video.md#verdict--what-the-walk-said)). + +**Reject ▾** (`x`, then a digit: 1 doesn't match · 2 wrong speaker · 3 irrelevant · 4 repeats · 5 weak · 6 privacy · +7 other; under the transport, and on the clip bench) takes the clip on screen out of the project's cut in one write — +asked in the page first (the reason, a note: required for doesn't match and other), with an **Undo** after, on record +in `removed.json` — or **Reject, keep in place** writes the verdict only, for removal later. **Wrong speaker** beside +it is the same flow with its reason preset ([report-video.md](report-video.md#verdict--what-the-walk-said)). Not on a +take. + +**Play keeps its place in its URL** (`?clip=&at=&t=` and `rejected=1` — an old `incorrect=1` still works — replaced at most once a second, never a history entry of its own), so **Edit this clip** (E) and then the browser's **Back** — or the bench's **‹ Back to the cut** — lands paused on the same second of the same clip. When an edit moved that clip in the cut, Play resumes by the clip and the offset into it, and says **Back at c02 · 00:03.0 (the cut changed)**. diff --git a/umtool/docs/piece.md b/umtool/docs/piece.md @@ -85,7 +85,7 @@ filled one), the reader on the right. | Bench | Address | Keys | The bar | |---|---|---|---| -| Clip ([clip-bench.md](clip-bench.md)) | `/projects/<p>/clip/<id>` | `y` confirm, `x` note, `[ ] , .` nudge, space play, `p` `n` walk | "Extend c04 to the end of the sentence?" → **Extend to m:ss** (or **Fetch to m:ss**), **Keep the cut here**; else "Is c04 what the report says it is?" — **Yes, confirmed**, **No, note what is wrong** | +| Clip ([clip-bench.md](clip-bench.md)) | `/projects/<p>/clip/<id>` | `y` confirm, `x` reject (then 1–7, the reason), `[ ] , .` nudge, space play, `p` `n` walk | "Extend c04 to the end of the sentence?" → **Extend to m:ss** (or **Fetch to m:ss**), **Keep the cut here**; else "Keep c04 in the cut?" — **Yes, confirmed**, **Reject ▾** (doesn't match, wrong speaker, irrelevant, repeats, weak, privacy, other) | | Claim ([claim-bench.md](claim-bench.md)) | `/projects/<p>/claim/<id>` | j/k cue | "Save the ruling on k01?" → **Save ruling**, **Next claim** | | Narration | `/projects/<p>/narration` | j/k card, `a`, `r` | "Approve the narration of t1?" → **Approve**, **Reject with a note** | | Takes | `/projects/<p>/takes` | `n` `p` listen, `l` `m` `x` | "Is <take> the take for <group>?" → **Like**, **Maybe**, **No** | diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -49,7 +49,7 @@ travel. umtool never reorders as a side effect of a window edit. "date": "2016-09-12", // optional: overrides the record's upload date "note": "…", // why it is in the cut (editorial, for humans) "correction": "…", // what the REPORT got wrong here; never rendered - "verdict": "confirmed", // or "incorrect"; absent = nobody has looked yet + "verdict": "confirmed", // or "incorrect" / "rejected" (+ "reason"); absent = nobody has looked yet "assist": { "by": "assistant", … }, // the clip finder's provenance (see "Highlights"); never rendered "chapter": "…", // chapter title; falls back to date + title "blur": { "on": true }, // optional: its PICTURE blurred, a caption on it (knobs.md) @@ -145,8 +145,13 @@ reads as though it were trimmed. **A clip ruled incorrect blocks.** A walk's `verdict: "incorrect"` (with its `correction`) on a clip still in the timeline is `clip-incorrect`, **blocking**, in `umtool check` — "e01 is marked incorrect: Other speaker, not Ember — remove it, fix it and re-confirm, or clear the verdict" — and a take of the cut refuses with that sentence before it -renders anything (`umtool take`, the takes page, a batch). Play the cut skips the clip unless **Show clips marked -incorrect** is ticked. +renders anything (`umtool take`, the takes page, a batch). Play the cut skips the clip unless **Show rejected +clips** is ticked. + +**A clip rejected for a cut reason does not block.** `verdict: "rejected"` (irrelevant, repeats, weak, privacy, +other — the report is right, the clip just does not belong in this cut) kept in place is `clip-rejected`, **open**: +"c07 is rejected (irrelevant) but still in the cut — remove it (umtool timeline <p> reject c07 irrelevant), or clear +the verdict". Play the cut skips it like a fact error; a take does not refuse it. - **The build** cuts to `[cutStart − render.leadIn, cutEnd]` (lead-in 0.4 s by default, clamped into the extent) when both are present, and to the extent @@ -172,23 +177,43 @@ be the worst of both. ### `verdict` — what the walk said -`"confirmed"`, `"incorrect"`, or **absent**. Never rendered, like `correction`, -and written by the same three writers (the clip bench's `y` and `x`, -`PUT /api/report/window`, `umtool window --verdict confirmed|incorrect`). An +`"confirmed"`, `"incorrect"`, `"rejected"`, or **absent**. Never rendered, like `correction`, +and written by the same three writers (the clip bench's `y` and **Reject ▾** (`x`), +`PUT /api/report/window`, `umtool window --verdict confirmed|incorrect` / `--reject <why>`). An empty value deletes the key. +**Reject — why?** The walk rejects a clip for a reason, and *doesn't match* is only one of them +(`lib/report/rejectReasons.mjs` is the vocabulary; the bench, Play the cut, the CLI and `umtool check` all read it). +Two kinds, stored two ways on purpose, because they mean different things to the **report**: + +| reason | kind | on disk | its note | +|---|---|---|---| +| `not-matching` — what is said doesn't match the quote or claim | fact | `verdict: "incorrect"` (no `reason`: every manifest written before reasons) | `correction`, **required** | +| `wrong-speaker` — somebody else is talking | fact | `verdict: "incorrect"`, `reason: "wrong-speaker"` | `correction`, optional | +| `irrelevant` — accurate, not relevant to this cut | cut | `verdict: "rejected"`, `reason: "irrelevant"` | `rejectNote`, optional | +| `repeats` — covered by an earlier clip | cut | `reason: "repeats"` | `rejectNote` (which clip), optional | +| `weak` — accurate and relevant, not strong enough | cut | `reason: "weak"` | `rejectNote`, optional | +| `privacy` — holds something that must not be published | cut | `reason: "privacy"` | `rejectNote`, optional | +| `other` | cut | `reason: "other"` | `rejectNote`, **required** | + +A fact reason is a correction for the next report pass (`umtool corrections`) and blocks `umtool check` while the +clip is in the cut (`clip-incorrect`). A cut reason is **never** a correction — "irrelevant" must not read as "the +report is wrong" — and is an open row (`clip-rejected`). `verdict=<reason>` is shorthand for either (`umtool set <p> +<clip> verdict=irrelevant rejectNote=…`); a verdict changed to anything else drops the reason and the rejectNote, and +a reason only goes with the verdict it explains (a fact reason under `rejected`, or a cut reason under `incorrect`, is +refused in a sentence). + A clip is a *claim*: the report said somebody said this, here. Walking the cut is somebody checking that claim against the audio. -**`reason` — wrong speaker.** Beside `verdict: "incorrect"`, `reason: "wrong-speaker"` says what is wrong without a -note (a `correction` stays optional; it is the only structured reason — say anything else in the correction). -`umtool set <p> <clip> verdict=wrong-speaker` (shorthand for incorrect + the reason) marks it; a verdict changed to -anything else drops the reason. **Wrong speaker** on the clip bench and in Play the cut does more in one write -(`umtool timeline <p> wrong-speaker <clip> [--correction T]`, `POST /api/report/timeline` `op: "wrong-speaker"`): it -marks the clip so and **removes it from the timeline** — asked in the page first (what goes, an optional note), an -undo point first (**Undo** right after, or `umtool timeline <p> undo`), and the removal **on record** in -`removed.json` beside the manifest (id, channel, video, window, reason, correction, when; append-only — `umtool -corrections` lists those still out of the cut under "Taken out of the cut"). +**Reject, taken out.** **Reject ▾** on the clip bench and in Play the cut (and **Wrong speaker**, the same flow +with its reason preset) does more in one write (`umtool timeline <p> reject <clip> <why> [--note T]`, +`POST /api/report/timeline` `op: "reject"`; `wrong-speaker <clip> [--correction T]` is reject with that reason): it +marks the clip so and **removes it from the timeline** — asked in the page first (the reason, a note), an undo point +first (**Undo** right after, or `umtool timeline <p> undo`), and the removal **on record** in `removed.json` beside +the manifest (id, channel, video, window, reason, correction, the reject `note`, when; append-only — `umtool +corrections` lists those still out of the cut under "Taken out of the cut"). **Reject, keep in place** writes the +verdict only, for removal later (`umtool window <p> <clip> --reject <why> [--note T]`). **A removal re-anchors what named the clip** (every `remove`, not only Wrong speaker), and says so line by line (`re-anchored: …` in the CLI, `reanchored` in the route's answer): a deck marker `after` it moves to the clip before @@ -201,7 +226,8 @@ holds only the timeline, so nothing else could move with it). | on disk | state | `correction` | |---|---|---| | `verdict: "confirmed"` | **confirmed** | optional — a *note* | -| `verdict: "incorrect"` | **incorrect** | **required** | +| `verdict: "incorrect"` | **incorrect** | **required** (unless `reason: "wrong-speaker"`) | +| `verdict: "rejected"` | **rejected** (+ `reason`) | optional — a *note*; the facts are right | | neither | **not yet reviewed** | — | **The note is not always a complaint.** On a confirmed clip `correction` says @@ -234,7 +260,7 @@ to let somebody undo a note they wrote before the rule existed would be a trap. <project>` all read it, and `walkReadiness()` reads the same verdict rule to decide what the walk VISITS (unjudged and fetched — see [clip-bench.md](clip-bench.md#what-the-walk-skips)), and the last opens with -`N clips: A incorrect, B confirmed (C with a note), D not yet reviewed (ids: …)` +`N clips: A incorrect, [R rejected (not corrections),] B confirmed (C with a note), D not yet reviewed (ids: …)` so the walk's coverage is visible beside the defects it found. A card entry is `{"type":"card", "id", "style", "seconds", …}` — see the pipeline diff --git a/umtool/e2e/bench-shell.spec.ts b/umtool/e2e/bench-shell.spec.ts @@ -85,18 +85,18 @@ test("the clip bench: the top bar, the one question with its consequence, the re test("the clip bench's keys walk the cut: n and p", async ({ page }) => { await page.goto(urls.clipBenchHref(SHELL, "s01")); - // Live once the bench's own keys answer: `x` puts the cursor in the note. - const note = page.locator("[data-attrib-field=correction]"); + // Live once the bench's own keys answer: `x` opens Reject ▾'s reasons (Escape closes them). + const menu = page.locator("[data-reject-menu]"); await expect(async () => { await page.locator("body").press("x"); - await expect(note).toBeFocused({ timeout: 500 }); + await expect(menu).toBeVisible({ timeout: 500 }); }).toPass({ timeout: 10_000 }); - await note.blur(); + await page.locator("body").press("Escape"); await page.locator("body").press("n"); await expect(page.locator("[data-bench=s02]")).toBeVisible(); await expect(page.locator("[data-bench-pos]")).toHaveText("2 of 2"); // s02 ends the sentence and is locked: the bar asks the walk's question. - await expect(page.locator("[data-verdict-question]")).toHaveText("Is s02 what the report says it is?"); + await expect(page.locator("[data-verdict-question]")).toHaveText("Keep s02 in the cut?"); await expect(page.locator("[data-verdict-yes]")).toHaveClass(/bg-signal/); await page.locator("body").press("p"); await expect(page.locator("[data-bench=s01]")).toBeVisible(); @@ -108,7 +108,7 @@ test("Extend saves the sentence's end at once, and Reset puts the window back", await bar.locator("[data-verdict-extend]").click(); await expect.poll(() => endOf("s01")).toBe(9); // The clip now ends the sentence: the bar asks the walk's question. - await expect(bar.locator("[data-verdict-question]")).toHaveText("Is s01 what the report says it is?"); + await expect(bar.locator("[data-verdict-question]")).toHaveText("Keep s01 in the cut?"); await expect(page.locator("[data-bench-note]")).toContainText("R undoes it"); // Reset (the button, as R) undoes the saved extension. await page.locator("[data-reset]").click(); diff --git a/umtool/e2e/clip-bench.spec.ts b/umtool/e2e/clip-bench.spec.ts @@ -56,6 +56,8 @@ const readClipIn = (project: string, id: string) => { date?: string; correction?: string; verdict?: string; + reason?: string; + rejectNote?: string; cutStart?: number; cutEnd?: number; muteFrom?: number; @@ -100,12 +102,14 @@ const setField = async ( * box), so it doubles as the readiness probe for the keys that do. */ const keyboardLive = async (page: import("@playwright/test").Page) => { - const box = page.locator("[data-attrib-field=correction]"); + // Live once the bench's own keys answer: `x` opens Reject ▾'s reasons, Escape closes them unasked. + const menu = page.locator("[data-reject-menu]"); await expect(async () => { await page.locator("body").press("x"); - await expect(box).toBeFocused({ timeout: 500 }); + await expect(menu).toBeVisible({ timeout: 500 }); }).toPass({ timeout: 10_000 }); - await box.blur(); + await page.locator("body").press("Escape"); + await expect(menu).toHaveCount(0); }; const token = async ( @@ -681,23 +685,32 @@ test("`y` saves a window you nudged but never saved, in the same write", async ( await expect.poll(() => readClip("c01").verdict).toBeUndefined(); }); -test("`x` requires the note, writes both fields at once, and stays put", async ({ page }) => { +test("`x` opens Reject ▾; 1 (doesn't match) requires the note, writes both fields at once, and stays put", async ({ page }) => { await page.goto(bench("c03")); - // The key IS the assertion: `x` answers "no" by putting the cursor where the - // answer goes -- and keyboardLive() blurs it again with the box still empty, - // which must write NOTHING. Blurring out of a box you were asked to fill is - // not an answer. + // `x` opens the reasons and Escape closes them: nothing is written by asking. await keyboardLive(page); expect(readClip("c03").verdict).toBeUndefined(); expect(readClip("c03").correction).toBeUndefined(); await expect(page.locator("[data-verdict-state]")).toHaveText("not yet reviewed"); - - await setField(page, "correction", "The speaker here is the caller, not the host."); - // ONE patch. The manifest never holds a complaint with no verdict, which is - // why the bench sends them together rather than in two saves. + await expect(page.locator("[data-verdict-no]")).toContainText("Reject ▾"); + + await page.locator("body").press("x"); + await page.locator("body").press("1"); + const ask = page.locator('[data-reject-ask="not-matching"]'); + await expect(ask.locator("[data-reject-what]")).toContainText("Reject c03"); + await expect(ask.locator("[data-reject-what]")).toContainText("as doesn't match?"); + // The note IS the answer for doesn't match: nothing can be written without it. + await expect(page.locator("[data-reject-note]")).toBeFocused(); + await expect(page.locator("[data-reject-keep]")).toBeDisabled(); + await expect(page.locator("[data-reject-remove]")).toBeDisabled(); + await page.locator("[data-reject-note]").fill("The speaker here is the caller, not the host."); + await page.locator("[data-reject-keep]").click(); + // ONE patch. The manifest never holds a complaint with no verdict. await expect.poll(() => readClip("c03").verdict).toBe("incorrect"); expect(readClip("c03").correction).toContain("the caller"); - await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect"); + expect(readClip("c03").reason).toBeUndefined(); + await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect — doesn't match"); + await expect(page.locator("[data-attrib-field=correction]")).toHaveValue(/the caller/); // And it STAYS: the note is there to be read back against the clip. await expect(page.locator("[data-bench=c03]")).toBeVisible(); }); @@ -706,7 +719,7 @@ test("`y` on an incorrect clip keeps the note — it becomes a note, not a defec page, }) => { await page.goto(bench("c03")); - await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect"); + await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect — doesn't match"); await page.locator("[data-verdict-yes]").click(); await expect.poll(() => readClip("c03").verdict).toBe("confirmed"); @@ -718,18 +731,21 @@ test("`y` on an incorrect clip keeps the note — it becomes a note, not a defec await expect(page.locator("[data-verdict-state]")).toHaveText("confirmed · with note"); }); -test("`x` on a confirmed clip that already has a note takes the yes back", async ({ page }) => { +test("Reject ▾ → doesn't match on a confirmed clip that already has a note takes the yes back", async ({ page }) => { // The operator's case: a clip confirmed WITH a note ("this is another speaker, // but it does contain what you say") re-auditioned and found wrong after all. - // The note already says what is wrong, so "no" must not wait for an edit to - // it -- the verdict flips on the button, and the note stays. + // The note already says what is wrong, so it is there already -- the verdict + // flips on the button, and the note stays. await page.goto(bench("c03")); await expect(page.locator("[data-verdict-state]")).toHaveText("confirmed · with note"); await page.locator("[data-verdict-no]").click(); + await page.locator('[data-reject-reason="not-matching"]').click(); + await expect(page.locator("[data-reject-note]")).toHaveValue(/the caller/); + await page.locator("[data-reject-keep]").click(); await expect.poll(() => readClip("c03").verdict).toBe("incorrect"); expect(readClip("c03").correction).toContain("the caller"); - await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect"); + await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect — doesn't match"); // Stays put, like every "no": the note is there to be read back. await expect(page.locator("[data-bench=c03]")).toBeVisible(); }); @@ -788,7 +804,7 @@ test("a note written before `incorrect` existed still reads as incorrect", async expect(readClip("c02").verdict).toBeUndefined(); await page.goto(bench("c02")); - await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect"); + await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect — doesn't match"); await expect(page.locator("[data-bench=c02]")).toHaveAttribute("data-verdict", "incorrect"); await page.goto(urls.section(PROJECT, "timeline")); @@ -809,6 +825,31 @@ test("a note written before `incorrect` existed still reads as incorrect", async expect(readClip("c02").correction).toBeUndefined(); }); +test("Reject ▾ → irrelevant: out of the cut on record, never a correction; Undo puts it back as it was", async ({ page }) => { + const before = readFileSync(MANIFEST, "utf8"); + await page.goto(bench("c01")); + await keyboardLive(page); + await page.locator("body").press("x"); + await page.locator("body").press("3"); + const ask = page.locator('[data-reject-ask="irrelevant"]'); + await expect(ask.locator("[data-reject-what]")).toContainText("as irrelevant?"); + // Not a fact error, and the page never says it is. + await expect(ask).toContainText("the report is right; nothing here is a correction"); + await expect(ask).not.toContainText("doesn't match"); + await page.locator("[data-reject-note]").fill("about the tour, not the lawsuit"); + await page.screenshot({ path: test.info().outputPath("bench-reject-irrelevant.png") }); + await page.locator("[data-reject-remove]").click(); + await expect(page.locator('[data-reject-done="c01"]')).toContainText("Removed c01 from the cut (irrelevant)."); + const m = JSON.parse(readFileSync(MANIFEST, "utf8")) as { timeline: { id: string }[] }; + expect(m.timeline.map((e) => e.id)).not.toContain("c01"); + const rec = JSON.parse(readFileSync(path.join(path.dirname(MANIFEST), "removed.json"), "utf8")) as { removed: Record<string, unknown>[] }; + expect(rec.removed.at(-1)).toMatchObject({ id: "c01", reason: "irrelevant", note: "about the tour, not the lawsuit" }); + // Undo (the structural undo): the manifest exactly as it was. + await page.locator("[data-reject-undo]").click(); + await expect(page.locator("[data-reject-undone]")).toContainText("the clip is back in the cut"); + await expect.poll(() => readFileSync(MANIFEST, "utf8")).toBe(before); +}); + // --------------------------------------------------------------------------- // How you listen. // @@ -1554,9 +1595,9 @@ test("the last attribution field is on screen at a laptop's 1366×768", async ({ expect(await reachable()).toBeLessThanOrEqual(0); - // And in the taller state: "no" adds the line telling you the note IS the - // answer, which is exactly when the box has to be there to type into. + // And in the taller state: Reject ▾ opens its reasons in the answer column, + // on screen, and the last field is still there to type into. await page.locator("[data-verdict-no]").click(); - await expect(page.locator("[data-attrib-field=correction]")).toBeFocused(); + await expect(page.locator("[data-reject-menu]")).toBeInViewport(); expect(await reachable()).toBeLessThanOrEqual(0); }); diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -1871,7 +1871,7 @@ makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out // The same cut with the story modules on (play-modules.spec.ts): a chapter opening c02, // a then-and-now pair (c01 → c02) and a status ledger -- drawn in Play the cut through // the module contract's `play`. Its own copy, so play-cut.spec's pages stay as they are. -// And c03 ruled INCORRECT by the walk: Play skips it unless "Show clips marked incorrect". +// And c03 ruled INCORRECT by the walk: Play skips it unless "Show rejected clips". { const { dir: playModulesDir } = makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), @@ -1893,6 +1893,9 @@ writeFileSync(pmFile, JSON.stringify(pm, null, 2) + "\n"); // Wrong speaker in Play the cut (play-modules.spec.ts), which WRITES (removes c02, then undoes): // its own copy, so no other spec's cut moves under it. makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), name: "play-wrong-fixture", title: "The Play Wrong Speaker Fixture" }); +// Reject ▾ in Play the cut (play-modules.spec.ts), which WRITES (removes c02 as irrelevant, undoes; rejects +// it in place as weak, undoes): its own copy too. +makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), name: "play-reject-fixture", title: "The Play Reject Fixture" }); // TWO MORE cached windows for vid1, and they are the regression rather than // decoration. diff --git a/umtool/e2e/phone-walk.spec.ts b/umtool/e2e/phone-walk.spec.ts @@ -216,15 +216,20 @@ test("Confirm advances with the moved edges and offers Undo; Undo puts both back expect([e.start, e.end]).toEqual([3, 6]); }); -test("Note what's wrong is a sheet with the keyboard up; saving it marks the clip incorrect and stays", async ({ page, request }) => { +test("Reject… is a sheet: the reasons, then doesn't match with its note, kept in place, marks the clip incorrect and stays", async ({ page, request }) => { await page.setViewportSize(PHONE); await page.goto(urls.clipBenchHref(WALK, "p02")); await walkReady(page, "p02"); await page.locator("[data-walk-note]").click(); - const field = page.locator("[data-walk-note-field]"); + const sheet = page.locator("[data-walk-sheet]"); + await expect(sheet.locator("[data-reject-menu]")).toBeVisible(); + await sheet.locator('[data-reject-reason="not-matching"]').click(); + const field = sheet.locator("[data-reject-note]"); await expect(field).toBeFocused(); await field.fill("the speaker is the co-host"); - await page.locator("[data-walk-note-save]").click(); + await sheet.locator("[data-reject-keep]").click(); + await expect(sheet.locator('[data-reject-done="p02"]')).toContainText("Rejected p02 (doesn't match), still in the cut."); + await sheet.locator("[data-walk-sheet-close]").click(); await expect(page.locator("[data-walk-sheet]")).toHaveCount(0); await expect(page.locator("[data-walk-verdict]")).toHaveAttribute("data-walk-verdict", "incorrect"); await expect.poll(() => entryOf(WALK, "p02").verdict).toBe("incorrect"); diff --git a/umtool/e2e/play-modules.spec.ts b/umtool/e2e/play-modules.spec.ts @@ -73,7 +73,7 @@ test("the chapter card, the pair strip and the status ledger play in Play the cu await page.screenshot({ path: test.info().outputPath("play-chapter-down.png") }); }); -test("a clip ruled incorrect is skipped by default (struck through on the strip, its correction on hover); the toggle plays it, remembered", async ({ page }) => { +test("a clip ruled incorrect is skipped by default (struck through on the strip, why on hover); the toggle plays it, remembered", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 1000 }); await page.goto(urls.playHref(PROJECT)); await expect(root(page)).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 }); @@ -82,9 +82,10 @@ test("a clip ruled incorrect is skipped by default (struck through on the strip, await expect(rows).toHaveCount(4); expect(await rows.evaluateAll((els) => els.map((e) => e.getAttribute("data-play-row")))).toEqual(["c01", "c02", "k01", "c04"]); const marker = page.locator('[data-play-skipped="c03"]'); - await expect(marker).toHaveAttribute("title", "c03 skipped — marked incorrect: Other speaker, not the host."); + // An `incorrect` written before reasons existed reads as "doesn't match", in the new words. + await expect(marker).toHaveAttribute("title", "c03 skipped — rejected — doesn't match: Other speaker, not the host"); await expect(marker).toHaveCSS("text-decoration-line", "line-through"); - await expect(page.locator("[data-play-incorrect]")).toContainText("Skipping 1 clip marked incorrect: c03"); + await expect(page.locator("[data-play-rejected]")).toContainText("Skipping 1 rejected clip: c03 (doesn't match)"); // Next from k01 goes straight to c04. await page.locator('[data-play-row="k01"]').press("Enter"); await expect(root(page)).toHaveAttribute("data-play-item", "k01"); @@ -93,19 +94,19 @@ test("a clip ruled incorrect is skipped by default (struck through on the strip, await page.screenshot({ path: test.info().outputPath("play-incorrect-skipped.png") }); // Shown for re-review: back in the cut, greyed and struck through, the correction on hover. - await page.locator("[data-play-show-incorrect]").check(); + await page.locator("[data-play-show-rejected]").check(); await expect(rows).toHaveCount(5); const c03 = page.locator('[data-play-row="c03"]'); - await expect(c03).toHaveAttribute("data-play-row-incorrect", ""); - await expect(c03).toHaveAttribute("title", "c03: marked incorrect — Other speaker, not the host."); + await expect(c03).toHaveAttribute("data-play-row-rejected", ""); + await expect(c03).toHaveAttribute("title", "c03: rejected — doesn't match: Other speaker, not the host"); await expect(page.locator("[data-play-skipped]")).toHaveCount(0); - await expect(page.locator("[data-play-incorrect]")).toContainText("Playing 1 clip marked incorrect"); + await expect(page.locator("[data-play-rejected]")).toContainText("Playing 1 rejected clip"); // Remembered by this browser. await page.reload(); await expect(root(page)).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 }); - await expect(page.locator("[data-play-show-incorrect]")).toBeChecked(); + await expect(page.locator("[data-play-show-rejected]")).toBeChecked(); await expect(rows).toHaveCount(5); - await page.locator("[data-play-show-incorrect]").uncheck(); + await page.locator("[data-play-show-rejected]").uncheck(); await expect(rows).toHaveCount(4); }); @@ -131,7 +132,7 @@ test("Edit this clip, then the browser's Back: Play the cut again, paused at the await expect(page.locator("[data-play-back-toast]")).toHaveCount(0); }); -test("Wrong speaker in Play the cut: asked in the page, the clip leaves the reel on record, Undo puts it back", async ({ page }) => { +test("Wrong speaker in Play the cut (Reject with its reason preset): asked in the page, the clip leaves the reel on record, Undo puts it back", async ({ page }) => { const WRONG = "reports/play-wrong-fixture"; const dir = path.join(HERE, "..", ".e2e-song", "reports", "play-wrong-fixture"); await page.setViewportSize({ width: 1366, height: 1000 }); @@ -143,11 +144,11 @@ test("Wrong speaker in Play the cut: asked in the page, the clip leaves the reel await expect(root(page)).toHaveAttribute("data-play-item", "c02"); await page.locator("[data-wrong-speaker-start]").click(); // It says what will go before anything is written. - await expect(page.locator("[data-wrong-speaker-what]")).toContainText("Remove c02 (playvid 3.50 s–5.50 s) from the cut as wrong speaker?"); + await expect(page.locator('[data-reject-ask="wrong-speaker"] [data-reject-what]')).toContainText("Reject c02 (playvid 3.50 s–5.50 s) as wrong speaker?"); expect(readFileSync(path.join(dir, "video.manifest.json"), "utf8")).toContain('"id": "c02"'); - await page.locator("[data-wrong-speaker-note]").fill("Other speaker, not the host"); - await page.locator("[data-wrong-speaker-remove]").click(); - await expect(page.locator('[data-wrong-speaker-removed="c02"]')).toBeVisible(); + await page.locator("[data-reject-note]").fill("Other speaker, not the host"); + await page.locator("[data-reject-remove]").click(); + await expect(page.locator('[data-reject-done="c02"]')).toContainText("Removed c02 from the cut (wrong speaker)."); await expect(rows).toHaveCount(4, { timeout: 15_000 }); await expect(page.locator('[data-play-row="c02"]')).toHaveCount(0); const m = JSON.parse(readFileSync(path.join(dir, "video.manifest.json"), "utf8")) as { timeline: { id: string }[] }; @@ -156,8 +157,65 @@ test("Wrong speaker in Play the cut: asked in the page, the clip leaves the reel expect(rec.removed.at(-1)).toMatchObject({ id: "c02", reason: "wrong-speaker", correction: "Other speaker, not the host", video: "playvid", start: 3.5, end: 5.5 }); await page.screenshot({ path: test.info().outputPath("play-wrong-speaker-removed.png") }); // Undo: back in the reel, where it was. - await page.locator("[data-wrong-speaker-undo]").click(); - await expect(page.locator("[data-wrong-speaker-undone]")).toBeVisible(); + await page.locator("[data-reject-undo]").click(); + await expect(page.locator("[data-reject-undone]")).toBeVisible(); await expect(rows).toHaveCount(5, { timeout: 15_000 }); expect(await rows.evaluateAll((els) => els.map((e) => e.getAttribute("data-play-row")))).toEqual(["c01", "c02", "k01", "c03", "c04"]); }); + +test("Reject ▾ in Play the cut: x then 3 rejects as irrelevant — out of the reel on record, Undo; keep in place skips it, says why, Undo", async ({ page }) => { + const REJ = "reports/play-reject-fixture"; + const dir = path.join(HERE, "..", ".e2e-song", "reports", "play-reject-fixture"); + const manifest = () => JSON.parse(readFileSync(path.join(dir, "video.manifest.json"), "utf8")) as { timeline: Record<string, unknown>[] }; + await page.setViewportSize({ width: 1366, height: 1000 }); + await page.goto(urls.playHref(REJ)); + await expect(root(page)).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 }); + const rows = page.locator("[data-play-row]"); + await expect(rows).toHaveCount(5); + await page.locator('[data-play-row="c02"]').press("Enter"); + await expect(root(page)).toHaveAttribute("data-play-item", "c02"); + + // x opens the reasons; "doesn't match" is one of seven, and only its own label says so. + await page.keyboard.press("x"); + const menu = page.locator("[data-reject-menu]"); + await expect(menu).toBeVisible(); + expect(await menu.locator("[data-reject-reason]").evaluateAll((els) => els.map((e) => e.getAttribute("data-reject-reason")))).toEqual([ + "not-matching", "wrong-speaker", "irrelevant", "repeats", "weak", "privacy", "other", + ]); + await expect(menu.locator('[data-reject-reason="irrelevant"]')).toHaveText("3irrelevant"); + await page.screenshot({ path: test.info().outputPath("play-reject-menu.png") }); + // 3: irrelevant. It is asked in the page, and it is not a correction. + await page.keyboard.press("3"); + const ask = page.locator('[data-reject-ask="irrelevant"]'); + await expect(ask.locator("[data-reject-what]")).toContainText("Reject c02 (playvid 3.50 s–5.50 s) as irrelevant?"); + await expect(ask.locator("[data-reject-what]")).toContainText("the report is right; nothing here is a correction"); + await expect(ask).not.toContainText("doesn't match"); + await page.locator("[data-reject-remove]").click(); + await expect(page.locator('[data-reject-done="c02"]')).toContainText("Removed c02 from the cut (irrelevant)."); + await expect(rows).toHaveCount(4, { timeout: 15_000 }); + expect(manifest().timeline.map((e) => e.id)).not.toContain("c02"); + const rec = JSON.parse(readFileSync(path.join(dir, "removed.json"), "utf8")) as { removed: Record<string, unknown>[] }; + expect(rec.removed.at(-1)).toMatchObject({ id: "c02", reason: "irrelevant", correction: null, video: "playvid", start: 3.5, end: 5.5 }); + await page.locator("[data-reject-undo]").click(); + await expect(page.locator("[data-reject-undone]")).toContainText("the clip is back in the cut"); + await expect(rows).toHaveCount(5, { timeout: 15_000 }); + expect(manifest().timeline.find((e) => e.id === "c02")?.verdict).toBeUndefined(); + + // Reject, keep in place: the verdict only. Play skips it and says why; Undo writes the verdict back. + await page.locator('[data-play-row="c02"]').press("Enter"); + await expect(root(page)).toHaveAttribute("data-play-item", "c02"); + await page.locator("[data-reject-open]").click(); + await page.locator('[data-reject-reason="weak"]').click(); + await page.locator("[data-reject-note]").fill("c01 says it better"); + await page.locator("[data-reject-keep]").click(); + await expect(page.locator('[data-reject-done="c02"]')).toContainText("Rejected c02 (weak), still in the cut."); + await expect.poll(() => manifest().timeline.find((e) => e.id === "c02")).toMatchObject({ verdict: "rejected", reason: "weak", rejectNote: "c01 says it better" }); + await expect(rows).toHaveCount(4, { timeout: 15_000 }); + await expect(page.locator('[data-play-skipped="c02"]')).toHaveAttribute("title", "c02 skipped — rejected — weak: c01 says it better"); + await expect(page.locator("[data-play-rejected]")).toContainText("Skipping 1 rejected clip: c02 (weak)"); + await page.screenshot({ path: test.info().outputPath("play-reject-kept.png") }); + await page.locator("[data-reject-undo]").click(); + await expect(page.locator("[data-reject-undone]")).toContainText("the verdict is as it was"); + await expect.poll(() => manifest().timeline.find((e) => e.id === "c02")?.verdict ?? null).toBeNull(); + await expect(rows).toHaveCount(5, { timeout: 15_000 }); +}); diff --git a/umtool/e2e/take-walk.spec.ts b/umtool/e2e/take-walk.spec.ts @@ -26,12 +26,14 @@ const takeClip = (id: string) => (takeDoc().patch.timeline as { id: string; verd /** The bench's keys answer once it has hydrated (`x` focuses the note box). */ const keyboardLive = async (page: import("@playwright/test").Page) => { - const box = page.locator("[data-attrib-field=correction]"); + // Live once the bench's own keys answer: `x` opens Reject ▾'s reasons, Escape closes them unasked. + const menu = page.locator("[data-reject-menu]"); await expect(async () => { await page.locator("body").press("x"); - await expect(box).toBeFocused({ timeout: 500 }); + await expect(menu).toBeVisible({ timeout: 500 }); }).toPass({ timeout: 10_000 }); - await box.blur(); + await page.locator("body").press("Escape"); + await expect(menu).toHaveCount(0); }; let masterBefore = ""; diff --git a/umtool/lib/inbox/groups.mjs b/umtool/lib/inbox/groups.mjs @@ -125,6 +125,7 @@ const ACTION_LABEL = { "clip-cue-gap": "Fix the window", "clip-cut-outside": "Fix the cut", "clip-incorrect": "Remove or fix the clip", + "clip-rejected": "Take the clip out", "window-overlap": "Fix the windows", "no-punctuation": "Check the windows", "manifest-invalid": "Fix the manifest", diff --git a/umtool/lib/inbox/what.mjs b/umtool/lib/inbox/what.mjs @@ -30,6 +30,7 @@ export const WHAT = { "clip-cue-gap": "clips over a cue gap", "clip-cut-outside": "cuts outside the window", "clip-incorrect": "clips marked incorrect", + "clip-rejected": "rejected clips still in the cut", "window-overlap": "windows overlap", "no-punctuation": "windows without punctuation", "manifest-invalid": "manifest invalid", diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs @@ -15,6 +15,7 @@ import { ffprobeSource, } from "umtool-report-to-video/sources"; import { rawCacheOf } from "../report/raw-cache.mjs"; +import { rejectionOf } from "../report/rejectReasons.mjs"; import { resolveVideoDirSync } from "yt-dlp-transcript-common/lib/videoDir-server.mjs"; import { deliverablesState, finishCommand, outDirState, leftoversOf } from "../report/storage.mjs"; import { CHANNELS_DIR, inside, resolveInRoots } from "../paths.mjs"; @@ -213,6 +214,7 @@ export function correctionsOf(m) { // What the walk said about the clip this text is attached to. A note on a // CONFIRMED clip is not a defect in the report, and a reader who cannot // tell the two apart will go and "fix" a clip nobody complained about. + // Nor is one on a REJECTED clip (irrelevant, weak, …): its facts are right. verdict: clipVerdict(e), })); } @@ -223,7 +225,10 @@ export function correctionsOf(m) { * "confirmed" -> the description is accurate. A `correction` here is a NOTE: * why a good clip's window moved, a caveat for the writers. * "incorrect" -> it is not, and the `correction` says how. The writer refuses - * one without the other. + * one without the other. A FACT verdict: the report is wrong. + * "rejected" -> accurate, but out of this cut, and `reason` says why + * (irrelevant, repeats, weak, privacy, other -- rejectReasons.mjs). + * NOT a fact verdict: nothing here is a correction. * absent -> nobody has been here yet. * * LEGACY: a clip carrying a `correction` and no `verdict` was written by the @@ -234,7 +239,7 @@ export function correctionsOf(m) { */ export const clipVerdict = (e) => { const v = e?.verdict; - if (v === "confirmed" || v === "incorrect") return v; + if (v === "confirmed" || v === "incorrect" || v === "rejected") return v; return String(e?.correction ?? "").trim() ? "incorrect" : "unreviewed"; }; @@ -252,6 +257,20 @@ export const incorrectWhy = (e) => { export const incorrectClips = (timeline) => (Array.isArray(timeline) ? timeline : []).filter((e) => e && (e.kind ?? e.type) === "clip" && clipVerdict(e) === "incorrect"); +/** The timeline's clips REJECTED for a cut reason (irrelevant, repeats, …) and still in it, in timeline order. */ +export const rejectedClips = (timeline) => + (Array.isArray(timeline) ? timeline : []).filter((e) => e && (e.kind ?? e.type) === "clip" && clipVerdict(e) === "rejected"); + +/** + * A clip REJECTED (not a fact error) that is still in the timeline, said once: + * `umtool check`'s open row. Not blocking -- the report is right, the cut just + * should not hold it; nothing is wrong until somebody ships it. + */ +export const rejectedWhy = (e, project = "<project>") => { + const r = rejectionOf(e); + return `${e?.id} is rejected (${r?.why ?? "rejected"}) but still in the cut — remove it (umtool timeline ${project} reject ${e?.id} ${r?.reason ?? "other"}), or clear the verdict`; +}; + /** Does this clip carry a written note, whatever the verdict says? */ export const clipHasNote = (e) => !!String(e?.correction ?? "").trim(); @@ -275,9 +294,11 @@ export function reviewOf(m) { /** Confirmed AND annotated: a note on a good clip is not a defect. */ confirmedWithNote: of("confirmed").filter((r) => r.note).length, incorrect: of("incorrect").length, + /** Rejected for a cut reason (irrelevant, repeats, …): not a defect in the report. */ + rejected: of("rejected").length, unreviewed: of("unreviewed").length, unreviewedIds: of("unreviewed").map((r) => r.id), - /** Confirmed or incorrect: somebody has been here and said something. */ + /** Confirmed, incorrect or rejected: somebody has been here and said something. */ reviewed: rows.length - of("unreviewed").length, }; } @@ -988,6 +1009,11 @@ export const REPORT_DECISION_KINDS = [ // would count its marks, and the video would cite a clip somebody already // said is wrong. Remove it, fix it and re-confirm, or clear the verdict. "clip-incorrect", + // A clip REJECTED for a cut reason (irrelevant, repeats, weak, privacy, + // other -- not a fact error) that is still in the timeline. `open`, not + // blocking: the report is right, and Play the cut already skips it; the + // decision left is to take it out (`umtool timeline <p> reject`). + "clip-rejected", // A ledger entry nobody has ruled on. BLOCKING, which is earned here: both // the stated and the implied total lie if you act on an unadjudicated ledger, // and they lie quietly, in a chart, with his name on it. @@ -1244,6 +1270,10 @@ export async function reportDecisions(ctx, summary) { for (const e of incorrectClips(clips)) { add("clip-incorrect", e.id, incorrectWhy(e), "blocking", { href: clipHref(e.id) }); } + // A clip rejected (irrelevant, weak, …) but kept in place: open, never blocking. + for (const e of rejectedClips(clips)) { + add("clip-rejected", e.id, rejectedWhy(e, id), "open", { href: clipHref(e.id) }); + } // THE CUT MUST BE INSIDE THE EXTENT. `start`/`end` is the reviewed extent and // `cutStart`/`cutEnd` is what actually plays; a cut outside it renders diff --git a/umtool/lib/report/deliver.mjs b/umtool/lib/report/deliver.mjs @@ -301,6 +301,7 @@ export async function deliverStateOf(project, { manifest = null, entries = null total: list.length, confirmed: list.filter((r) => r.verdict === "confirmed").length, incorrect: list.filter((r) => r.verdict === "incorrect").length, + rejected: list.filter((r) => r.verdict === "rejected").length, unreviewed: list.filter((r) => r.verdict === "unreviewed").length, cut: list.filter((r) => r.verdict === "confirmed" && r.cut).length, ids: list.map((r) => r.id), @@ -318,6 +319,8 @@ export async function deliverStateOf(project, { manifest = null, entries = null total: rows.length, confirmed: confirmed.length, incorrect: rows.filter((r) => r.verdict === "incorrect").length, + // Rejected for a cut reason (irrelevant, repeats, …): not confirmed, so never shared, and not a correction. + rejected: rows.filter((r) => r.verdict === "rejected").length, unreviewed: rows.filter((r) => r.verdict === "unreviewed").length, }, cut: confirmed.length - needCut.length, @@ -329,6 +332,7 @@ export async function deliverStateOf(project, { manifest = null, entries = null excluded: { shared: [...shared].sort(), incorrect: rows.filter((r) => r.verdict === "incorrect").map((r) => r.id), + rejected: rows.filter((r) => r.verdict === "rejected").map((r) => r.id), }, candidates: candidates.map((r) => ({ id: r.id, section: r.section, file: r.file })), nextName, @@ -357,7 +361,8 @@ export function renderListMd(project, name, sections, { excluded }) { `${total} clip${total === 1 ? "" : "s"}: every clip the umtool bench CONFIRMED, minus ` + `${excluded.shared.length} already shared${excluded.shared.length ? ` (${excluded.shared.join(" ")})` : ""}` + ` and ${excluded.incorrect.length} ruled incorrect` + - `${excluded.incorrect.length ? ` (${excluded.incorrect.join(" ")})` : ""}.`, + `${excluded.incorrect.length ? ` (${excluded.incorrect.join(" ")})` : ""}` + + `${excluded.rejected?.length ? ` and ${excluded.rejected.length} rejected (${excluded.rejected.join(" ")})` : ""}.`, "", "Folders: `orig/` (the cut as fetched), " + Object.entries(SHARE_PROFILES).map(([k, p]) => `\`${k}/\` (${p.label})`).join(", ") + diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -43,8 +43,8 @@ import { buildFileOf, outDirOf, variantsState } from "./variantsView.mjs"; export const AUDIO_KNOBS = Object.freeze(["offset", "gain", "fadeIn", "fadeOut"]); export const BLUR_KNOBS = Object.freeze(["on", "caption", "strength", "from", "to"]); const MARK_KEYS = ["marks", "mark.add", "mark.remove", "mark.verdict"]; -/** The walk's verdict, set like a knob: verdict=confirmed|incorrect|wrong-speaker, reason=wrong-speaker, correction=… (`key=` clears). */ -const REVIEW_KEYS = ["verdict", "reason", "correction"]; +/** The walk's verdict, set like a knob: verdict=confirmed|incorrect|rejected|<a reject reason>, reason=…, rejectNote=…, correction=… (`key=` clears). */ +const REVIEW_KEYS = ["verdict", "reason", "rejectNote", "correction"]; const SET_KEYS = [...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS]; export const SET_USAGE = [ @@ -59,8 +59,10 @@ export const SET_USAGE = [ " (the verdict by name or by this cut's label, e.g. Episodes@190.2; a JSON object for its knobs too);", " mark.remove=<id>; mark.verdict=<verdict> (the first mark's, or --mark <id>'s; every clip carrying", " the id); marks='[{\"id\":\"c1\",\"verdict\":\"CORROBORATED\",\"at\":190.2},…]' sets them all (`marks=` none).", - " verdict=confirmed|incorrect|wrong-speaker (the walk's; wrong-speaker is incorrect + reason=wrong-speaker,", - " which needs no correction); correction=<what the report got wrong>; `verdict=` clears it.", + " verdict=confirmed|incorrect|rejected, or a reject reason as shorthand (the walk's; lib/report/rejectReasons.mjs):", + " not-matching|wrong-speaker are FACT errors -- incorrect (+ reason=wrong-speaker, which needs no correction);", + " irrelevant|repeats|weak|privacy|other are CUT reasons -- rejected + reason, rejectNote=<why> (other needs one),", + " never a correction; correction=<what the report got wrong>; `verdict=` clears it.", " audio.offset ms (-2000…2000, + = sound later),", " audio.gain dB (-20…20), audio.fadeIn / audio.fadeOut s (0–5).", " blur.on=true blurs the clip's picture at the encode (the sound untouched; `blur.on=` clears the whole blur);", @@ -208,7 +210,12 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("blur" in entryPatch) results.blur = result.entry.blur ?? null; if ("layout" in entryPatch) results.layout = result.entry.layout ?? "clip"; if (REVIEW_KEYS.some((k) => k in entryPatch)) { - results.review = { verdict: result.entry.verdict ?? null, reason: result.entry.reason ?? null, correction: result.entry.correction ?? null }; + results.review = { + verdict: result.entry.verdict ?? null, + reason: result.entry.reason ?? null, + ...(result.entry.rejectNote ? { rejectNote: result.entry.rejectNote } : {}), + correction: result.entry.correction ?? null, + }; } notes = editNotes ?? notes; } @@ -229,8 +236,10 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("layout" in results) out(`${clipId}: layout ${results.layout}`); if (results.review) { const r = results.review; - out(`${clipId}: ${r.verdict ?? "not reviewed"}${r.reason ? ` (${r.reason})` : ""}${r.correction ? ` — ${r.correction}` : ""}`); - if (r.reason === "wrong-speaker") out(` still in the cut: umtool timeline <project> wrong-speaker ${clipId} takes it out, on the record`); + out(`${clipId}: ${r.verdict ?? "not reviewed"}${r.reason ? ` (${r.reason}${r.rejectNote ? `: ${r.rejectNote}` : ""})` : ""}${r.correction ? ` — ${r.correction}` : ""}`); + if (r.reason === "wrong-speaker" || r.verdict === "rejected") { + out(` still in the cut: umtool timeline <project> reject ${clipId} ${r.reason} takes it out, on the record`); + } } const n = noted(notes); if (n) out(n); diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -54,6 +54,7 @@ import { } from "./knobs.mjs"; import { validateNarration } from "umtool-report-to-video/narration"; import { parseMuteFrom } from "./playback.mjs"; +import { FACT_REASONS, applyVerdictPatch, rejectPatch, rejectReasonOf } from "./rejectReasons.mjs"; import { DELIVERABLES_MODES } from "./storage.mjs"; import { createSnapshot, listSnapshots } from "./snapshots.mjs"; import { benchPrepAfterWrite } from "./benchPrepTrigger.mjs"; @@ -92,9 +93,10 @@ function withManifestLock(fn) { /** * The structured reasons an incorrect verdict may carry (`reason`): each says * what is wrong without a note. "wrong-speaker": somebody else is talking -- - * the clip comes out of the cut (removeWrongSpeaker), on the record. + * the clip comes out of the cut (removeWrongSpeaker), on the record. The + * reasons a clip is REJECTED (verdict "rejected") are rejectReasons.mjs's. */ -export const VERDICT_REASONS = Object.freeze(["wrong-speaker"]); +export const VERDICT_REASONS = FACT_REASONS; export const MANIFEST_NAME = "video.manifest.json"; const manifestFile = (dir) => path.join(dir, MANIFEST_NAME); @@ -491,63 +493,14 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n // ---- the walk's verdict ------------------------------------------------- // - // Whether somebody has LOOKED at this clip and said the description is what - // the clip actually is. Three states, and an absent key is the honest way - // to say "nobody has been here": - // - // verdict: "confirmed" -> the description is accurate - // verdict: "incorrect" -> it is not, and `correction` says how - // neither -> not yet reviewed - // - // `correction` is OPTIONAL under a confirmed verdict and REQUIRED under an - // incorrect one. The two are not the same sentence: a note on a good clip - // is why its window moved or a caveat for the writers, while an incorrect - // clip with no note is a complaint nobody can act on. So the rule is a - // property of the ENTRY AFTER the patch, which makes both halves of it one - // check -- setting `incorrect` with no note, and clearing the note off a - // clip that is already `incorrect`, are the same error. - // - // LEGACY, and deliberately not migrated: a clip carrying a `correction` and - // no `verdict` predates `incorrect` and READS as incorrect (clipVerdict()). - // The requirement above is keyed on the explicit value, so those entries can - // still be cleared -- a rule that refused to let somebody undo a note they - // wrote before the rule existed would be a trap. - // - // A STRUCTURED REASON beside an incorrect verdict (`reason`, one of - // VERDICT_REASONS): "wrong-speaker" -- the clip is somebody else talking, - // which says what is wrong without a note, so it stands for one. A reason - // goes only with `incorrect`; a verdict changed to anything else drops it. - // `verdict: "wrong-speaker"` is shorthand for incorrect + that reason (the - // CLI's `umtool set <p> <clip> verdict=wrong-speaker`). - let reasonIn = patch.reason; - if (patch.verdict !== undefined) { - let v = String(patch.verdict ?? "").trim(); - if (VERDICT_REASONS.includes(v)) { - if (reasonIn === undefined) reasonIn = v; - v = "incorrect"; - } - if (!v) delete entry.verdict; - else if (v !== "confirmed" && v !== "incorrect") { - throw new Error( - `verdict must be "confirmed", "incorrect" or ${VERDICT_REASONS.map((r) => `"${r}"`).join(", ")}, or empty to clear it (got \`${v}\`)`, - ); - } else entry.verdict = v; - if (entry.verdict !== "incorrect" && reasonIn === undefined) delete entry.reason; - } - if (reasonIn !== undefined) { - const r = String(reasonIn ?? "").trim(); - if (!r) delete entry.reason; - else if (!VERDICT_REASONS.includes(r)) { - throw new Error(`reason must be ${VERDICT_REASONS.map((x) => `"${x}"`).join(", ")}, or empty to clear it (got \`${r}\`); say anything else in the correction`); - } else entry.reason = r; - } - if (entry.reason && entry.verdict !== "incorrect") { - throw new Error(`a reason (${entry.reason}) goes with an incorrect verdict`); - } - - if (entry.verdict === "incorrect" && !String(entry.correction ?? "").trim() && !entry.reason) { - throw new Error("an incorrect verdict needs its note: say what the report got wrong"); - } + // Whether somebody has LOOKED at this clip, and what they said: confirmed, + // incorrect (a FACT error -- doesn't match, wrong speaker -- `correction` + // says what the report got wrong), or rejected (accurate, but out of this + // cut: irrelevant, repeats, weak, privacy, other). The rule is a property + // of the ENTRY AFTER the patch -- setting `incorrect` with no note and + // clearing the note off an incorrect clip are the same error. The whole + // vocabulary and its rules: rejectReasons.mjs (applyVerdictPatch). + applyVerdictPatch(entry, patch); // ---- what the deck will say --------------------------------------------- // @@ -1798,8 +1751,9 @@ export async function removeEntry(dir, id, { token = null, at = null } = {}) { // ---- removals on the record ------------------------------------------------ // // `removed.json` beside the manifest: every clip taken out of the cut BECAUSE -// of what it is (Wrong speaker), newest last -- its id, where it came from -// (channel, video, window), the reason, the correction, when. Append-only: an +// of what it is (Reject: wrong speaker, irrelevant, …), newest last -- its id, +// where it came from (channel, video, window), the reason (rejectReasons.mjs), +// the correction, the reject note (`note`, when one was given), when. Append-only: an // undo puts the clip back in the timeline and leaves the line, and a reader // (`umtool corrections`) lists only those still out of the cut. export const REMOVED_FILE = "removed.json"; @@ -1835,17 +1789,39 @@ async function recordRemoved(dir, row) { * @param {{ token?: string | null, at?: number | null, correction?: string | null, now?: () => Date }} [opts] */ export async function removeWrongSpeaker(dir, id, { token = null, at = null, correction = null, now = () => new Date() } = {}) { - const res = await structural(dir, "wrong-speaker", token, (m) => { + return rejectClip(dir, id, "wrong-speaker", { token, at, note: correction, now }); +} + +/** + * REJECT, TAKEN OUT: one write that rejects clip `id` for `reason` (one of + * rejectReasons.mjs's REJECT_REASONS: a fact reason marks it `incorrect`, + * the note its correction; a cut reason marks it `rejected`, the note its + * rejectNote) and takes it out of the timeline -- removeEntry's path, an undo + * point first, what named it re-anchored -- then puts the removal on record + * (removed.json, with the reason and the note). `umtool timeline <p> reject + * <id> <reason>`, the walk's and Play the cut's Reject. + * + * @param {string} dir + * @param {string} id + * @param {string} reason + * @param {{ token?: string | null, at?: number | null, note?: string | null, now?: () => Date }} [opts] + */ +export async function rejectClip(dir, id, reason, { token = null, at = null, note = null, now = () => new Date() } = {}) { + const r = rejectReasonOf(String(reason ?? "").trim()); + const verdictPatch = rejectPatch(String(reason ?? "").trim(), note); + const res = await structural(dir, r?.id === "wrong-speaker" ? "wrong-speaker" : "reject", token, (m) => { const entry = m.timeline[entryIndex(m.timeline, id, at)]; if (entry.type !== "clip") throw new Error(`${id} is a ${entry.type ?? "non-clip"} entry, not a clip`); - patchClipEntry(m, id, { verdict: "incorrect", reason: "wrong-speaker", ...(correction ? { correction } : {}) }); + patchClipEntry(m, id, verdictPatch); return removeIn(m, id, at); }); const e = res.removed ?? {}; + const rejectNote = String(e.rejectNote ?? "").trim(); const record = { id, - reason: "wrong-speaker", + reason: r?.id ?? String(reason), correction: String(e.correction ?? "").trim() || null, + ...(rejectNote ? { note: rejectNote } : {}), channel: typeof e.channel === "string" ? e.channel : null, video: typeof e.video === "string" ? e.video : null, start: e.start ?? null, diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs @@ -11,7 +11,8 @@ import { DEFAULT_VARIANT, selectVariant } from "umtool-report-to-video/build-video"; import { deckOn, estimatedDuration, estimateSchedule, scheduleFrom, transitionOf } from "umtool-report-to-video/deck"; import { resolveFactcheck } from "umtool-report-to-video/factcheck"; -import { clipDateKey, clipVerdict, readManifest } from "../projects/report.mjs"; +import { clipDateKey, readManifest } from "../projects/report.mjs"; +import { rejectionOf } from "./rejectReasons.mjs"; import { dateKeyLabel } from "./playCut.mjs"; import { pickWindow, projectCache, windowVersion, windowsFor } from "./serve.mjs"; import { playableTakes, resolveTakeManifest } from "./takeManifest.mjs"; @@ -77,8 +78,19 @@ export async function playView(project, { take = null } = {}) { cutStart: fin(e.cutStart) ? e.cutStart : null, cutEnd: fin(e.cutEnd) ? e.cutEnd : null, blur: e.blur && typeof e.blur === "object" ? e.blur : null, - // Ruled incorrect (the walk's verdict): its correction -- Play skips it unless asked to show it. - incorrect: clipVerdict(e) === "incorrect" ? text(e.correction) || (e.reason === "wrong-speaker" ? "wrong speaker" : "marked incorrect") : null, + // Rejected by the walk (a fact error -- doesn't match, wrong speaker -- or a cut + // reason: irrelevant, repeats, …): why, in words -- Play skips it unless asked to show it. + rejected: (() => { + const r = rejectionOf(e); + return r ? { reason: r.reason, label: r.label, fact: r.fact, why: r.why } : null; + })(), + // The verdict's fields as written: what Reject prefills, and what its keep-in-place Undo writes back. + review: { + verdict: typeof e.verdict === "string" ? e.verdict : null, + reason: typeof e.reason === "string" ? e.reason : null, + correction: typeof e.correction === "string" ? e.correction : null, + rejectNote: typeof e.rejectNote === "string" ? e.rejectNote : null, + }, // The window the bench would play: its name for the raw route, the source second its file starts at, // and the version of its bytes (`v`: a refetch under the same name is a new URL -- serve.mjs, // "A REPLACED FILE IS A NEW FILE"). diff --git a/umtool/lib/report/reject-reasons.test.mjs b/umtool/lib/report/reject-reasons.test.mjs @@ -0,0 +1,181 @@ +// Why a clip is rejected on the walk (lib/report/rejectReasons.mjs): FACT +// reasons (not-matching, wrong-speaker) stay the `incorrect` verdict -- a +// correction for the report, blocking in `umtool check` -- while CUT reasons +// (irrelevant, repeats, weak, privacy, other) are `verdict: "rejected"`, never +// a correction, and an OPEN check row while the clip is still in the cut. +// Manifests written before (incorrect, with or without wrong-speaker; a legacy +// correction with no verdict) read exactly as they did. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { MANIFEST_NAME, REMOVED_FILE, patchClipEntry, readRemoved, rejectClip, undoStructural } from "./manifest.mjs"; +import { CUT_REASONS, FACT_REASONS, REJECT_REASONS, rejectPatch, rejectionOf } from "./rejectReasons.mjs"; +import { clipVerdict, correctionsOf, incorrectClips, incorrectWhy, rejectedClips, rejectedWhy, reviewOf } from "../projects/report.mjs"; +import { decisionsFor } from "../projects/core.mjs"; +import { walkProjects } from "../projects/walk.mjs"; + +const clip = (id, extra = {}) => ({ type: "clip", id, video: `v-${id}`, start: 10, end: 20, ...extra }); +const base = () => ({ slug: "t", provenance: { channelSlug: "chan" }, render: { width: 1920, height: 1080, fps: 30 }, timeline: [clip("c01"), clip("c02"), clip("c03")] }); + +test("the vocabulary: seven reasons in menu order, two of them fact errors", () => { + assert.deepEqual(REJECT_REASONS.map((r) => r.id), ["not-matching", "wrong-speaker", "irrelevant", "repeats", "weak", "privacy", "other"]); + assert.deepEqual(FACT_REASONS, ["wrong-speaker"]); + assert.deepEqual(CUT_REASONS, ["irrelevant", "repeats", "weak", "privacy", "other"]); + // Only "doesn't match" says doesn't match. + assert.deepEqual(REJECT_REASONS.filter((r) => /match/.test(r.label)).map((r) => r.id), ["not-matching"]); +}); + +test("rejectPatch: a fact reason is incorrect (the note its correction); a cut reason is rejected (the note its rejectNote)", () => { + assert.deepEqual(rejectPatch("not-matching", "Says 2019, not 2020."), { verdict: "incorrect", reason: "", correction: "Says 2019, not 2020." }); + assert.throws(() => rejectPatch("not-matching", ""), /needs its note/); + assert.deepEqual(rejectPatch("wrong-speaker"), { verdict: "incorrect", reason: "wrong-speaker" }); + assert.deepEqual(rejectPatch("irrelevant"), { verdict: "rejected", reason: "irrelevant", rejectNote: "" }); + assert.deepEqual(rejectPatch("repeats", "c01"), { verdict: "rejected", reason: "repeats", rejectNote: "c01" }); + assert.throws(() => rejectPatch("other", " "), /other needs a note/); + assert.throws(() => rejectPatch("boring"), /a reject reason is one of/); +}); + +test("the writer: rejected + a cut reason; shorthands; a reason only with the verdict it explains; a new verdict drops them", () => { + const m = base(); + // Shorthand: verdict=<cut reason> is rejected + that reason. + patchClipEntry(m, "c01", { verdict: "irrelevant", rejectNote: "about the 2019 tour" }); + assert.deepEqual([m.timeline[0].verdict, m.timeline[0].reason, m.timeline[0].rejectNote], ["rejected", "irrelevant", "about the 2019 tour"]); + assert.equal(m.timeline[0].correction, undefined, "a cut reason is never a correction"); + // Spelled out. + patchClipEntry(m, "c02", { verdict: "rejected", reason: "weak" }); + assert.equal(m.timeline[1].reason, "weak"); + // Refusals, in sentences. + assert.throws(() => patchClipEntry(m, "c03", { verdict: "rejected" }), /needs its reason/); + assert.throws(() => patchClipEntry(m, "c03", { verdict: "rejected", reason: "wrong-speaker" }), /fact error: its verdict is incorrect/); + assert.throws(() => patchClipEntry(m, "c03", { verdict: "incorrect", reason: "irrelevant" }), /not a fact error/); + assert.throws(() => patchClipEntry(m, "c03", { verdict: "other" }), /other needs a note/); + assert.throws(() => patchClipEntry(m, "c03", { verdict: "confirmed", rejectNote: "x" }), /goes with a rejected verdict/); + assert.throws(() => patchClipEntry(m, "c03", { verdict: "maybe" }), /verdict must be "confirmed", "incorrect", "rejected"/); + // not-matching is the bare incorrect verdict: no reason stored, a note required. + assert.throws(() => patchClipEntry(m, "c03", { verdict: "not-matching" }), /needs its note/); + patchClipEntry(m, "c03", { verdict: "not-matching", correction: "Wrong date." }); + assert.deepEqual([m.timeline[2].verdict, m.timeline[2].reason], ["incorrect", undefined]); + // Rejected -> incorrect: the cut reason and its note go; the correction is required again. + assert.throws(() => patchClipEntry(m, "c01", { verdict: "incorrect" }), /needs its note/); + patchClipEntry(m, "c01", { verdict: "wrong-speaker" }); + assert.deepEqual([m.timeline[0].verdict, m.timeline[0].reason, m.timeline[0].rejectNote], ["incorrect", "wrong-speaker", undefined]); + // Incorrect (wrong speaker) -> rejected: the fact reason goes with it. + patchClipEntry(m, "c01", { verdict: "privacy" }); + assert.deepEqual([m.timeline[0].verdict, m.timeline[0].reason], ["rejected", "privacy"]); + // Confirmed: reason and note gone. + patchClipEntry(m, "c02", { verdict: "confirmed" }); + assert.deepEqual([m.timeline[1].verdict, m.timeline[1].reason, m.timeline[1].rejectNote], ["confirmed", undefined, undefined]); + // Cleared. + patchClipEntry(m, "c01", { verdict: "" }); + assert.deepEqual([m.timeline[0].verdict, m.timeline[0].reason], [undefined, undefined]); +}); + +test("back-compat: a manifest written before reasons reads exactly as before", () => { + const old = { + timeline: [ + clip("a", { verdict: "incorrect", correction: "Other speaker, not Ember." }), + clip("b", { verdict: "incorrect", reason: "wrong-speaker" }), + clip("c", { correction: "wrong date" }), // the bench's legacy `x` + clip("d", { verdict: "confirmed", correction: "window moved" }), + clip("e"), + ], + }; + assert.deepEqual(old.timeline.map(clipVerdict), ["incorrect", "incorrect", "incorrect", "confirmed", "unreviewed"]); + assert.deepEqual(incorrectClips(old.timeline).map((e) => e.id), ["a", "b", "c"]); + assert.deepEqual(rejectedClips(old.timeline), []); + assert.equal(incorrectWhy(old.timeline[0]), "a is marked incorrect: Other speaker, not Ember — remove it, fix it and re-confirm, or clear the verdict"); + assert.equal(incorrectWhy(old.timeline[1]), "b is marked incorrect: wrong speaker — remove it, fix it and re-confirm, or clear the verdict"); + assert.deepEqual(correctionsOf(old).map((c) => [c.id, c.text, c.verdict]), [ + ["a", "Other speaker, not Ember.", "incorrect"], + ["b", "Wrong speaker.", "incorrect"], + ["c", "wrong date", "incorrect"], + ["d", "window moved", "confirmed"], + ]); + // And says why, in the new words. + assert.deepEqual(old.timeline.map((e) => rejectionOf(e)?.why ?? null), ["doesn't match: Other speaker, not Ember", "wrong speaker", "doesn't match: wrong date", null, null]); + const r = reviewOf(old); + assert.deepEqual([r.incorrect, r.rejected, r.confirmed, r.unreviewed, r.reviewed], [3, 0, 1, 1, 4]); +}); + +test("a rejected clip is not a correction: correctionsOf leaves it out unless it carries a note, and then as a note", () => { + const m = { timeline: [clip("a", { verdict: "rejected", reason: "irrelevant" }), clip("b", { verdict: "rejected", reason: "weak", correction: "the window moved" })] }; + assert.deepEqual(correctionsOf(m).map((c) => [c.id, c.verdict]), [["b", "rejected"]]); + assert.deepEqual(incorrectClips(m.timeline), []); + assert.deepEqual(rejectedClips(m.timeline).map((e) => e.id), ["a", "b"]); + assert.equal(rejectedWhy(m.timeline[0], "p"), "a is rejected (irrelevant) but still in the cut — remove it (umtool timeline p reject a irrelevant), or clear the verdict"); + assert.equal(reviewOf(m).rejected, 2); +}); + +test("rejectClip: rejected, taken out, re-anchored and on record with the reason and note; undo puts it back", async () => { + const dir = await mkdtemp(path.join(tmpdir(), "umtool-reject-")); + try { + await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(base(), null, 2) + "\n"); + const r = await rejectClip(dir, "c02", "repeats", { note: "covered by c01", now: () => new Date("2026-10-30T12:00:00Z") }); + assert.deepEqual([r.removed.verdict, r.removed.reason, r.removed.rejectNote], ["rejected", "repeats", "covered by c01"]); + assert.ok(r.snapshot?.rel, "an undo point"); + const m = JSON.parse(await readFile(path.join(dir, MANIFEST_NAME), "utf8")); + assert.deepEqual(m.timeline.map((e) => e.id), ["c01", "c03"]); + const rec = (await readRemoved(dir)).at(-1); + assert.deepEqual( + { ...rec, reanchored: rec.reanchored.length }, + { id: "c02", reason: "repeats", correction: null, note: "covered by c01", channel: null, video: "v-c02", start: 10, end: 20, at: 1, reanchored: 0, when: "2026-10-30T12:00:00.000Z" }, + ); + await undoStructural(dir); + const back = JSON.parse(await readFile(path.join(dir, MANIFEST_NAME), "utf8")); + assert.deepEqual(back.timeline.map((e) => e.id), ["c01", "c02", "c03"]); + assert.equal(back.timeline[1].verdict, undefined, "the undo point is the file before the rejection"); + // A fact reason: incorrect, the note its correction, on record as such. + const f = await rejectClip(dir, "c03", "not-matching", { note: "He says March." }); + assert.deepEqual([f.removed.verdict, f.removed.reason, f.removed.correction], ["incorrect", undefined, "He says March."]); + assert.deepEqual([f.record.reason, f.record.correction, "note" in f.record], ["not-matching", "He says March.", false]); + // Refused before anything is written. + await assert.rejects(rejectClip(dir, "c01", "not-matching"), /needs its note/); + await assert.rejects(rejectClip(dir, "c01", "nope"), /a reject reason is one of/); + assert.equal(JSON.parse(await readFile(path.join(dir, REMOVED_FILE), "utf8")).removed.length, 2); + } finally { + await rm(dir, { recursive: true }); + } +}); + +async function decisionsOf(timeline) { + const root = await mkdtemp(path.join(tmpdir(), "clip-rejected-")); + try { + const channelsDir = path.join(root, "channels"); + const reportsRoot = path.join(root, "reports"); + const vdir = path.join(channelsDir, "chan", "data", "vid"); + await mkdir(vdir, { recursive: true }); + const cues = Array.from({ length: 200 }, (_, i) => ({ start: i, end: i + 1, text: `Line ${i}.` })); + await writeFile(path.join(vdir, "transcript.cues.json"), JSON.stringify({ cues })); + const dir = path.join(reportsRoot, "cut"); + await mkdir(dir, { recursive: true }); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({ + schemaVersion: 1, slug: "cut", title: "Cut", + provenance: { channelSlug: "chan", channelsDir: path.relative(dir, channelsDir), siteOrigin: "https://example.test" }, + render: { width: 1920, height: 1080, fps: 30 }, + timeline: timeline.map((e) => ({ type: "clip", video: "vid", cite: Math.floor(e.start), lock: true, ...e })), + }, null, 2)); + const [ref] = (await walkProjects(reportsRoot)).filter((p) => p.id === "cut"); + return (await decisionsFor(ref, reportsRoot)).filter((d) => d.kind === "clip-incorrect" || d.kind === "clip-rejected"); + } finally { + await rm(root, { recursive: true, force: true }); + } +} + +test("umtool check: a fact error still in the cut blocks; a cut reason kept in place is open, never blocking", async () => { + const ds = await decisionsOf([ + { id: "c01", start: 10, end: 20, verdict: "rejected", reason: "irrelevant" }, + { id: "c02", start: 30, end: 40, verdict: "incorrect", reason: "wrong-speaker" }, + { id: "c03", start: 50, end: 60, verdict: "rejected", reason: "other", rejectNote: "the audio clips" }, + { id: "c04", start: 70, end: 80, verdict: "confirmed" }, + ]); + assert.deepEqual(ds.map((d) => [d.kind, d.target, d.severity, d.why]), [ + ["clip-incorrect", "c02", "blocking", "c02 is marked incorrect: wrong speaker — remove it, fix it and re-confirm, or clear the verdict"], + ["clip-rejected", "c01", "open", "c01 is rejected (irrelevant) but still in the cut — remove it (umtool timeline cut reject c01 irrelevant), or clear the verdict"], + ["clip-rejected", "c03", "open", "c03 is rejected (other: the audio clips) but still in the cut — remove it (umtool timeline cut reject c03 other), or clear the verdict"], + ]); +}); diff --git a/umtool/lib/report/rejectReasons.mjs b/umtool/lib/report/rejectReasons.mjs @@ -0,0 +1,197 @@ +// WHY A CLIP IS REJECTED ON THE WALK (operator, 2026-10-30: "I tend to want to +// reject clips not because they don't match, but are irrelevant ... non-matching +// being one reason among others"). +// +// One vocabulary, read by the writer (manifest.mjs patchClipEntry, rejectClip), +// `umtool check`, Play the cut, the clip bench, the CLI and the docs. Two kinds +// of reason, stored two ways ON PURPOSE, because they mean different things to +// the REPORT: +// +// FACT reasons -- the report got something wrong. `verdict: "incorrect"`, as +// it always was: `correction` says what (`umtool corrections` hands it to the +// next report pass), and a clip like that still in the cut BLOCKS `umtool +// check` (clip-incorrect). +// not-matching what is said does not match the quote or claim. The +// `incorrect` verdict with no `reason` -- every manifest +// written before this file reads exactly as before. +// wrong-speaker somebody else is talking (`reason: "wrong-speaker"`). +// +// CUT reasons -- the report is RIGHT; the clip just does not belong in this +// cut. `verdict: "rejected"` + `reason`, with an optional `rejectNote`. Never +// a correction: "irrelevant" must not read as "the report is wrong". Still in +// the cut, it is an OPEN (not blocking) check row (clip-rejected). +// irrelevant accurate, but not relevant to this cut +// repeats covered by an earlier clip (the note: which one) +// weak accurate and relevant, not strong enough +// privacy holds something that must not be published +// other anything else -- the note says what (required) + +/** + * @typedef {{ id: string, label: string, fact: boolean, hint: string, note: "required" | "optional", placeholder: string }} RejectReason + */ + +/** @type {readonly RejectReason[]} In menu order: the digit is the index + 1. */ +export const REJECT_REASONS = Object.freeze([ + { id: "not-matching", label: "doesn't match", fact: true, note: "required", hint: "what is said doesn't match the quote or claim — a correction for the report", placeholder: "what the report got wrong: wording, addressee, date…" }, + { id: "wrong-speaker", label: "wrong speaker", fact: true, note: "optional", hint: "somebody else is talking — a correction for the report", placeholder: "who it is, if you know (optional)" }, + { id: "irrelevant", label: "irrelevant", fact: false, note: "optional", hint: "accurate, but not relevant to this cut", placeholder: "why, if it helps (optional)" }, + { id: "repeats", label: "repeats", fact: false, note: "optional", hint: "covered by an earlier clip", placeholder: "which clip it repeats, e.g. c07 (optional)" }, + { id: "weak", label: "weak", fact: false, note: "optional", hint: "accurate and relevant, but not strong enough", placeholder: "what is missing, if it helps (optional)" }, + { id: "privacy", label: "privacy", fact: false, note: "optional", hint: "contains something that must not be published (identifying info)", placeholder: "what, so nobody puts it back (optional)" }, + { id: "other", label: "other", fact: false, note: "required", hint: "anything else — say what", placeholder: "why it comes out (required)" }, +]); + +/** The structured reasons an `incorrect` verdict may carry (`reason`). not-matching is the bare verdict. */ +export const FACT_REASONS = Object.freeze(["wrong-speaker"]); + +/** The reasons a `rejected` verdict carries (`reason`, required). */ +export const CUT_REASONS = Object.freeze(REJECT_REASONS.filter((r) => !r.fact).map((r) => r.id)); + +/** Every reason id, both kinds. */ +export const REJECT_REASON_IDS = Object.freeze(REJECT_REASONS.map((r) => r.id)); + +/** @param {string} id */ +export const rejectReasonOf = (id) => REJECT_REASONS.find((r) => r.id === id) ?? null; + +const flat = (v) => (typeof v === "string" ? v.replace(/\s+/g, " ").trim() : ""); + +/** + * Why this clip is rejected, read off the entry -- null when it is not (unreviewed + * or confirmed). A legacy `correction` with no verdict is `incorrect`, as + * clipVerdict() reads it. + * + * @param {any} e a timeline entry + * @returns {null | { reason: string, label: string, fact: boolean, note: string, why: string }} + */ +export function rejectionOf(e) { + const v = e?.verdict; + const correction = flat(e?.correction); + if (v === "rejected") { + const r = rejectReasonOf(String(e?.reason ?? "")) ?? rejectReasonOf("other"); + const note = flat(e?.rejectNote); + return { reason: /** @type {RejectReason} */ (r).id, label: /** @type {RejectReason} */ (r).label, fact: false, note, why: note ? `${r?.label}: ${note}` : String(r?.label) }; + } + if (v === "incorrect" || (v !== "confirmed" && v !== "rejected" && correction)) { + const r = e?.reason === "wrong-speaker" ? rejectReasonOf("wrong-speaker") : rejectReasonOf("not-matching"); + const note = correction.replace(/[.\s]+$/, ""); + return { reason: /** @type {RejectReason} */ (r).id, label: /** @type {RejectReason} */ (r).label, fact: true, note, why: note ? `${r?.label}: ${note}` : String(r?.label) }; + } + return null; +} + +/** + * The clip-entry patch (manifest.mjs patchClipEntry) that rejects a clip for + * `reason`, with `note`: a fact reason writes the `incorrect` verdict and the + * note as its `correction`; a cut reason writes `rejected` + `reason` + + * `rejectNote` (and leaves any correction alone -- a note on a clip whose + * facts are right is still only a note). + * + * @param {string} reason + * @param {string | null | undefined} [note] + * @returns {Record<string, string>} + */ +export function rejectPatch(reason, note) { + const r = rejectReasonOf(String(reason ?? "").trim()); + if (!r) throw new Error(`a reject reason is one of ${REJECT_REASON_IDS.join(", ")} (got \`${reason}\`)`); + const n = String(note ?? "").trim(); + if (r.note === "required" && !n) { + throw new Error(r.id === "not-matching" ? "doesn't match needs its note: say what the report got wrong" : `${r.label} needs a note: say why it comes out`); + } + if (r.id === "not-matching") return { verdict: "incorrect", reason: "", correction: n }; + if (r.id === "wrong-speaker") return { verdict: "incorrect", reason: "wrong-speaker", ...(n ? { correction: n } : {}) }; + return { verdict: "rejected", reason: r.id, rejectNote: n }; +} + +/** + * THE WALK'S VERDICT, written onto a clip entry (manifest.mjs patchClipEntry + * calls this after the attribution fields, so `correction` is already the + * patched one). Mutates `entry`; throws in a sentence on a bad value. + * + * verdict: "confirmed" -> the description is accurate + * verdict: "incorrect" -> it is not (a FACT reason), and `correction` says how + * -- or `reason: "wrong-speaker"` stands for the note + * verdict: "rejected" -> accurate, but out of this cut: `reason` is one of + * CUT_REASONS, `rejectNote` optional (required for other) + * neither -> not yet reviewed + * + * Shorthands, so a CLI `verdict=<reason>` says it in one word: a FACT reason + * ("not-matching", "wrong-speaker") is `incorrect` + that reason, a CUT reason + * is `rejected` + it. A verdict changed to anything else drops the reason and + * the rejectNote (a reason goes only with the verdict it explains). + * + * LEGACY, and deliberately not migrated: a clip carrying a `correction` and no + * `verdict` predates `incorrect` and READS as incorrect (clipVerdict()). The + * note requirement is keyed on the explicit value, so those entries can still + * be cleared. + * + * @param {Record<string, any>} entry + * @param {Record<string, any>} patch + */ +export function applyVerdictPatch(entry, patch) { + let reasonIn = patch.reason; + if (patch.verdict !== undefined) { + let v = String(patch.verdict ?? "").trim(); + if (v === "not-matching") { + if (reasonIn === undefined) reasonIn = ""; + v = "incorrect"; + } else if (FACT_REASONS.includes(v)) { + if (reasonIn === undefined) reasonIn = v; + v = "incorrect"; + } else if (CUT_REASONS.includes(v)) { + if (reasonIn === undefined) reasonIn = v; + v = "rejected"; + } + if (!v) delete entry.verdict; + else if (v !== "confirmed" && v !== "incorrect" && v !== "rejected") { + throw new Error( + `verdict must be "confirmed", "incorrect", "rejected" or a reject reason (${REJECT_REASON_IDS.join(", ")}), or empty to clear it (got \`${v}\`)`, + ); + } else entry.verdict = v; + if (entry.verdict !== "incorrect" && entry.verdict !== "rejected" && reasonIn === undefined) delete entry.reason; + // A reason belongs to the verdict it explains: a fact reason does not survive a move to rejected, nor the reverse. + if (reasonIn === undefined && entry.reason) { + const fits = entry.verdict === "rejected" ? CUT_REASONS : FACT_REASONS; + if (!fits.includes(entry.reason)) delete entry.reason; + } + } + if (reasonIn !== undefined) { + let r = String(reasonIn ?? "").trim(); + // not-matching IS the bare incorrect verdict: no reason stored. + if (r === "not-matching" && entry.verdict === "incorrect") r = ""; + const allowed = entry.verdict === "rejected" ? CUT_REASONS : FACT_REASONS; + if (!r) delete entry.reason; + else if (!allowed.includes(r)) { + if (entry.verdict === "rejected") { + throw new Error( + `a rejected clip's reason must be ${CUT_REASONS.map((x) => `"${x}"`).join(", ")} (got \`${r}\`)` + + (FACT_REASONS.includes(r) || r === "not-matching" ? ` — ${r} is a fact error: its verdict is incorrect` : ""), + ); + } + if (entry.verdict === "incorrect" && CUT_REASONS.includes(r)) { + throw new Error(`${r} is not a fact error: reject the clip (verdict=${r}) rather than marking it incorrect`); + } + throw new Error(`reason must be ${FACT_REASONS.map((x) => `"${x}"`).join(", ")}, or empty to clear it (got \`${r}\`); say anything else in the correction`); + } else entry.reason = r; + } + if (patch.rejectNote !== undefined) { + const n = String(patch.rejectNote ?? "").trim(); + if (n) entry.rejectNote = n; + else delete entry.rejectNote; + } + if (entry.verdict !== "rejected") { + if (patch.rejectNote !== undefined && String(patch.rejectNote ?? "").trim()) { + throw new Error("a rejectNote goes with a rejected verdict"); + } + delete entry.rejectNote; + } + if (entry.reason && entry.verdict !== "incorrect" && entry.verdict !== "rejected") { + throw new Error(`a reason (${entry.reason}) goes with an incorrect verdict`); + } + if (entry.verdict === "incorrect" && !String(entry.correction ?? "").trim() && !entry.reason) { + throw new Error("an incorrect verdict needs its note: say what the report got wrong"); + } + if (entry.verdict === "rejected") { + if (!entry.reason) throw new Error(`a rejected verdict needs its reason: ${CUT_REASONS.join(", ")}`); + if (entry.reason === "other" && !entry.rejectNote) throw new Error("rejected as other needs a note (rejectNote): say why it comes out"); + } +} diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs @@ -51,6 +51,7 @@ import { manifestToken, moveEntry, removeEntry, + rejectClip, removeWrongSpeaker, REMOVED_FILE, removePost, @@ -60,6 +61,8 @@ import { upsertPost, } from "./manifest.mjs"; +import { REJECT_REASON_IDS, rejectionOf } from "./rejectReasons.mjs"; + export const TIMELINE_USAGE = [ "usage: umtool timeline <project> [ls] [--json] the cut: index, id, type, video, start–end, date title", " umtool timeline <project> insert --after <id|-> <channel>/<video>@<start>-<end> [--id ID]", @@ -70,7 +73,10 @@ export const TIMELINE_USAGE = [ " are dates gets --date as one too. The section is <id>'s unless --section says", " umtool timeline <project> move <id> --to <index> <index> is its place AFTER the move (0 first)", " umtool timeline <project> remove <id> | duplicate <id> (--at <index> names one of an id's twins)", - " umtool timeline <project> wrong-speaker <id> [--correction TEXT] mark it incorrect (wrong speaker) and remove it, on the record (removed.json)", + " umtool timeline <project> reject <id> <why> [--note TEXT] reject it and remove it, on the record (removed.json):", + ` <why> is ${REJECT_REASON_IDS.join("|")} -- not-matching and wrong-speaker are fact`, + " errors (incorrect, the note its correction; not-matching needs one), the rest cut reasons (rejected; other needs a note)", + " umtool timeline <project> wrong-speaker <id> [--correction TEXT] the same as reject <id> wrong-speaker", " a removal re-anchors what named the clip (a marker to the clip before, a chapter to the next in its section; pair/status/deck-claim references dropped) and says so", " umtool timeline <project> post <json|@file> add a post, or replace the one with its id", " umtool timeline <project> post-remove <id>", @@ -84,8 +90,8 @@ export const TIMELINE_USAGE = [ "validators, and on a generated manifest leaves an `edit` note for its generator. The Cut tab's timeline.", ].join("\n"); -const VERBS = ["ls", "insert", "move", "remove", "wrong-speaker", "duplicate", "post", "post-remove", "teaser", "undo"]; -const VALUED = new Set(["--after", "--to", "--at", "--id", "--section", "--title", "--stream-title", "--date", "--quote", "--cite", "--cite-url", "--take", "--correction"]); +const VERBS = ["ls", "insert", "move", "remove", "reject", "wrong-speaker", "duplicate", "post", "post-remove", "teaser", "undo"]; +const VALUED = new Set(["--after", "--to", "--at", "--id", "--section", "--title", "--stream-title", "--date", "--quote", "--cite", "--cite-url", "--take", "--correction", "--note"]); /** What `--take <id>` does on a take's timeline (takeEdit.mjs): the walk's structure and its undo. */ const TAKE_VERBS = ["ls", "move", "remove", "undo"]; @@ -150,6 +156,11 @@ export function timelineRows(manifest) { start: e.start ?? null, end: e.end ?? null, ...(e.cutStart != null && e.cutEnd != null ? { cutStart: e.cutStart, cutEnd: e.cutEnd } : {}), + // Rejected on the walk, kept in place: why ("rejected — irrelevant", "incorrect — wrong speaker"). + ...(() => { + const r = rejectionOf(e); + return r ? { rejected: `${r.fact ? "incorrect" : "rejected"} — ${r.why}` } : {}; + })(), } : {}), date: typeof e.date === "string" ? e.date : null, @@ -167,7 +178,7 @@ export function timelineLines(rows) { ? `${String(r.video ?? "?").padEnd(14)} ${fmt(r.start)}–${fmt(r.end)}${r.cutStart != null ? ` (cut ${fmt(r.cutStart)}–${fmt(r.cutEnd)})` : ""}` : "".padEnd(14); const label = [r.date, r.title].filter(Boolean).join(" "); - return `${String(r.index).padStart(3)} ${r.id.padEnd(w)} ${r.type.padEnd(tw)} ${span}${label ? ` ${label}` : ""}`; + return `${String(r.index).padStart(3)} ${r.id.padEnd(w)} ${r.type.padEnd(tw)} ${span}${label ? ` ${label}` : ""}${r.rejected ? ` [${r.rejected}]` : ""}`; }); } @@ -406,6 +417,14 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) => ({ result, editNotes } = await write((token) => removeEntry(project.dir, id, { token, at }))); break; } + case "reject": { + const id = need(rest[0], "a clip id"); + const why = need(rest[1], `why: ${REJECT_REASON_IDS.join(", ")}`); + const n = flags.get("--note") ?? flags.get("--correction"); + const note = typeof n === "string" && n.trim() ? n.trim() : null; + ({ result, editNotes } = await write((token) => rejectClip(project.dir, id, why, { token, at, note }))); + break; + } case "wrong-speaker": { const id = need(rest[0], "a clip id"); const c = flags.get("--correction"); @@ -446,7 +465,7 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) => } out(summaryOf(verb, result, attribution)); for (const line of result.reanchored ?? []) out(` re-anchored: ${line}`); - if (result.record) out(` on record: ${REMOVED_FILE} (${result.record.reason}${result.record.correction ? `: ${result.record.correction}` : ""})`); + if (result.record) out(` on record: ${REMOVED_FILE} (${result.record.reason}${result.record.correction ? `: ${result.record.correction}` : ""}${result.record.note ? `: ${result.record.note}` : ""})`); if (result.snapshot?.rel && !result.snapshot.skipped) out(` undo point: ${result.snapshot.rel}`); else if (result.snapshot?.error) out(` NO undo point: ${result.snapshot.error}`); const n = noted(editNotes); @@ -539,6 +558,10 @@ function summaryOf(verb, r, attribution) { return `removed ${r.id} (was at ${r.at})`; case "wrong-speaker": return `removed ${r.id} (was at ${r.at}): marked incorrect, wrong speaker`; + case "reject": { + const why = rejectionOf(r.removed); + return `removed ${r.id} (was at ${r.at}): ${why?.fact ? "marked incorrect" : "rejected"}, ${why?.label ?? r.record?.reason}`; + } case "duplicate": return `duplicated as ${r.id} at ${r.at}`; case "post": diff --git a/umtool/lib/report/walkCli.mjs b/umtool/lib/report/walkCli.mjs @@ -63,7 +63,10 @@ export async function walkCommand(args, { root = REPORTS_ROOT, out = (s) => cons const cut = c.cutStart != null ? ` cut ${hms(c.cutStart)}–${hms(c.cutEnd)}` : ""; out( `${c.onWalk ? "→" : " "} ${String(c.cut ?? "").padStart(3)} ${c.id.padEnd(idW)} ${win.padEnd(22)}${cut} ${c.seconds.toFixed(1).padStart(6)}s ` + - `${c.verdict.padEnd(10)} ${c.fetched ? "fetched" : "NOT FETCHED"}${c.correction ? ` note: ${c.correction}` : ""}`, + `${c.verdict.padEnd(10)} ${c.fetched ? "fetched" : "NOT FETCHED"}` + + // A rejection says why: "(wrong speaker)", "(irrelevant: covered in c07)"; a fact one's note is its correction. + (c.rejected ? ` (${c.rejected.label}${!c.rejected.fact && c.rejected.note ? `: ${c.rejected.note}` : ""})` : "") + + (c.correction ? ` note: ${c.correction}` : ""), ); } const enc = project.id.split("/").map(encodeURIComponent).join("/"); diff --git a/umtool/lib/report/walkData.mjs b/umtool/lib/report/walkData.mjs @@ -17,6 +17,7 @@ // // Plain ESM: `umtool walk` runs it under bare node. import { clipVerdict, readClipDetail, readManifest, walkOrder, walkReadiness } from "../projects/report.mjs"; +import { rejectionOf } from "./rejectReasons.mjs"; import { manifestToken } from "./manifest.mjs"; /** @@ -76,7 +77,8 @@ export function walkNeighbours(order, onWalk, clipId) { * @typedef {{ * id: string, cut: number | null, channel: string | null, video: string, start: number, end: number, * seconds: number, cutStart: number | null, cutEnd: number | null, - * verdict: "confirmed" | "incorrect" | "unreviewed", correction: string | null, quote: string | null, + * verdict: "confirmed" | "incorrect" | "rejected" | "unreviewed", correction: string | null, quote: string | null, + * rejected: { reason: string, label: string, fact: boolean, note: string, why: string } | null, * fetched: boolean, onWalk: boolean, * }} WalkClip */ @@ -111,6 +113,11 @@ export async function walkOf(project, { take = null, all = false } = {}) { cutEnd: e.cutEnd ?? null, verdict: clipVerdict(e), correction: typeof e.correction === "string" && e.correction.trim() ? e.correction.trim() : null, + // Why it was rejected (a fact error or a cut reason), in words; null when it was not. + rejected: (() => { + const r = rejectionOf(e); + return r ? { reason: r.reason, label: r.label, fact: r.fact, note: r.note, why: r.why } : null; + })(), quote: typeof e.quote === "string" ? e.quote : null, fetched: !!e.fetched, onWalk: onWalk.has(e.id),