commit 9cccd3d21d137afa20abb8f9d6816b42ba3c854e
parent cbe7cb2f08415a39266dfd5ec12cdd238d1bf78e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 00:24:56 -0400
umtool: the Cut tab links the clip editor; e2e clip-editor.spec.ts on a fixture of an assistant's clips (release 35 C2)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 246 insertions(+), 2 deletions(-)
diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx
@@ -8,7 +8,7 @@ import {
} from "@/lib/projects/report.mjs";
import { listTakes } from "@/lib/report/takes.mjs";
import { buttonVariants } from "@/components/ui/button";
-import { clipBenchHref, clipDeckHref, mixHref as toolsMixHref, projectHref, takesHref } from "@/lib/hrefs";
+import { clipBenchHref, clipDeckHref, clipEditorHref, mixHref as toolsMixHref, projectHref, takesHref } from "@/lib/hrefs";
import { montageClipsOf, momentKeysOf, readRulingsState } from "@/lib/report/montageRulings.mjs";
import FetchUnfetchedButton from "../FetchUnfetchedButton";
import { clipRecord, storedUrlOf } from "@/lib/clips/stored";
@@ -68,6 +68,11 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor
return montage.filter((e) => !doc.rulings[keys.get(e.id) ?? ""]).length;
})
: 0;
+ // The clip editor (release 35 C2): a cut that is not a montage -- how many
+ // of its clips the clip finder proposed (`assist`), and how many a person
+ // has edited since.
+ const assisted = (m?.timeline ?? []).filter((e: { type?: string; assist?: unknown }) => e?.type === "clip" && e.assist && typeof e.assist === "object") as { assist: { by?: string } }[];
+ const assistedByYou = assisted.filter((e) => e.assist.by === "operator").length;
// Fetch windows (release 35): the body the button sends, sized here; a run
// still going is followed when the page opens. A rulings file that does not
// parse leaves the button out (the clip deck says what is wrong with it).
@@ -162,6 +167,17 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor
Clips — {unruled ? `${unruled} of ${montage.length} to rule` : `${montage.length} ruled`}
</Link>
)}
+ {/* Any other cut's clips -- an assistant's above all -- adjusted by a person (release 35 C2). */}
+ {montage.length === 0 && clips.length > 0 && (
+ <Link
+ href={clipEditorHref(project.id)}
+ data-clip-editor-link={assisted.length}
+ className={buttonVariants({ size: "lg" })}
+ >
+ Clip editor — {clips.length} clip{clips.length === 1 ? "" : "s"}
+ {assisted.length ? ` · ${assisted.length} by the assistant${assistedByYou ? `, ${assistedByYou} edited by you` : ""}` : ""}
+ </Link>
+ )}
{/* Alternative renders of part of the cut, judged on their own page --
where the first one is made, too (release 33's take maker). */}
{takes.exists ? (
diff --git a/umtool/components/projects/review/ClipEditor.tsx b/umtool/components/projects/review/ClipEditor.tsx
@@ -612,6 +612,9 @@ type Target = { channel: string; video: string; from: number; to: number; projec
const Player = forwardRef<PlayerHandle, { targets: Target[]; cut: Cut; onTime: (t: number) => void; onPlaying: (p: boolean) => void }>(function Player({ targets, cut, onTime, onPlaying }, ref) {
const [found, setFound] = useState<{ play: CitedPlay; from: number } | null | undefined>(undefined);
const media = useRef<HTMLMediaElement | null>(null);
+ // The seek to the cut on load is the player's own, not a person's: it must
+ // not move the playhead somebody just set by clicking a word.
+ const ownSeek = useRef(false);
const cutRef = useRef(cut);
cutRef.current = cut;
const key = targets.map((t) => `${t.clip}|${t.from}|${t.to}`).join(",");
@@ -652,7 +655,9 @@ const Player = forwardRef<PlayerHandle, { targets: Target[]; cut: Cut; onTime: (
},
seek: (t: number) => {
const m = media.current;
- if (m) m.currentTime = fileT(t);
+ if (!m) return;
+ ownSeek.current = true;
+ m.currentTime = fileT(t);
},
}));
@@ -674,9 +679,15 @@ const Player = forwardRef<PlayerHandle, { targets: Target[]; cut: Cut; onTime: (
tabIndex: -1,
controls: true,
onLoadedMetadata: (e: React.SyntheticEvent<HTMLMediaElement>) => {
+ ownSeek.current = true;
e.currentTarget.currentTime = fileT(cutRef.current.cutStart);
},
+ onSeeked: (e: React.SyntheticEvent<HTMLMediaElement>) => {
+ if (ownSeek.current) ownSeek.current = false;
+ else onTime(sourceT(e.currentTarget.currentTime));
+ },
onTimeUpdate: (e: React.SyntheticEvent<HTMLMediaElement>) => {
+ if (e.currentTarget.paused) return;
const t = sourceT(e.currentTarget.currentTime);
onTime(t);
// Loop the cut while it plays inside it.
diff --git a/umtool/e2e/clip-editor.spec.ts b/umtool/e2e/clip-editor.spec.ts
@@ -0,0 +1,137 @@
+import { test, expect } from "@playwright/test";
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// The clip editor (release 35 C2): a person hops in on an assistant's clips.
+// The Cut tab links it; the strip colours the turns by role and marks the
+// laughs; a nudge trims (the clip is "edited by you"); K keeps and the ruling
+// follows the clip when its start moves; a word click puts the playhead there
+// and Split here cuts the clip in two; Merge with next joins them; Restore
+// puts the assistant's version back; X cuts; a comment is a note anchored to
+// the clip and an agent's reply shows in its thread; an unused proposal is
+// brought in; "This is the host" writes the speaker's role and offers
+// Re-propose. Fixture: e2e/fixtures/clip-editor-fixture.mjs.
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const PROJECT = "reports/clip-editor-fixture";
+const DIR = path.join(FIXTURE, "reports", "clip-editor-fixture");
+
+type Clip = { id: string; start: number; end: number; cutStart?: number; cutEnd?: number; quote?: string; assist?: { by: string; proposal?: string; edits: { what: string }[] } };
+const json = (name: string) => {
+ try {
+ return JSON.parse(readFileSync(path.join(DIR, name), "utf8"));
+ } catch {
+ return null;
+ }
+};
+const clips = (): Clip[] => (json("video.manifest.json")?.timeline ?? []).filter((e: { type: string }) => e.type === "clip");
+const clip = (id: string) => clips().find((c) => c.id === id) ?? null;
+const ruling = (at: string) => (json("montage-rulings.json")?.rulings ?? {})[`testchan/vid1@${at}`]?.verdict ?? null;
+
+test("the clip editor: trim, keep (the ruling follows), split, merge, restore, cut, comment + an agent's reply, bring in, the host", async ({ page, request }) => {
+ test.setTimeout(150_000);
+ await page.setViewportSize({ width: 1366, height: 900 });
+
+ // The Cut tab links the editor for a cut that is not a montage.
+ await page.goto(urls.section(PROJECT, "cut"));
+ const link = page.locator("[data-clip-editor-link]");
+ await expect(link).toHaveAttribute("data-clip-editor-link", "3");
+ await expect(link).toContainText("Clip editor — 3 clips · 3 by the assistant");
+ await link.click();
+
+ const editor = page.locator("[data-clip-editor]");
+ await expect(editor).toHaveAttribute("data-clip-editor", "r001");
+ await expect(page.locator("[data-editor-provenance]")).toHaveText("by the assistant · 0.80 · host laughs at the line");
+ await expect(page.locator("[data-editor-player]")).not.toHaveAttribute("data-editor-player", "looking", { timeout: 15_000 });
+ // The strip: turns by role, laughs, the words.
+ await expect(page.locator('[data-turn-role="host"]')).toHaveCount(3);
+ await expect(page.locator('[data-turn-role="subject"]')).toHaveCount(3);
+ await expect(page.locator("[data-laugh]")).toHaveCount(2);
+ await expect(page.locator("[data-editor-words]")).toHaveAttribute("data-editor-words", "words");
+ await expect(page.locator("[data-editor-proposals]")).toHaveAttribute("data-editor-proposals", "2");
+
+ // A nudge trims: out +0.5. The clip is the operator's now.
+ await page.locator('[data-nudge="out:0.5"]').click();
+ await expect.poll(() => clip("r001")?.cutEnd).toBe(3.5);
+ expect(clip("r001")?.assist?.by).toBe("operator");
+ await expect(page.locator("[data-editor-provenance]")).toContainText("edited by you · the assistant scored it 0.80 · 1 edit");
+
+ // K keeps; moving the in point moves the ruling with the clip.
+ await page.keyboard.press("k");
+ await expect.poll(() => ruling("1.00")).toBe("keep");
+ await page.locator('[data-nudge="in:0.5"]').click();
+ await expect.poll(() => ruling("1.50")).toBe("keep");
+ expect(ruling("1.00")).toBeNull();
+ await expect(page.locator("[data-editor-ruling]")).toHaveAttribute("data-editor-ruling", "keep");
+
+ // A word puts the playhead there; Split here.
+ await page.locator('[data-word-t="2.4"]').click();
+ await expect(page.locator("[data-playhead]")).toHaveCount(1);
+ await page.locator('[data-action="split"]').click();
+ await expect.poll(() => clip("r001-2")?.cutStart).toBe(2.4);
+ expect(clip("r001")?.cutEnd).toBe(2.4);
+ expect(clip("r001-2")?.quote).toBe("sentence. And");
+ await expect(page.locator('[data-editor-row="r001-2"]')).toHaveCount(1);
+
+ // Merge with next joins them again.
+ await page.locator('[data-action="merge"]').click();
+ await expect.poll(() => clip("r001-2")).toBeNull();
+ expect([clip("r001")?.cutStart, clip("r001")?.cutEnd]).toEqual([1.5, 3.5]);
+
+ // Restore the assistant's version: the edges, and the clip is the assistant's again.
+ await page.locator('[data-action="restore"]').click();
+ await expect.poll(() => clip("r001")?.cutStart).toBe(1);
+ expect(clip("r001")?.cutEnd).toBe(3);
+ expect(clip("r001")?.assist?.by).toBe("assistant");
+ expect(clip("r001")?.assist?.edits.map((e) => e.what)).toEqual(["trim", "trim", "split", "merge", "restore"]);
+ await expect.poll(() => ruling("1.00")).toBe("keep");
+ await expect(page.locator("[data-editor-provenance]")).toHaveText("by the assistant · 0.80 · host laughs at the line");
+
+ // → the next clip; X cuts it.
+ await page.keyboard.press("ArrowRight");
+ await expect(editor).toHaveAttribute("data-clip-editor", "r002");
+ await page.keyboard.press("x");
+ await expect.poll(() => ruling("4.00")).toBe("cut");
+
+ // A comment: a note anchored to the clip.
+ await page.locator("[data-clip-note-input]").fill("tighten the start, he breathes first");
+ await page.locator("[data-clip-note-add]").click();
+ await expect(page.locator('[data-clip-notes="r002"] [data-note-id]')).toHaveCount(1);
+ type Note = { id: string; status: string; anchor: { kind: string; entry?: string }; replies: { author: string; text: string }[] };
+ const notes = (): Note[] => json("notes.json")?.notes ?? [];
+ await expect.poll(() => notes().length).toBe(1);
+ expect(notes()[0].anchor).toEqual({ kind: "entry", entry: "r002" });
+ // An agent replies (as the MCP's notes tool does); the thread shows it.
+ const read = await (await request.get(`/api/notes?project=${encodeURIComponent(PROJECT)}`)).json();
+ const replied = await request.post(`/api/notes?project=${encodeURIComponent(PROJECT)}`, {
+ headers: { authorization: "Bearer umtool-e2e-token" },
+ data: { token: read.token, op: { op: "reply", id: notes()[0].id, text: "moved the in point to the breath" } },
+ });
+ expect(replied.ok()).toBe(true);
+ await page.reload();
+ await expect(editor).toHaveAttribute("data-clip-editor", "r002");
+ const thread = page.locator('[data-clip-notes="r002"] [data-note-id]');
+ await expect(thread.locator("[data-note-reply]")).toContainText("moved the in point to the breath");
+ await thread.locator('[data-note-action="resolve"]').click();
+ await expect.poll(() => notes()[0].status).toBe("resolved");
+ await expect(page.locator('[data-clip-notes="r002"]')).toHaveAttribute("data-open-notes", "0");
+
+ // Bring in an unused proposal: it is a clip, the operator's, and leaves the list.
+ await page.locator('[data-bring-in="p004"]').click();
+ await expect(editor).toHaveAttribute("data-clip-editor", "vid1-9");
+ await expect(page.locator("[data-editor-proposals]")).toHaveAttribute("data-editor-proposals", "1");
+ expect(clip("vid1-9")).toMatchObject({ cutStart: 9, cutEnd: 12, assist: { by: "operator", proposal: "p004" } });
+ expect(clips().map((c) => c.id)).toEqual(["r001", "r002", "r003", "vid1-9"]);
+
+ // "This is the host" on a subject turn: the role is the operator's; Re-propose is offered.
+ await page.locator('[data-turn-speaker="1"]').first().click();
+ await page.locator('[data-set-host="1"]').click();
+ await expect.poll(() => json("reactions.json")?.speakers?.[1]).toMatchObject({ index: 1, role: "host", how: "operator" });
+ await expect(page.locator("[data-repropose-button]")).toBeDisabled();
+ await expect(page.locator('[data-turn-role="subject"]')).toHaveCount(0);
+});
diff --git a/umtool/e2e/fixtures/clip-editor-fixture.mjs b/umtool/e2e/fixtures/clip-editor-fixture.mjs
@@ -0,0 +1,76 @@
+// What clip-editor.spec.ts edits (release 35 C2): a report video of three
+// clips an assistant proposed (the clip finder's `assist` on each) on one
+// synthetic source (vid1, its cues the fixture corpus's), the source's
+// reactions.json (two speakers, host and subject, their turns, two laughs,
+// five proposals -- two not in the cut) and its word timings (the cue text
+// spread evenly over each cue), and every clip's window cached in the
+// project's out/clips-raw (a copy of vid1's 0-9 s). Its own project: the spec
+// writes the manifest, montage-rulings.json, notes.json and reactions.json.
+//
+// r001 1.0-3.0 (p001) r002 4.0-6.0 (p002) r003 6.5-8.5 (p003)
+// unused: p004 9-12, p005 13-15
+//
+// Synthetic, like every fixture.
+import { copyFileSync, mkdirSync, writeFileSync } from "node:fs";
+import path from "node:path";
+
+const write = (dir, name, doc) => {
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(path.join(dir, name), JSON.stringify(doc, null, 2) + "\n");
+};
+
+/**
+ * @param {{ reports: string, manifest: Function, cachedWindow: string, cues: Array<[number, number, string]> }} o
+ */
+export function makeClipEditorFixture({ reports, manifest, cachedWindow, cues }) {
+ const dir = path.join(reports, "clip-editor-fixture");
+ const assist = (p, s, e, cs, ce, score, why) => ({ by: "assistant", proposal: p, score, why, original: { start: s, end: e, cutStart: cs, cutEnd: ce }, edits: [] });
+ const clip = (id, s, e, cs, ce, p, score, why, quote) => ({ type: "clip", id, video: "vid1", start: s, end: e, cutStart: cs, cutEnd: ce, quote, assist: assist(p, s, e, cs, ce, score, why) });
+ const doc = manifest("clip-editor-fixture", "The Clip Editor Fixture", { siteOrigin: "https://archive.example" }, [
+ clip("r001", 0.5, 3.5, 1, 3, "p001", 0.8, "host laughs at the line", "This is a complete sentence."),
+ clip("r002", 4, 6, 4, 6, "p002", 0.7, "a comment", "And this one runs on"),
+ clip("r003", 6.5, 8.5, 6.5, 8.5, "p003", 0.6, "a short comment", "of that it finishes here."),
+ ]);
+ doc.render.fetchPad = 0;
+ write(dir, "video.manifest.json", doc);
+
+ const words = [];
+ for (const [start, end, text] of cues) {
+ const ws = text.split(/\s+/).filter(Boolean);
+ const step = (end - start) / ws.length;
+ ws.forEach((w, i) => words.push({ w, start: +(start + i * step).toFixed(2), end: +(start + (i + 0.8) * step).toFixed(2) }));
+ }
+ write(dir, "words.json", { words });
+ write(dir, "reactions.json", {
+ version: 1,
+ source: { channel: "testchan", video: "vid1", duration: 21, words: "words.json", diarization: { generatedAt: "2026-01-01T00:00:00.000Z", engine: "sherpa-onnx" } },
+ params: { target: 600, laughMin: 0.25, mergeGap: 6, setupMax: 20, clipMax: 75 },
+ speakers: [
+ { index: 0, role: "host", label: "Host", seconds: 9, turns: 4, how: "auto" },
+ { index: 1, role: "subject", label: "Subject", seconds: 12, turns: 3, how: "auto" },
+ ],
+ turns: [
+ { start: 0, end: 2.2, speaker: 1 },
+ { start: 2.4, end: 3.8, speaker: 0 },
+ { start: 4, end: 6.2, speaker: 1 },
+ { start: 6.4, end: 9, speaker: 0 },
+ { start: 9.2, end: 15, speaker: 1 },
+ { start: 15.2, end: 21, speaker: 0 },
+ ],
+ laughs: [
+ { start: 2.6, end: 3.2, score: 0.71, speaker: 0 },
+ { start: 7.0, end: 7.6, score: 0.44, speaker: 0 },
+ ],
+ moments: [],
+ proposals: [
+ { id: "p001", start: 0.5, end: 3.5, score: 0.8, moments: [], used: true, clipId: "r001", why: "host laughs at the line" },
+ { id: "p002", start: 4, end: 6, score: 0.7, moments: [], used: true, clipId: "r002", why: "a comment" },
+ { id: "p003", start: 6.5, end: 8.5, score: 0.6, moments: [], used: true, clipId: "r003", why: "a short comment" },
+ { id: "p004", start: 9, end: 12, score: 0.5, moments: [], used: false, why: "a long comment" },
+ { id: "p005", start: 13, end: 15, score: 0.3, moments: [], used: false, why: "a chuckle" },
+ ],
+ });
+ mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true });
+ copyFileSync(cachedWindow, path.join(dir, "out", "clips-raw", "vid1_0.00-9.00.mp4"));
+ return { dir };
+}
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -30,6 +30,7 @@ import { makeDeleteFixture } from "./delete-fixture.mjs";
import { makeDraftReviewFixture } from "./draft-review-fixture.mjs";
import { makeReviewPlayerFixture } from "./review-player-fixture.mjs";
import { makeClipDeckFixture } from "./clip-deck-fixture.mjs";
+import { makeClipEditorFixture } from "./clip-editor-fixture.mjs";
import { makeBenchShellFixture } from "./bench-shell-fixture.mjs";
import { makeYoutubeFixture } from "./youtube-fixture.mjs";
import { makeBoardFixture, makeResearchFixture } from "./research-fixture.mjs";
@@ -1804,6 +1805,8 @@ makeDraftReviewFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out
makeReviewPlayerFixture({ reports, channels: CHANNELS, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
// Release 34 N1: the montage clip deck, six instances ruled by ear (clip-deck.spec.ts).
makeClipDeckFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
+// Release 35 C2: the clip editor, an assistant's clips adjusted by hand (clip-editor.spec.ts).
+makeClipEditorFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 });
// P4b: the bench shell's own clips, and the Media tab's fields with their draft files.
makeBenchShellFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
// Release 28 M6: the YouTube text, previewed and built (media-draft-e.spec.ts).
@@ -2140,6 +2143,7 @@ console.log(` deliver-stop-fixture (writable: six confirmed clips to
console.log(` takes-fixture (writable: takes/ with 4 takes over 2 groups, 1 skipped)`);
console.log(` takes-make-fixture (writable: one clip, its window cached, no takes/ -- the take maker's)`);
console.log(` clip-deck-fixture (writable: six montage clips, windows cached, edits.json + voice-match.json -- the clip deck's)`);
+console.log(` clip-editor-fixture (writable: three assistant clips, reactions.json + words.json, windows cached -- the clip editor's)`);
console.log(` narration-fixture (writable: a narrated card, voiced by the editor stub's tone)`);
console.log(` narration-review-fixture (writable: two narrated cards, nothing judged)`);
console.log(` draft-review-fixture (writable: drafted on-screen, narration, teaser; an alternative), draft-review-build-fixture`);