commit 4779aee89cd25afdee5e7f0f4552fe0a29ca6071
parent a6ad73ab8f4f050406933a1f81cc8182388a8f9b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 07:17:46 -0400
umtool: P5 specs — create.spec and settings.spec; the specs that read /articles/new, ?from= and the palette follow Create
- create.spec (10): the lines, the chip and the rail; j/k, Enter, Escape; fits
1366×768; every line driven to its writer on the fixture (a case, the
estimate, R2's two hand-offs confirmed, the chain started and cancelled,
/?from= → a project, a sweep report, a song).
- settings.spec (7): the policy round trip (moved from article-new.spec), the
day's spend; the index prune's plan (Keep it changes nothing, Confirm drops
the stale record), the rebuild as a job, a refused storage move; the roots.
- article-new, inbox, shell, redirects, projects: Create's addresses; the
redirect spec asks a `has` row with its key. test:scripts runs lib/create
and lib/settings. A plan's deliverables line says an unset switch reads as
local; the system jobs are named for the Running list.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
11 files changed, 510 insertions(+), 72 deletions(-)
diff --git a/package.json b/package.json
@@ -24,7 +24,7 @@
"wt": "node scripts/worktree.mjs",
"e2e:sharded": "node scripts/run-sharded-e2e.mjs",
"e2e:all": "node scripts/e2e-all.mjs",
- "test:scripts": "node --test scripts/*.test.mjs umtool/report-to-video/*.test.mjs umtool/lib/*.test.mjs umtool/lib/report/*.test.mjs umtool/lib/annotations/*.test.mjs umtool/lib/articles/*.test.mjs umtool/lib/pieces/*.test.mjs umtool/lib/inbox/*.test.mjs umtool/lib/research/*.test.mjs umtool/lib/work/*.test.mjs",
+ "test:scripts": "node --test scripts/*.test.mjs umtool/report-to-video/*.test.mjs umtool/lib/*.test.mjs umtool/lib/report/*.test.mjs umtool/lib/annotations/*.test.mjs umtool/lib/articles/*.test.mjs umtool/lib/pieces/*.test.mjs umtool/lib/inbox/*.test.mjs umtool/lib/research/*.test.mjs umtool/lib/work/*.test.mjs umtool/lib/create/*.test.mjs umtool/lib/settings/*.test.mjs",
"test": "pnpm -r --no-bail --no-sort --workspace-concurrency=1 run test; a=$?; pnpm run test:scripts; b=$?; [ $a -eq 0 ] && [ $b -eq 0 ]",
"typecheck": "pnpm -r --no-bail --no-sort --workspace-concurrency=1 exec tsc --noEmit",
"lint": "pnpm --filter export run lint",
diff --git a/umtool/components/NewProjectMenu.tsx b/umtool/components/NewProjectMenu.tsx
@@ -163,6 +163,7 @@ export default function NewProjectMenu({
aria-label="sweep report"
data-new-report
autoFocus={inline}
+ data-autofocus={inline ? "" : undefined}
value={byHand ? "" : src}
onChange={(e) => {
const v = e.target.value;
@@ -183,6 +184,7 @@ export default function NewProjectMenu({
<Field label={fromLabel} hint={fromHint} className="min-w-0 basis-full">
<Input
autoFocus={sourceFirst}
+ data-autofocus={sourceFirst ? "" : undefined}
value={src}
onChange={(e) => setSrc(e.target.value)}
placeholder={fromPlaceholder}
@@ -195,6 +197,7 @@ export default function NewProjectMenu({
<Field label="Folder">
<Input
autoFocus={!sourceFirst && !(inline && reports?.length)}
+ data-autofocus={inline && !sourceFirst && !reports?.length ? "" : undefined}
value={slug}
onChange={(e) => setSlug(e.target.value)}
placeholder="e.g. donkey-kong"
diff --git a/umtool/components/create/CreateView.tsx b/umtool/components/create/CreateView.tsx
@@ -102,10 +102,29 @@ export default function CreateView({
[show],
);
- // A form opened from the address is scrolled into view.
+ // An open form takes the focus: its first field (the one marked
+ // data-autofocus, else the first control), once the list's controls are
+ // live -- a form opened from the address was server-rendered inside the
+ // list's disabled fieldset, where React's autoFocus never runs.
useEffect(() => {
- if (initial) root.current?.querySelector(`[data-make-form="${initial}"]`)?.scrollIntoView({ block: "nearest" });
- }, [initial]);
+ if (!open) return;
+ let frames = 0;
+ let raf = 0;
+ const go = () => {
+ const region = root.current?.querySelector<HTMLElement>(`[data-make-form="${open}"]`);
+ const el =
+ region?.querySelector<HTMLElement>("[data-autofocus]") ??
+ region?.querySelector<HTMLElement>("input:not([type=hidden]):not([type=radio]):not([type=checkbox]), textarea, select");
+ if (el && !el.matches(":disabled")) {
+ if (!region?.contains(document.activeElement)) el.focus();
+ region?.scrollIntoView({ block: "nearest" });
+ return;
+ }
+ if (++frames < 30) raf = requestAnimationFrame(go);
+ };
+ raf = requestAnimationFrame(go);
+ return () => cancelAnimationFrame(raf);
+ }, [open]);
const form = (m: Make) => {
const cancel = () => close(m);
@@ -184,7 +203,9 @@ export default function CreateView({
<LitActions>
<Button
type="button"
- className="lit-go"
+ // Filled on the lit line -- until its form is open:
+ // then the form's own button is the one primary action.
+ className={open === l.make ? undefined : "lit-go"}
data-make={l.make}
aria-expanded={open === l.make}
aria-controls={`make-${l.make}`}
diff --git a/umtool/components/create/forms.tsx b/umtool/components/create/forms.tsx
@@ -90,7 +90,7 @@ export function ResearchForm({ sources, onCancel }: { sources: SourceOption[]; o
}}
>
<Field label="Question" hint="The case's query; its board opens next" className="min-w-0 basis-full">
- <Input autoFocus required value={query} onChange={(e) => setQuery(e.target.value)} aria-label="question" placeholder="e.g. how many employees" />
+ <Input autoFocus data-autofocus="" required value={query} onChange={(e) => setQuery(e.target.value)} aria-label="question" placeholder="e.g. how many employees" />
</Field>
<Field label="Title">
<Input value={title} onChange={(e) => setTitle(e.target.value)} aria-label="case title" placeholder="the question, unless named" className="w-56" />
@@ -160,7 +160,7 @@ export function BoardForm({
}}
>
<Field label="Board" hint={chosen ? `${chosen.quotes} ${chosen.quotes === 1 ? "quote" : "quotes"} · ${chosen.sections} ${chosen.sections === 1 ? "section" : "sections"}` : undefined}>
- <Select autoFocus value={pick} onChange={(e) => setPick(e.target.value)} aria-label="board" data-board-pick="" className="w-80">
+ <Select autoFocus data-autofocus="" value={pick} onChange={(e) => setPick(e.target.value)} aria-label="board" data-board-pick="" className="w-80">
{cases.map((c) => (
<option key={c.id} value={c.id}>
{c.title} · {c.quotes} {c.quotes === 1 ? "quote" : "quotes"}
@@ -279,7 +279,7 @@ export function ArticleVideoForm({
}}
>
<Field label="Article">
- <Select autoFocus value={article} onChange={(e) => setArticle(e.target.value)} aria-label="article" className="w-80">
+ <Select autoFocus data-autofocus="" value={article} onChange={(e) => setArticle(e.target.value)} aria-label="article" className="w-80">
{articles.map((a) => (
<option key={a.id} value={a.id}>
{a.title} — {a.id}
diff --git a/umtool/e2e/article-new.spec.ts b/umtool/e2e/article-new.spec.ts
@@ -3,14 +3,15 @@ import { readFileSync, rmSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { WARM_TIMEOUT, warm } from "./warm";
+import * as urls from "./urls";
// ---------------------------------------------------------------------------
-// /articles/new (release 27 S8): the generation policy (written through the
-// editor's settings action, the key never shown) and a new article's first
-// iteration — a sweep the editor runs — over the editor stub.
+// A new article (release 27 S8): its first iteration — a sweep the editor
+// runs — over the editor stub. The form is Create's "Article from a question"
+// (/create?make=article, P5; it was /articles/new, which redirects there).
+// The generation policy moved to /settings/generation: settings.spec.ts.
//
-// WRITES articles/new-e2e/ (through the stub; removed after) and the stub's
-// in-memory policy (put back to `balanced` after)
+// WRITES articles/new-e2e/ (through the stub; removed after)
// ---------------------------------------------------------------------------
const HERE = path.dirname(fileURLToPath(import.meta.url));
@@ -22,59 +23,25 @@ const stubAsked = (route: string) =>
test.beforeAll(async ({ playwright }) => {
test.setTimeout(WARM_TIMEOUT);
- await warm(playwright, ["/articles/new", "/api/articles/policy", "/api/articles/channels"]);
+ await warm(playwright, [urls.newArticleHref(), "/api/articles/policy", "/api/articles/channels"]);
});
-test.afterAll(async ({ request }) => {
+test.afterAll(() => {
rmSync(path.join(FIXTURE, "articles", ARTICLE), { recursive: true, force: true });
- await request.post("/api/articles/policy", { data: { routes: { sweep: "code", "revise-report": "api", "revise-video": "local", narrate: "local", research: "api" } } });
});
-test("/drafts is /articles/new now, and /articles links to it", async ({ page }) => {
- await page.goto("/drafts");
- await expect(page).toHaveURL(/\/articles\/new$/);
+test("/drafts and /articles/new land on Create's article form, and Work (/articles) links to Create", async ({ page }) => {
+ for (const old of ["/drafts", "/articles/new"]) {
+ await page.goto(old);
+ await expect(page).toHaveURL(/\/create\?make=article$/);
+ await expect(page.getByRole("form", { name: "new article" })).toBeVisible();
+ }
await page.goto("/articles");
- await page.getByRole("link", { name: "new article" }).click();
- await expect(page).toHaveURL(/\/articles\/new$/);
-});
-
-test("the policy: presets write their routes, a route alone makes it custom, caps are the editor's to refuse; the key is a file", async ({ page }) => {
- await page.goto("/articles/new");
- const policy = page.getByRole("region", { name: "generation policy" });
- await expect(policy).toHaveAttribute("data-policy-preset", "balanced");
- await expect(policy.getByRole("button", { name: "balanced" })).toHaveAttribute("aria-pressed", "true");
- // The key FILE's path (the editor's read redacts it; settings.json names it)
- // and whether a file is there — never a key.
- await expect(policy.locator("[data-key-file-exists]")).toContainText("anthropic.env");
- await expect(policy.locator("[data-today-usd]")).toHaveAttribute("data-today-usd", "0.42");
-
- await policy.getByRole("button", { name: "api", exact: true }).click();
- await expect(policy).toHaveAttribute("data-policy-preset", "api");
- expect(stubAsked("settings").at(-1)).toMatchObject({
- patch: { generation: { routes: { sweep: "api", "revise-report": "api", "revise-video": "api", narrate: "api", research: "api" } } },
- authorization: "Bearer umtool-e2e-token",
- });
-
- await policy.getByRole("combobox", { name: "route narrate" }).selectOption("local");
- await expect(policy).toHaveAttribute("data-policy-preset", "custom");
-
- await policy.getByRole("textbox", { name: "cap sweep" }).fill("50");
- await policy.getByRole("button", { name: "Save caps" }).click();
- await expect(policy.getByRole("alert")).toContainText("generation.caps.sweep");
- await policy.getByRole("textbox", { name: "cap sweep" }).fill("4");
- await policy.getByRole("button", { name: "Save caps" }).click();
- await expect(policy.getByRole("status")).toHaveText("saved caps");
- expect(stubAsked("settings").at(-1)).toMatchObject({ patch: { generation: { caps: { sweep: 4, max: 10 } } } });
- for (const r of stubAsked("settings")) expect(JSON.stringify(r)).not.toContain("apiKeyFile");
- await policy.getByRole("textbox", { name: "cap sweep" }).fill("5");
- await policy.getByRole("button", { name: "Save caps" }).click();
- await expect(policy.getByRole("textbox", { name: "cap sweep" })).toHaveValue("5");
-
- await policy.getByRole("button", { name: "balanced" }).click();
- await expect(policy).toHaveAttribute("data-policy-preset", "balanced");
+ await page.locator("[data-work-create]").click();
+ await expect(page).toHaveURL(/\/create$/);
});
test("a new article: question, channels, the local pipeline — its first iteration runs, and the page is its iterations", async ({ page }) => {
- await page.goto("/articles/new");
+ await page.goto(urls.newArticleHref());
const form = page.getByRole("form", { name: "new article" });
await form.getByRole("textbox", { name: "question" }).fill("What did the channel say about the vote?");
await form.getByRole("textbox", { name: "find a channel" }).fill("site");
@@ -95,8 +62,15 @@ test("a new article: question, channels, the local pipeline — its first iterat
await expect(form.getByRole("combobox", { name: "extractor for this sweep" })).toHaveValue("claude-haiku-4-5");
await form.getByRole("combobox", { name: "extractor for this sweep" }).selectOption("claude-haiku-5-5");
+ // The estimate is said before anything runs (P5): what such runs have spent
+ // (the fixture's ledger: one $0.42 sweep on claude-sonnet-5-5), under the cap.
+ await expect(form.locator("[data-estimate]")).toContainText("1 earlier run on claude-sonnet-5-5: typical $0.42, most $0.42 · stops at $9.00 (its cap)");
+ await form.getByRole("textbox", { name: "cap" }).fill("5");
+ await expect(form.locator("[data-estimate]")).toContainText("stops at $5.00 (its cap)");
+
await form.getByRole("radio", { name: /pipeline/ }).check();
await expect(form.getByRole("combobox", { name: "model" })).toHaveValue("qwen3:8b");
+ await expect(form.locator("[data-estimate]")).toContainText("Runs on the local model: no API spend");
await expect(form.getByRole("combobox", { name: "extractor for this sweep" }), "the pipeline has no extractor").toHaveCount(0);
await form.getByRole("button", { name: "Start" }).click();
diff --git a/umtool/e2e/create.spec.ts b/umtool/e2e/create.spec.ts
@@ -0,0 +1,241 @@
+import { test, expect, type Page } from "@playwright/test";
+import { existsSync, readFileSync, rmSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import { BOARD_CASE } from "./fixtures/research-fixture.mjs";
+import * as urls from "./urls";
+import { WARM_TIMEOUT, warm } from "./warm";
+
+// ---------------------------------------------------------------------------
+// Create (plans/umtool-redesign.md, P5; canvas "Create"): "What are you
+// making?" -- one lit list of lines, each opening its form inline, each form a
+// shell over a writer that already exists. Every path is driven to its writer
+// on the fixture and the editor stub:
+//
+// research POST /api/research/cases → the case's board
+// article r28's NewArticleForm → report-draft (article-new.spec
+// drives the form; here the line, the chip, the estimate)
+// article-board R2's hand-off: the plan, then the seeded sweep (stub)
+// video-board R2's hand-off: the plan, then the project
+// video-article the chain's steps, then the chain as a umtool job
+// video-recording /?from= (the editor's hand-off) prefilled → a project
+// video-report the sweep reports on disk → a project
+// song a song
+//
+// WRITES (each removed after): .umtool/research/p5-*, articles/p5-board,
+// p5-board/, p5-rec/, p5-rep/, reports/videos/p5-song/; a chain job on
+// zeta i1, cancelled
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const STUB_LOG = path.join(FIXTURE, "editor-stub.requests.json");
+const stubAsked = (route: string) =>
+ existsSync(STUB_LOG) ? (JSON.parse(readFileSync(STUB_LOG, "utf8")) as { route?: string; [k: string]: unknown }[]).filter((r) => r.route === route) : [];
+const caseJson = (id: string) => JSON.parse(readFileSync(path.join(FIXTURE, ".umtool", "research", id, "case.json"), "utf8"));
+const manifestOf = (dir: string) => JSON.parse(readFileSync(path.join(FIXTURE, dir, "video.manifest.json"), "utf8"));
+
+const WRITTEN = [
+ ".umtool/research/p5-case",
+ ".umtool/research/p5-board",
+ "articles/p5-board",
+ "p5-board",
+ "p5-rec",
+ "p5-rep",
+ "reports/videos/p5-song",
+];
+const clean = () => {
+ for (const p of WRITTEN) rmSync(path.join(FIXTURE, p), { recursive: true, force: true });
+};
+
+const line = (page: Page, make: string) => page.locator(`[data-make-line="${make}"]`);
+const form = (page: Page, make: string) => page.locator(`[data-make-form="${make}"]`);
+
+test.beforeAll(async ({ playwright }) => {
+ test.setTimeout(WARM_TIMEOUT);
+ clean();
+ await warm(playwright, [urls.createHref(), urls.createHref({ make: "article" }), "/api/research/cases", "/api/articles/channels"]);
+});
+test.afterAll(clean);
+
+test("the lines, grouped Research · Article · Video · Song; the policy chip links Settings; + Create is lit, no place", async ({ page }) => {
+ await page.goto(urls.createHref());
+ await expect(page.getByRole("navigation", { name: "Breadcrumb" }).locator("h1")).toHaveText("What are you making?");
+ await expect(page.locator("[data-make-group]")).toHaveText([/^Research/, /^Article/, /^Video/, /^Song/]);
+ await expect(page.locator("[data-make-line]")).toHaveCount(8);
+ // The boards and the reports on disk are counted on their lines.
+ await expect(line(page, "article-board")).toContainText(/ · \d+ quotes?/);
+ await expect(line(page, "video-report")).toContainText(/ · \d+ found/);
+ const chip = page.locator("[data-policy-chip]");
+ await expect(chip).toHaveAttribute("data-policy-chip", "balanced");
+ await expect(chip).toHaveText("Generation: balanced · Claude Code: sweeps · API: report revisions, research · local: video revisions, drafts");
+ await expect(chip).toHaveAttribute("href", urls.generationPolicyHref());
+ const rail = page.locator("[data-app-rail]");
+ await expect(rail.locator("[data-rail-create]")).toHaveAttribute("aria-current", "page");
+ await expect(rail.locator("nav[aria-label=Main] > a[aria-current]")).toHaveCount(0);
+ // The rail's + Create from anywhere comes here.
+ await page.goto(urls.workHref());
+ await page.locator("[data-app-rail] [data-rail-create]").click();
+ await expect(page).toHaveURL(/\/create$/);
+});
+
+test("keys: j/k light the lines, Enter opens the form on its first field, Escape closes it back to the line", async ({ page }) => {
+ await page.goto(urls.createHref());
+ await expect(page.locator("[data-lit-list][data-hydrated]")).toBeAttached();
+ await expect(line(page, "research")).toHaveAttribute("data-lit", "");
+ await page.keyboard.press("j");
+ await expect(line(page, "article")).toHaveAttribute("data-lit", "");
+ await page.keyboard.press("Enter");
+ await expect(form(page, "article")).toBeVisible();
+ await expect(page).toHaveURL(/\/create\?make=article$/);
+ await expect(form(page, "article").getByRole("textbox", { name: "question" })).toBeFocused();
+ // The form's own keys are the form's: j types, it does not move the light.
+ await page.keyboard.type("jk");
+ await expect(line(page, "article")).toHaveAttribute("data-lit", "");
+ await page.keyboard.press("Escape");
+ await expect(form(page, "article")).toHaveCount(0);
+ await expect(page.locator('[data-make="article"]')).toBeFocused();
+ await expect(page).toHaveURL(/\/create$/);
+ // Down the left column and into the right: the head follows the column.
+ for (let i = 0; i < 2; i++) await page.keyboard.press("j");
+ await expect(line(page, "video-article")).toHaveAttribute("data-lit", "");
+ const head = await page.locator(".lit-head").boundingBox();
+ const lit = await line(page, "video-article").boundingBox();
+ expect(Math.abs(head!.x - lit!.x)).toBeLessThan(2);
+});
+
+test("fits 1366×768: every line, and an open form under its line", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 768 });
+ await page.goto(urls.createHref());
+ for (const g of await page.locator("[data-make-group]").all()) {
+ const b = await g.boundingBox();
+ expect(b!.y + b!.height).toBeLessThanOrEqual(768);
+ }
+ await page.goto("/?from=testchan%2Fvid1");
+ const f = await form(page, "video-recording").boundingBox();
+ expect(f!.y + f!.height).toBeLessThanOrEqual(768);
+ const w = await page.evaluate(() => document.documentElement.scrollWidth);
+ expect(w).toBeLessThanOrEqual(1366);
+});
+
+test("Research a question → a case (R2's store), and its board opens", async ({ page }) => {
+ await page.goto(urls.createHref({ make: "research" }));
+ const f = form(page, "research");
+ await expect(f.getByRole("textbox", { name: "question" })).toBeFocused();
+ await f.getByRole("textbox", { name: "question" }).fill("lighthouse budget");
+ await f.getByRole("textbox", { name: "case title" }).fill("P5 case");
+ await f.getByRole("button", { name: "Open a case" }).click();
+ await page.waitForURL(/\/research\/p5-case$/, { timeout: 20_000 });
+ await expect(page.getByRole("navigation", { name: "Breadcrumb" }).locator("h1")).toHaveText("P5 case");
+ expect(caseJson("p5-case")).toMatchObject({ title: "P5 case", scope: { query: "lighthouse budget" } });
+ expect(caseJson("p5-case").scope.source).toMatch(/^local:/);
+});
+
+test("Article from a question: the estimate before it runs, under the policy's chip (the form is article-new.spec's)", async ({ page }) => {
+ await page.goto(urls.createHref({ make: "article" }));
+ const f = form(page, "article");
+ await expect(f.getByRole("form", { name: "new article" })).toBeVisible();
+ // The policy is the chip, not a panel, on Create.
+ await expect(page.getByRole("region", { name: "generation policy" })).toHaveCount(0);
+ await expect(f.locator("[data-estimate]")).toContainText("1 earlier run on claude-sonnet-5-5: typical $0.42, most $0.42 · stops at $5.00 (its cap)");
+ await expect(f.locator("[data-estimate]")).toContainText("today $0.42 of $20.00");
+ await f.getByRole("radio", { name: /research/ }).check();
+ await expect(f.locator("[data-estimate]")).toHaveAttribute("data-estimate", "research");
+ await f.getByRole("button", { name: "Cancel" }).click();
+ await expect(form(page, "article")).toHaveCount(0);
+});
+
+test("from a board: R2's hand-offs, planned then confirmed — an article (a seeded sweep) and a video (a project)", async ({ page, request }) => {
+ const made = await (await request.post("/api/research/cases", { data: { title: "P5 board" } })).json();
+ expect(made.case.id).toBe("p5-board");
+ const source = caseJson(BOARD_CASE).scope.source;
+ for (const t of [400, 404]) {
+ const pinned = await request.post("/api/research/cases/p5-board/quotes", { data: { source, channel: "night-desk", video: "nd-2023", t } });
+ expect(pinned.ok(), await pinned.text()).toBe(true);
+ }
+
+ // The article: the plan names the model and the cap; nothing is asked of the editor until the confirm.
+ await page.goto(urls.createHref({ make: "article-board", case: "p5-board" }));
+ const f = form(page, "article-board");
+ await expect(f.getByRole("combobox", { name: "board" })).toHaveValue("p5-board");
+ const before = stubAsked("report-draft").length;
+ await f.getByRole("button", { name: "Plan the article" }).click();
+ const art = page.locator('dialog[data-handoff="article"]');
+ await expect(art).toContainText("the board as cited markdown: 2 quotes");
+ await expect(art).toContainText(/Runs on\s*claude-/);
+ expect(stubAsked("report-draft").length).toBe(before);
+ await art.getByRole("button", { name: /^Start the sweep/ }).click();
+ await page.waitForURL(/\/articles\/p5-board/, { timeout: 20_000 });
+ const asked = stubAsked("report-draft").at(-1)!;
+ expect(asked).toMatchObject({ task: "sweep", article: "p5-board" });
+ expect(String(asked.seed)).toContain("P5 board");
+ expect(caseJson("p5-board").handoffs.map((h: { to: string }) => h.to)).toEqual(["article"]);
+
+ // The video: its plan lists the cue spans; the confirm writes the project.
+ await page.goto(urls.createHref({ make: "video-board", case: "p5-board" }));
+ await form(page, "video-board").getByRole("button", { name: "Plan the video" }).click();
+ const vid = page.locator('dialog[data-handoff="video"]');
+ await expect(vid).toContainText("2 — each the cue span of a pinned quote");
+ await expect(vid).toContainText("night-desk/nd-2023");
+ await vid.getByRole("button", { name: "Create the project" }).click();
+ await page.waitForURL(/\/projects\/p5-board$/, { timeout: 20_000 });
+ expect(manifestOf("p5-board").timeline).toHaveLength(2);
+});
+
+test("Video from an article: the chain's steps for its iteration, then the chain runs as a umtool job", async ({ page, request }) => {
+ 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");
+ await f.getByRole("combobox", { name: "iteration" }).selectOption("1");
+ 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 });
+ // It is umtool's own job; stop it (a cancelled chain is a paused one).
+ const running = (await (await request.get("/api/jobs")).json()).running as { id: string; label: string } | null;
+ if (running) {
+ expect(running.label).toBe("chain zeta i1");
+ await request.post("/api/articles/chain", { data: { cancel: running.id } });
+ }
+ await expect.poll(async () => (await (await request.get("/api/jobs")).json()).running, { timeout: 30_000 }).toBeNull();
+});
+
+test("Video from a recording: the editor's /?from= lands here prefilled, and makes the project", async ({ page }) => {
+ await page.goto("/?from=testchan%2Fvid1");
+ await expect(page).toHaveURL(/\/create\?from=testchan%2Fvid1$/);
+ const f = form(page, "video-recording");
+ await expect(f.locator("[data-new-from]")).toHaveValue("testchan/vid1");
+ await expect(f.locator("[data-new-slug]")).toBeFocused();
+ await expect(f.locator("[data-new-kind]")).toHaveCount(0);
+ await page.keyboard.type("p5-rec");
+ await page.keyboard.press("Enter");
+ await page.waitForURL(/\/projects\/p5-rec$/, { timeout: 20_000 });
+ expect(manifestOf("p5-rec").provenance.channelSlug).toBe("testchan");
+});
+
+test("Video from a sweep report: the reports on disk are offered, and one becomes a project", async ({ page }) => {
+ await page.goto(urls.createHref({ make: "video-report" }));
+ const f = form(page, "video-report");
+ const pick = f.getByRole("combobox", { name: "sweep report" });
+ await expect(pick).toBeFocused();
+ // Every sweep report the walk finds (an article's sweep iteration among them), then a path by hand.
+ const bike = pick.locator("option", { hasText: "reports/bike-fixture" });
+ await expect(bike).toHaveCount(1);
+ await expect(pick.locator("option").last()).toHaveText("A path typed by hand…");
+ await pick.selectOption((await bike.getAttribute("value"))!);
+ await f.locator("[data-new-slug]").fill("p5-rep");
+ await f.locator("[data-new-create]").click();
+ await page.waitForURL(/\/projects\/p5-rep$/, { timeout: 20_000 });
+ expect(existsSync(path.join(FIXTURE, "p5-rep", "sweep-report.md"))).toBe(true);
+});
+
+test("A song: the song scaffold", async ({ page }) => {
+ await page.goto(urls.createHref({ make: "song" }));
+ const f = form(page, "song");
+ await expect(f.locator("[data-new-slug]")).toBeFocused();
+ await f.locator("[data-new-slug]").fill("p5-song");
+ await f.getByRole("button", { name: "Create the song" }).click();
+ await page.waitForURL(/\/projects\/.*p5-song$/, { timeout: 20_000 });
+ expect(existsSync(path.join(FIXTURE, "reports", "videos", "p5-song"))).toBe(true);
+});
diff --git a/umtool/e2e/projects.spec.ts b/umtool/e2e/projects.spec.ts
@@ -565,7 +565,7 @@ test("new project offers the brand preset, and only a branded scaffold carries r
const slug = "brand-ui-probe";
const created = path.join(FIXTURE, slug);
rmSync(created, { recursive: true, force: true });
- // The form lives on the projects index (+ Create → A project) until /create (P5).
+ // The form on the projects index (+ new project); Create's video lines are the same form (create.spec.ts).
await page.goto(urls.projectsHref());
await page.locator("[data-new-project]").click();
const brand = page.locator("[data-new-brand]");
diff --git a/umtool/e2e/redirects.spec.ts b/umtool/e2e/redirects.spec.ts
@@ -37,7 +37,7 @@ function parts(href: string): [string, [string, string][]] {
return [u.pathname, [...u.searchParams.entries()]];
}
-test("the table has the P3 rows, reserved /browse tools before the catch-all", () => {
+test("the table has the P3 and P5 rows, reserved /browse tools before the catch-all", () => {
const sources = REDIRECTS.map((r) => r.source);
const catchAll = sources.indexOf("/browse/:path*");
expect(catchAll).toBeGreaterThan(0);
@@ -46,19 +46,24 @@ test("the table has the P3 rows, reserved /browse tools before the catch-all", (
expect(sources.indexOf(s), `${s} must come before the catch-all`).toBeLessThan(catchAll);
}
for (const r of REDIRECTS) expect(r.permanent, r.source).toBe(false);
+ // P5: the editor's hand-off, only when the query has `from`; the new-article form.
+ expect(REDIRECTS.find((r) => r.source === "/")).toMatchObject({ destination: "/create", has: [{ type: "query", key: "from" }] });
+ expect(REDIRECTS.find((r) => r.source === "/articles/new")?.destination).toBe("/create?make=article");
});
for (const row of REDIRECTS) {
const from = fill(row.source);
- test(`${row.source} → ${row.destination} (307, query kept)`, async ({ request }) => {
- for (const query of ["", "q=x+y¬e=n1"]) {
+ // A row that matches only when the query HAS a key is asked with it.
+ const needs = (row.has ?? []).filter((h) => h.type === "query").map((h) => `${h.key}=testchan%2Fvid1`);
+ test(`${row.source}${needs.length ? `?${needs.join("&")}` : ""} → ${row.destination} (307, query kept)`, async ({ request }) => {
+ for (const query of (["", "q=x+y¬e=n1"] as string[]).map((q) => [...needs, ...(q ? [q] : [])].join("&"))) {
const url = query ? `${from}?${query}` : from;
const res = await request.get(url, { maxRedirects: 0 });
expect(res.status(), url).toBe(307);
expect(parts(res.headers()["location"]), url).toEqual(parts(expected(row.destination, query)));
}
// And where it lands answers (the escape hatch needs a project to open).
- const landed = await request.get(row.source === "/browse/at" ? `${from}?path=find` : from);
+ const landed = await request.get(row.source === "/browse/at" ? `${from}?path=find` : needs.length ? `${from}?${needs.join("&")}` : from);
expect(landed.status(), `${from} → ${landed.url()}`).toBe(200);
});
}
@@ -81,7 +86,8 @@ for (const [old, now] of [
}
test("a page that did not move is not redirected", async ({ request }) => {
- for (const p of ["/", "/work", "/tools", "/projects", "/sites/priv", "/articles/delta", "/articles/new", "/settings/system"]) {
+ // `/` is the Inbox unless the query has `from` (the hand-off row).
+ for (const p of ["/", "/?hidden=1", "/work", "/tools", "/projects", "/sites/priv", "/articles/delta", "/create", "/create?make=song", "/settings", "/settings/generation", "/settings/system"]) {
const res = await request.get(p, { maxRedirects: 0 });
expect(res.status(), p).toBe(200);
}
diff --git a/umtool/e2e/settings.spec.ts b/umtool/e2e/settings.spec.ts
@@ -0,0 +1,186 @@
+import { test, expect, type APIRequestContext } from "@playwright/test";
+import { existsSync, readFileSync, rmSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+import { WARM_TIMEOUT, warm } from "./warm";
+
+// ---------------------------------------------------------------------------
+// Settings (plans/umtool-redesign.md, P5), on the fixture and the editor stub:
+//
+// /settings/generation the generation policy (written through the editor's
+// settings action, the key never shown; it moved here
+// from /articles/new) and the day's spend, job by job,
+// from the fixture's ledger
+// /settings/system the maintenance a terminal did, each action that
+// changes anything a plan first: the index prune's
+// plan shown, Keep it changes nothing, Confirm drops
+// the record; the rebuild runs as a job; a storage
+// move with no media root is refused, never offered
+//
+// WRITES the stub's in-memory policy (put back to `balanced` after), a
+// scaffolded project the spec deletes again (so its index record goes
+// stale), and the fixture's index (UMTOOL_CACHE_DIR, rebuilt every run)
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const STUB_LOG = path.join(FIXTURE, "editor-stub.requests.json");
+const stubAsked = (route: string) =>
+ (JSON.parse(readFileSync(STUB_LOG, "utf8")) as { route?: string; [k: string]: unknown }[]).filter((r) => r.route === route);
+const STALE = "p5-stale-record";
+
+test.beforeAll(async ({ playwright }) => {
+ test.setTimeout(WARM_TIMEOUT);
+ await warm(playwright, [urls.generationPolicyHref(), urls.systemHref(), "/settings", "/api/articles/policy"]);
+});
+test.afterAll(async ({ request }) => {
+ rmSync(path.join(FIXTURE, STALE), { recursive: true, force: true });
+ await request.post("/api/articles/policy", { data: { routes: { sweep: "code", "revise-report": "api", "revise-video": "local", narrate: "local", research: "api" } } });
+});
+
+test("/settings lists generation and system; both light Settings", async ({ page }) => {
+ await page.goto("/settings");
+ await expect(page.locator("[data-tool-entry=generation] a")).toHaveAttribute("href", urls.generationPolicyHref());
+ await expect(page.locator("[data-tool-entry=system] a")).toHaveAttribute("href", urls.systemHref());
+ await page.goto(urls.systemHref());
+ await expect(page.locator("[data-policy-link]")).toHaveAttribute("href", urls.generationPolicyHref());
+});
+
+test("generation: presets write their routes, a route alone makes it custom, caps are the editor's to refuse; the key is a file", async ({ page }) => {
+ await page.goto(urls.generationPolicyHref());
+ await expect(page.locator("[data-policy-summary]")).toHaveText(
+ "Generation: balanced · Claude Code: sweeps · API: report revisions, research · local: video revisions, drafts",
+ );
+ const policy = page.getByRole("region", { name: "generation policy" });
+ await expect(policy).toHaveAttribute("data-policy-preset", "balanced");
+ await expect(policy.getByRole("button", { name: "balanced" })).toHaveAttribute("aria-pressed", "true");
+ // The key FILE's path (the editor's read redacts it; settings.json names it)
+ // and whether a file is there — never a key.
+ await expect(policy.locator("[data-key-file-exists]")).toContainText("anthropic.env");
+ await expect(policy.locator("[data-today-usd]")).toHaveAttribute("data-today-usd", "0.42");
+
+ await policy.getByRole("button", { name: "api", exact: true }).click();
+ await expect(policy).toHaveAttribute("data-policy-preset", "api");
+ expect(stubAsked("settings").at(-1)).toMatchObject({
+ patch: { generation: { routes: { sweep: "api", "revise-report": "api", "revise-video": "api", narrate: "api", research: "api" } } },
+ authorization: "Bearer umtool-e2e-token",
+ });
+
+ await policy.getByRole("combobox", { name: "route narrate" }).selectOption("local");
+ await expect(policy).toHaveAttribute("data-policy-preset", "custom");
+
+ await policy.getByRole("textbox", { name: "cap sweep" }).fill("50");
+ await policy.getByRole("button", { name: "Save caps" }).click();
+ await expect(policy.getByRole("alert")).toContainText("generation.caps.sweep");
+ await policy.getByRole("textbox", { name: "cap sweep" }).fill("4");
+ await policy.getByRole("button", { name: "Save caps" }).click();
+ await expect(policy.getByRole("status")).toHaveText("saved caps");
+ expect(stubAsked("settings").at(-1)).toMatchObject({ patch: { generation: { caps: { sweep: 4, max: 10 } } } });
+ for (const r of stubAsked("settings")) expect(JSON.stringify(r)).not.toContain("apiKeyFile");
+ // Read back on a fresh load: the round trip is the editor's, not the page's state.
+ await page.reload();
+ await expect(page.getByRole("region", { name: "generation policy" })).toHaveAttribute("data-policy-preset", "custom");
+ await expect(page.getByRole("region", { name: "generation policy" }).getByRole("textbox", { name: "cap sweep" })).toHaveValue("4");
+ const again = page.getByRole("region", { name: "generation policy" });
+ await again.getByRole("textbox", { name: "cap sweep" }).fill("5");
+ await again.getByRole("button", { name: "Save caps" }).click();
+ await expect(again.getByRole("textbox", { name: "cap sweep" })).toHaveValue("5");
+
+ await again.getByRole("button", { name: "balanced" }).click();
+ await expect(again).toHaveAttribute("data-policy-preset", "balanced");
+});
+
+test("generation: the day's spend, job by job, from the ledger", async ({ page }) => {
+ await page.goto(urls.generationPolicyHref());
+ const spend = page.locator("[data-spend-today]");
+ await expect(spend).toHaveAttribute("data-spend-today", "0.42");
+ await expect(spend).toContainText("of the $20.00 daily cap · 1 job");
+ const job = spend.locator("[data-spend-job=fixture-1]");
+ await expect(job).toContainText("sweep · zeta i1");
+ await expect(job).toContainText("claude-sonnet-5-5");
+ await expect(job).toContainText("$0.42");
+ await expect(spend.getByRole("list", { name: "last 7 days" }).locator("li")).toHaveCount(7);
+});
+
+async function planOf(request: APIRequestContext, data: Record<string, unknown>) {
+ const r = await request.post("/api/system/index", { data: { ...data, dryRun: true } });
+ expect(r.ok()).toBe(true);
+ return (await r.json()).plan as { rows: { label: string }[]; blocked: boolean; summary: string };
+}
+
+test("system: the index prune is a plan — Keep it changes nothing, Confirm drops the stale record", async ({ page, request }) => {
+ // A project the index has a record of, then gone from disk: its record is stale.
+ rmSync(path.join(FIXTURE, STALE), { recursive: true, force: true });
+ const made = await request.post("/api/projects/new", { data: { kind: "report-video", slug: STALE } });
+ expect(made.ok(), await made.text()).toBe(true);
+ expect((await request.get("/api/browse/projects")).ok()).toBe(true); // the walk writes the record
+ rmSync(path.join(FIXTURE, STALE), { recursive: true, force: true });
+ await expect.poll(async () => (await planOf(request, { action: "prune" })).rows.map((r) => r.label)).toContain(STALE);
+
+ await page.goto(urls.systemHref());
+ const panel = page.locator("[data-panel=index]");
+ await panel.getByRole("button", { name: "Prune…" }).click();
+ const plan = page.getByRole("region", { name: "plan index prune" });
+ await expect(plan).toContainText("Prune the index");
+ await expect(plan.getByRole("list", { name: "touches" }).locator(`[data-plan-row="${STALE}"]`)).toBeVisible();
+ await plan.getByRole("button", { name: "Keep it" }).click();
+ await expect(plan).toBeHidden();
+ // Nothing was written: the record is still there.
+ expect((await planOf(request, { action: "prune" })).rows.map((r) => r.label)).toContain(STALE);
+
+ await panel.getByRole("button", { name: "Prune…" }).click();
+ const n = (await planOf(request, { action: "prune" })).rows.length;
+ await plan.locator("[data-plan-confirm]").click();
+ await expect(panel.locator("[data-plan-done='index prune']")).toHaveText(`Dropped ${n} ${n === 1 ? "record" : "records"}`);
+ const after = await planOf(request, { action: "prune" });
+ expect(after.rows).toEqual([]);
+ expect(after.blocked).toBe(true);
+});
+
+test("system: the index rebuild runs as a umtool job, after its plan", async ({ page, request }) => {
+ await page.goto(urls.systemHref());
+ const panel = page.locator("[data-panel=index]");
+ await panel.getByRole("button", { name: "Rebuild…" }).click();
+ const plan = page.getByRole("region", { name: "plan index rebuild" });
+ await expect(plan).toContainText(/Re-read \d+ projects/);
+ await expect(plan).toContainText("Runs as a job");
+ await plan.getByRole("button", { name: "Rebuild the index" }).click();
+ await expect(panel.locator("[data-plan-done='index rebuild']")).toHaveText("The index rebuild is running — a job, in Running");
+ // The job is umtool's own, through the CLI, and finishes.
+ await expect
+ .poll(async () => ((await (await request.get("/api/jobs?n=8")).json()).jobs as { label: string; state: string }[]).find((j) => j.label === "index-rebuild")?.state, { timeout: 60_000 })
+ .toBe("done");
+});
+
+test("system: a storage move with no media root is refused in the plan, never offered, and the API refuses its confirm", async ({ page, request }) => {
+ await page.goto(urls.systemHref());
+ const panel = page.locator("[data-panel=storage]");
+ await expect(panel).toContainText("no media root (UMTOOL_MEDIA_DIR unset)");
+ await panel.getByRole("button", { name: "Move every out/ to the media root…" }).click();
+ const plan = page.getByRole("region", { name: "plan storage move-out all" });
+ await expect(plan.getByRole("list", { name: "refused" })).toContainText("UMTOOL_MEDIA_DIR is not set");
+ await expect(plan).toHaveAttribute("data-plan-blocked", "yes");
+ await expect(plan.locator("[data-plan-confirm]")).toHaveCount(0);
+ await plan.getByRole("button", { name: "Keep it" }).click();
+ await expect(plan).toBeHidden();
+
+ const refused = await request.post("/api/system/storage", { data: { action: "move-out", all: true } });
+ expect(refused.status()).toBe(409);
+ expect((await refused.json()).plan.refusals[0]).toContain("UMTOOL_MEDIA_DIR is not set");
+ // A project id, never a path; an unknown one is a 404.
+ expect((await request.post("/api/system/storage", { data: { action: "move-back", project: "no/such", dryRun: true } })).status()).toBe(404);
+ expect((await request.post("/api/system/storage", { data: { action: "rm", project: "x" } })).status()).toBe(400);
+ // Nothing on disk moved.
+ expect(existsSync(path.join(FIXTURE, "reports", "report-fixture", "video.manifest.json"))).toBe(true);
+});
+
+test("system: the doctor's roots are the fixture's", async ({ page, request }) => {
+ await page.goto(urls.systemHref());
+ const roots = page.locator("[data-panel=roots]");
+ await expect(roots).toContainText(".e2e-song");
+ await expect(roots).toContainText("UMTOOL_MEDIA_DIR unset");
+ const doctor = await (await request.get("/api/doctor")).json();
+ expect(doctor.roots.reports.path).toContain(".e2e-song");
+ expect(doctor.roots.media.tiered).toBe(false);
+});
diff --git a/umtool/e2e/shell.spec.ts b/umtool/e2e/shell.spec.ts
@@ -27,6 +27,7 @@ const PLACES: { url: string; lit: string; current: "page" | "true" }[] = [
{ url: urls.mixHref(), lit: "tools", current: "true" },
{ url: urls.findHref(), lit: "tools", current: "true" },
{ url: urls.systemHref(), lit: "settings", current: "page" },
+ { url: urls.generationPolicyHref(), lit: "settings", current: "page" },
];
for (const { url, lit, current } of PLACES) {
@@ -109,15 +110,15 @@ test("the palette jumps to a piece, moves with the arrows, closes on Escape, and
await expect(page).toHaveURL(/\/articles\/zeta$/);
});
-test("a create action from the palette", async ({ page }) => {
+test("a create action from the palette opens its line of /create (P5)", async ({ page }) => {
await page.goto(urls.workHref());
await ready(page);
await page.keyboard.press("Control+k");
- await page.keyboard.type("new project");
- await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "new-project");
+ await page.keyboard.type("video from a recording");
+ await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "new-video-recording");
await page.keyboard.press("Enter");
- await expect(page).toHaveURL(/\/projects\?new=1$/);
- await expect(page.locator("[data-new-project-form]")).toBeVisible();
+ await expect(page).toHaveURL(/\/create\?make=video-recording$/);
+ await expect(page.locator("[data-make-form=video-recording] [data-new-project-form]")).toBeVisible();
});
test("a bench collapses the rail; its head still links home", async ({ page }) => {
diff --git a/umtool/lib/system/actions.ts b/umtool/lib/system/actions.ts
@@ -106,7 +106,8 @@ export async function applyIndex(action: IndexAction): Promise<{ message: string
const dropped = await pruneIndex();
return { message: `Dropped ${dropped} ${dropped === 1 ? "record" : "records"}` };
}
- const job = runJob("index rebuild", [cliStep("rebuild the project index", ["index", "--rebuild"], 30 * 60_000)], null);
+ // The kind reads as "Index rebuild" in the rail's Running list (lib/running.mjs ownJobLabel).
+ const job = runJob("index-rebuild", [cliStep("rebuild the project index", ["index", "--rebuild"], 30 * 60_000)], null);
return { message: "The index rebuild is running", job };
}
@@ -162,7 +163,11 @@ export async function planStorage(input: StorageInput): Promise<ActionPlanView>
if (x.state === "failed") refusals.push(`${x.name}/: ${x.error}`);
}
if (!r.results.length) rows.push({ label: "—", what: "no clips/ and no share-*/ yet; only the switch is set" });
- rows.push({ label: "storage.deliverables", what: `${r.before ?? "local (unset)"} → ${to}`, state: r.before === to ? "already" : "would-move" });
+ rows.push({
+ label: "storage.deliverables",
+ what: r.before === to ? `${to} already` : `${r.before ?? "unset (reads as local)"} → ${to}`,
+ state: r.before === to ? "already" : "would-move",
+ });
} catch (e) {
refusals.push(e instanceof Error ? e.message : String(e));
}
@@ -237,8 +242,9 @@ export async function applyStorage(input: StorageInput): Promise<{ message: stri
return { message: `Moving ${p.id}'s deliverables to ${input.to}`, job };
}
const target = input.all ? "--all" : (input.project as string);
+ // "Move out reports/x", "Move back every project" in the Running list.
const job = runJob(
- `storage ${input.action} ${input.all ? "all" : target}`,
+ `${input.action} ${input.all ? "every project" : target}`,
[cliStep(`${input.action} ${input.all ? "every project" : target}`, ["storage", input.action, target], 60 * 60_000)],
input.all ? null : target,
);