commit e4d40c3df4cab1d88799bf3b8b1591ec40179451
parent 015269cdefba212663ff90ca701a3a0b73fed6d8
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 23:36:50 -0500
umtool: un-reject -- `umtool timeline <p> restore <id>` and the Cut tab's Removed list with Restore
Owed 6 Nov: removed.json keeps a rejected clip's id, window and reason only, so a clip taken out by mistake
came back as a bare re-insert (its claim, quote, cite and edges lost). restoreRemoved (manifest.mjs) puts it
back from the newest revision that holds it (revisions/ newest first, then a legacy copy), the entry as it was
there, at its old place -- after the nearest entry that came before it there and is still in the cut, else
before the nearest after it, else at its recorded index -- as an insert, so every later write is kept; an undo
point first; refused when it is in the cut already, or when no revision holds it (naming the insert that
re-adds it from its record). What its removal re-anchored or dropped (a marker, a deck claim, its group) is
listed as not put back. The draft's only.
- `umtool timeline <p> removed [--json]`: the clips on record still out of the cut (removedOutOfCut);
`restore <id>`. Registry rows (verbs.mjs), the help (groups.mjs), cli.md regenerated, a knobs.md row.
- POST /api/report/timeline {op: "restore", id}.
- The Cut tab's "removed from the cut" list (RemovedClips.tsx), each row a Restore button.
Tests: restore-removed.test.mjs (back as it was at its old place with a later trim and insert kept; its
neighbour gone; no revision refused; the CLI's list and restore); timeline-edit.spec's Restore through the UI.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
11 files changed, 367 insertions(+), 5 deletions(-)
diff --git a/umtool/app/api/report/timeline/route.ts b/umtool/app/api/report/timeline/route.ts
@@ -15,6 +15,7 @@ import {
removeSection,
sectionsOf,
rejectClip,
+ restoreRemoved,
removeWrongSpeaker,
removePost,
undoStructural,
@@ -50,6 +51,7 @@ export const dynamic = "force-dynamic";
// 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
+// restore { id } un-reject: a removed clip back from the newest revision holding it
// duplicate { id, at? }
// insert { afterId: id | null, at?, entry: "<channel>/<video>@<start>-<end>" | { type, … } }
// teaser { id, at?, patch: { lines?, beat?, dip?, tail?, tailWait? } }
@@ -157,6 +159,9 @@ export async function POST(request: Request) {
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 "restore":
+ // Un-reject: the removed clip back, as the newest revision holding it had it, at its old place.
+ return restoreRemoved(dir, id, { token });
case "duplicate":
return duplicateEntry(dir, id, { token, at });
case "insert":
diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx
@@ -38,6 +38,9 @@ import { readVoiceMatch, voiceMatchSummary } from "yt-dlp-transcript-common/lib/
import { clipMomentKey } from "umtool-report-to-video/montage-rulings";
import { trailerCandidates } from "@/lib/report/trailerCandidates.mjs";
import IntroRow from "./IntroEditor";
+import RemovedClips, { type RemovedRow } from "./RemovedClips";
+import { readRemoved, removedOutOfCut } from "@/lib/report/manifest.mjs";
+import { rejectReasonOf } from "@/lib/report/rejectReasons.mjs";
// The Cut tab: the timeline, read back -- the walk into it, its takes, every
// entry with what is wrong with it, and the corrections the walk collected.
@@ -55,6 +58,17 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor
verdict: "confirmed" | "incorrect" | "rejected" | "unreviewed";
}[];
const clips = entries.filter((e) => e.kind === "clip");
+ // The clips taken out on record and still out (removed.json), each with Restore (un-reject).
+ const removed: RemovedRow[] = (removedOutOfCut(await readRemoved(project.dir), m) as Record<string, unknown>[]).map((r) => ({
+ id: String(r.id),
+ channel: typeof r.channel === "string" ? r.channel : null,
+ video: typeof r.video === "string" ? r.video : null,
+ start: typeof r.start === "number" ? r.start : null,
+ end: typeof r.end === "number" ? r.end : null,
+ why: rejectReasonOf(String(r.reason ?? ""))?.label ?? String(r.reason ?? "removed"),
+ note: typeof r.note === "string" ? r.note : typeof r.correction === "string" ? r.correction : null,
+ when: typeof r.when === "string" ? r.when : null,
+ }));
// The walk's ★ clips, as trailer beats (lib/report/trailerCandidates.mjs).
const candidates = trailerCandidates(m);
// How much of the cut has been walked. One definition, shared with the bench
@@ -601,6 +615,8 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor
</section>
)}
+ <RemovedClips project={project.id} rows={removed} />
+
{/* --- corrections ------------------------------------------------ */}
{/*
Not a decision and not a defect in the CUT: a correction says the
diff --git a/umtool/components/projects/report/RemovedClips.tsx b/umtool/components/projects/report/RemovedClips.tsx
@@ -0,0 +1,82 @@
+"use client";
+
+import Link from "next/link";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { Button } from "@/components/ui/button";
+import { clipBenchHref } from "@/lib/hrefs";
+import { announceManifestChanged, refusalOf, timelineOp } from "../timelineApi";
+
+// THE REMOVED LIST (the Cut tab): the clips taken out on record (removed.json: Reject, Wrong speaker) that are
+// still out of the cut, newest first, each with Restore -- un-reject (lib/report/manifest.mjs restoreRemoved):
+// the clip back as the newest revision holding it had it, at its old place, every later write kept. The CLI
+// twin is `umtool timeline <p> removed` and `restore <id>`.
+
+export type RemovedRow = {
+ id: string;
+ channel: string | null;
+ video: string | null;
+ start: number | null;
+ end: number | null;
+ why: string;
+ note: string | null;
+ when: string | null;
+};
+
+export default function RemovedClips({ project, rows }: { project: string; rows: RemovedRow[] }) {
+ const router = useRouter();
+ const [busy, setBusy] = useState<string | null>(null);
+ const [said, setSaid] = useState<{ id: string; ok: boolean; text: string } | null>(null);
+ const restore = async (id: string) => {
+ setBusy(id);
+ setSaid(null);
+ // No token: a restore is an insert, never a rollback, so a write since this page read the cut is kept, not refused.
+ const res = await timelineOp(project, null, "restore", { id });
+ setBusy(null);
+ if (!res.ok) {
+ setSaid({ id, ok: false, text: refusalOf(res) });
+ return;
+ }
+ const j = res.json as { at?: number; notPutBack?: string[] };
+ const left = Array.isArray(j.notPutBack) && j.notPutBack.length ? ` Not put back: ${j.notPutBack.join("; ")}.` : "";
+ setSaid({ id, ok: true, text: `${id} is back in the cut at ${j.at}.${left}` });
+ announceManifestChanged(project);
+ router.refresh();
+ };
+ if (!rows.length && !said) return null;
+ return (
+ <section data-removed-clips="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2">
+ <h2 className="micro mb-1.5">removed from the cut — {rows.length}</h2>
+ {rows.length > 0 && (
+ <ul className="space-y-1">
+ {rows.map((r) => (
+ <li key={r.id} data-removed-clip={r.id} className="flex flex-wrap items-baseline gap-x-2 text-[12px] leading-snug">
+ <Link href={clipBenchHref(project, r.id)} className="ink-link font-mono text-[11px]">
+ {r.id}
+ </Link>
+ <span className="text-[11px] text-[var(--color-dim)]">
+ {r.channel ?? "?"}/{r.video ?? "?"} @ {r.start ?? "?"}–{r.end ?? "?"}
+ </span>
+ <span data-removed-why="">
+ {r.why}
+ {r.note ? `: ${r.note}` : ""}
+ </span>
+ {r.when && <span className="text-[11px] text-[var(--color-dim)]">{r.when.slice(0, 10)}</span>}
+ <Button type="button" size="sm" variant="outline" className="ml-auto" data-removed-restore={r.id} disabled={busy !== null} onClick={() => void restore(r.id)}>
+ {busy === r.id ? "Restoring…" : "Restore"}
+ </Button>
+ </li>
+ ))}
+ </ul>
+ )}
+ {said && (
+ <p role="status" data-removed-said={said.ok ? "ok" : "refused"} className={`mt-1 text-[12px] ${said.ok ? "" : "text-[var(--color-bad)]"}`}>
+ {said.text}
+ </p>
+ )}
+ <p className="mt-1.5 text-[11px] text-[var(--color-dim)]">
+ <code className="font-mono">umtool timeline {project} restore <id></code>
+ </p>
+ </section>
+ );
+}
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -99,7 +99,7 @@ Inbox cannot disagree about what is wrong with one.
| `refresh <article> [--iteration N] [--no-fetch] [--yes] [--json]` · `refresh --check [<article>] [--force]` | the refresh's plan, `--yes` starts it; the daily check now ([refresh.md](refresh.md)) |
| `clip <channel>/<video>@<start>-<end> [--snap words] [--title T] [--site <id>] [--folder F] [--json] [--progress ndjson]` | **quick clip**: a basic-mode project (`quick-clips/<slug>`, the footage alone), its window asked of the editor (fetch-windows, followed to its end; Rumble fetched whole), `--snap words` its edges snapped to the words heard (the editor's transcribe op), rendered as the take `clip` (`take <p> --id clip --full`: the heavy slot), then the mp4's path and the share line. `--json`: `{project, output, share: {platform, archive, text}, snapped?}`; `--progress ndjson`: events, the last `quick-clip` (the app's `POST /api/report/quick-clip` job). **Exit 0 · 1 failed (the editor, the render) · 2 usage** ([knobs.md](knobs.md#basic-output-the-footage-alone)) |
| `share <project> [<clip>] [--take <t>] [--site <id>] [--json]` | a clip's **share line** (the clip named, else the first): its platform page at the first second it plays and its archive moment, a Rumble folder id as the embed id the archive serves — the twin of **Copy share line** (`GET /api/report/share-line`). `--json`: `{clip, seconds, platform, archive, text}` |
-| `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>` · `place <id>… --before <id\|-> [--section N]` · `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. `place` is Play's drag on the reel strip: the entries land before that entry (`-`: the end), their clips joining section N (default: the section of the clip they land after), every other clip keeping its own and the markers following, an emptied section refused, each place its own undo point ([knobs.md](knobs.md#the-reel-strip-zoom-and-reorder)). 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> [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>` · `place <id>… --before <id\|-> [--section N]` · `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. `place` is Play's drag on the reel strip: the entries land before that entry (`-`: the end), their clips joining section N (default: the section of the clip they land after), every other clip keeping its own and the markers following, an emptied section refused, each place its own undo point ([knobs.md](knobs.md#the-reel-strip-zoom-and-reorder)). 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`; `removed` lists the clips on that record still out of the cut, and `restore <id>` un-rejects one — the entry from the newest revision that holds it (claim, quote, cite and edges as they were) at its old place (after the entry before it there, else before the one after), every later write kept, an undo point first, and what its removal re-anchored or dropped listed as `not put back:` (the Cut tab's **Removed** list, **Restore**); `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> insert (--to-section N \| --group G) <channel>/<video>@<start>-<end> [--id ID] [--lock] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` | a clip at the **end of section N**, or **after group G's last clip and one of its clips** (the run stays together): one write, the marker that followed that last clip re-anchored after the new one, so the clip lands in the section and every other clip keeps its own; the attribution as `insert --after`'s. The Candidates panel's Insert is this ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press)) |
| `timeline <project> groups [ls] [--json]` · `groups import <file> [--skip-missing] [--drop-empty]` · `groups set <gid\|-> <id…> [--claim C]` · `groups move <gid> --to <index>` · `groups move <gid> --to after <gid>` · `groups label <gid> <claim…>` · `groups promote <gid> [--label L]` · `groups remove <gid>` · `order <file\|@file\|id…>` | **claim groups** (`groups` beside the timeline; the Cut tab's group bars): runs of clips inside one section making one claim — `ls` by section, each group's id, claim and clips (`--json` with the token); `import` a claim-groups file (`{sections: [{label, groups: [{claim, ids}]}]}`) in ONE write — the cut re-ordered to it, its groups the cut's, the markers following; a file section is the deck section of its name, else the one most of its clips are in; **exit 1** for an id the cut lacks (`--skip-missing`) or a section left with no clip (`--drop-empty` removes its marker); `set` (the clips already together), `label`, `remove` (ungroup), `move` the whole group (before the group at that index, or after one, in its section), `promote` (a level-2 marker at its first clip titled with its claim — the one group edit the render sees; `--label` when the claim is over 24); `order` the named entries in the places they hold (every clip keeping its section). A clip moved out of its group's run leaves it; moved alone into the middle of one, it joins. Every write an undo point (`undo`) ([knobs.md](knobs.md#claim-groups-runs-of-clips-that-make-one-claim)) |
| `timeline <project> --take <take> [ls \| move <id> --to <index> \| remove <id> \| undo \| insert <spec> --after <id>\|-]` | 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. `insert` puts a clip (`<channel>/<video>@<start>-<end>`) into the take only (`takeEdit.mjs insertTakeEntry`) -- the app's **+ Add a clip to <take> only** on the take walk page, and Play's **+ Add a clip here** on a take with its own timeline |
@@ -299,6 +299,8 @@ draft (the project's manifest); *project*: a project's other files, or reads; *c
| `timeline <project> duplicate <id> [--at N]` | an entry twice | form · *draft* |
| `timeline <project> reject <id> not-matching\|wrong-speaker\|irrelevant\|repeats\|weak\|privacy\|other [--note NOTE]` | an entry rejected and removed, on the record | form · *draft* |
| `timeline <project> wrong-speaker <id> [--correction CORRECTION]` | an entry removed: the wrong speaker | form · *draft* |
+| `timeline <project> removed` | the clips removed on record and still out of the cut | form · *project* |
+| `timeline <project> restore <id>` | un-reject: a removed clip back as it was, at its old place | form · *draft* |
| `timeline <project> post <post>` | a post added, or the one with its id replaced | form · *draft* |
| `timeline <project> post-remove <id>` | a post out of the cut | form · *draft* |
| `timeline <project> teaser <id> <patch>` | a teaser's lines, beat, dip, tail | form · *draft* |
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -720,6 +720,10 @@ in `removed.json` — or **Reject, keep in place** writes the verdict only, for
it is the same flow with its reason preset ([report-video.md](report-video.md#verdict--what-the-walk-said)). Not on a
take.
+| knob | UI | CLI | route |
+|---|---|---|---|
+| un-reject: a removed clip back — the entry from the newest revision that holds it (claim, quote, cite, edges as they were), at its old place, every later write kept; what its removal re-anchored or dropped is said, not put back | the Cut tab's **removed from the cut** list (the clips on record in `removed.json` still out), **Restore** | `umtool timeline <p> removed` (the list), `umtool timeline <p> restore <id>` | `POST /api/report/timeline {op: "restore", id}` |
+
**Play and the clip bench are one app.** **Edit this clip** (E) opens the bench IN PLACE: Play is hidden and paused
but never unmounted, so its composed deck, decoded sound, measured edges, the strip's zoom and the take stay as they
were (`components/projects/cutApp/CutApp.tsx`; the bench's data is `GET /api/report/bench`, the same function its own
diff --git a/umtool/e2e/timeline-edit.spec.ts b/umtool/e2e/timeline-edit.spec.ts
@@ -36,6 +36,7 @@ test.beforeEach(() => {
copyFileSync(PRISTINE, MANIFEST);
rmSync(path.join(DIR, "revisions"), { recursive: true, force: true });
rmSync(path.join(DIR, "notes.json"), { force: true });
+ rmSync(path.join(DIR, "removed.json"), { force: true });
});
/** The project page on the tab that holds `name`: the timeline (the Cut), or the on-screen panel's structure editors (Build). */
@@ -157,3 +158,21 @@ test("a post added, then removed; the fact-check's labels once the deck is on",
.poll(() => ((manifest().render.chrome as { factcheck?: { tally?: unknown } }).factcheck ?? {}).tally)
.toEqual({ showAt: "first" });
});
+
+test("the Removed list: a rejected clip is listed and Restore puts it back as it was, at its old place", async ({ page, request }) => {
+ const a02 = manifest().timeline.find((e) => e.id === "a02")!;
+ const rej = await request.post("/api/report/timeline", { data: { project: PROJECT, op: "reject", id: "a02", reason: "repeats", note: "covered by a01" } });
+ expect(rej.ok(), await rej.text()).toBe(true);
+ await expect.poll(order).toEqual(["t1", "a01", "a03"]);
+ await open(page);
+ const list = page.locator("[data-removed-clips]");
+ await expect(list.locator("[data-removed-clip]")).toHaveCount(1);
+ await expect(list.locator('[data-removed-clip="a02"] [data-removed-why]')).toContainText("covered by a01");
+ await list.locator('[data-removed-restore="a02"]').click();
+ await expect(list.locator('[data-removed-said="ok"]')).toContainText("a02 is back in the cut at 2");
+ await expect.poll(order).toEqual(["t1", "a01", "a02", "a03"]);
+ // The entry as it was before the reject: no verdict, every field it had.
+ expect(manifest().timeline.find((e) => e.id === "a02")).toEqual(a02);
+ await expect.poll(() => shownOrder(page)).toEqual(["t1", "a01", "a02", "a03"]);
+ await expect(page.locator("[data-removed-clip]")).toHaveCount(0);
+});
diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs
@@ -866,7 +866,7 @@ export const GROUPS = [
],
docs: [
["`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>` · `place <id>… --before <id\\|-> [--section N]` · `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. `place` is Play's drag on the reel strip: the entries land before that entry (`-`: the end), their clips joining section N (default: the section of the clip they land after), every other clip keeping its own and the markers following, an emptied section refused, each place its own undo point ([knobs.md](knobs.md#the-reel-strip-zoom-and-reorder)). 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))"],
+ "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. `place` is Play's drag on the reel strip: the entries land before that entry (`-`: the end), their clips joining section N (default: the section of the clip they land after), every other clip keeping its own and the markers following, an emptied section refused, each place its own undo point ([knobs.md](knobs.md#the-reel-strip-zoom-and-reorder)). 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`; `removed` lists the clips on that record still out of the cut, and `restore <id>` un-rejects one — the entry from the newest revision that holds it (claim, quote, cite and edges as they were) at its old place (after the entry before it there, else before the one after), every later write kept, an undo point first, and what its removal re-anchored or dropped listed as `not put back:` (the Cut tab's **Removed** list, **Restore**); `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> insert (--to-section N \\| --group G) <channel>/<video>@<start>-<end> [--id ID] [--lock] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]`",
"a clip at the **end of section N**, or **after group G's last clip and one of its clips** (the run stays together): one write, the marker that followed that last clip re-anchored after the new one, so the clip lands in the section and every other clip keeps its own; the attribution as `insert --after`'s. The Candidates panel's Insert is this ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press))"],
["`timeline <project> groups [ls] [--json]` · `groups import <file> [--skip-missing] [--drop-empty]` · `groups set <gid\\|-> <id…> [--claim C]` · `groups move <gid> --to <index>` · `groups move <gid> --to after <gid>` · `groups label <gid> <claim…>` · `groups promote <gid> [--label L]` · `groups remove <gid>` · `order <file\\|@file\\|id…>`",
diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs
@@ -363,6 +363,8 @@ function timeline() {
tl("duplicate", "draft", "an entry twice", [id(), num("--at")]),
tl("reject", "draft", "an entry rejected and removed, on the record", [id(), pick("why", REJECT_WHYS, { required: true }), opt("--note", { type: "text" })]),
tl("wrong-speaker", "draft", "an entry removed: the wrong speaker", [id(), opt("--correction", { type: "text" })]),
+ tl("removed", "project", "the clips removed on record and still out of the cut", []),
+ tl("restore", "draft", "un-reject: a removed clip back as it was, at its old place", [arg("id", { help: "the removed clip's id (timeline removed lists them)" })]),
tl("post", "draft", "a post added, or the one with its id replaced", [arg("post", { type: "text", atFile: true, help: "JSON (@file: from a terminal)" })]),
tl("post-remove", "draft", "a post out of the cut", [arg("id", { context: "post" })]),
tl("teaser", "draft", "a teaser's lines, beat, dip, tail", [id(), arg("patch", { type: "text", atFile: true, help: "a JSON patch (@file: from a terminal)" })]),
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -77,7 +77,7 @@ import { DELIVERABLES_MODES } from "./storage.mjs";
import { COMBO_DEFAULTS, COMBO_ITEM_KEYS, validatePostCombo, validatePostComboRender } from "umtool-report-to-video/post-combo";
import { SCENE_DEFAULTS, validatePostSceneRender } from "umtool-report-to-video/post-media-scene";
import { PICTURE_REPLY_DEFAULTS, validatePictureReplyRender } from "umtool-report-to-video/post-picture";
-import { createSnapshot, listSnapshots } from "./snapshots.mjs";
+import { createSnapshot, listSnapshots, readSnapshot } from "./snapshots.mjs";
import { benchPrepAfterWrite } from "./benchPrepTrigger.mjs";
import { citeFollow, clockOf, qrFollowsCite } from "./citeFollow.mjs";
import { syncPatchMarkers, syncSectionMarkers } from "./patchMarkers.mjs";
@@ -2590,6 +2590,107 @@ export async function rejectClip(dir, id, reason, { token = null, at = null, not
return { ...res, record };
}
+/**
+ * The clips removed on record (removed.json) that are still out of the cut, one per id -- its newest removal --
+ * newest first. A clip put back (undo, restore) drops off; its lines stay on record.
+ *
+ * @param {Array<Record<string, any>>} rows readRemoved's
+ * @param {Record<string, any> | null} manifest
+ */
+export function removedOutOfCut(rows, manifest) {
+ const inCut = new Set((manifest?.timeline ?? []).map((e) => (isObj(e) ? e.id : null)));
+ const seen = new Set();
+ const out = [];
+ for (const r of [...(rows ?? [])].reverse()) {
+ const id = isObj(r) && typeof r.id === "string" ? r.id : null;
+ if (!id || seen.has(id)) continue;
+ seen.add(id);
+ if (!inCut.has(id)) out.push(r);
+ }
+ return out;
+}
+
+/**
+ * The newest revision of the manifest (revisions/, newest first; then a legacy copy) whose timeline holds clip `id`: the entry as it
+ * was there -- claim, quote, cite, edges and all -- with the ids before and after it. null when none does.
+ *
+ * @param {string} dir
+ * @param {string} id
+ */
+export async function removedClipInRevisions(dir, id) {
+ // The undo points in revisions/ first, newest first; then a legacy copy beside the manifest (the writer's
+ // rate-limited .bak, a hand-made copy), which may be older than they are.
+ const snaps = await listSnapshots(dir);
+ for (const snap of [...snaps.filter((x) => !x.legacy), ...snaps.filter((x) => x.legacy)]) {
+ let m = null;
+ try {
+ m = await readSnapshot(dir, snap.rel);
+ } catch {
+ continue;
+ }
+ const tl = Array.isArray(m?.timeline) ? m.timeline : [];
+ const k = tl.findIndex((e) => isObj(e) && e.id === id && e.type === "clip");
+ if (k < 0) continue;
+ const ids = (xs) => xs.map((e) => (isObj(e) ? e.id : null)).filter((x) => typeof x === "string");
+ return { entry: JSON.parse(JSON.stringify(tl[k])), from: snap.rel, before: ids(tl.slice(0, k)).reverse(), after: ids(tl.slice(k + 1)) };
+ }
+ return null;
+}
+
+/**
+ * UN-REJECT: put clip `id`, taken out of the cut (Reject, Wrong speaker, a plain remove), back -- the entry from
+ * the newest revision that holds it, so its claim, quote, cite and edges are as they were, at its old place: after
+ * the nearest entry that came before it there and is still in the cut, else before the nearest that came after
+ * it, else at the index its removal was recorded at. Every later write to the cut is kept (it is an insert, not
+ * a rollback); an undo point first. What its removal re-anchored or dropped (a marker moved, a deck claim, its
+ * claim group) is not put back, and is returned as `notPutBack` to say so. The draft's only: a version is opened
+ * in the draft first. `umtool timeline <p> restore <id>`, the Cut tab's Removed list.
+ *
+ * @param {string} dir
+ * @param {string} id
+ * @param {{ token?: string | null }} [opts]
+ */
+export async function restoreRemoved(dir, id, { token = null } = {}) {
+ if (takeScopeOf(dir)) throw new Error("a removed clip is restored into the draft (open the version in the draft first)");
+ const clipId = String(id ?? "").trim();
+ if (!clipId) throw new Error("restore needs the removed clip's id");
+ const record = (await readRemoved(dir)).filter((r) => isObj(r) && r.id === clipId).at(-1) ?? null;
+ return prepAfter(dir, clipIdOf, structural(dir, "restore", token, (m, found) => {
+ if (m.timeline.some((e) => isObj(e) && e.id === clipId)) throw new Error(`${clipId} is in the cut already`);
+ if (!found) {
+ throw new Error(
+ `no revision of the manifest holds ${clipId} (revisions/ keeps the newest ${AUTO_SNAPSHOT_KEEP} undo points)` +
+ (record ? `: re-add it from its record -- umtool timeline <p> insert ${record.channel}/${record.video}@${record.start}-${record.end}` : ""),
+ );
+ }
+ const tl = m.timeline;
+ const indexOf = (x) => tl.findIndex((e) => isObj(e) && e.id === x);
+ let at = -1;
+ let placed = null;
+ for (const x of found.before) {
+ const k = indexOf(x);
+ if (k >= 0) {
+ at = k + 1;
+ placed = { after: x };
+ break;
+ }
+ }
+ if (at < 0) {
+ for (const x of found.after) {
+ const k = indexOf(x);
+ if (k >= 0) {
+ at = k;
+ placed = { before: x };
+ break;
+ }
+ }
+ }
+ if (at < 0) at = Math.max(0, Math.min(tl.length, Number.isInteger(record?.at) ? record.at : tl.length));
+ tl.splice(at, 0, found.entry);
+ return { id: clipId, at, entry: found.entry, from: found.from, ...(placed ?? {}), notPutBack: Array.isArray(record?.reanchored) ? record.reanchored : [] };
+ }, { prepare: () => removedClipInRevisions(dir, clipId) }));
+}
+
/** Copy one entry to just after itself, under a fresh id. A copied claim is dropped (one claim, one entry). *
* @param {string} dir
* @param {string} id
diff --git a/umtool/lib/report/restore-removed.test.mjs b/umtool/lib/report/restore-removed.test.mjs
@@ -0,0 +1,100 @@
+// UN-REJECT (owed 6 Nov: removed.json keeps id/window/reason only): `umtool timeline <p> restore <id>` puts a
+// removed clip back from the newest revision that holds it -- claim, quote, cite and edges as they were -- at its
+// old place, every later write kept; `removed` lists what is still out.
+//
+// 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";
+
+const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-restore-"));
+process.env.REPORTS_DIR = ROOT;
+const { MANIFEST_NAME, readRemoved, rejectClip, removeEntry, removedOutOfCut, restoreRemoved, updateClip } = await import("./manifest.mjs");
+const { timelineCommand } = await import("./timelineCli.mjs");
+
+const C02 = {
+ type: "clip", id: "c02", channel: "chan", video: "v2", start: 30, end: 44, cutStart: 31.2, cutEnd: 42.8, lockEnd: true,
+ cite: 31, quote: "the whole sentence, as cited", citeUrl: "https://example.test/v/chan/v2?t=31",
+ claim: { id: "k1", verdict: "CONTRADICTED", at: 35, label: "1 SEIZURE" },
+};
+const base = () => ({
+ schemaVersion: 1, slug: "r", title: "R",
+ provenance: { siteOrigin: "https://example.test", channelSlug: "chan" },
+ render: { width: 1920, height: 1080, fps: 30 },
+ timeline: [
+ { type: "clip", id: "c01", video: "v1", start: 10, end: 20 },
+ structuredClone(C02),
+ { type: "clip", id: "c03", video: "v3", start: 50, end: 60 },
+ ],
+});
+async function project(name) {
+ const dir = path.join(ROOT, name);
+ await mkdir(dir, { recursive: true });
+ await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(base(), null, 2) + "\n");
+ return dir;
+}
+const read = async (dir) => JSON.parse(await readFile(path.join(dir, MANIFEST_NAME), "utf8"));
+const ids = async (dir) => (await read(dir)).timeline.map((e) => e.id);
+
+test.after(() => rm(ROOT, { recursive: true, force: true }));
+
+test("restore: the rejected clip back as it was, at its old place, every later write kept", async () => {
+ const dir = await project("back");
+ await rejectClip(dir, "c02", "irrelevant", { note: "off topic" });
+ assert.deepEqual(await ids(dir), ["c01", "c03"]);
+ // Later writes: c01 trimmed, a clip inserted at the end. The restore must keep both.
+ await updateClip(dir, "c01", { start: 11, end: 19 });
+ const m = await read(dir);
+ m.timeline.push({ type: "clip", id: "c04", video: "v4", start: 70, end: 80 });
+ await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(m, null, 2) + "\n");
+ assert.deepEqual(removedOutOfCut(await readRemoved(dir), await read(dir)).map((r) => r.id), ["c02"]);
+
+ const r = await restoreRemoved(dir, "c02");
+ assert.equal(r.at, 1);
+ assert.equal(r.after, "c01");
+ assert.match(r.from, /^revisions\/.*auto-before-reject\.manifest\.json$/);
+ const now = await read(dir);
+ assert.deepEqual(now.timeline.map((e) => e.id), ["c01", "c02", "c03", "c04"]);
+ // The entry as it was before the reject: no rejected verdict, claim/quote/cite/edges intact.
+ assert.deepEqual(now.timeline[1], C02);
+ assert.deepEqual([now.timeline[0].start, now.timeline[0].end], [11, 19], "the trim after the reject is kept");
+ // Off the list; its line stays on record.
+ assert.deepEqual(removedOutOfCut(await readRemoved(dir), now), []);
+ assert.equal((await readRemoved(dir)).length, 1);
+ await assert.rejects(restoreRemoved(dir, "c02"), /c02 is in the cut already/);
+});
+
+test("restore: its neighbour before gone too, it goes before the one after; nothing holds it -- refused, naming the insert", async () => {
+ const dir = await project("neighbour");
+ await rejectClip(dir, "c02", "weak");
+ await removeEntry(dir, "c01");
+ await restoreRemoved(dir, "c02");
+ assert.deepEqual(await ids(dir), ["c02", "c03"]);
+
+ const bare = await project("bare");
+ await rejectClip(bare, "c02", "weak");
+ await rm(path.join(bare, "revisions"), { recursive: true, force: true });
+ await rm(path.join(bare, `${MANIFEST_NAME}.bak`), { force: true });
+ await assert.rejects(restoreRemoved(bare, "c02"), /no revision of the manifest holds c02.*insert chan\/v2@30-44/s);
+ assert.deepEqual(await ids(bare), ["c01", "c03"], "nothing written");
+});
+
+test("umtool timeline <p> removed | restore <id>: the list, then the clip back, with an undo point", async () => {
+ const dir = await project("cli");
+ await rejectClip(dir, "c02", "repeats", { note: "covered by c01" });
+ const lines = [];
+ const run = (...a) => timelineCommand(a, { root: ROOT, out: (s) => lines.push(s), err: (s) => lines.push(`ERR ${s}`) });
+ assert.equal(await run("cli", "removed"), 0, lines.join("\n"));
+ assert.match(lines.join("\n"), /c02\s+chan\/v2@30-44\s+.*covered by c01/);
+ assert.match(lines.at(-1), /1 removed clip out of cli -- umtool timeline cli restore <id> puts one back/);
+ assert.equal(await run("cli", "restore", "c02"), 0, lines.join("\n"));
+ assert.match(lines.join("\n"), /restored c02 at 1 \(after c01\), as it was in revisions\//);
+ assert.match(lines.join("\n"), /undo point: revisions\/.*auto-before-restore/);
+ assert.deepEqual(await ids(dir), ["c01", "c02", "c03"]);
+ assert.equal(await run("cli", "removed", "--json"), 0);
+ assert.deepEqual(JSON.parse(lines.at(-1)).removed, []);
+ assert.equal(await run("cli", "restore", "c02"), 1);
+ assert.match(lines.at(-1), /c02 is in the cut already/);
+});
diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs
@@ -73,6 +73,9 @@ import {
removeEntry,
removeSection,
rejectClip,
+ readRemoved,
+ removedOutOfCut,
+ restoreRemoved,
sectionsOf,
updateSection,
removeWrongSpeaker,
@@ -92,7 +95,7 @@ import {
upsertPost,
} from "./manifest.mjs";
-import { REJECT_REASON_IDS, rejectionOf } from "./rejectReasons.mjs";
+import { REJECT_REASON_IDS, rejectReasonOf, rejectionOf } from "./rejectReasons.mjs";
import { groupModel, parseOrderText } from "./claimGroups.mjs";
import { sectionModel } from "./sectionEdit.mjs";
@@ -123,6 +126,11 @@ export const TIMELINE_USAGE = [
` <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",
+ " umtool timeline <project> removed [--json] the clips taken out on record (removed.json) and still out",
+ " umtool timeline <project> restore <id> UN-REJECT: put a removed clip back -- the entry from the newest",
+ " revision that holds it (claim, quote, cite, edges intact) at its old place (after the entry",
+ " before it there), every later write kept; an undo point first; a marker or deck claim its",
+ " removal moved or dropped stays as it is, and is listed",
" 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>",
@@ -181,7 +189,7 @@ export const TIMELINE_USAGE = [
].join("\n");
const SECTION_VERBS = ["sections", "section-move", "section-add", "section-boundary", "section-remove", "section-set"];
-const VERBS = ["ls", "insert", "add-video", "set-video", "move", "place", "remove", "reject", "wrong-speaker", "duplicate", "post", "post-remove", "teaser", "undo", ...SECTION_VERBS, "split", "flash-forward", "order", "groups", "threads"];
+const VERBS = ["ls", "insert", "add-video", "set-video", "move", "place", "remove", "reject", "wrong-speaker", "removed", "restore", "duplicate", "post", "post-remove", "teaser", "undo", ...SECTION_VERBS, "split", "flash-forward", "order", "groups", "threads"];
const GROUP_VERBS = ["ls", "import", "set", "move", "label", "promote", "remove"];
const VALUED = new Set(["--group", "--after", "--before", "--to", "--at", "--id", "--section", "--title", "--stream-title", "--date", "--quote", "--cite", "--cite-url", "--take", "--correction", "--note", "--to-section", "--label", "--color", "--level", "--claim", "--conversation", "--from", "--fit", "--bass", "--gain", "--enter", "--hold"]);
/** What `--take <id>` does on a take's timeline (takeEdit.mjs): the walk's structure and its undo. */
@@ -571,6 +579,20 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) =>
if (verb === "threads") return await threadsCommand(project, manifest, { write: flags.has("--write"), only: flags.has("--conversation") ? String(flags.get("--conversation")) : null, json, out });
+ if (verb === "removed") {
+ const rows = removedOutOfCut(await readRemoved(project.dir), manifest);
+ if (json) {
+ out(JSON.stringify({ project: project.id, token: await manifestToken(project.dir), removed: rows }, null, 2));
+ return 0;
+ }
+ for (const r of rows) {
+ const why = rejectReasonOf(String(r.reason ?? ""));
+ out(`${String(r.id).padEnd(10)} ${r.channel ?? "?"}/${r.video ?? "?"}@${r.start ?? "?"}-${r.end ?? "?"} ${why?.label ?? r.reason ?? ""}${r.note || r.correction ? `: ${r.note ?? r.correction}` : ""} (${String(r.when ?? "").slice(0, 16)}, was at ${r.at})`);
+ }
+ out(`${rows.length} removed clip${rows.length === 1 ? "" : "s"} out of ${project.id}${rows.length ? ` -- umtool timeline ${project.id} restore <id> puts one back` : ""}`);
+ return 0;
+ }
+
if (verb === "ls") {
const rows = timelineRows(manifest);
if (json) {
@@ -710,6 +732,11 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) =>
({ result, editNotes } = await write((token) => removeWrongSpeaker(project.dir, id, { token, at, correction })));
break;
}
+ case "restore": {
+ const id = need(rest[0], "the removed clip's id (umtool timeline <project> removed lists them)");
+ ({ result, editNotes } = await write((token) => restoreRemoved(project.dir, id, { token })));
+ break;
+ }
case "duplicate": {
const id = need(rest[0], "an entry id");
({ result, editNotes } = await write((token) => duplicateEntry(project.dir, id, { token, at })));
@@ -877,6 +904,8 @@ 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}`);
+ // What a restored clip's removal re-anchored or dropped stays as it is now: said, not undone.
+ for (const line of result.notPutBack ?? []) out(` not put back: ${line}`);
// The claim groups following the edit (claimGroups.mjs syncGroups), and an import's words.
for (const line of result.groupNotes ?? []) out(` groups: ${line}`);
for (const line of result.notes ?? []) out(` ${line}`);
@@ -1242,6 +1271,8 @@ function summaryOf(verb, r, attribution) {
const why = rejectionOf(r.removed);
return `removed ${r.id} (was at ${r.at}): ${why?.fact ? "marked incorrect" : "rejected"}, ${why?.label ?? r.record?.reason}`;
}
+ case "restore":
+ return `restored ${r.id} at ${r.at}${r.after ? ` (after ${r.after})` : r.before ? ` (before ${r.before})` : ""}, as it was in ${r.from}`;
case "duplicate":
return `duplicated as ${r.id} at ${r.at}`;
case "post":