commit 8cafa35cdd92f70f64e2f3a26dcfb3f86380686b
parent 81cff877b0bf4a9c4bc5ae8602589a543cbba3fe
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 15:35:18 -0500
umtool: a quick clip that fails removes the project it made
After scaffolding, a failed step (the editor's fetch, the snap, the render) removes the
half-made project and says so, so a retry is made under the same name rather than
piling up -2, -3 beside it. The error says what failed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 60 insertions(+), 41 deletions(-)
diff --git a/umtool/lib/report/quickClip.mjs b/umtool/lib/report/quickClip.mjs
@@ -204,52 +204,61 @@ export async function quickClip(ask, { root = REPORTS_ROOT, channelsDir = CHANNE
siteOrigin: origin, channelsDir, timeline: [clip],
});
const project = { id: made.id, dir: made.dir };
- const { updateRender } = await import("./manifest.mjs");
- await updateRender(project.dir, { mode: "basic" });
- say(`project ${project.id} (basic: the footage alone)${origin ? `, archive ${origin}` : ""}`);
-
- // 2. The window, asked of the editor.
- if (deps.fetch) await deps.fetch(project);
- else {
- const fw = await import("./fetchWindows.mjs");
- await fetchThroughEditor(project, { cfg: cfg ?? fw.editorConfig(), pollMs, say });
- }
+ // A quick clip that fails after this point takes its project with it: a retry makes it afresh under the same
+ // name, never a pile of half-made `-2`, `-3` beside it. What failed is in the error.
+ try {
+ const { updateRender } = await import("./manifest.mjs");
+ await updateRender(project.dir, { mode: "basic" });
+ say(`project ${project.id} (basic: the footage alone)${origin ? `, archive ${origin}` : ""}`);
- // 3. --snap words: the edges to the words heard.
- let snapped = null;
- if (ask.snap === "words") {
- const from = Math.max(0, spec.start - SNAP_PAD_S);
- const to = spec.end + SNAP_PAD_S;
- const src = await resolveLocalSource({ video, slug: spec.channel, from, to }, { rawDir: path.join(project.dir, "out", "clips-raw"), channelsDir });
- if (!src) throw new Error(`--snap words: no window on disk holds ${from.toFixed(2)}–${to.toFixed(2)} (the fetch landed a narrower one?)`);
- const { mkdir } = await import("node:fs/promises");
- const work = path.join(project.dir, "out", "quick-clip");
- await mkdir(work, { recursive: true });
- const a = Math.max(from, src.windowStart);
- const b = Math.min(to, src.windowEnd);
- const words = await (deps.transcribe ?? editorWords)({ path: src.path, start: r2(a - src.windowStart), end: r2(b - src.windowStart), out: path.join(work, "words.json") });
- const heard = words.map((w) => ({ w: w.w ?? w.text, start: w.start + src.windowStart, end: w.end + src.windowStart }));
- snapped = snapToWords(heard, spec.start, spec.end);
- if (!snapped) say("--snap words: no word heard inside the edges -- they stay as asked");
+ // 2. The window, asked of the editor.
+ if (deps.fetch) await deps.fetch(project);
else {
- const { updateClip } = await import("./manifest.mjs");
- await updateClip(project.dir, "c01", {
- start: r2(Math.min(spec.start, snapped.cutStart)), end: r2(Math.max(spec.end, snapped.cutEnd)), cutStart: snapped.cutStart, cutEnd: snapped.cutEnd,
- });
- say(`snapped to the words: ${snapped.cutStart}–${snapped.cutEnd} ("${snapped.first}" … "${snapped.last}")`);
+ const fw = await import("./fetchWindows.mjs");
+ await fetchThroughEditor(project, { cfg: cfg ?? fw.editorConfig(), pollMs, say });
}
- }
- // 4. The render, as a take: the heavy slot, the record, the take panel.
- const take = deps.take ?? (await import("./takeCli.mjs")).takeCommand;
- const code = await take([project.id, "--id", QUICK_CLIP_TAKE, "--label", "Quick clip", "--full", ...(progress ? ["--progress", progress] : [])], { reportsRoot: root, log, err });
- if (code !== 0) throw new Error(`the render failed (umtool take ${project.id} --id ${QUICK_CLIP_TAKE} exited ${code}; its record: umtool take status ${project.id} --id ${QUICK_CLIP_TAKE})`);
- const { takesDirOf } = await import("./takes.mjs");
- const output = path.join(takesDirOf(project.dir), QUICK_CLIP_TAKE, "preview.mp4");
+ // 3. --snap words: the edges to the words heard.
+ let snapped = null;
+ if (ask.snap === "words") {
+ const from = Math.max(0, spec.start - SNAP_PAD_S);
+ const to = spec.end + SNAP_PAD_S;
+ const src = await resolveLocalSource({ video, slug: spec.channel, from, to }, { rawDir: path.join(project.dir, "out", "clips-raw"), channelsDir });
+ if (!src) throw new Error(`--snap words: no window on disk holds ${from.toFixed(2)}–${to.toFixed(2)} (the fetch landed a narrower one?)`);
+ const { mkdir } = await import("node:fs/promises");
+ const work = path.join(project.dir, "out", "quick-clip");
+ await mkdir(work, { recursive: true });
+ const a = Math.max(from, src.windowStart);
+ const b = Math.min(to, src.windowEnd);
+ const words = await (deps.transcribe ?? editorWords)({ path: src.path, start: r2(a - src.windowStart), end: r2(b - src.windowStart), out: path.join(work, "words.json") });
+ const heard = words.map((w) => ({ w: w.w ?? w.text, start: w.start + src.windowStart, end: w.end + src.windowStart }));
+ snapped = snapToWords(heard, spec.start, spec.end);
+ if (!snapped) say("--snap words: no word heard inside the edges -- they stay as asked");
+ else {
+ const { updateClip } = await import("./manifest.mjs");
+ await updateClip(project.dir, "c01", {
+ start: r2(Math.min(spec.start, snapped.cutStart)), end: r2(Math.max(spec.end, snapped.cutEnd)), cutStart: snapped.cutStart, cutEnd: snapped.cutEnd,
+ });
+ say(`snapped to the words: ${snapped.cutStart}–${snapped.cutEnd} ("${snapped.first}" … "${snapped.last}")`);
+ }
+ }
+
+ // 4. The render, as a take: the heavy slot, the record, the take panel.
+ const take = deps.take ?? (await import("./takeCli.mjs")).takeCommand;
+ const code = await take([project.id, "--id", QUICK_CLIP_TAKE, "--label", "Quick clip", "--full", ...(progress ? ["--progress", progress] : [])], { reportsRoot: root, log, err });
+ if (code !== 0) throw new Error(`the render failed (umtool take ${project.id} --id ${QUICK_CLIP_TAKE} exited ${code}; its record: umtool take status ${project.id} --id ${QUICK_CLIP_TAKE})`);
+ const { takesDirOf } = await import("./takes.mjs");
+ const output = path.join(takesDirOf(project.dir), QUICK_CLIP_TAKE, "preview.mp4");
- // 5. The share line.
- const share = await projectShareLine(project, { clip: "c01" });
- return { project: project.id, dir: project.dir, output, snapped, share: { platform: share.platform, archive: share.archive, text: share.text || shareLineText(share) } };
+ // 5. The share line.
+ const share = await projectShareLine(project, { clip: "c01" });
+ return { project: project.id, dir: project.dir, output, snapped, share: { platform: share.platform, archive: share.archive, text: share.text || shareLineText(share) } };
+ } catch (e) {
+ const { rm } = await import("node:fs/promises");
+ await rm(project.dir, { recursive: true, force: true }).catch(() => {});
+ say(`removed the half-made project ${project.id}`);
+ throw e;
+ }
}
/**
diff --git a/umtool/lib/report/quickClip.test.mjs b/umtool/lib/report/quickClip.test.mjs
@@ -134,6 +134,16 @@ test("quickClip: a basic project, the window asked, the edges snapped, the take
assert.equal(await quickClipCommand(["yt/vid1@42-58", "--progress", "ndjson"], { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps, log: (s) => ev.push(JSON.parse(s)), err: () => {} }), 0);
assert.equal(ev.at(-1).ev, "quick-clip");
assert.ok(ev.slice(0, -1).every((e) => e.ev === "quick-clip-step"));
+ // A quick clip whose render fails takes its half-made project with it; the retry gets the same name.
+ const failing = { ...deps, take: async () => 1 };
+ await assert.rejects(quickClip({ spec: "yt/vid1@43-57", title: "Fails once" }, { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps: failing }), /the render failed/);
+ const { existsSync } = await import("node:fs");
+ assert.equal(existsSync(path.join(REPORTS, "quick-clips", "fails-once")), false, "no half project left");
+ const retry = await quickClip({ spec: "yt/vid1@43-57", title: "Fails once" }, { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps });
+ assert.equal(retry.project, "quick-clips/fails-once", "not fails-once-2");
+ // A failed fetch too.
+ await assert.rejects(quickClip({ spec: "yt/vid1@44-56", title: "No window" }, { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps: { ...deps, fetch: async () => { throw new Error("the editor refused"); } } }), /the editor refused/);
+ assert.equal(existsSync(path.join(REPORTS, "quick-clips", "no-window")), false);
// Refusals: a bad spec, a site with no siteUrl.
assert.equal(await quickClipCommand(["yt/vid1"], { root: REPORTS, log: () => {}, err: () => {} }), 2);
await assert.rejects(quickClip({ spec: "yt/vid1@1-2", site: "private" }, { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps }), /no public siteUrl/);