commit 1ffc9130d7c4be795dfaaa44bcc98cef6ea8d90f
parent 044ca54e5f6cb7fd37bb9008a557eff13378d46a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 08:01:09 -0400
umtool: Video from an article defaults to the newest iteration with its own report, never a video revision; the plan line names the iteration
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
4 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/umtool/components/create/forms.tsx b/umtool/components/create/forms.tsx
@@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
import HandoffDialog from "@/components/research/HandoffDialog";
import { Button } from "@/components/ui/button";
import { Field, Input, Select } from "@/components/ui/field";
+import { chainable, defaultChainIteration } from "@/lib/create/iterations.mjs";
import { articleHref } from "@/lib/hrefs";
import { researchCaseHref, researchCasesApi } from "@/lib/research/hrefs";
import type { CaseSummary } from "@/lib/research/case-types";
@@ -226,9 +227,11 @@ export function ArticleVideoForm({
.then((r) => json<{ iterations: IterRow[] }>(r))
.then((b) => {
if (!live) return;
- const done = b.iterations.filter((it) => it.status === "done" && it.reportFrom !== null);
+ // Done, with a report, newest first; the default is the newest with a
+ // report of its own (a chain cuts from a report), never a video revision.
+ const done = chainable(b.iterations);
setIts(done);
- setN((done.find((it) => it.currentReport) ?? done[0])?.n ?? null);
+ setN(defaultChainIteration(b.iterations) ?? done[0]?.n ?? null);
})
.catch((e: Error) => live && setError(e.message));
return () => {
@@ -266,6 +269,7 @@ export function ArticleVideoForm({
if (!articles.length) {
return <p className="m-0 text-[12.5px] text-text-2">No article in the store yet. Start one from a question.</p>;
}
+ const chosen = its?.find((it) => it.n === n) ?? null;
const todo = chain ? chain.steps.filter((s) => !s.optional) : [];
const from = chain?.resumeAt ? todo.findIndex((s) => s.name === chain.resumeAt) : -1;
return (
@@ -310,6 +314,12 @@ export function ArticleVideoForm({
{its && its.length === 0 && <p className="m-0 basis-full text-[12px] text-muted">This article has no done iteration with a report: the chain runs over one.</p>}
{chain && (
<p className="m-0 basis-full text-[12px] text-muted" data-chain-plan={chain.resumeAt ?? "done"}>
+ {chosen && (
+ <span className="mr-1 text-text-2" data-chain-iteration={chosen.n}>
+ {chosen.label} · {chosen.kind}
+ {chosen.hasReport ? "" : ` (the report of i${chosen.reportFrom})`}:
+ </span>
+ )}
{chain.job?.state === "running"
? "Its chain is running now."
: chain.resumeAt === null
diff --git a/umtool/e2e/create.spec.ts b/umtool/e2e/create.spec.ts
@@ -186,9 +186,15 @@ test("Video from an article: the chain's steps for its iteration, then the chain
await page.goto(urls.createHref({ make: "video-article", article: "zeta" }));
const f = form(page, "video-article");
await expect(f.getByRole("combobox", { name: "article" })).toHaveValue("zeta");
- // The newest done iteration is offered first; the chain runs over the one chosen.
- await expect(f.getByRole("combobox", { name: "iteration" })).toHaveValue("3");
+ // The default is the newest done iteration with its OWN report (zeta's i2, a
+ // revise-report), never i3, a video revision carrying i1's report; the plan
+ // line names it. The chain runs over the one chosen.
+ await expect(f.getByRole("combobox", { name: "iteration" })).toHaveValue("2");
+ await expect(f.locator("[data-chain-iteration]")).toHaveText("i2 · revise-report:");
+ await f.getByRole("combobox", { name: "iteration" }).selectOption("3");
+ await expect(f.locator("[data-chain-iteration]")).toHaveText("i3 · revise-video (the report of i1):");
await f.getByRole("combobox", { name: "iteration" }).selectOption("1");
+ await expect(f.locator("[data-chain-iteration]")).toHaveText("i1 · sweep:");
await expect(f.locator("[data-chain-plan]")).toContainText(/\d+ of 10 steps to run, from “/);
await f.getByRole("button", { name: "Make the video" }).click();
await page.waitForURL(/\/articles\/zeta\?tab=iterations$/, { timeout: 20_000 });
diff --git a/umtool/lib/create/create.test.mjs b/umtool/lib/create/create.test.mjs
@@ -3,6 +3,7 @@ import { test } from "node:test";
import assert from "node:assert/strict";
import { policyChip, routeGroups, routeSummary } from "./policy.mjs";
import { estimateOf, estimateText, spendHistory } from "./estimate.mjs";
+import { chainable, defaultChainIteration } from "./iterations.mjs";
const TASKS = ["sweep", "revise-report", "revise-video", "narrate", "research", "cut", "onscreen", "teaser", "flips", "threads", "youtube"];
const media = (r) => ({ cut: r, onscreen: r, teaser: r, flips: r, threads: r, youtube: r });
@@ -45,3 +46,17 @@ test("an estimate: the past runs' typical and most, under the cap; a local model
assert.equal(estimateText(estimateOf(h, { task: "sweep", model: "claude-opus", cap: 3, local: false })), "No earlier run on claude-opus in the ledger · stops at $3.00 (its cap)");
assert.equal(estimateText(estimateOf(h, { task: "sweep", model: "qwen3:8b", cap: 5, local: true })), "Runs on the local model: no API spend");
});
+
+test("video from an article: the newest done iteration with its OWN report is the default, never a video revision", () => {
+ // The fixture's zeta: i1 sweep (report), i2 revise-report (report), i3 revise-video (i1's report), i4 failed.
+ const its = [
+ { n: 4, status: "failed", hasReport: false, reportFrom: null },
+ { n: 3, status: "done", hasReport: false, reportFrom: 1 },
+ { n: 2, status: "done", hasReport: true, reportFrom: 2 },
+ { n: 1, status: "done", hasReport: true, reportFrom: 1 },
+ ];
+ assert.deepEqual(chainable(its).map((i) => i.n), [3, 2, 1]);
+ assert.equal(defaultChainIteration(its), 2);
+ assert.equal(defaultChainIteration([{ n: 2, status: "done", hasReport: false, reportFrom: 1 }]), null);
+ assert.equal(defaultChainIteration([]), null);
+});
diff --git a/umtool/lib/create/iterations.mjs b/umtool/lib/create/iterations.mjs
@@ -0,0 +1,26 @@
+// ---------------------------------------------------------------------------
+// Which iteration "Video from an article" (/create, P5) offers first: the
+// NEWEST done iteration with a report of its OWN -- a chain cuts from a report,
+// so a video revision that carries an earlier iteration's report is never the
+// default (it can still be chosen). Plain ESM, unit-tested.
+// ---------------------------------------------------------------------------
+
+/**
+ * The iterations a chain can run over: done, with a report (its own or an
+ * ancestor's), newest first.
+ * @template {{ n: number, status: string, hasReport: boolean, reportFrom: number | null }} T
+ * @param {T[]} iterations
+ * @returns {T[]}
+ */
+export function chainable(iterations) {
+ return iterations.filter((it) => it.status === "done" && it.reportFrom !== null).sort((a, b) => b.n - a.n);
+}
+
+/**
+ * The default: the newest done iteration with its own report, else null.
+ * @param {{ n: number, status: string, hasReport: boolean, reportFrom: number | null }[]} iterations
+ * @returns {number | null}
+ */
+export function defaultChainIteration(iterations) {
+ return chainable(iterations).find((it) => it.hasReport)?.n ?? null;
+}