commit 867373d751d3bc41f329cb3d63b0b19b7f5d3dea
parent e4742019a52da5783b409a74e966a3865a5d6fe0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 02:26:26 -0400
umtool: the clip editor on the clip finder's writer -- setSpeakerRole from common, Re-propose as the propose job, a proposal brought in with its window (release 35 C2)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
11 files changed, 115 insertions(+), 91 deletions(-)
diff --git a/plans/FACTS.md b/plans/FACTS.md
@@ -10740,7 +10740,9 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri
words — `reactions.source.words` else `<project>/words.json`, `[{w|word|text, start, end}]` or `{words: […]}` —
else the clip's cues), `POST {project, op, token, …}` (409 stale token; 400 + `errors` for StructureRefused).
- **"Unused proposals"** = `reactions.json` proposals that NO manifest clip's `assist.proposal` names (not the file's own
- `used`, which is what the last propose did). The editor never writes reactions.json except a speaker's role through
- `umtool/lib/report/clipEditorBridge.mjs` `setSpeakerRole(dir, index, role)` — a LOCAL STAND-IN for C1's writer (sets
- `role`, `label`, `how: "operator"`; other speakers untouched) — and `reproposeAvailable = false` until C1's
- `umtool clips propose` is wired in that same file.
+ `used`, which is what the last propose did). Bring-in: the proposal's start/end is the CUT, the window
+ `WINDOW_PAD_S` (1.5 s, common/lib/clips/assist.mjs) wider each side inside the duration, `original` all four. The
+ editor writes reactions.json only through `umtool/lib/report/clipEditorBridge.mjs`, which re-exports the clip
+ finder's `setSpeakerRole` (common/lib/clips/reactions.mjs: one host / one subject, `rolesChangedAt`) beside a lenient
+ reader (`{doc, error}`). Re-propose = `POST /api/report/clips {project, mode: "propose"}` (a job), offered while
+ `rolesChangedAt > proposedAt` (the view carries both).
diff --git a/plans/release-35/clip-editor.md b/plans/release-35/clip-editor.md
@@ -43,16 +43,17 @@ lead paragraphs; role tokens and the redesign's primitives; synthetic fixtures o
a silence between turns, else cue boundaries, within 1.5 s). Drafted locally, written once after 450 ms.
- Keep / Cut (toggle), Split here, Merge with next, Restore the assistant's version, Bring in (the proposals no clip
names), This is the host / Not the host (a click on a turn, or the Speakers list), Re-propose (offered after a role
- change; disabled with its reason until C1's propose is wired), Render (the picked or whole-cut take again, else the
+ change: the clip finder's proposal pass as a job), Render (the picked or whole-cut take again, else the
Takes page).
- Provenance: "by the assistant · 0.83 · why" / "edited by you · …" / "added by you" / "brought in by you", and the
edit history.
- Comments: the clip's notes (`{kind: "entry", entry}`), their threads with an agent's replies, Resolve / Won't fix
/ Reopen / Reply, a box for another (no autofocus, so the keys keep working).
- Keys: space, `j` / `l`, `i` / `o`, `s`, `m`, `k`, `x`, ← / →.
-4. **The seam onto C1** — `umtool/lib/report/clipEditorBridge.mjs` holds `readReactions` (lenient: `{doc, error}`) and a
- LOCAL `setSpeakerRole(dir, index, role)` (sets `role`, `label`, `how: "operator"`; other speakers untouched) and
- `reproposeAvailable = false`. Every caller imports from it.
+4. **The seam onto C1** — `umtool/lib/report/clipEditorBridge.mjs` holds `readReactions` (lenient: `{doc, error}`) and
+ re-exports C1's `setSpeakerRole` (until C1 merged it held a local stand-in; wired after the merge of main
+ 151d7c55). Re-propose posts `/api/report/clips {project, mode: "propose"}` and follows the job, offered while
+ `rolesChangedAt > proposedAt`; a bring-in uses C1's shape (the proposal is the cut, the window `WINDOW_PAD_S` wider).
## Files
@@ -73,12 +74,7 @@ GATES_PLACEHOLDER
## Found and left
-- C1's `setSpeakerRole` (common/lib/clips/reactions.mjs, on `r35/clip-analysis`) takes the role OFF every other
- speaker that held it (one host, one subject) and records `rolesChangedAt`; the local stand-in leaves the others alone.
- Swapping is `clipEditorBridge.mjs` alone (re-export C1's `setSpeakerRole`; keep the lenient reader); the page then
- shows the demotion because every write returns the whole view.
-- Re-propose: the button is disabled with "Re-propose arrives with the clip finder (umtool clips propose)". Wiring it
- is `reproposeAvailable` plus one `op: "repropose"` calling C1's umtool-side propose (never touching `by:
- "operator"` clips — C1's `applyProposals` already guarantees it).
- A clip merged away leaves its notes anchored to an id no clip has; they still list under `umtool notes` (the anchor
resolves to nothing). Not migrated.
+- The unused-proposal list is every proposal no clip names, best first — 92 on the live nik-drop-clips project. No
+ paging yet; it scrolls in the side column.
diff --git a/umtool/components/projects/review/ClipEditor.tsx b/umtool/components/projects/review/ClipEditor.tsx
@@ -256,6 +256,34 @@ export default function ClipEditor({
if (j) setRolesChanged(true);
});
};
+ // Re-propose: the clip finder's proposal pass as a job (`umtool clips
+ // propose`, /api/report/clips); clips a person edited are never touched.
+ const [proposing, setProposing] = useState<{ id: string; state: string; error: string | null } | null>(null);
+ const repropose = async () => {
+ await flush();
+ setError(null);
+ const r = await fetch("/api/report/clips", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, mode: "propose" }) });
+ const j = (await r.json().catch(() => ({}))) as { job?: { id: string; state: string; error: string | null }; error?: string };
+ if (!r.ok || !j.job) setError(j.error ?? `HTTP ${r.status}`);
+ else setProposing({ id: j.job.id, state: j.job.state, error: j.job.error });
+ };
+ useEffect(() => {
+ if (!proposing || proposing.state !== "running") return;
+ const t = setInterval(async () => {
+ const r = await fetch(`/api/report/clips?job=${proposing.id}`, { cache: "no-store" }).catch(() => null);
+ if (!r?.ok) return;
+ const j = (await r.json()) as { id: string; state: string; error: string | null };
+ setProposing({ id: j.id, state: j.state, error: j.error });
+ if (j.state !== "running") {
+ await reload().catch(() => {});
+ setRolesChanged(false);
+ setStatus(j.state === "done" ? "Re-proposed: the assistant's untouched clips follow the new roles" : `Re-propose ${j.state}${j.error ? `: ${j.error}` : ""}`);
+ }
+ }, 1500);
+ return () => clearInterval(t);
+ }, [proposing, reload]);
+ const rx = view.reactions;
+ const rolesStale = rolesChanged || (!!rx?.rolesChangedAt && (!rx.proposedAt || rx.rolesChangedAt > rx.proposedAt));
const snap = () => {
if (!points.length) {
setError("nothing to snap to here: no words, cues or turns in this span");
@@ -434,11 +462,18 @@ export default function ClipEditor({
</button>
</div>
)}
- {rolesChanged && (
- <div data-repropose="" className="flex flex-wrap items-center gap-2 text-[12px] text-text-2">
- <span>The roles changed: the proposals were made with the old ones.</span>
- <button type="button" data-repropose-button="" disabled={!view.repropose.available} title={view.repropose.why ?? undefined} className={buttonVariants({ size: "sm" })}>
- Re-propose
+ {(rolesStale || proposing) && view.reactions && (
+ <div data-repropose={proposing?.state ?? ""} className="flex flex-wrap items-center gap-2 text-[12px] text-text-2">
+ {rolesStale && <span>The roles changed since the clips were proposed.</span>}
+ <button
+ type="button"
+ data-repropose-button=""
+ disabled={!view.repropose.available || busy || proposing?.state === "running"}
+ title={view.repropose.why ?? "the proposal pass again with the new roles; clips you edited stay as they are"}
+ onClick={() => void repropose()}
+ className={buttonVariants({ size: "sm" })}
+ >
+ {proposing?.state === "running" ? "Re-proposing…" : "Re-propose"}
</button>
{!view.repropose.available && view.repropose.why && <span className="text-muted" data-repropose-why="">{view.repropose.why}</span>}
</div>
@@ -581,6 +616,7 @@ export default function ClipEditor({
<span>
{s.index} · {s.role ? ROLE_WORD[s.role] : "no role"}
{s.how === "operator" ? " (you said)" : s.how === "auto" ? " (auto)" : ""}
+ {typeof s.sameAs === "number" ? ` · same voice as ${s.sameAs}` : ""}
</span>
<span className="num font-mono text-[11px] text-muted">{typeof s.seconds === "number" ? `${Math.round(s.seconds)} s` : ""}</span>
{s.role !== "host" && (
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -1084,9 +1084,12 @@ keep / cut and comments work the same. Nothing in it calls a model.
<clip id>}` in `notes.json`), with their thread — an agent's replies too —
and Resolve / Reopen: the same notes `umtool notes` reads and answers.
- **Speakers:** a click on a turn says whose it is; **This is the host** (or
- **Not the host**) writes that speaker's role into `reactions.json` (`how:
- "operator"`), and **Re-propose** is offered (it runs the clip finder's
- `umtool clips propose`; until that lands the button is disabled and says so).
+ **Not the host**) writes that speaker's role into `reactions.json` through the
+ clip finder's writer (`how: "operator"`; the speaker who held the role is
+ handed back as "other"), and while the roles changed after the last proposal
+ pass (`rolesChangedAt` later than `proposedAt`) **Re-propose** is offered: the
+ clip finder's `umtool clips propose` as a job, which never touches a clip a
+ person edited.
- **Render:** the picked take (or the one whole-cut take) made again, else the
Takes page.
@@ -1104,7 +1107,8 @@ A split's first half keeps the id and `original`; the second is a fresh id
(`r004-2`), the operator's, with no `original`. A merge keeps the first clip's
id. A clip added from the strip is `{by: "operator", edits: [add]}`; a proposal
brought in also keeps `proposal`, `score`, `why` and the proposal's edges as
-`original`. Split, merge and add are structural edits: each takes an
+`original` (a proposal's start/end is the cut; the window is 1.5 s wider each
+side). Split, merge and add are structural edits: each takes an
`auto-before-<op>` snapshot first, so the Cut tab's **Undo last edit** takes it
back. The writers are `lib/report/manifest.mjs` (`updateClip`, `restoreClip`,
`splitClip`, `mergeClips`, `addClip`); the editor's operations are
diff --git a/umtool/e2e/clip-editor.spec.ts b/umtool/e2e/clip-editor.spec.ts
@@ -12,8 +12,8 @@ import * as urls from "./urls";
// 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.
+// brought in; "This is the host" writes the speaker's role (the clip
+// finder's writer) and offers Re-propose. Fixture: e2e/fixtures/clip-editor-fixture.mjs.
// ---------------------------------------------------------------------------
const HERE = path.dirname(fileURLToPath(import.meta.url));
@@ -125,13 +125,16 @@ test("the clip editor: trim, keep (the ruling follows), split, merge, restore, c
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(clip("vid1-9")).toMatchObject({ start: 7.5, end: 13.5, 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();
+ // The clip finder's writer: one host, so the other speaker is handed back as "other".
+ expect(json("reactions.json")?.speakers?.[0]?.role).toBe("other");
+ await expect(page.locator("[data-repropose-button]")).toBeEnabled();
await expect(page.locator('[data-turn-role="subject"]')).toHaveCount(0);
+ await expect(page.locator('[data-turn-role="other"]')).toHaveCount(3);
});
diff --git a/umtool/e2e/fixtures/clip-editor-fixture.mjs b/umtool/e2e/fixtures/clip-editor-fixture.mjs
@@ -45,6 +45,7 @@ export function makeClipEditorFixture({ reports, manifest, cachedWindow, cues })
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 },
+ proposedAt: "2026-01-01T00:00:00.000Z",
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" },
@@ -63,11 +64,11 @@ export function makeClipEditorFixture({ reports, manifest, cachedWindow, cues })
],
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: "p001", start: 1, end: 3, 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" },
+ { id: "p004", start: 9, end: 12, score: 0.5, moments: [], used: false, clipId: null, why: "a long comment" },
+ { id: "p005", start: 13, end: 15, score: 0.3, moments: [], used: false, clipId: null, why: "a chuckle" },
],
});
mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true });
diff --git a/umtool/lib/report/clipEditor.mjs b/umtool/lib/report/clipEditor.mjs
@@ -40,6 +40,7 @@ import {
import { momentKeysOf, readRulingsState, setMontageRuling } from "./montageRulings.mjs";
import { readReactions, reproposeAvailable, REPROPOSE_UNAVAILABLE, setSpeakerRole, SPEAKER_ROLES } from "./clipEditorBridge.mjs";
import { quoteBetween, unusedProposals, wordsOf } from "./clipEditorModel.mjs";
+import { WINDOW_PAD_S } from "yt-dlp-transcript-common/lib/clips/assist.mjs";
export { StaleToken, StructureRefused };
@@ -124,6 +125,8 @@ export async function clipEditorView(project) {
speakers: Array.isArray(doc.speakers) ? doc.speakers.filter(isObj) : [],
proposals: unusedProposals(doc, clips),
proposalCount: Array.isArray(doc.proposals) ? doc.proposals.length : 0,
+ proposedAt: typeof doc.proposedAt === "string" ? doc.proposedAt : null,
+ rolesChangedAt: typeof doc.rolesChangedAt === "string" ? doc.rolesChangedAt : null,
}
: null,
repropose: { available: reproposeAvailable, why: reproposeAvailable ? null : REPROPOSE_UNAVAILABLE },
@@ -225,7 +228,7 @@ const num = (v, what) => {
* add { video, channel?, cutStart, cutEnd } a selection on the strip
* bring-in { proposal } one of the clip finder's unused proposals
* ruling { clip, verdict: "keep" | "cut" | null }
- * role { speaker, role } reactions.json, through the clip finder's writer
+ * role { speaker, role | null } reactions.json, through the clip finder's writer
* with `token` (the manifest's, from the view) on every manifest edit.
* Returns `{ op, result, carried, view }`.
*/
@@ -293,7 +296,11 @@ export async function runClipEditorOp(project, body, { now = null } = {}) {
const video = doc?.source?.video;
const channel = doc?.source?.channel;
if (typeof video !== "string") throw new OpError("reactions.json names no source video");
- const cut = { cutStart: fin(p.cutStart) ? p.cutStart : p.start, cutEnd: fin(p.cutEnd) ? p.cutEnd : p.end };
+ // A proposal's start/end IS the cut; the window leaves the clip finder's
+ // WINDOW_PAD_S either side for trimming, inside the recording.
+ const cut = { cutStart: p.start, cutEnd: p.end };
+ const dur = fin(doc?.source?.duration) ? doc.source.duration : Infinity;
+ const win = { start: Math.max(0, p.start - WINDOW_PAD_S), end: Math.max(p.end, Math.min(dur, p.end + WINDOW_PAD_S)) };
const near = clipsOf(manifest).find((e) => e.video === video);
const quote = near ? await quoteFor(project, near.id, cut.cutStart, cut.cutEnd) : typeof p.text === "string" ? p.text : "";
result = await addClip(
@@ -302,11 +309,11 @@ export async function runClipEditorOp(project, body, { now = null } = {}) {
video,
...(typeof channel === "string" && channel !== manifest.provenance?.channelSlug ? { channel } : {}),
...cut,
- start: p.start,
- end: p.end,
+ start: win.start,
+ end: win.end,
...(typeof p.clipId === "string" ? { id: p.clipId } : {}),
...(quote ? { quote } : {}),
- proposal: { id: p.id, ...(fin(p.score) ? { score: p.score } : {}), ...(typeof p.why === "string" ? { why: p.why } : {}), start: p.start, end: p.end },
+ proposal: { id: p.id, ...(fin(p.score) ? { score: p.score } : {}), ...(typeof p.why === "string" ? { why: p.why } : {}), start: win.start, end: win.end },
},
{ token, now },
);
@@ -325,8 +332,9 @@ export async function runClipEditorOp(project, body, { now = null } = {}) {
case "role": {
const index = Number(body.speaker);
if (!Number.isInteger(index) || index < 0) throw new OpError("speaker is a speaker's index");
- if (!SPEAKER_ROLES.includes(body.role)) throw new OpError(`role must be one of ${SPEAKER_ROLES.join(", ")}`);
- result = await setSpeakerRole(dir, index, body.role);
+ if (body.role !== null && !SPEAKER_ROLES.includes(body.role)) throw new OpError(`role must be one of ${SPEAKER_ROLES.join(", ")}, or null`);
+ const doc = await setSpeakerRole(dir, index, body.role);
+ result = { speaker: doc.speakers.find((x) => x?.index === index) ?? null };
structural = false;
break;
}
diff --git a/umtool/lib/report/clipEditor.test.mjs b/umtool/lib/report/clipEditor.test.mjs
@@ -52,8 +52,8 @@ const REACTIONS = {
laughs: [{ start: 15, end: 16.5, score: 0.7, speaker: 0 }],
moments: [],
proposals: [
- { id: "p001", start: 10, end: 20, score: 0.8, moments: [], used: true, clipId: "r001", why: "host laughs" },
- { id: "p002", start: 30, end: 40, score: 0.7, moments: [], used: true, clipId: "r002", why: "a comment" },
+ { id: "p001", start: 11, end: 19, score: 0.8, moments: [], used: true, clipId: "r001", why: "host laughs" },
+ { id: "p002", start: 31, end: 39, score: 0.7, moments: [], used: true, clipId: "r002", why: "a comment" },
{ id: "p003", start: 62, end: 68, score: 0.5, moments: [], used: false, why: "a short laugh" },
{ id: "p004", start: 70, end: 75, score: 0.6, moments: [], used: false, why: "a long comment" },
],
@@ -243,13 +243,20 @@ test("runClipEditorOp: bring in an unused proposal (it leaves the list); add fro
const brought = view.clips.find((c) => c.assist?.proposal === "p003");
assert.equal(brought.quote, "w62 w63 w64 w65 w66 w67");
assert.equal(brought.assist.by, "operator");
+ // The proposal is the cut; the window leaves 1.5 s either side.
+ assert.deepEqual([brought.cutStart, brought.cutEnd, brought.start, brought.end], [62, 68, 60.5, 69.5]);
+ assert.deepEqual(brought.assist.original, { start: 60.5, end: 69.5, cutStart: 62, cutEnd: 68 });
await runClipEditorOp(p, { op: "add", clip: "r002", cutStart: 41, cutEnd: 44 }, { now: NOW });
const m = await read(p.dir);
assert.deepEqual(m.timeline.map((e) => e.id).slice(0, 4), ["r001", "r002", "v1-41", "k1"]);
await runClipEditorOp(p, { op: "role", speaker: 1, role: "host" });
const { doc } = await readReactions(p.dir);
assert.deepEqual(doc.speakers[1], { index: 1, role: "host", label: "Host", seconds: 50, turns: 3, how: "operator" });
- assert.equal(doc.speakers[0].role, "host");
+ // The clip finder's writer: one host -- the other speaker who held it is handed back as "other".
+ assert.equal(doc.speakers[0].role, "other");
+ assert.ok(doc.rolesChangedAt);
+ const after = await clipEditorView(p);
+ assert.equal(after.reactions.rolesChangedAt, doc.rolesChangedAt);
await assert.rejects(setSpeakerRole(p.dir, 9, "host"), /no speaker 9/);
await assert.rejects(runClipEditorOp(p, { op: "bring-in", proposal: "p999" }), /no proposal p999/);
} finally {
diff --git a/umtool/lib/report/clipEditorBridge.mjs b/umtool/lib/report/clipEditorBridge.mjs
@@ -5,16 +5,14 @@
// writes exactly one thing into it -- a speaker's role, when the operator says
// "This is the host" on the strip -- through C1's exported `setSpeakerRole`.
//
-// Until C1 lands this module holds a THIN LOCAL WRITER behind the same two
-// names (`readReactions`, `setSpeakerRole`) and says that re-proposing is not
-// here yet (`reproposeAvailable`). Swapping to C1's is a change to this file
-// alone: every caller in umtool imports from here.
-import { readFile, rename, writeFile } from "node:fs/promises";
+// `readReactions` here is lenient and says WHY a file is unreadable (the
+// clip finder's own reader answers null); the role writer is the clip
+// finder's. Every caller in umtool imports from here.
+import { readFile } from "node:fs/promises";
import path from "node:path";
export const REACTIONS_FILE = "reactions.json";
export const SPEAKER_ROLES = Object.freeze(["host", "subject", "other"]);
-const ROLE_LABEL = { host: "Host", subject: "Subject", other: "Other" };
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
@@ -41,48 +39,15 @@ export async function readReactions(dir) {
}
}
-let queue = Promise.resolve();
-/** @template T @param {() => Promise<T>} fn @returns {Promise<T>} */
-function withLock(fn) {
- const run = queue.then(fn, fn);
- queue = run.then(
- () => undefined,
- () => undefined,
- );
- return run;
-}
-
/**
- * Set one speaker's role, the operator's (`how: "operator"`). Atomic (tmp +
- * rename), in the file's own formatting. Other speakers are left as they are:
- * a voice split in two clusters may be the host twice.
- *
- * LOCAL STAND-IN for C1's `setSpeakerRole` (same arguments, same effect).
- * @param {string} dir
- * @param {number} index the speaker's `index`
- * @param {"host" | "subject" | "other"} role
+ * Set one speaker's role, the operator's -- THE CLIP FINDER'S WRITER
+ * (common/lib/clips/reactions.mjs): marking a host or a subject takes that
+ * role off any other speaker that held it; `null` hands the speaker back to
+ * the analysis; `rolesChangedAt` is stamped, so the page offers Re-propose
+ * while it is later than `proposedAt`. Returns the document as written.
*/
-export async function setSpeakerRole(dir, index, role) {
- if (!SPEAKER_ROLES.includes(role)) throw new Error(`role must be one of ${SPEAKER_ROLES.join(", ")}`);
- const file = path.join(/* turbopackIgnore: true */ dir, REACTIONS_FILE);
- return withLock(async () => {
- const { doc, error } = await readReactions(dir);
- if (error) throw new Error(`${error}; not writing it`);
- if (!doc) throw new Error(`no ${REACTIONS_FILE} in this project`);
- const speakers = Array.isArray(doc.speakers) ? doc.speakers : [];
- const s = speakers.find((x) => isObj(x) && x.index === index);
- if (!s) throw new Error(`no speaker ${index} in ${REACTIONS_FILE}`);
- s.role = role;
- s.label = ROLE_LABEL[role];
- s.how = "operator";
- const tmp = `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
- await writeFile(tmp, JSON.stringify(doc, null, 2) + "\n", "utf8");
- await rename(tmp, file);
- return { speaker: s, doc };
- });
-}
+export { setSpeakerRole } from "yt-dlp-transcript-common/lib/clips/reactions.mjs";
-/** Whether "Re-propose" can run here (C1's `umtool clips propose`): not until C1 lands. */
-export const reproposeAvailable = false;
-/** What the button says while it cannot. */
-export const REPROPOSE_UNAVAILABLE = "Re-propose arrives with the clip finder (umtool clips propose)";
+/** Re-propose is the clip finder's proposal pass: POST /api/report/clips {project, mode: "propose"} (`umtool clips propose`, a job). */
+export const reproposeAvailable = true;
+export const REPROPOSE_UNAVAILABLE = null;
diff --git a/umtool/lib/report/clipEditorTypes.ts b/umtool/lib/report/clipEditorTypes.ts
@@ -27,7 +27,7 @@ export type EditorClip = {
montage: boolean;
};
-export type Speaker = { index: number; role?: "host" | "subject" | "other"; label?: string; seconds?: number; turns?: number; how?: "auto" | "operator" };
+export type Speaker = { index: number; role?: "host" | "subject" | "other"; label?: string; seconds?: number; turns?: number; how?: "auto" | "operator"; sameAs?: number };
export type Proposal = { id: string; start: number; end: number; score?: number; why?: string; moments?: string[]; used?: boolean; clipId?: string | null };
export type EditorView = {
@@ -41,6 +41,8 @@ export type EditorView = {
speakers: Speaker[];
proposals: Proposal[];
proposalCount: number;
+ proposedAt: string | null;
+ rolesChangedAt: string | null;
} | null;
repropose: { available: boolean; why: string | null };
};
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -489,7 +489,7 @@ export async function splitClip(dir, clipId, at, { token = null, quotes = {}, no
b.id = freshEntryId(m.timeline, e.id);
b.start = t;
if (hasCut) b.cutStart = t;
- if (b.cite != null) b.cite = t;
+ if (typeof b.cite === "number") b.cite = t;
if (b.muteFrom != null && b.muteFrom < t) delete b.muteFrom;
delete b.claim;
const qb = textOr(quotes.second, b.quote ?? null);