Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 24ed270cb2f091087f095fb523297061ff31e025
parent 5f262003c8d5d91590961d3d71485a9ea638223e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 06:42:02 -0400

umtool: a standalone report video's stepper has no Research or Article (not applicable, dimmed, its reason the title); a video scaffolded from a research board has its Research done and links the board

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/components/piece/PieceFrame.tsx | 9+++++++++
Mumtool/components/projects/report/OverviewTab.tsx | 13+++++++++++++
Mumtool/components/ui/stepper.tsx | 20+++++++++++++++-----
Mumtool/e2e/piece.spec.ts | 41+++++++++++++++++++++++++++++++++++++++--
Aumtool/lib/pieces/board.mjs | 34++++++++++++++++++++++++++++++++++
Aumtool/lib/pieces/board.test.mjs | 17+++++++++++++++++
Mumtool/lib/pieces/frame.ts | 31+++++++++++++++++++++++--------
Mumtool/lib/pieces/tabs.mjs | 34+++++++++++++++++++++++++++-------
Mumtool/lib/pieces/tabs.test.mjs | 18+++++++++++++++++-
9 files changed, 194 insertions(+), 23 deletions(-)

diff --git a/umtool/components/piece/PieceFrame.tsx b/umtool/components/piece/PieceFrame.tsx @@ -6,6 +6,7 @@ import { Stepper } from "@/components/ui/stepper"; import { Tabs, type TabItem } from "@/components/ui/tabs"; import { articleHref, projectHref, projectsHref } from "@/lib/hrefs"; import { PIECE_TABS } from "@/lib/pieces/tabs.mjs"; +import { researchCaseHref } from "@/lib/research/hrefs"; import type { PieceFrame as Frame } from "@/lib/pieces/frame"; import LifecycleChip from "./LifecycleChip"; import Menu from "./Menu"; @@ -78,6 +79,14 @@ export default function PieceFrame({ below={ <div className="flex flex-wrap items-center gap-x-6 gap-y-2" data-piece-frame={frame.pieceId} data-piece-stage={frame.stage} data-piece-lifecycle={frame.lifecycle}> <Stepper steps={frame.steps} /> + {frame.board && ( + <span className="text-[12.5px] text-muted" data-piece-from-board={frame.board.id}> + from the board{" "} + <Link href={researchCaseHref(frame.board.id)} prefetch={false} className="ink-link"> + {frame.board.title} + </Link> + </span> + )} {article && ( <span className="text-[12.5px] text-muted" data-piece-article={`${article.site}/${article.report}`}> a video of{" "} diff --git a/umtool/components/projects/report/OverviewTab.tsx b/umtool/components/projects/report/OverviewTab.tsx @@ -8,6 +8,7 @@ import { Table, TD, TH } from "@/components/ui/table"; import { ARTICLES_KEY } from "@/lib/articles/key.mjs"; import { readArticleIterations, type IterationRow } from "@/lib/articles/generation"; import { articleHref } from "@/lib/hrefs"; +import { researchCaseHref } from "@/lib/research/hrefs"; import { Markdown } from "@/lib/markdown"; import { decisionsForProject } from "@/lib/projects"; import type { PieceFrame } from "@/lib/pieces/frame"; @@ -139,6 +140,18 @@ export default async function OverviewTab({ project, detail, frame }: ReportTabP </ul> </section> + {frame.board && ( + <section data-piece-board={frame.board.id}> + <h2 className="micro mb-1.5">Research board</h2> + <Link href={researchCaseHref(frame.board.id)} prefetch={false} className="ink-link text-[13px]"> + {frame.board.title} + </Link> + <p className="text-[12px] text-muted"> + its quotes made this cut{frame.board.at ? ` · ${frame.board.at.slice(0, 10)}` : ""} + </p> + </section> + )} + {article && ( <section data-piece-linked-article={`${article.site}/${article.report}`}> <h2 className="micro mb-1.5">Article</h2> diff --git a/umtool/components/ui/stepper.tsx b/umtool/components/ui/stepper.tsx @@ -1,17 +1,25 @@ import { cn } from "@/lib/utils"; // The stage stepper (canvas `.stepper`): Research → Article → Video → Deliver. -// Done stages are ink, the current one Signal, the rest seams. Information, not +// Done stages are ink, the current one Signal, the rest seams. A stage that does +// not apply to this piece (`na`: a video no article claims has no Article) is +// dimmed, its dot a dashed ring, its reason the `title`. Information, not // navigation: it says where a piece is, and the page's tabs take you there. -export type Step = { label: string; state: "done" | "current" | "todo" }; +export type Step = { label: string; state: "done" | "current" | "todo" | "na"; title?: string }; export function Stepper({ steps, className, ...props }: React.ComponentProps<"ol"> & { steps: Step[] }) { return ( <ol className={cn("flex flex-wrap items-center", className)} aria-label="Stage" {...props}> {steps.map((s, i) => ( - <li key={s.label} data-step={s.state} className="flex items-center" aria-current={s.state === "current" ? "step" : undefined}> + <li + key={s.label} + data-step={s.state} + title={s.title} + className="flex items-center" + aria-current={s.state === "current" ? "step" : undefined} + > {i > 0 && ( - <span aria-hidden="true" className={cn("mx-2.5 h-px w-10", s.state === "todo" ? "bg-seam-2" : "bg-text-2")} /> + <span aria-hidden="true" className={cn("mx-2.5 h-px w-10", s.state === "todo" || s.state === "na" ? "bg-seam-2" : "bg-text-2")} /> )} <span className={cn( @@ -19,10 +27,12 @@ export function Stepper({ steps, className, ...props }: React.ComponentProps<"ol s.state === "done" && "text-text-2", s.state === "current" && "font-semibold text-text", s.state === "todo" && "text-muted-2", + s.state === "na" && "text-muted-2 opacity-55", )} > - <i className="stepper-dot" aria-hidden="true" /> + <i className={cn("stepper-dot", s.state === "na" && "border-dashed")} aria-hidden="true" /> {s.label} + {s.state === "na" && <span className="sr-only"> (not applicable: {s.title ?? "does not apply"})</span>} </span> </li> ))} diff --git a/umtool/e2e/piece.spec.ts b/umtool/e2e/piece.spec.ts @@ -1,5 +1,10 @@ import { test, expect, type Page } from "@playwright/test"; +import { 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 { researchCaseHref } from "../lib/research/hrefs"; // --------------------------------------------------------------------------- // The piece page (plans/umtool-redesign.md, P4a-1): a report video's project @@ -10,6 +15,7 @@ import * as urls from "./urls"; // --------------------------------------------------------------------------- const PROJECT = "reports/report-fixture"; +const FIXTURE = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".e2e-song"); const PIECE = `p:${PROJECT}`; const tab = (page: Page, id: string) => page.getByTestId(`piece-tab-${id}`); @@ -28,9 +34,13 @@ test("the frame: title, trail, stepper at Video, the Next card, seven tabs with const frame = page.locator(`[data-piece-frame="${PIECE}"]`); await expect(frame).toHaveAttribute("data-piece-stage", "video"); const steps = page.getByRole("list", { name: "Stage" }).locator("li"); - await expect(steps).toHaveText(["Research", "Article", "Video", "Deliver"]); + await expect(steps).toHaveText([/^Research/, /^Article/, /^Video/, /^Deliver/]); await expect(steps.nth(2)).toHaveAttribute("aria-current", "step"); - await expect(steps.nth(1)).toHaveAttribute("data-step", "done"); + // No article claims it and no board made it: Research and Article do not apply, and say why. + await expect(steps.nth(0)).toHaveAttribute("data-step", "na"); + await expect(steps.nth(0)).toHaveAttribute("title", "no research board"); + await expect(steps.nth(1)).toHaveAttribute("data-step", "na"); + await expect(steps.nth(1)).toHaveAttribute("title", "no article"); await expect(steps.nth(3)).toHaveAttribute("data-step", "todo"); const tabs = page.getByRole("navigation", { name: "Piece" }).getByRole("link"); @@ -176,3 +186,30 @@ test("fits 1366×768: the head, the tabs and the Next card's action without a ho const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); expect(overflow).toBeLessThanOrEqual(0); }); + +test("a video started from a research board: Research done, Article not applicable, the board linked", async ({ page, request }) => { + const made = (await (await request.post("/api/research/cases", { data: { title: "Piece board" } })).json()) as { case: { id: string } }; + const id = made.case.id; + const slug = "piece-board-video"; + try { + const board = (await (await request.get(`/api/research/cases/${BOARD_CASE}`)).json()) as { + case: { scope: { source: string }; quotes: { cite: { channel: string; video: string; t: number } }[] }; + }; + const q = board.case.quotes[0].cite; + const pin = await request.post(`/api/research/cases/${id}/quotes`, { data: { source: board.case.scope.source, channel: q.channel, video: q.video, t: q.t } }); + expect(pin.ok(), await pin.text()).toBe(true); + const done = await request.post(`/api/research/cases/${id}/handoff`, { data: { to: "video", slug, confirm: true } }); + expect(done.ok(), await done.text()).toBe(true); + + await page.goto(urls.projectHref(slug)); + const steps = page.getByRole("list", { name: "Stage" }).locator("li"); + await expect(steps.nth(0)).toHaveAttribute("data-step", "done"); + await expect(steps.nth(1)).toHaveAttribute("data-step", "na"); + await expect(steps.nth(1)).toHaveAttribute("title", "no article"); + await expect(page.locator(`[data-piece-board="${id}"] a`)).toHaveAttribute("href", researchCaseHref(id)); + await expect(page.locator(`[data-piece-from-board="${id}"] a`)).toHaveText("Piece board"); + } finally { + await request.post("/api/projects/delete", { data: { project: slug, force: true } }); + rmSync(path.join(FIXTURE, ".umtool", "research", id), { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/pieces/board.mjs b/umtool/lib/pieces/board.mjs @@ -0,0 +1,34 @@ +// Which research board a project was scaffolded from (R2's "Start a video from +// this board"). The hand-off is recorded on the CASE, not the project: the +// confirm writes `{ to: "video", href: /projects/<slug>, at, what }` into the +// case's `handoffs` (lib/research/handoff.ts confirmVideo). So the board of a +// project is the case whose video hand-off names it -- the newest, should two. +// Pure: the page reads the cases (lib/pieces/frame.ts) and asks this. + +/** The path of an href, decoded segment by segment, without its query or hash. */ +function pathOf(href) { + const bare = String(href ?? "").split(/[?#]/)[0]; + try { + return bare.split("/").map(decodeURIComponent).join("/"); + } catch { + return bare; + } +} + +/** + * @param {string} projectId + * @param {{ id: string, title: string, handoffs?: { to: string, href: string, at?: string }[] }[]} cases + * @returns {{ id: string, title: string, at: string | null } | null} + */ +export function boardOfProject(projectId, cases) { + const want = `/projects/${projectId}`; + let best = null; + for (const c of cases) { + for (const h of c.handoffs ?? []) { + if (h.to !== "video" || pathOf(h.href) !== want) continue; + const at = h.at ?? null; + if (!best || (at ?? "") > (best.at ?? "")) best = { id: c.id, title: c.title, at }; + } + } + return best; +} diff --git a/umtool/lib/pieces/board.test.mjs b/umtool/lib/pieces/board.test.mjs @@ -0,0 +1,17 @@ +// The board a project was scaffolded from: the case whose video hand-off names it. +import assert from "node:assert/strict"; +import test from "node:test"; +import { boardOfProject } from "./board.mjs"; + +test("a project's board is the case whose video hand-off names it, the newest when two do", () => { + const cases = [ + { id: "ferret", title: "Ferret sanctuary", handoffs: [{ to: "article", href: "/articles/ferret?tab=iterations", at: "2026-10-14T09:00:00Z" }] }, + { id: "permit", title: "The permit", handoffs: [{ to: "video", href: "/projects/the-permit", at: "2026-10-14T10:00:00Z" }] }, + { id: "permit-2", title: "The permit, again", handoffs: [{ to: "video", href: "/projects/the-permit", at: "2026-10-14T11:00:00Z" }] }, + ]; + assert.deepEqual(boardOfProject("the-permit", cases), { id: "permit-2", title: "The permit, again", at: "2026-10-14T11:00:00Z" }); + assert.equal(boardOfProject("ferret", cases), null, "an article hand-off is not a video's board"); + assert.equal(boardOfProject("reports/x", []), null); + // Encoded segments and a query on the href still match. + assert.equal(boardOfProject("a b", [{ id: "c", title: "C", handoffs: [{ to: "video", href: "/projects/a%20b?tab=cut" }] }])?.id, "c"); +}); diff --git a/umtool/lib/pieces/frame.ts b/umtool/lib/pieces/frame.ts @@ -4,7 +4,10 @@ import { whatOf } from "../inbox/what.mjs"; import { lifecycleOf, readLifecycle, type LifecycleState } from "../lifecycle"; import { projectPieceId, readPieceGraph, type Piece } from "../pieces"; import { stageOf } from "../work/facets.mjs"; -import { stepsOf } from "./tabs.mjs"; +import { pieceSteps } from "./tabs.mjs"; +import { boardOfProject } from "./board.mjs"; +import { listCases, readCase } from "../research/cases.mjs"; +import { REPORTS_ROOT } from "../paths"; import type { Decision } from "../decisions"; // --------------------------------------------------------------------------- @@ -23,7 +26,7 @@ import type { Decision } from "../decisions"; // fresh, as everywhere. // --------------------------------------------------------------------------- -export type StepState = "done" | "current" | "todo"; +export type StepState = "done" | "current" | "todo" | "na"; export type PieceFrame = { /** The piece this page is part of, or null when the graph does not list it (a project the walk refused). */ @@ -33,18 +36,28 @@ export type PieceFrame = { article: { title: string; site: string; report: string; href: string; via: string; cut: boolean } | null; lifecycle: LifecycleState; lifecycleError: string | null; - steps: { label: string; state: StepState }[]; + steps: { label: string; state: StepState; title?: string }[]; + /** The research board (R2 case) this project was scaffolded from, when a case's video hand-off names it. */ + board: { id: string; title: string; at: string | null } | null; /** The bucket the stepper lights (research … deliver). */ stage: string; }; -/** The four stages, lit for one bucket (lib/pieces/tabs.mjs). */ -export function stepsFor(bucket: string, lifecycle: LifecycleState): PieceFrame["steps"] { - return stepsOf(bucket, lifecycle) as PieceFrame["steps"]; +/** + * The research board a project was scaffolded from: the case whose video + * hand-off names it (lib/pieces/board.mjs). Cases are few; a case that does not + * read is skipped, never an error on the project page. + */ +async function boardOf(projectId: string): Promise<PieceFrame["board"]> { + const list = (await listCases(REPORTS_ROOT).catch(() => [])) as { id: string; error?: string }[]; + const cases = await Promise.all( + list.filter((c) => !c.error).map((c) => readCase(REPORTS_ROOT, c.id).catch(() => null)), + ); + return boardOfProject(projectId, cases.filter(Boolean) as { id: string; title: string; handoffs?: { to: string; href: string; at?: string }[] }[]); } export async function readPieceFrame(project: { id: string; state?: string | null }): Promise<PieceFrame> { - const [graph, life] = await Promise.all([readPieceGraph(), readLifecycle()]); + const [graph, life, board] = await Promise.all([readPieceGraph(), readLifecycle(), boardOf(project.id)]); const pieceId = graph.pieceOfProject.get(project.id) ?? projectPieceId(project.id); const piece = graph.byId.get(pieceId) ?? null; const lifecycle = lifecycleOf(life, pieceId); @@ -56,7 +69,9 @@ export async function readPieceFrame(project: { id: string; state?: string | nul const stage = piece ? stageOf({ kind: piece.kind, stage: piece.stage, looksDone: piece.looksDone, projectState: piece.kind === "project" ? piece.stage : null }) : "video"; - return { piece, pieceId, article, lifecycle, lifecycleError: life.error ?? null, steps: stepsFor(stage, lifecycle), stage }; + const kind = piece?.kind ?? "project"; + const steps = pieceSteps({ kind, bucket: stage, lifecycle, fromBoard: kind === "project" && !!board }) as PieceFrame["steps"]; + return { piece, pieceId, article, board, lifecycle, lifecycleError: life.error ?? null, steps, stage }; } export type NextCall = { diff --git a/umtool/lib/pieces/tabs.mjs b/umtool/lib/pieces/tabs.mjs @@ -25,18 +25,38 @@ export const STAGE_STEPS = [ /** * The stepper, lit for one bucket: the stages before it done, it current, the - * rest to do. A piece marked done has walked them all. + * rest to do; a stage that does not apply to this piece is `na` (dimmed, with + * its reason as `title`). A piece marked done has walked every stage it has. * * @param {string} bucket research | article | video | deliver * @param {string} lifecycle active | parked | done - * @returns {{ label: string, state: "done" | "current" | "todo" }[]} + * @param {Record<string, string>} [na] stage id → why it does not apply + * @returns {{ label: string, state: "done" | "current" | "todo" | "na", title?: string }[]} */ -export function stepsOf(bucket, lifecycle) { +export function stepsOf(bucket, lifecycle, na = {}) { const at = STAGE_STEPS.findIndex((s) => s.id === bucket); - return STAGE_STEPS.map((s, i) => ({ - label: s.label, - state: lifecycle === "done" || i < at ? "done" : i === at ? "current" : "todo", - })); + return STAGE_STEPS.map((s, i) => + na[s.id] + ? { label: s.label, state: "na", title: na[s.id] } + : { label: s.label, state: lifecycle === "done" || i < at ? "done" : i === at ? "current" : "todo" }, + ); +} + +/** + * A piece's stepper. An ARTICLE walks all four stages from its own stage (one + * in the making is at Research, P2a's rule). A PROJECT no article claims has + * no Article stage, and no Research stage either -- unless it was scaffolded + * from a research board (R2's "Start a video from this board"), whose board + * was its research. + * + * @param {{ kind: string, bucket: string, lifecycle: string, fromBoard?: boolean }} p + */ +export function pieceSteps({ kind, bucket, lifecycle, fromBoard = false }) { + if (kind === "article") return stepsOf(bucket, lifecycle); + return stepsOf(bucket, lifecycle, { + ...(fromBoard ? {} : { research: "no research board" }), + article: "no article", + }); } /** The tabs of a report-video piece, in order; the key that opens each is its position. */ diff --git a/umtool/lib/pieces/tabs.test.mjs b/umtool/lib/pieces/tabs.test.mjs @@ -2,7 +2,7 @@ import assert from "node:assert/strict"; import test from "node:test"; import { STAGES } from "../work/facets.mjs"; -import { PIECE_TABS, PIECE_TAB_IDS, SECTION_TAB, STAGE_STEPS, stepsOf, tabOf, tabOfKey, tabOfNoteAnchor, tabOfSection } from "./tabs.mjs"; +import { PIECE_TABS, PIECE_TAB_IDS, SECTION_TAB, STAGE_STEPS, pieceSteps, stepsOf, tabOf, tabOfKey, tabOfNoteAnchor, tabOfSection } from "./tabs.mjs"; test("seven tabs, in the canvas's order; keys 1–7 open them", () => { assert.deepEqual(PIECE_TAB_IDS, ["overview", "cut", "media", "build", "deliver", "sources", "history"]); @@ -45,3 +45,19 @@ test("the stepper: before the bucket done, it current, after it to do; a done pi assert.deepEqual(stepsOf("video", "done").map((s) => s.state), ["done", "done", "done", "done"]); assert.deepEqual(stepsOf("video", "active").map((s) => s.label), ["Research", "Article", "Video", "Deliver"]); }); + +test("a piece's stepper: an article walks all four; a standalone video has no Research or Article; a board's video has its Research", () => { + const states = (steps) => steps.map((s) => s.state); + // An article in the making with a video project already: at Research (P2a's rule). + assert.deepEqual(states(pieceSteps({ kind: "article", bucket: "research", lifecycle: "active" })), ["current", "todo", "todo", "todo"]); + // A report video no article claims: Research and Article do not apply, and say why. + const alone = pieceSteps({ kind: "project", bucket: "video", lifecycle: "active" }); + assert.deepEqual(states(alone), ["na", "na", "current", "todo"]); + assert.deepEqual(alone.slice(0, 2).map((s) => s.title), ["no research board", "no article"]); + // Scaffolded from a research board: Research done, Article still not applicable. + const board = pieceSteps({ kind: "project", bucket: "video", lifecycle: "active", fromBoard: true }); + assert.deepEqual(states(board), ["done", "na", "current", "todo"]); + assert.equal(board[1].title, "no article"); + // Marked done: every stage it has is done; the ones it never had stay not applicable. + assert.deepEqual(states(pieceSteps({ kind: "project", bucket: "deliver", lifecycle: "done" })), ["na", "na", "done", "done"]); +});