commit 68a1461565a8a31bf42150c5f6d3827b73853325 parent 1ffc9130d7c4be795dfaaa44bcc98cef6ea8d90f Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Wed, 14 Oct 2026 08:01:55 -0400 merge ux/integration (P4a-1) into ux/p5 Conflicts resolved: the Inbox imports P4a-1's whatOf and drops the ?from form (P5); the plan keeps both records (P4a-1's rollout, then P5's) and one status row per phase. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Diffstat:
67 files changed, 2517 insertions(+), 941 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -55,6 +55,10 @@ - **umtool's rail shows what is running, the editor's jobs too, and what it costs.** The foot of the rail lists umtool's own job and the editor's live ones (`GET /api/ops/jobs?active=1`): each with what it is, what it works on, how far it is, queued or running, and a report draft's spend so far; the label row says **Running N** and the day's Claude API spend. A row links to its article when it has one, else to the editor's `/jobs`. Queued syncs and the editor's lane runners fold into one line ("+ 140 queued · 3 lanes"). When the editor's jobs cannot be read the rail says why — **Editor unreachable**, **Editor's WORKER_TOKEN not set** (it answered 503) — and never just "nothing running". It asks every 8 s, and not while the tab is hidden. - **umtool's Inbox has a card for drafts nobody has reviewed.** A report video whose fields a model drafted (narration, on-screen text, the teaser, the cut, flips, threads, the YouTube text) and that are not approved is one card under **Review** ("Narration draft · 5 fields · by qwen3:8b"); **Review drafts** opens the project's review page, and the card goes once they are approved. The decisions API carries them as `drafts-unreviewed` rows, one per field. - **umtool waits at most 5 s for the editor.** A read from the editor's ops API is given 5 s (a write 30 s) and a read is kept 2 s, so the rail, a page and a poll asking at once ask once; an editor that does not answer is said to be unreachable rather than hanging the page. +- **umtool: a report video's page is a piece page.** `/projects/<project>` has a head — the title, the lifecycle (**Active ▾**: Park, Mark done, Reactivate, with Undo), **⋯** (Delete project) and the stage stepper (Research → Article → Video → Deliver, the piece's own; an article's video says whose it is and links it) — then seven tabs: **Overview** (the **Next** card, the project's decisions, its stats, the article and its iterations, the README), **Cut** (the walk, takes, the timeline, corrections), **Media** (the drafts, the narration and review links, the YouTube text), **Build** (the final video, the build chain, on-screen), **Deliver** (deliver, exports), **Sources** and **History** (revisions, provenance, notes). The tab is the address (`?tab=build`); an old link lands where it did (`?all=1` on the Cut, a note's link on the tab its anchor is on). Song projects keep their page. +- **The Next card is the piece's top call in the Inbox, with its one action.** `n` runs it; `1`–`7` open the tabs. A parked or done piece's Next is **Reactivate**. +- **A project-wide decision links the tab that settles it.** A build out of date or never built opens **Build**, the deliverables' storage **Deliver**, an unpunctuated source **Sources**; a clip's or a claim's still opens its bench, and a bench's way back is the **Cut**. +- **umtool: links on a project page are ink, not Signal.** The teal is kept for the lit line and the one primary action (the Next card's, **Walk the cut**); the drafts panel, the review and narration pages, the iterations and the new-article form follow. - **Articles, iterations, report-video projects and takes can be deleted, and every delete shows its plan first.** `archilyzer reports delete <id>` prints what would go — each path with its size, what is kept and why, and anything that stops it — and deletes nothing until `--apply`; `--iteration <n>` deletes one iteration. Deleting an article removes its directory (report, video, history, notes, iterations), each iteration's video project under `settings.generation.projectsRoot` and its staged exports. A published article is refused unless `--force`, which unpublishes it first; an article with a running iteration is always refused. An iteration is refused while it is the current article or video, the one the article's report came from, running, or the parent or original of another iteration, and its number is never given out again. The usage ledger, the shared prepared-media cache and the corpus's git history are kept. The same deletes run over HTTP as `pnpm ops delete-article {id, force?, dryRun?}` and `pnpm ops delete-iteration {id, n, dryRun?}`, which answer a refusal as a 409 with the plan. - **umtool: Delete article, `Delete i<n>`, Delete project and `Delete take <id>`.** Each button reads the plan, shows it (what goes with sizes, what is kept, what refuses) and deletes only on **Confirm delete**; **Keep it** closes it. **Delete article** is on an article's page (one in the making too) and returns to `/articles`, which says what went; `Delete i<n>` is on each iteration of the Iterations tab. **Delete project** on a report-video project removes its directory, and its `out/` or deliverables on the media drive when they are its own copy; it is refused while a job works in the project, for an article's current video, and — unless you tick **delete anyway** — for a project whose manifest names an article with a video attached. `Delete take <id>` removes `takes/<id>/`; the take whose manifest is the project's own needs **delete anyway**, and its verdict and notes are kept. - **Reports and their revisions can be generated by the editor: `pnpm ops report-draft`.** `{"task": "sweep", "article", "question", "channels"}` drafts a new report of an article as its next iteration; `{"task": "revise-report" | "revise-video", "article", "iteration", "feedback"}` revises one; `{"task": "narrate", "article", "iteration"}` drafts the narration of an iteration's video cut; `"copyOf": N` runs iteration N again on another `"model"`. Each is a **Report draft** job on /jobs, on the Claude API (`draft:api`) or the local model (`draft:local`) by the model, and `pnpm ops job cancel` stops one. Every quote a model writes must be the transcript's words within 90 seconds of its link, or the finding is dropped; links cite the archive, never the platform. The answer names the job and the iteration; the job's log ends with the outcome. Needs a restart of the editor. diff --git a/plans/umtool-redesign.md b/plans/umtool-redesign.md @@ -352,9 +352,10 @@ P0 design ─► P1 foundation ─┬─► P3 inbox/work/tools/URLs ─┬─ | P3 inbox/work/tools/URLs | `ux/p3` → `main` `01120bfe` | LIVE 2026-10-14 (umtool BUILD_ID q7e29Em…) | | P2b jobs + drafts | `ux/p2b` → `main` `44c7b758` | LIVE 2026-10-14 (umtool BUILD_ID J2YDbFuc…) | | R2 research boards | `ux/r2` → `main` `b8561669` | LIVE 2026-10-14 (editor N0OAYPyM…, umtool 9lPefuiS…) | -| P5 create + settings | `ux/p5` | done on the branch, awaiting review (not merged) | -| P4a-1 piece frame | `ux/p4a` | in progress | -| P4a-2, P4a-3 | — | after P4a-1 | +| P4a-1 piece frame | `ux/p4a` → `main` `a92251aa` | LIVE 2026-10-14 (umtool ErWqdPdg…) | +| P5 create + settings | `ux/p5` | shipped on the branch (review rulings applied; not merged) | +| P4a-2 article-rooted merge | `ux/p4a2` | in progress | +| P4a-3 song pieces | — | after P4a-2 | | R3, P4b, P6 | — | after R2 / P4a / all | ### P2a, as shipped @@ -1197,6 +1198,183 @@ was a real editor bug also seen on r24/r25: the build and cleanup toggles' forms click before hydration submitted natively and was dropped. Fixed in `ff3baf6b` (both disabled until `useHydrated()`); `channel-build-toggle.spec` + `cleanup-page.spec` then 3 runs, 2/2 each. +### P4a-1, as shipped + +**What.** A report video's project page (`/projects/<path>`) is a piece page: a frame around one tab of the +sections `ReportProject` drew top to bottom, moved unchanged. Song projects (`SongProject`, `CutPage`) and sweep +reports keep their pages (P4a-3); the article-rooted merge is P4a-2. + +- **The frame** (`components/piece/PieceFrame.tsx`, kind-blind): the head through `AppShell` — the trail + (`projects / <project id>`), the piece's title as the `<h1>`, the lifecycle chip, **⋯**, the page's status line + (`4 clips · 2 other · 0:12 · not built`, still the head's last `.micro`) — and under it, in a new `below` row of + `AppHeader`/`AppShell`, the stage **Stepper** (P1's) and, for an article's video, "a video of <article>". Then + P1's link **Tabs**, then the tab's body, then the Inbox's `UndoBar`. +- **Which piece** (`lib/pieces/frame.ts`): the project's piece from P2a's graph (`pieceOfProject`) — `p:<id>`, or + the article's `a:<site>/<report>` when an article claims it — so the stepper, the lifecycle and the Next call are + the article's for an article's video. The stepper's bucket is Work's (`stageOf`: an article's own stage; a + project's `deliver` when it looks done, else `video`); lit by `stepsOf` (`lib/pieces/tabs.mjs`, pure): before the + bucket done, it current, after it to do, all done once the piece is marked done. +- **The lifecycle chip** (`components/piece/LifecycleChip.tsx`): **Active ▾** / **Parked ▾** / **Done ▾** opening + Park and Mark done (active), Reactivate and Mark done (parked), Reactivate (done) — P3's `LifecycleButton`, the + same POST and Undo bar. **⋯** holds the project id and **Delete project** (the delete plan, unchanged). Both are + one small menu (`components/piece/Menu.tsx`): trigger disabled until hydrated; Escape, a click away or a + lifecycle change closes it. +- **The Next card** (`components/piece/NextCard.tsx`, on the Overview): `readNextCall` narrows `readInbox()` to the + piece, groups and ranks it the Inbox's way (`summarizeGroups`), skips Quiet, and takes the top card: its `what` + (the Inbox's words, now `lib/inbox/what.mjs`, which `app/page.tsx` imports instead of its own table), its `why`, + the count in Meter, "then N more calls", and its ONE action, filled Signal — a link, or Mark done for + `looks-done`. A parked or done piece's Next is **Reactivate** ("2 calls hidden while it is parked"). Nothing + waiting says so, with no button. It streams in under a `<Suspense>` (the Inbox is read whole), so the page never + waits on it; the fallback is `data-next-pending`. +- **Tabs, `?tab=`** (`lib/pieces/tabs.mjs`, unit-tested): Overview · Cut · Media · Build · Deliver · Sources · + History, counts in Meter (Cut: clips; Media: drafted fields; Sources: recordings). `?tab=` and not a segment: it is + the canvas's address (`…?tab=media`) and the article page's own key (`?tab=iterations`), so P4a-2's merged piece + keeps one spelling — and a project id is a path resolved longest-prefix, with the leftover segments a VIEW the + kind declares (`clip/<id>`, `takes`, `review` …), so `/projects/a/b/build` could be a project called `build`. + **Old addresses land:** no `tab` is the Overview; `?all=1` (the cut's "show every quote") opens the Cut; + `?note=<id>` opens the tab its anchor is drawn on (a row's `entry`/`edit` note → Cut, a timed `moment` → Build, + read from the project's `notes.json`); `/browse/<project>` rides P3's redirect. A bad `tab` is the Overview. + `projectHref(id, { tab })` builds them (the Overview never written). Only the tab on show is read: the Sources + tab's cue reads, History's snapshot diffs and Deliver's exports cost nothing on the Overview. The Tabs primitive no + longer prefetches (P3's finding: every page is dynamic, a prefetch is a full render — seven per piece page). +- **Keys** (`components/piece/PieceKeys.tsx`): `1`–`7` open the tabs, `n` runs the Next card's visible action + (while React reveals a streamed boundary a hidden copy waits in a `<div hidden>`; the key and the spec skip it). + Bound after hydration (`data-piece-keys="ready"`); never while typing, on a focused `<video>` (`n` there is a + timed note), inside an open menu or dialog, with a modifier, or after another handler took the key. +- **A project-wide decision links its tab** (`lib/projects/report.mjs` `decisionTab`): `stale-build`/`unbuilt` → + Build, the deliverables' storage → Deliver (`out`'s → Build), `no-punctuation` → Sources; a clip's or a claim's + still links its bench. The clip, claim and takes pages' way back is the Cut (`projectHref(id, { tab: "cut" })`). + +**Section → tab** (the 14 sections `ReportProject` drew, plus its title bar's pieces; `SECTION_TAB` names each for +`e2e/urls.ts` `section(project, name)`): + +| Section (its attribute) | Tab | +|---|---| +| Title bar: title, subtitle, channel / generated / cited / enumerated | head (title) + Overview (**This video** stats) | +| Title bar: **Walk the cut** (`data-walk-cut`, `data-walk-start`, `data-ready-count`) | Cut | +| Title bar: **Narration — N** (`data-narration-link`), **Review drafts — N** (`data-review-link`) | Media | +| Title bar: **Takes — N** (`data-takes-link`) | Cut | +| Title bar: the final mp4, **open in mix** (`data-mix-deliverable`) | Build | +| Title bar: **Delete project** | ⋯ menu (every tab) | +| `GeneratedBanner` (`generated-banner`) | every tab, above the body | +| 1. README (`data-readme`) | Overview | +| 2. Decisions (`data-project`, `data-decision`) | Overview | +| 3. Sources + availability + **Tag cited** (`data-sources`, `data-tag-cited`) | Sources | +| 4. `ReportBuildChain` | Build | +| 5. `DraftPanel` (release 28) | Media | +| 6. `OnscreenSection` (2152 lines, parked whole until P4b) | Build | +| 7. `DeliverSection` (`data-deliver`) | Deliver | +| 8. The cut: `FetchUnfetchedButton`, `TimelineList` rows (`data-entry`), show every quote | Cut | +| 9. Corrections for the next pass (`data-corrections`) | Cut | +| 10. Revisions (`data-revisions`, `data-snapshot`) | History | +| 11. `YoutubeSection` (release 28, `data-youtube`) | Media | +| 12. Export + podcast (`data-exports`, `data-export-variant`) | Deliver | +| 13. Provenance (`data-provenance`) | History | +| 14. Notes: prose and sibling `.md` files (`data-notes`) | History | +| new: the Next card, the article and its newest five iterations (article store) | Overview | + +The sections live in `components/projects/report/{Overview,Cut,Media,Build,Deliver,Sources,History}Tab.tsx`, +moved verbatim in `f0f53642` (each tab does its own reads); `ReportProject.tsx` reads the manifest's detail once, +picks the tab and renders the frame. + +**The Signal-as-link sweep** (P1's ruling, done in `52c72351`): on the piece page and r28's files beside it, a link +that wore `text-[var(--color-sel)]` is `.ink-link` (the tabs' clip, bench, mix, quote, cite, takes, provenance URL +links; `DraftPanel`, `DraftsReview`, `NarrationPage`, `IterationsTab`'s Compare, `ResearchSlot`, `StructureEditors`' +"+ add a post", `OnscreenSection`'s post link and "at m:ss" jump), and a state that wore it is ink: a timeline row's +id, `DeliverSection`'s section letter, `OnscreenSection`'s current row (semibold) and current-entry readout, the +build chain's `cutting` chip, `ChainPanel`'s start step, `IterationsTab`'s current card edge (`--muted`), +`NewArticleForm`'s picked channels (the `on` chip: `--muted` edge, `--panel-2`). **Walk the cut** is the Cut tab's +one filled action (`go`). Left as Signal, by rule: `focus:border-[var(--color-sel)]` on inputs (focus), and +`OnscreenSection`'s current-segment fill in the strip and the posts window (`:1814`, `:1852` — the play-head). Left +as noted: `OnscreenSection.tsx:283` `bg-[#0d0f14]` (the neutral video frame) and `:1739` `#000` (a preview's +default background), frame stand-ins. r28's literal `/browse/…` hrefs on these pages now go through `lib/hrefs` +(`clipBenchHref`, `takesHref`, `narrationHref`, `reviewHref`, `projectHref`, `projectsHref`, `mixHref`). + +| sha | what | +|---|---| +| `f0f53642` | the frame (head, stepper, lifecycle chip, ⋯, Next card, tabs, keys), the seven tab components moved verbatim, `lib/pieces/{frame.ts,tabs.mjs}`, `lib/inbox/what.mjs`, `projectHref`'s `tab`, `e2e/urls.ts` `section()`, AppHeader/AppShell `below`, Tabs without prefetch | +| `52c72351` | the Signal sweep, r28's hrefs through `lib/hrefs`, benches back to the Cut, `decisionTab` | +| `2953c0d9` | 19 specs open their section's tab through `urls.section` (46 gotos); Delete project via **More** | +| `18d667f0` | `e2e/piece.spec.ts` (8); `stepsOf` pure and unit-tested | +| `ceb02eff` | the streamed twin: `n` takes the visible action, the fallback is `data-next-pending`; `onscreen.spec` reads the teaser's timeline row on the Cut | + +**Gates.** + +| Gate | Result | +|---|---| +| repo-wide `tsc --noEmit` | clean at `f0f53642`, `52c72351` and the tip (umtool typecheck clean at every commit) | +| umtool unit (`node --test umtool/lib/*.test.mjs umtool/lib/*/*.test.mjs umtool/report-to-video/*.test.mjs`) | 819 tests, 817 pass, 2 skipped, 0 fail (new: `lib/pieces/tabs.test.mjs` 5; `hrefs.test.mjs` +3 assertions) | +| `pnpm --filter umtool test` | 11/11 | +| `pnpm run test:scripts` (reads the capped build) | 970 tests, 968 pass, 2 skipped, 0 fail | +| capped umtool `next build` (corpus linked, `MemoryMax=5G`) | exit 0, compiled 10.4 s, 33 s wall, 1.45 GB max RSS; the link removed | +| full umtool e2e, run 1 (`18d667f0`) | 398 tests: 390 passed, 2 failed, 6 skipped, 8.2 min. Reds: `onscreen.spec:253` (asserted a timeline row on the Build tab), `piece.spec:52` (strict mode met the streamed twin) — both fixed in `ceb02eff`; then `piece.spec` + `onscreen.spec` 16/16 | +| full umtool e2e, run 2 (`ceb02eff`) | **398 tests: 392 passed, 0 failed, 6 skipped** (the song-data capability skips), 8.0 min; `piece.spec` 8/8 | + +**Spec churn:** 19 specs changed (46 `goto`s now `urls.section(project, name)`; 4 tests also hop to a second tab — +`report-longform` sources→decisions, `draft-review` review→onscreen, `onscreen` onscreen→timeline, `timeline-edit`'s +`open(page, "onscreen")` for the structure editors; `clip-bench`'s two walk-start hrefs are `urls.clipBenchHref`; +`article-delete` opens **More** before **Delete project**). No `data-testid` renamed. New: `e2e/piece.spec.ts` (8): +the frame (title, trail, status line, stepper at Video, seven tabs, the Overview alone), the Next card = the Inbox's +top card for the piece and its action, the tab as the URL (`?tab=`, `?all=1`, a bad tab, `/browse/…`, a click), a +note's link opening the Cut, the lifecycle chip Park → Parked + Undo + Reactivate in the Next card → Reactivate +(through `/api/pieces`), the keys (`2`, `7`, a digit typed in a field left alone, `1`, `n`), an article's video +(`a:articles/zeta`, its link, its iterations), 1366×768 with no horizontal scroll. + +**Screenshots** (job scratch `p4a-shots/final/`, 17): an article's report video (`gen-projects/msurf/i1`) on +Overview, Build and Media, and `reports/report-fixture`'s Overview, at 1366×768 and 1440×900, dark and light, on the +e2e build. Against the canvas's Piece · Overview: the head (title in Archivo, the chip and ⋯ on the right), the +stepper with the current stage Signal-ringed, the tabs with Meter counts and the Signal underline, the Next card with +its Signal edge and one filled action, the two-column Overview (decisions and iterations | stats and the article). +Differences: the trail sits above the title where the canvas has a kind · site micro line; the status line is on the +head's right; Media is release 28's panels as they were (the canvas's per-field review list is P4b's). +**Keyboard-only** (production build, both themes): the rail's 11 stops, the trail, **Lifecycle: Active**, **More**, +the seven tabs, the Next card's action — each with the 2 px Signal ring (`transition-colors` delays the colour +~150 ms on the chip, ⋯ and the filled action); Enter opens the chip's menu, Tab reaches Park, Escape closes; `4`, +`1`, `n` from the body. The frame has no motion of its own. + +**Found and left.** +- A project an article claims is still drawn as a project page (the article's stepper, lifecycle and Next call, and + "a video of <article>" in the head); P4a-2 renders it as the article's piece with Article/Iterations tabs. +- A standalone report video's stepper shows Research and Article done (Work's bucket rule: a project is at Video + until it looks done). An article in the making that already has a video project is at Research (P2a's rule). +- The Next card reads the whole Inbox and narrows it; on the live reports that is P3's measured 0.1–2 s warm, streamed + so the page does not wait. A per-piece reader would be cheaper; not needed yet. +- `DraftPanel`'s and `OnscreenSection`'s many **Draft with** / save buttons are P1's `primary` (a Signal outline, + "an action that is interaction-led but not THE action") — left; P4b's Media tab decides them. +- Activity rows (a build job's link) still open the Overview; only decisions carry a tab. + +**Follow-up (review, 2026-10-14).** +- **Rulings:** `?tab=` and the note landing stand; the three other open points (the `primary` buttons, activity + rows on the Overview, the Next card reading the whole Inbox) are accepted as they are. +- **The stepper says what does not apply** (`lib/pieces/tabs.mjs` `pieceSteps`, unit-tested): + - an article walks all four stages from its own stage; one in the making with a video project is at Research + (P2a's rule); + - a report video no article claims has no Article stage (`na`, title "no article") and no Research stage + ("no research board"); + - a video scaffolded from a research board has Research done and Article `na`; + - a piece marked done has every stage it has done; the `na` ones stay `na`. + The Stepper primitive gains the `na` state: dimmed, a dashed ring with no fill, the reason as the `title` and as + screen-reader text; the rule before it stays a seam. +- **`ux/integration` `b8561669` merged** at `c4300598`: R2's research boards (cases, `c:` ids, the article and + video hand-offs), the colour-transition fix in `components/ui`, the editor toggles' hydration fix. One conflict, + this plan (both records kept; R2's status row with P4a-1's). +- **A video's board is linked.** R2's video hand-off records itself on the CASE (`handoffs: [{ to: "video", href: + /projects/<slug>, at, what }]`), not in the project (its README names the case in prose). `lib/pieces/board.mjs` + `boardOfProject` (pure, unit-tested) finds the case whose video hand-off names the project, the newest if two; + `readPieceFrame` reads the cases (`lib/research/cases.mjs`, a case that does not read is skipped). The Overview + shows **Research board** with the case's title linking `/research/<case>`, and the head says "from the board + <title>". Owed to P4a-2: an article seeded from a board (`enqueueDraft`'s `seed`) — whether the article piece + should show its board too (the case records that hand-off the same way, `to: "article"`). + +| sha | what | +|---|---| +| `c4300598` | merge `ux/integration` `b8561669` (R2, the transition and toggle fixes) | +| `a494495e` | `pieceSteps` and the Stepper's `na`; `boardOfProject` + the board on the Overview and in the head; `piece.spec` asserts the standalone stepper and a board's video (9) | + +Gates at `a494495e`: repo-wide tsc clean; umtool unit 834 tests, 832 pass, 2 skipped, 0 fail (new: `board.test.mjs` +1, `tabs.test.mjs` +1); `pnpm --filter umtool test` 16/16; `test:scripts` 985, 983 pass, 2 skipped, 0 fail; capped +build exit 0 (10.0 s compile, 33 s wall, 1.39 GB); `piece.spec` 9/9 through the e2e entry; full umtool e2e at `a494495e` **407 tests: 401 passed, 0 failed, 6 skipped** (the song-data skips), 7.5 min. +Screenshot: `reports/report-fixture`'s Overview, dark, 1366×768 (job scratch `p4a-shots/followup/`). ### R2 rollout (orchestrator, 2026-10-14) `main` fast-forwarded to `b8561669`; common 4096/4096 in the primary (the real `settings.json`). After a ping to the @@ -1206,6 +1384,17 @@ before and after; only the auto-* lane runners were active), then umtool (44 s, `/research`, `/work` 200; `/api/research/cases` answers (0 cases); the editor's `report-draft` route lists `seed` among its keys and judges a seeded body on its other fields. +### P4a-1 rollout (orchestrator, 2026-10-14) + +Review rulings: a standalone report video's stepper shows Research and Article as not applicable (the lane's reason +text "no research board" on Research accepted); a video from a board shows Research done, Article not applicable. +Gates on `a494495e` (with R2 merged): full umtool e2e 401 passed, 0 failed, 6 skipped; test:scripts 983 pass, 0 fail; +capped build ok. `main` (R2's records, a plan-only conflict resolved keeping both) fast-forwarded to `a92251aa`; umtool +built (40 s) and restarted (`scripts/p4a-umtool.sh`). A first rollout attempt launched after the ff had aborted rebuilt +the then-live code into `.next` and was stopped before its restart; the build was let finish (identical code) and the +real rollout followed. Live: `/projects/quartering-diet` and its `?tab=cut|build|media` 200, an article's video project +200, `/browse/<p>` 307, the Overview tab `aria-current`, decisions API 828 rows with notes' hrefs intact. + ### P5, as shipped **What.** Create and Settings: one door to everything that can be made, and the settings a terminal held. Built on diff --git a/umtool/app/articles/page.tsx b/umtool/app/articles/page.tsx @@ -73,7 +73,7 @@ export default async function ArticlesPage({ searchParams }: { searchParams: Pro <ul className="flex flex-col gap-1 text-[12px]"> {pending.map((p) => ( <li key={p.id} data-pending-article={p.id} data-status={p.newest?.status ?? "none"} className="flex flex-wrap items-baseline gap-2"> - <Link href={`/articles/${p.id}?tab=iterations`} className="font-mono text-[var(--color-text)] hover:text-[var(--color-sel)]"> + <Link href={`/articles/${p.id}?tab=iterations`} className="font-mono text-[var(--color-text)] hover:underline"> {p.id} </Link> {p.newest && ( diff --git a/umtool/app/page.tsx b/umtool/app/page.tsx @@ -9,6 +9,7 @@ import { homeHref, systemHref } from "@/lib/hrefs"; import { readInbox, type GroupCard, type GroupSummary } from "@/lib/inbox"; import { summarizeGroups } from "@/lib/inbox/groups.mjs"; import { headlineNote, inboxHeadline } from "@/lib/inbox/headline.mjs"; +import { whatOf } from "@/lib/inbox/what.mjs"; import type { Decision } from "@/lib/decisions"; import type { LifecycleState } from "@/lib/lifecycle"; @@ -31,47 +32,6 @@ export const dynamic = "force-dynamic"; // with Reactivate; `?muted=1` the muted ones (lib/mutes.ts), each with Unmute. // --------------------------------------------------------------------------- -/** What a decision kind is, in a few words after the piece's title. */ -const WHAT: Record<string, string> = { - "research-proposal": "research proposal", - "iteration-failed": "run failed", - "iteration-ready": "iteration ready", - "drafts-unreviewed": "drafts to review", - "open-note": "open notes", - "unreadable-notes": "notes.json does not read", - "link-ambiguous": "video not linked", - "looks-done": "looks done", - "claim-unadjudicated": "claims never ruled", - "claim-incoherent": "claims that don't hold together", - "clip-no-cues": "clips with no cues", - "clip-unfetchable": "clips can't be fetched", - "clip-mid-sentence": "clips end mid-sentence", - "clip-cue-gap": "clips over a cue gap", - "clip-cut-outside": "cuts outside the window", - "window-overlap": "windows overlap", - "no-punctuation": "windows without punctuation", - "manifest-invalid": "manifest invalid", - "stale-build": "video out of date", - unbuilt: "never built", - "storage-unreachable": "media drive unreachable", - "storage-mismatch": "storage disagrees", - "unjudged-variant": "variants not judged", - "missing-cut": "cuts missing", - "stale-recipe": "recipes out of date", - "no-recipe": "no recipe", - "spec-problem": "spec problem", - "no-plan": "plans unnamed", - unattributed: "variants unattributed", - "thumb-unaccepted": "no cover accepted", - loudness: "loudness off target", - "shadowed-name": "no address of its own", - "unroutable-name": "no address of its own", - "ambiguous-project": "two kinds match", - "machine-tool": "a required tool is missing", - "machine-disk": "disk nearly full", -}; -const whatOf = (kind: string) => WHAT[kind] ?? kind.replace(/-/g, " "); - const GROUP_NOTE: Record<string, string> = { "your-call": "spend or failed runs", blocking: "active pieces only", diff --git a/umtool/components/articles/ChainPanel.tsx b/umtool/components/articles/ChainPanel.tsx @@ -112,7 +112,7 @@ export default function ChainPanel({ {chain.steps.map((s, i) => ( <li key={s.name} data-chain-step={s.name} data-step-status={s.status} title={s.detail ?? undefined} className="flex items-center gap-2"> <span className="num w-5 text-right text-[var(--color-dim)]">{i + 1}</span> - <span className={s.name === startAt && !running ? "text-[var(--color-sel)]" : s.optional ? "italic" : ""}>{s.label}</span> + <span className={s.name === startAt && !running ? "font-semibold text-[var(--color-text)]" : s.optional ? "italic" : ""}>{s.label}</span> {s.status !== "pending" && ( <span className={badgeVariants({ variant: STATUS_VARIANT[s.status] ?? "neutral", size: "sm" })}>{s.status}</span> )} diff --git a/umtool/components/articles/IterationsTab.tsx b/umtool/components/articles/IterationsTab.tsx @@ -232,7 +232,7 @@ function IterationCard({ data-iteration={it.n} data-kind={it.kind} data-status={it.status} - className={`rounded border p-3 ${it.currentReport || it.currentVideo ? "border-[var(--color-sel)]" : "border-[var(--color-line)]"} bg-[var(--color-panel)]`} + className={`rounded border p-3 ${it.currentReport || it.currentVideo ? "border-[var(--color-muted)]" : "border-[var(--color-line)]"} bg-[var(--color-panel)]`} > <header className="flex flex-wrap items-baseline gap-x-2 gap-y-1"> <h3 className="font-mono text-[15px] text-[var(--color-text)]">{it.label}</h3> @@ -539,7 +539,7 @@ export default function IterationsTab({ {compare.length === 2 && ( <Link href={`/articles/${article}/compare?a=${Math.min(...compare)}&b=${Math.max(...compare)}`} - className="ml-auto text-[var(--color-sel)] hover:underline" + className="ink-link ml-auto" > Compare i{Math.min(...compare)} and i{Math.max(...compare)} </Link> diff --git a/umtool/components/articles/NewArticleForm.tsx b/umtool/components/articles/NewArticleForm.tsx @@ -66,7 +66,7 @@ function ChannelPicker({ value, onChange }: { value: string[]; onChange: (v: str type="button" data-picked={s} aria-label={`remove ${nameOf(s)}`} - className="rounded border border-[var(--color-sel)] px-1.5 py-0.5 text-[12px] text-[var(--color-sel)] hover:bg-[var(--color-panel-2)]" + className="rounded border border-[var(--color-muted)] bg-[var(--color-panel-2)] px-1.5 py-0.5 text-[12px] text-[var(--color-text)] hover:bg-[var(--color-panel-2)]" onClick={() => toggle(s)} > {nameOf(s)} × @@ -93,7 +93,7 @@ function ChannelPicker({ value, onChange }: { value: string[]; onChange: (v: str type="button" aria-pressed={value.includes(c.slug)} title={`${c.slug}${c.sites.length ? ` · on ${c.sites.join(", ")}` : " · on no site"}`} - className={`rounded border px-1.5 py-0.5 text-[12px] hover:bg-[var(--color-panel-2)] ${value.includes(c.slug) ? "border-[var(--color-sel)] text-[var(--color-sel)]" : "border-[var(--color-line)]"}`} + className={`rounded border px-1.5 py-0.5 text-[12px] hover:bg-[var(--color-panel-2)] ${value.includes(c.slug) ? "border-[var(--color-muted)] bg-[var(--color-panel-2)] text-[var(--color-text)]" : "border-[var(--color-line)]"}`} onClick={() => toggle(c.slug)} > {c.name} diff --git a/umtool/components/articles/ResearchSlot.tsx b/umtool/components/articles/ResearchSlot.tsx @@ -161,7 +161,7 @@ function ProposalRow({ <ul className="flex flex-wrap gap-x-3 text-[11px]" aria-label={`${p.id} evidence`}> {p.evidence.map((href) => ( <li key={href}> - <a href={href} target="_blank" rel="noreferrer noopener" className="break-all text-[var(--color-sel)] hover:underline"> + <a href={href} target="_blank" rel="noreferrer noopener" className="ink-link break-all"> {href} </a> </li> diff --git a/umtool/components/piece/LifecycleChip.tsx b/umtool/components/piece/LifecycleChip.tsx @@ -0,0 +1,34 @@ +"use client"; + +import { LifecycleButton, type LifecycleState } from "@/components/dashboard/Lifecycle"; +import { badgeVariants } from "@/components/ui/badge"; +import { cn } from "@/lib/utils"; +import Menu from "./Menu"; + +// The piece's lifecycle in its head (canvas "Piece · Overview", `Active ▾`): +// the state as a chip, and the moves out of it -- Park and Mark done while it +// is active, Reactivate (and Mark done) while it is parked, Reactivate once it +// is done. The same POST and Undo bar as the Inbox's (components/dashboard/ +// Lifecycle.tsx); the page re-reads on a change. + +const WORD: Record<LifecycleState, string> = { active: "Active", parked: "Parked", done: "Done" }; + +export default function LifecycleChip({ piece, title, state }: { piece: string; title: string; state: LifecycleState }) { + return ( + <Menu + data-lifecycle-chip={state} + data-piece={piece} + trigger={ + <> + {WORD[state]} <span aria-hidden="true">▾</span> + </> + } + label={`Lifecycle: ${WORD[state]}`} + triggerClassName={cn(badgeVariants({ variant: state === "active" ? "neutral" : "on", size: "md" }), "cursor-pointer disabled:opacity-60")} + > + {state !== "active" && <LifecycleButton piece={piece} title={title} from={state} to="active" label="Reactivate" variant="quiet" size="md" className="justify-start" />} + {state === "active" && <LifecycleButton piece={piece} title={title} from={state} to="parked" label="Park" variant="quiet" size="md" className="justify-start" />} + {state !== "done" && <LifecycleButton piece={piece} title={title} from={state} to="done" label="Mark done" variant="quiet" size="md" className="justify-start" />} + </Menu> + ); +} diff --git a/umtool/components/piece/Menu.tsx b/umtool/components/piece/Menu.tsx @@ -0,0 +1,71 @@ +"use client"; + +import { useEffect, useRef, useState } from "react"; +import { useHydrated } from "@/components/ui/use-hydrated"; +import { cn } from "@/lib/utils"; + +// A small menu under a trigger in a piece's head: the lifecycle chip's and the +// ⋯ menu's. A panel below the trigger, right-aligned; Escape, a click away, or +// a lifecycle change (the `umtool:lifecycle` event a LifecycleButton sends) +// closes it. The trigger is disabled until hydration, the house rule: a press +// before React is listening opens nothing. +export default function Menu({ + trigger, + label, + className, + triggerClassName, + children, + ...props +}: { + trigger: React.ReactNode; + /** The trigger's accessible name when its text is not one ("More" for ⋯). */ + label?: string; + className?: string; + triggerClassName?: string; + children: React.ReactNode; +} & Omit<React.ComponentProps<"div">, "children">) { + const hydrated = useHydrated(); + const [open, setOpen] = useState(false); + const ref = useRef<HTMLDivElement>(null); + useEffect(() => { + if (!open) return; + const away = (e: MouseEvent) => { + if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); + }; + const key = (e: KeyboardEvent) => { + if (e.key === "Escape") setOpen(false); + }; + const changed = () => setOpen(false); + document.addEventListener("mousedown", away); + document.addEventListener("keydown", key); + window.addEventListener("umtool:lifecycle", changed); + return () => { + document.removeEventListener("mousedown", away); + document.removeEventListener("keydown", key); + window.removeEventListener("umtool:lifecycle", changed); + }; + }, [open]); + return ( + <div ref={ref} className={cn("relative", className)} {...props}> + <button + type="button" + disabled={!hydrated} + aria-expanded={open} + aria-haspopup="true" + aria-label={label} + onClick={() => setOpen((v) => !v)} + className={triggerClassName} + > + {trigger} + </button> + {open && ( + <div + data-menu-panel="" + className="absolute right-0 top-[calc(100%+4px)] z-30 flex min-w-[200px] flex-col items-stretch gap-0.5 rounded-[3px] border border-seam-2 bg-panel-2 p-1.5 shadow-lg" + > + {children} + </div> + )} + </div> + ); +} diff --git a/umtool/components/piece/NextCard.tsx b/umtool/components/piece/NextCard.tsx @@ -0,0 +1,73 @@ +import Link from "next/link"; +import { LifecycleButton } from "@/components/dashboard/Lifecycle"; +import { buttonVariants } from "@/components/ui/button"; +import { Card } from "@/components/ui/panel"; +import { readNextCall } from "@/lib/pieces/frame"; +import type { LifecycleState } from "@/lib/lifecycle"; + +// THE NEXT CARD (canvas "Piece · Overview", `.nextcard`): the piece's top call +// from the Inbox -- the same ranking, the same one action -- with the Signal +// edge, and `n` runs it (components/piece/PieceKeys.tsx). A parked or done +// piece's next move is Reactivate. Nothing waiting says so, with no button. +// +// Async: the Inbox is read whole (lib/inbox) and then narrowed, so the page +// streams this in under a <Suspense> rather than waiting on it. + +export function NextCardShell({ pending = false, children }: { pending?: boolean; children: React.ReactNode }) { + return ( + <Card lit data-next={pending ? undefined : ""} data-next-pending={pending ? "" : undefined} className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-[18px] gap-y-1 px-4 py-3.5"> + <span className="micro col-span-full">Next</span> + {children} + </Card> + ); +} + +export default async function NextCard({ pieceId, title, lifecycle }: { pieceId: string; title: string; lifecycle: LifecycleState }) { + const next = await readNextCall(pieceId, lifecycle).catch(() => null); + if (!next) { + return ( + <NextCardShell> + <div data-next-kind="none"> + <b className="text-[15px] font-semibold">Nothing waiting on you</b> + <small className="block text-[12.5px] text-muted">no call on this piece in the Inbox</small> + </div> + </NextCardShell> + ); + } + return ( + <NextCardShell> + <div className="min-w-0" data-next-kind={next.kind} data-next-group={next.group}> + <b className="text-[15px] font-semibold first-letter:uppercase inline-block">{next.what}</b> + {next.count > 1 && ( + <span className="ml-2 font-mono text-[12.5px] text-meter" data-next-count={next.count}> + {next.count} + </span> + )} + <small className="block truncate text-[12.5px] text-muted"> + {next.why} + {next.more > 0 && ` · then ${next.more} more call${next.more === 1 ? "" : "s"}`} + </small> + </div> + <span className="flex items-center gap-2.5"> + <kbd title="runs it">n</kbd> + <span data-next-action=""> + {next.lifecycleTo ? ( + <LifecycleButton + piece={pieceId} + title={title} + from={lifecycle} + to={next.lifecycleTo} + label={next.action.label} + variant="go" + size="md" + /> + ) : ( + <Link href={next.action.href} prefetch={false} className={buttonVariants({ variant: "go", size: "md" })}> + {next.action.label} + </Link> + )} + </span> + </span> + </NextCardShell> + ); +} diff --git a/umtool/components/piece/PieceFrame.tsx b/umtool/components/piece/PieceFrame.tsx @@ -0,0 +1,112 @@ +import Link from "next/link"; +import { UndoBar } from "@/components/dashboard/Lifecycle"; +import AppShell from "@/components/shell/AppShell"; +import { buttonVariants } from "@/components/ui/button"; +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"; +import PieceKeys from "./PieceKeys"; + +// --------------------------------------------------------------------------- +// THE PIECE PAGE's frame (plans/umtool-redesign.md, P4a-1; canvas "Piece · +// Overview"): the head -- the trail, the piece's title, the lifecycle chip and +// the ⋯ menu, the page's status line, the stage stepper -- then the tabs, as +// links (`?tab=`, lib/pieces/tabs.mjs), then the tab's own body. +// +// Kind-blind: the report-video page (components/projects/ReportProject.tsx) +// hands it the title, the counts and the body. `1`–`7` open the tabs and `n` +// runs the Next card's action (PieceKeys). +// --------------------------------------------------------------------------- + +export default function PieceFrame({ + project, + title, + frame, + tab, + counts, + note, + more, + children, +}: { + project: string; + title: string; + frame: Frame; + /** The tab on show. */ + tab: string; + /** A count beside a tab's name, in Meter (Cut: clips, Media: drafted fields, Sources: recordings). */ + counts: Partial<Record<string, number>>; + /** The page's one-line status, the head's last `.micro`. */ + note?: React.ReactNode; + /** The ⋯ menu's items (Delete project …). */ + more?: React.ReactNode; + children: React.ReactNode; +}) { + const hrefs = PIECE_TABS.map((t) => projectHref(project, { tab: t.id })); + const items: TabItem[] = PIECE_TABS.map((t, i) => ({ + href: hrefs[i], + label: t.label, + current: t.id === tab, + count: counts[t.id] ? counts[t.id] : undefined, + testid: `piece-tab-${t.id}`, + })); + const { article, piece } = frame; + return ( + <> + <AppShell + active="work" + crumbs={[{ href: projectsHref(), label: "projects" }, { label: project }, { label: title }]} + note={note} + actions={ + <> + {piece && <LifecycleChip piece={frame.pieceId} title={piece.title} state={frame.lifecycle} />} + {more && ( + <Menu + data-piece-more="" + label="More" + trigger={<span aria-hidden="true">⋯</span>} + triggerClassName={buttonVariants({ variant: "quiet", size: "md" })} + > + {more} + </Menu> + )} + </> + } + 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{" "} + <Link href={articleHref({ site: article.site, id: article.report })} prefetch={false} className="ink-link"> + {article.title} + </Link> + </span> + )} + </div> + } + /> + {frame.lifecycleError && ( + <p role="alert" className="px-4 pt-2 text-[12.5px] text-reject-text"> + {frame.lifecycleError} — every piece reads as active until it is fixed. + </p> + )} + <Tabs label="Piece" items={items} className="px-4" data-piece-tabs={tab} /> + <PieceKeys tabs={hrefs} /> + {children} + <UndoBar /> + </> + ); +} diff --git a/umtool/components/piece/PieceKeys.tsx b/umtool/components/piece/PieceKeys.tsx @@ -0,0 +1,52 @@ +"use client"; + +import { useRouter } from "next/navigation"; +import { useEffect, useState } from "react"; + +// A piece page's keys: `1`–`7` open the tabs, in order; `n` runs the Next +// card's action (the one control under `[data-next-action]`). Bound only after +// hydration -- the house rule's "disabled until hydrated", for a key -- and +// `data-piece-keys="ready"` says so to a spec. +// +// A key is the page's only when nobody else wants it: not while typing (an +// input, a textarea, a select, anything editable), not on a focused <video> +// (`n` there is a timed note, components/notes/TimedNotes.tsx), not inside an +// open dialog or menu, never with a modifier, and never when a handler before +// this one took it. +function isOurs(e: KeyboardEvent): boolean { + if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey) return false; + const t = e.target as HTMLElement | null; + if (!t || !(t instanceof HTMLElement)) return true; + if (/^(INPUT|TEXTAREA|SELECT|VIDEO|AUDIO)$/.test(t.tagName) || t.isContentEditable) return false; + if (t.closest("dialog[open], [role=dialog], [data-menu-panel]")) return false; + return true; +} + +export default function PieceKeys({ tabs }: { tabs: string[] }) { + const router = useRouter(); + const [ready, setReady] = useState(false); + useEffect(() => { + const onKey = (e: KeyboardEvent) => { + if (!isOurs(e)) return; + const n = Number(e.key); + if (Number.isInteger(n) && n >= 1 && n <= tabs.length) { + e.preventDefault(); + router.push(tabs[n - 1]); + return; + } + if (e.key === "n") { + // The visible one: while React streams the card in, a copy waits in a hidden <div>. + const act = [...document.querySelectorAll<HTMLElement>("[data-next-action] > a, [data-next-action] > button")].find( + (el) => !el.closest("[hidden]"), + ); + if (!act || (act instanceof HTMLButtonElement && act.disabled)) return; + e.preventDefault(); + act.click(); + } + }; + document.addEventListener("keydown", onKey); + setReady(true); + return () => document.removeEventListener("keydown", onKey); + }, [router, tabs]); + return <span hidden data-piece-keys={ready ? "ready" : "waiting"} />; +} diff --git a/umtool/components/projects/ClaimBenchPage.tsx b/umtool/components/projects/ClaimBenchPage.tsx @@ -92,7 +92,7 @@ export default async function ClaimBenchPage({ rail="collapsed" crumbs={[ { href: browseHref(), label: "projects" }, - { href: projectHref(project.id), label: project.name }, + { href: projectHref(project.id, { tab: "cut" }), label: project.name }, { label: claimId }, ]} note={`claim ${i + 1} of ${ledger.length} · ${outstanding} unadjudicated`} diff --git a/umtool/components/projects/ClipBenchPage.tsx b/umtool/components/projects/ClipBenchPage.tsx @@ -172,7 +172,7 @@ export default async function ClipBenchPage({ rail="collapsed" crumbs={[ { href: browseHref(), label: "projects" }, - { href: projectHref(project.id), label: project.name }, + { href: projectHref(project.id, { tab: "cut" }), label: project.name }, { label: clipId }, ]} // The progress reading moved INTO the bench, where pressing `y` can diff --git a/umtool/components/projects/DeliverSection.tsx b/umtool/components/projects/DeliverSection.tsx @@ -116,7 +116,7 @@ export default async function DeliverSection({ className="border-t border-[var(--color-line)] align-top" > <td className="px-1.5 py-1"> - <span className="font-mono text-[var(--color-sel)]">{s.letter}</span>{" "} + <span className="font-mono text-[var(--color-text)]">{s.letter}</span>{" "} <span className="text-[var(--color-dim)]">{s.heading ?? "—"}</span> </td> <td className="num px-1.5 py-1">{s.total}</td> diff --git a/umtool/components/projects/DraftPanel.tsx b/umtool/components/projects/DraftPanel.tsx @@ -5,6 +5,7 @@ import { useRouter } from "next/navigation"; import { useCallback, useEffect, useRef, useState } from "react"; import { badgeVariants } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; +import { reviewHref } from "@/lib/hrefs"; import { DraftAlternatives, DraftBadge, announceDraftsChanged, useDrafts } from "./drafts"; import { announceManifestChanged } from "./timelineApi"; import type { DraftRowView, DraftRunSummary, ProjectIteration } from "@/lib/articles/projectDraft"; @@ -243,7 +244,7 @@ function DraftRow({ </div> )} {!row.address && run && run.alternatives > 0 && ( - <Link href={`/browse/${project}/review`} className="text-[11px] text-[var(--color-sel)] hover:underline"> + <Link href={reviewHref(project)} className="ink-link text-[11px]"> {run.alternatives} alternative(s) kept — review them </Link> )} @@ -309,7 +310,7 @@ export default function DraftPanel({ {link.ok && ( <span className="text-[11px] text-[var(--color-dim)]"> steps on{" "} - <Link href={`/articles/${link.article}?tab=iterations`} className="font-mono text-[var(--color-sel)] hover:underline"> + <Link href={`/articles/${link.article}?tab=iterations`} className="ink-link font-mono"> {link.article} i{link.n} </Link> </span> diff --git a/umtool/components/projects/DraftsReview.tsx b/umtool/components/projects/DraftsReview.tsx @@ -1,6 +1,7 @@ "use client"; import Link from "next/link"; +import { narrationHref, projectHref } from "@/lib/hrefs"; import { DraftAlternatives, DraftBadge, useDrafts, type DraftsView } from "./drafts"; // `/browse/<project>/review`'s list (release 28, M0): every drafted field of @@ -39,7 +40,7 @@ export default function DraftsReview({ project, initial }: { project: string; in {drafted.length === 0 && loose.length === 0 && ( <p data-drafts-empty="" className="text-[12px] text-[var(--color-dim)]"> Nothing in this cut was drafted.{" "} - <Link href={`/browse/${project}`} className="text-[var(--color-sel)] hover:underline"> + <Link href={projectHref(project, { tab: "media" })} className="ink-link"> back to {project} </Link> </p> @@ -55,7 +56,7 @@ export default function DraftsReview({ project, initial }: { project: string; in <span className="font-mono text-[12px] text-[var(--color-text)]">{where(r.entry, r.field)}</span> <span className="micro">{r.label}</span> {r.field === "narration" && ( - <Link href={`/browse/${project}/narration`} className="text-[11px] text-[var(--color-sel)] hover:underline"> + <Link href={narrationHref(project)} className="ink-link text-[11px]"> edit and play on the narration page </Link> )} diff --git a/umtool/components/projects/NarrationPage.tsx b/umtool/components/projects/NarrationPage.tsx @@ -1,5 +1,6 @@ import Link from "next/link"; import BrowseHeader from "@/components/BrowseHeader"; +import { projectHref, projectsHref } from "@/lib/hrefs"; import { readManifest } from "@/lib/projects/report.mjs"; import { manifestToken } from "@/lib/report/manifest.mjs"; import { narrationReviewView } from "@/lib/report/narration-review.mjs"; @@ -21,8 +22,8 @@ export default async function NarrationPage({ project }: { project: ProjectRef } <div className="flex h-full flex-col"> <BrowseHeader crumbs={[ - { href: "/browse", label: "projects" }, - { href: `/browse/${project.id}`, label: project.id }, + { href: projectsHref(), label: "projects" }, + { href: projectHref(project.id), label: project.id }, { label: "narration" }, ]} note={ @@ -37,7 +38,7 @@ export default async function NarrationPage({ project }: { project: ProjectRef } {view.rows.length === 0 ? ( <p data-narration-empty="" className="text-[12px] text-[var(--color-dim)]"> No card in this cut carries a narration.{" "} - <Link href={`/browse/${project.id}`} className="text-[var(--color-sel)] hover:underline"> + <Link href={projectHref(project.id, { tab: "media" })} className="ink-link"> back to {project.id} </Link> </p> diff --git a/umtool/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx @@ -1398,7 +1398,7 @@ export default function OnscreenSection({ <button type="button" onClick={() => jump(row.id)} - className={`font-mono text-[11px] hover:underline ${isCurrent ? "text-[var(--color-sel)]" : "text-[var(--color-text)]"}`} + className={`font-mono text-[11px] hover:underline ${isCurrent ? "font-semibold text-[var(--color-text)]" : "text-[var(--color-text-2)]"}`} title="show this entry in the preview" > {row.id} @@ -1585,7 +1585,7 @@ export default function OnscreenSection({ target="_blank" rel="noreferrer noopener" data-testid="onscreen-post-link" - className="text-[11px] text-[var(--color-sel)] hover:underline" + className="ink-link text-[11px]" > open the post ↗ </a> @@ -1629,7 +1629,7 @@ export default function OnscreenSection({ <button type="button" data-testid="onscreen-post-jump" - className="num font-mono text-[var(--color-sel)] hover:underline" + className="ink-link num font-mono" onClick={() => setT(Math.min(schedule.total, Math.round(((p.timing!.in ?? p.timing!.appear ?? 0) + (p.timing!.in != null ? 1.5 : 0.25)) * 1000) / 1000))} title="show this post in the preview" > @@ -1875,7 +1875,7 @@ export default function OnscreenSection({ </span> </div> <div className="flex flex-wrap items-center gap-2 text-[11px] text-[var(--color-dim)]"> - <span className="font-mono text-[var(--color-sel)]" data-testid="onscreen-current"> + <span className="font-mono text-[var(--color-text)]" data-testid="onscreen-current"> {current?.id ?? "—"} </span> {schedule.estimated ? ( diff --git a/umtool/components/projects/ReportBuildChain.tsx b/umtool/components/projects/ReportBuildChain.tsx @@ -35,7 +35,7 @@ type Preset = { id: string; label: string }; const CLIP_STATE = { pending: "border-[var(--color-line)] text-[var(--color-dim)]", fetching: "border-[var(--color-meter)] text-[var(--color-meter)]", - cutting: "border-[var(--color-sel)] text-[var(--color-sel)]", + cutting: "border-[var(--color-text-2)] text-[var(--color-text)]", done: "border-[var(--color-good)] text-[var(--color-good)]", failed: "border-[var(--color-bad)] text-[var(--color-bad)]", } as const; diff --git a/umtool/components/projects/ReportProject.tsx b/umtool/components/projects/ReportProject.tsx @@ -1,75 +1,47 @@ -import { readdir, readFile } from "node:fs/promises"; import path from "node:path"; -import Link from "next/link"; import BrowseHeader from "@/components/BrowseHeader"; -import CopyButton from "@/components/CopyButton"; -import CheckSourcesButton from "@/components/dashboard/CheckSourcesButton"; -import { fmtAgo, fmtBytes } from "@/lib/format"; -import { Markdown } from "@/lib/markdown"; -import { - correctionsOf, - readClipDetail, - reviewOf, - sourcesOf, - unfetchedNeedingJudgement, - walkReadiness, -} from "@/lib/projects/report.mjs"; -import { EXPORT_FORMATS, exportableVariants } from "@/lib/report/export.mjs"; -import { diffManifests, formatChange } from "@/lib/report/manifest-diff.mjs"; -import { listSnapshots, readSnapshot } from "@/lib/report/snapshots.mjs"; -import { listTakes } from "@/lib/report/takes.mjs"; -import { podcastFor } from "@/lib/report/serve.mjs"; -import { narrationsOf } from "umtool-report-to-video/narration"; -import { draftedFields, isCodeDraft } from "yt-dlp-transcript-common/lib/report/drafted.mjs"; -import { readAlternatives } from "@/lib/report/drafts.mjs"; -import DeliverSection from "./DeliverSection"; -import DraftPanel from "./DraftPanel"; -import { draftRowsOf, draftRuns, projectIteration } from "@/lib/articles/projectDraft"; -import FetchUnfetchedButton from "./FetchUnfetchedButton"; -import OnscreenSection from "./OnscreenSection"; -import PodcastExport from "./PodcastExport"; -import ReportBuildChain from "./ReportBuildChain"; -import SnapshotButton from "./SnapshotButton"; -import DeleteProject from "./DeleteProject"; -import TagCitedButton from "./TagCitedButton"; -import YoutubeSection from "./YoutubeSection"; -import { RowControls, RowNotes, TimelineList } from "./TimelineEditor"; import GeneratedBanner from "@/components/notes/GeneratedBanner"; import { NotesProvider } from "@/components/notes/NotesProvider"; -import { decisionsForProject } from "@/lib/projects"; -import { badgeVariants, type BadgeVariants } from "@/components/ui/badge"; -import { buttonVariants } from "@/components/ui/button"; -import type { Severity } from "@/lib/decisions"; +import PieceFrame from "@/components/piece/PieceFrame"; +import { readNotes } from "@/lib/annotations/store.mjs"; +import { readPieceFrame } from "@/lib/pieces/frame"; +import { tabOf, tabOfNoteAnchor } from "@/lib/pieces/tabs.mjs"; +import { channelFor, clipsOf, readClipDetail } from "@/lib/projects/report.mjs"; +import { draftedFields, isCodeDraft } from "yt-dlp-transcript-common/lib/report/drafted.mjs"; import type { ProjectRef } from "@/lib/project-types"; +import DeleteProject from "./DeleteProject"; +import BuildTab from "./report/BuildTab"; +import CutTab from "./report/CutTab"; +import DeliverTab from "./report/DeliverTab"; +import HistoryTab from "./report/HistoryTab"; +import MediaTab from "./report/MediaTab"; +import OverviewTab from "./report/OverviewTab"; +import SourcesTab from "./report/SourcesTab"; +import { hms } from "./report/shared"; // --------------------------------------------------------------------------- -// A report video, as a page. +// A report video, as a PIECE PAGE (plans/umtool-redesign.md, P4a-1). // // The manifest IS the cut -- array order, absolute source seconds, one entry per // clip -- so the page is the timeline, read back. What it adds is the three // things the JSON cannot show you: whether each clip's material is actually on // disk, whether its window ends where a sentence does, and what the widener // would do to it if you ran it. +// +// Since P4a-1 the page is the piece frame (components/piece/PieceFrame.tsx: +// head, stage stepper, lifecycle, tabs) around ONE tab, and the sections it +// drew top to bottom live in the tabs (components/projects/report/*), moved +// unchanged. Which section is on which tab is lib/pieces/tabs.mjs SECTION_TAB. +// Only the tab on show is read: the Sources tab's cue reads, the History tab's +// snapshot diffs and the Deliver tab's exports cost nothing on the Overview. // --------------------------------------------------------------------------- -const hms = (t: number) => { - const s = Math.max(0, Math.floor(t)); - const h = Math.floor(s / 3600); - const m = Math.floor((s % 3600) / 60); - const sec = s % 60; - return h > 0 - ? `${h}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")}` - : `${m}:${String(sec).padStart(2, "0")}`; -}; - -const TONE: Record<Severity, BadgeVariants["variant"]> = { - blocking: "blocking", - open: "open", - info: "info", -}; - -function Pill({ tone, children }: { tone?: BadgeVariants["variant"]; children: React.ReactNode }) { - return <span className={badgeVariants({ variant: tone ?? "info", size: "sm" })}>{children}</span>; +/** The tab a `?note=` opens: where the note's anchor is drawn. */ +async function noteTab(dir: string, note: string | undefined): Promise<string | null> { + if (!note) return null; + const { doc } = await readNotes(path.join(dir, "notes.json")).catch(() => ({ doc: null })); + const n = doc?.notes?.find((x: { id: string }) => x.id === note) as { anchor?: { kind?: string } } | undefined; + return n?.anchor?.kind ? tabOfNoteAnchor(n.anchor.kind) : null; } export default async function ReportProject({ @@ -80,12 +52,11 @@ export default async function ReportProject({ search: Record<string, string | undefined>; }) { const detail = await readClipDetail(project.dir); - const decisions = await decisionsForProject(project); if (!detail) { return ( <div className="flex h-full flex-col"> - <BrowseHeader crumbs={[{ href: "/browse", label: "projects" }, { label: project.id }]} /> + <BrowseHeader crumbs={[{ href: "/projects", label: "projects" }, { label: project.id }]} /> <main className="deck-main flex-1 p-4"> <p className="text-[12px] text-[var(--color-bad)]"> <code className="font-mono">video.manifest.json</code> could not be parsed. @@ -98,766 +69,50 @@ export default async function ReportProject({ ); } - const { manifest: m, build, entries, channelsDir, shadowExists } = detail; - const corrections = correctionsOf(m) as { - id: string; - channel: string | null; - video: string; - at: number; - href: string; - text: string; - verdict: "confirmed" | "incorrect" | "unreviewed"; - }[]; + const { manifest: m, build, entries } = detail; + const tab = tabOf(search, { noteTab: !search.tab ? await noteTab(project.dir, search.note) : null }); + const frame = await readPieceFrame(project); const clips = entries.filter((e) => e.kind === "clip"); - // How much of the cut has been walked. One definition, shared with the bench - // header and `umtool corrections`. - const review = reviewOf(m); - // And how much of it can be walked TODAY: the walk visits the clips that - // still need judgement and have something to play, so the gap between these - // two numbers is what is waiting on a download rather than on somebody. - const readiness = walkReadiness(clips); - // What the walk is waiting on: the same clips the rows below mark "not - // fetched yet". - const pendingFetch = unfetchedNeedingJudgement(clips) as string[]; - const walkStart = (readiness.readyIds[0] as string | undefined) ?? clips[0]?.id; const nonClips = entries.filter((e) => e.kind !== "clip"); const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0); - const showAll = search.all === "1"; - const p = (m.provenance ?? {}) as Record<string, unknown>; - - // ---- the long-form reads: sources, revisions, notes, exports ------------ - const sources = await sourcesOf(project.dir, { manifest: m }); - const snapshots = await listSnapshots(project.dir); - const diffs = await Promise.all( - snapshots.map(async (sn) => { - try { - return diffManifests(await readSnapshot(project.dir, sn.rel), m); - } catch { - return null; - } - }), - ); - const readme = await readFile(path.join(project.dir, "README.md"), "utf8").catch(() => null); - // Sibling notes: every .md that is neither the report nor the README. - const names = await readdir(project.dir).catch(() => [] as string[]); - const noteFiles = names.filter((n) => /\.md$/i.test(n) && !/^readme\.md$/i.test(n) && n !== "sweep-report.md").sort(); - const noteTexts = await Promise.all(noteFiles.map((n) => readFile(path.join(project.dir, n), "utf8").catch(() => ""))); - const variants = await exportableVariants(project.dir); - // Each exportable cut's podcast files, as they are on disk (build-podcast.mjs). - const podcastOf = async (v: string) => { - const f = async (which: "m4a" | "mp3" | "notes") => { - const got = await podcastFor(project, m, v, which); - return got ? { size: got.size, mtimeMs: got.mtimeMs } : null; - }; - return { m4a: await f("m4a"), mp3: await f("mp3"), notes: await f("notes") }; - }; - const podcasts = new Map(await Promise.all(variants.map(async (v) => [v, await podcastOf(v)] as const))); - const takes = await listTakes(project.dir); - const narrated = narrationsOf(m).length; - // The drafts review (release 28): drafted fields, and alternatives kept. - // (A field a code path made — the converter's timeline — is not a draft to review.) - const draftedCount = draftedFields(m).filter((d) => !isCodeDraft(d.provenance)).length; - const alternativesCount = (await readAlternatives(project.dir)).length; - // "Draft with" (release 28 M9): the iteration the project was made from, and - // each media task's last run here. - const draftLink = await projectIteration(project.dir); - const draftRunsNow = draftLink.ok ? await draftRuns(project.dir) : {}; - - // Provenance splits by SHAPE: a scalar or a URL stays in the table; a long - // string, or one with a newline, is prose the author wrote and reads as a - // paragraph under Notes. No field is moved or rewritten. - const isProse = (v: unknown) => typeof v === "string" && (v.length > 120 || v.includes("\n")); - const scalars = Object.entries(p).filter(([, v]) => !isProse(v) && (typeof v !== "object" || v === null)); - const prose = Object.entries(p).filter(([, v]) => isProse(v)) as [string, string][]; - const structured = Object.entries(p).filter(([, v]) => typeof v === "object" && v !== null); - const days = (ms: number) => Math.floor((Date.now() - ms) / 86_400_000); - - // ---- what a clip's "mix" link opens --------------------------------------- - // - // The widest cached RAW window, not the built segment. Three reasons: it - // exists as soon as a clip has been fetched once (segments only exist after a - // build), it has NO CHROME burned in -- which is what a mix is looking at -- - // and it is the file the bench already has peaks for. The built segment is the - // fallback, and the link says which it is. - // - // start/end are the clip's window MINUS the file's own start, because a mix - // spec is relative to the file it names. The arithmetic is exact and known - // here; making the client do it would be a second place to get it wrong. - const mixHref = (e: { - id: string; - start: number; - end: number; - widest: { name: string; path: string; from: number } | null; - segment: string | null; - }): string | null => { - const q = new URLSearchParams(); - if (e.widest) { - // The window's own path, not a rebuild of it: the editor fetches into - // the corpus, so "out/clips-raw/<name>" is a file that is not there. - q.set("body", e.widest.path); - q.set("start", (e.start - e.widest.from).toFixed(2)); - q.set("end", (e.end - e.widest.from).toFixed(2)); - } else if (e.segment) { - q.set("body", path.join(project.dir, e.segment)); - } else { - return null; - } - q.set("from", project.id); - q.set("clip", e.id); - return `/mix?${q}`; - }; + // The tabs' counts: cheap, from the manifest already read. + const drafted = draftedFields(m).filter((d) => !isCodeDraft(d.provenance)).length; + const recordings = new Set(clipsOf(m).map((e: { video: string }) => `${channelFor(m, e)}/${e.video}`)).size; + const props = { project, detail, search }; return ( <div className="flex h-full flex-col"> - <BrowseHeader - crumbs={[{ href: "/browse", label: "projects" }, { label: project.id }]} + <PieceFrame + project={project.id} + title={typeof m.title === "string" && m.title ? m.title : project.id} + frame={frame} + tab={tab} + counts={{ cut: clips.length, media: drafted, sources: recordings }} note={ `${clips.length} clips` + (nonClips.length ? ` · ${nonClips.length} other` : "") + ` · ${hms(runtime)} · ${build.built ? "built" : "not built"}` } - /> - - <div className="flex flex-wrap items-start gap-3 border-b border-[var(--color-line)] px-4 py-2"> - <div className="min-w-0 flex-1"> - <h1 className="truncate text-[15px] text-[var(--color-text)]">{m.title}</h1> - {m.subtitle && <p className="text-[12px] text-[var(--color-dim)]">{m.subtitle}</p>} - <div className="num mt-1 flex flex-wrap items-center gap-x-3 text-[11px] text-[var(--color-dim)]"> - {typeof p.channel === "string" && p.channel && <span>{p.channel}</span>} - {m.generatedOn && <span>generated {m.generatedOn}</span>} - {typeof p.videosCited === "number" && <span>{p.videosCited} videos cited</span>} - {typeof p.enumeratedMatches === "number" && ( - <span>{p.enumeratedMatches} enumerated matches</span> - )} - </div> - </div> - {/* ---- the way in ---- - Every clip row carries a bench link, which is the right control for - "go to that one" and the wrong one for "start". Reviewing a cut is - watching every clip in order, and the first clip is where that - begins -- so it is a button in the title bar rather than the - eleventh link on a page whose first screenful is decisions, - sources and the build chain. */} - {clips.length > 0 && ( - <div data-walk-cut="" className="flex flex-col items-start gap-1"> - {/* Where the walk STARTS is where the walk goes: the first clip - that still needs an answer and can be played. A cut whose - first clip is already judged (or not fetched) would otherwise - open on a clip `n` immediately leaves. */} - <Link - href={`/browse/${project.id}/clip/${walkStart}`} - data-walk-start={walkStart} - className={buttonVariants({ variant: "primary", size: "lg" })} - > - Walk the cut → start at {walkStart} - </Link> - <span className="text-[11px] text-[var(--color-dim)]" data-walk-progress=""> - <kbd>p</kbd> / <kbd>n</kbd> move between clips · {review.reviewed} of {review.total}{" "} - reviewed{review.incorrect > 0 ? ` · ${review.incorrect} incorrect` : ""} - {" · "} - <span data-ready-count=""> - ready {readiness.ready} of {readiness.needing} needing judgement - </span> - </span> - </div> - )} - {/* Alternative renders of part of the cut, made elsewhere and judged - on their own page. Only when there is a takes/ to look at. */} - {/* The narration script, card by card, before synthesis -- only when - some card carries one. */} - {narrated > 0 && ( - <Link - href={`/browse/${project.id}/narration`} - data-narration-link={narrated} - className={buttonVariants({ size: "lg" })} - > - Narration — {narrated} - </Link> - )} - {/* Every drafted field, judged before a final build -- only when a - draft task wrote one, or kept an alternative. */} - {(draftedCount > 0 || alternativesCount > 0) && ( - <Link - href={`/browse/${project.id}/review`} - data-review-link={draftedCount} - className={buttonVariants({ size: "lg" })} - > - Review drafts — {draftedCount} - </Link> - )} - {takes.exists && ( - <Link - href={`/browse/${project.id}/takes`} - data-takes-link={takes.takes.length} - className={buttonVariants({ size: "lg" })} - > - Takes — {takes.takes.length} - </Link> - )} - {build.built && ( - <div className="text-right text-[11px] text-[var(--color-dim)]"> - <div className="font-mono text-[var(--color-text)]">{build.slug}.mp4</div> - <div className="num"> - {fmtBytes(build.finalSize)} · {fmtAgo(build.finalMtimeMs)} - </div> - {/* No window: the whole thing is the point of a deliverable link. */} - <Link - href={`/mix?body=${encodeURIComponent(build.finalPath)}&from=${encodeURIComponent(project.id)}`} - data-mix-deliverable="" - className="text-[var(--color-sel)] hover:underline" - > - open in mix - </Link> - </div> - )} - <div className="flex basis-full justify-end sm:basis-auto"> - <DeleteProject project={project.id} /> - </div> - </div> - - <NotesProvider target={{ project: project.id }}> - <main className="deck-main flex-1 space-y-4 p-4"> - <GeneratedBanner generatedBy={typeof m.generatedBy === "string" ? m.generatedBy : null} /> - {/* --- the author's own account of the cut, first ------------------ */} - {readme && ( - <section data-readme="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> - <div className="max-h-[40vh] overflow-y-auto"> - <Markdown text={readme} /> - </div> - </section> - )} - - {/* --- what is wrong, first ------------------------------------- */} - {decisions.length > 0 && ( - <section data-project={project.id}> - <h2 className="micro mb-1.5"> - {decisions.filter((d) => d.severity !== "info").length} waiting of {decisions.length} - </h2> - <ul className="space-y-1"> - {decisions.map((d, i) => ( - <li - key={`${d.kind}-${d.target}-${i}`} - data-decision={d.kind} - data-severity={d.severity} - data-target={d.target} - className="flex flex-wrap items-baseline gap-2 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-1.5" - > - <span className={badgeVariants({ variant: TONE[d.severity], size: "sm" })}> - {d.severity} - </span> - <span className="font-mono text-[12px] text-[var(--color-text)]">{d.target}</span> - <span className="text-[12px] text-[var(--color-dim)]">{d.why}</span> - <span className="micro ml-auto">{d.kind}</span> - </li> - ))} - </ul> - </section> - )} - - {/* --- the sources ---------------------------------------------- */} - <section data-sources="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> - <div className="mb-1 flex flex-wrap items-baseline gap-3"> - <h2 className="micro"> - sources — {sources.rows.length} - </h2> - <span className="num text-[11px] text-[var(--color-dim)]" data-sources-checked={sources.checkedAtMs ? String(Math.round(sources.checkedAtMs)) : "never"}> - {sources.checkedAtMs - ? `availability checked ${days(sources.checkedAtMs)} d ago` - : "availability never checked"} - </span> - <span className="ml-auto"> - <CheckSourcesButton projects={[project.id]} label="re-check availability" /> - </span> - </div> - {/* Beside the sources, because these ARE the sources: tagging them in - the archive is a statement about the recordings this table lists, - and the count in the control is the count in its heading. */} - <div className="mt-1.5"> - <TagCitedButton project={project.id} /> - </div> - <div className="num text-[11px] text-[var(--color-dim)]"> - cues from <code className="font-mono">{channelsDir}</code> - {shadowExists && ( - <span className="ml-2 text-[var(--color-meter)]"> - (this project’s own shadow tree) - </span> - )} - {" · "}QR codes resolve to{" "} - <code className="font-mono">{String(p.siteOrigin ?? "") || "(nothing — siteOrigin is unset)"}</code> - </div> - {sources.rows.length > 0 && ( - <div className="mt-2 overflow-x-auto"> - <table className="w-full border-collapse text-[11px]"> - <thead> - <tr className="micro text-left"> - <th className="px-1.5 py-0.5">source</th> - <th className="px-1.5 py-0.5">clips</th> - <th className="px-1.5 py-0.5">cues</th> - <th className="px-1.5 py-0.5">coverage</th> - <th className="px-1.5 py-0.5">availability</th> - <th className="px-1.5 py-0.5">cite target</th> - </tr> - </thead> - <tbody> - {sources.rows.map((r) => { - const a = r.availability; - return ( - <tr - key={r.key} - data-source={r.key} - data-cues={r.cues} - data-cue-gap={r.coverageGap ? r.coverageGap.clip : ""} - data-availability={a ? a.state : "never"} - data-cite-override={r.cite.differs ? "1" : "0"} - className="border-t border-[var(--color-line)] align-top" - > - <td className="px-1.5 py-1"> - <a href={r.cite.override ?? r.cite.derived} target="_blank" rel="noreferrer" className="font-mono text-[var(--color-sel)] hover:underline"> - {r.key} - </a> - {r.title && <div className="truncate text-[var(--color-dim)]" style={{ maxWidth: "24rem" }}>{r.title}</div>} - </td> - <td className="px-1.5 py-1 font-mono"> - {r.clips.map((c, i) => ( - <span key={c}> - {i > 0 && " "} - <Link href={`/browse/${project.id}/clip/${c}`} className="text-[var(--color-sel)] hover:underline"> - {c} - </Link> - </span> - ))} - </td> - <td className="px-1.5 py-1"> - {r.cues === "missing" ? ( - <Pill tone="blocking">missing</Pill> - ) : r.cues === "no-punctuation" ? ( - <Pill>no punctuation</Pill> - ) : ( - <span className="text-[var(--color-dim)]">present</span> - )} - </td> - <td className="num px-1.5 py-1"> - {r.coverageGap ? ( - <span className="text-[var(--color-dirty)]"> - cues end {r.coverageGap.cuesEnd.toFixed(0)} s · {r.coverageGap.clip} needs {r.coverageGap.needs.toFixed(0)} s - </span> - ) : r.cuesEnd != null ? ( - <span className="text-[var(--color-dim)]">cues to {r.cuesEnd.toFixed(0)} s</span> - ) : ( - <span className="text-[var(--color-dim)]">—</span> - )} - </td> - <td className="num px-1.5 py-1"> - {a ? ( - <span className={a.ok ? "text-[var(--color-dim)]" : "text-[var(--color-bad)]"} title={a.error ?? undefined}> - {a.state} · {days(a.checkedAtMs)} d ago - </span> - ) : ( - <span className="text-[var(--color-dim)]">never checked</span> - )} - </td> - <td className="px-1.5 py-1"> - {r.cite.differs ? ( - <span className="text-[var(--color-dim)]"> - <Pill>citeUrl</Pill>{" "} - <a href={r.cite.override!} target="_blank" rel="noreferrer" className="font-mono text-[var(--color-sel)] hover:underline"> - override - </a> - </span> - ) : ( - <span className="text-[var(--color-dim)]">derived</span> - )} - </td> - </tr> - ); - })} - </tbody> - </table> - </div> - )} - </section> - - {/* --- building it ---------------------------------------------- */} - <ReportBuildChain - project={project.id} - entries={entries.map((e) => ({ id: e.id, kind: e.kind }))} - /> - - {/* --- drafting it ----------------------------------------------- */} - {/* Each draftable section drafted by a model, as a step on the - iteration the project was made from. After the build chain (a - draft changes what the next build makes), before the sections it - writes into. */} - <DraftPanel project={project.id} link={draftLink} rows={draftRowsOf(m as Record<string, unknown>)} runs={draftRunsNow} /> - - {/* --- what is drawn over it --------------------------------------- */} - {/* The on-screen panel: its settings, its words and a live preview of - both. After the build chain, because "re-render on-screen" is a run - of that chain over segments it already built; before Deliver, - because the panel is part of the video that gets delivered. */} - <OnscreenSection - project={project.id} - generatedBy={typeof m.generatedBy === "string" ? m.generatedBy : null} - entries={entries.map((e) => ({ id: e.id, kind: e.kind, segment: !!e.segment }))} - built={!!build.built} - /> - - {/* --- delivering it --------------------------------------------- */} - {/* After the build chain, because that is the order the work happens - in: the video is one deliverable and the written report with its - own clip files is the other, and both wait on the same walk. */} - <DeliverSection project={project} manifest={m} entries={entries} /> - - {/* --- the timeline --------------------------------------------- */} - <section> - <h2 className="micro mb-1.5"> - the cut — {entries.length} entries, in array order - </h2> - {/* The gap between "ready" and "needing", closed in one press. Every - row below it that reads "not fetched yet" is one of these, and - closing them one bench page at a time was the loop this replaces. - The default pad is the fetch route's own (±20 s), so a clip - fetched here and a clip fetched from the bench land in the same - file. */} - {pendingFetch.length > 0 && ( - <div className="mb-1.5"> - <FetchUnfetchedButton - project={project.id} - pending={pendingFetch.map((id) => ({ id, padBefore: 20, padAfter: 20 }))} - /> - </div> - )} - <TimelineList project={project.id} count={entries.length}> - {entries.map((e, at) => { - // Anything that is not a CLIP renders generically. The timeline's - // vocabulary is open -- one real manifest carries `scroll` and - // `chart` beside its cards -- and a page that only knows two words - // either crashes on the third or silently drops it. - if (e.kind !== "clip") { - return ( - <li - key={`${e.id}@${at}`} - data-entry={e.id} - data-kind={e.kind} - data-at={at} - tabIndex={0} - className="flex flex-wrap items-baseline gap-2 rounded border border-dashed border-[var(--color-line)] px-3 py-1.5 text-[12px] outline-none focus:border-[var(--color-sel)]" - > - <RowControls id={e.id} at={at} /> - <span className="font-mono text-[var(--color-dim)]">{e.id}</span> - <Pill>{e.style ? `${e.kind} · ${e.style}` : e.kind}</Pill> - <span className="text-[var(--color-text)]"> - {e.heading ?? e.title ?? e.label ?? ""} - </span> - {e.seconds != null && <span className="num micro ml-auto">{e.seconds}s</span>} - <div className="basis-full"> - <RowNotes id={e.id} project={project.id} /> - </div> - </li> - ); - } - // `endsSentence === null` means the source has no punctuation to - // read, which is a different thing to say than "this cut is fine". - const midSentence = e.endsSentence === false && !e.lockEnd && !e.lock; - return ( - <li - key={`${e.id}@${at}`} - data-entry={e.id} - data-kind="clip" - data-at={at} - tabIndex={0} - data-cached={e.cached ? "1" : "0"} - data-fetched={e.fetched ? "1" : "0"} - data-mid-sentence={midSentence ? "1" : "0"} - className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-1.5 outline-none focus:border-[var(--color-sel)]" - > - <div className="flex flex-wrap items-baseline gap-2 text-[12px]"> - <RowControls id={e.id} at={at} /> - <span className="font-mono text-[var(--color-sel)]">{e.id}</span> - <span className="num font-mono text-[11px] text-[var(--color-dim)]"> - {e.video} {hms(e.start)}–{hms(e.end)} ({(e.end - e.start).toFixed(1)}s) - </span> - {e.lock && <Pill>locked</Pill>} - {!e.lock && e.lockStart && <Pill>start pinned</Pill>} - {!e.lock && e.lockEnd && <Pill>end pinned</Pill>} - {/* The PLAYER's question, and the walk's: is this clip - watchable end to end right now. `data-cached` keeps the - BUILD's -- the padded window it would fetch -- because - the build chain reads it and they are different. */} - {e.fetched ? ( - <Pill>cached</Pill> - ) : ( - <Pill tone="open"> - not fetched yet - </Pill> - )} - {e.segment && <Pill>segment built</Pill>} - {!e.hasCues && ( - <Pill tone={TONE.blocking}>no cues</Pill> - )} - {midSentence && <Pill tone="open">ends mid-sentence</Pill>} - {e.noPunctuation && <Pill>source unpunctuated</Pill>} - {e.proposed && ( - <Pill tone="open"> - widener would move it - </Pill> - )} - <span className="ml-auto flex items-center gap-2"> - {mixHref(e) ? ( - <Link - href={mixHref(e)!} - data-mix-link={e.id} - className="text-[11px] text-[var(--color-sel)] hover:underline" - > - mix - </Link> - ) : ( - // Never a dead link that 400s: a clip with nothing - // fetched has nothing to open. - <span className="micro" data-mix-link-disabled={e.id}> - fetch it first - </span> - )} - <Link - href={`/browse/${project.id}/clip/${e.id}`} - data-bench-link={e.id} - className="text-[11px] text-[var(--color-sel)] hover:underline" - > - bench → - </Link> - <span className="micro">§{e.section ?? 0}</span> - </span> - </div> - {(showAll || midSentence || e.proposed) && e.quote && ( - <p className="mt-1 text-[11px] leading-snug text-[var(--color-dim)]"> - “{String(e.quote).slice(0, 240)} - {String(e.quote).length > 240 ? "…" : ""}” - </p> - )} - {midSentence && e.endCueText && ( - <p className="num mt-1 text-[11px] text-[var(--color-dirty)]"> - cut lands inside: “…{String(e.endCueText).trim().slice(-64)}” - </p> - )} - {e.proposed && ( - <p className="num mt-1 text-[11px] text-[var(--color-dirty)]"> - resolve-windows would make it {hms(e.proposed.start)}–{hms(e.proposed.end)} — - set <code className="font-mono">lock</code> if this window is deliberate - </p> - )} - <RowNotes id={e.id} project={project.id} /> - </li> - ); - })} - </TimelineList> - <div className="mt-2"> - <Link - href={`/browse/${project.id}${showAll ? "" : "?all=1"}`} - className="text-[11px] text-[var(--color-sel)] hover:underline" - > - {showAll ? "hide quotes" : "show every quote"} - </Link> - </div> - </section> - - {/* --- corrections ------------------------------------------------ */} - {/* - Not a decision and not a defect in the CUT: a correction says the - REPORT got something wrong -- wrong speaker, wrong addressee, wrong - date -- and the fix belongs to the next sweep, not to this manifest. - So it is collected here rather than filed in the inbox, in the same - shape `umtool corrections` prints, because the list's real destination - is somebody's next prompt. - */} - {corrections.length > 0 && ( - <section - data-corrections="" - className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2" - > - <h2 className="micro mb-1.5"> - corrections for the next pass —{" "} - {corrections.filter((c) => c.verdict === "incorrect").length} - {corrections.some((c) => c.verdict !== "incorrect") && - ` · ${corrections.filter((c) => c.verdict !== "incorrect").length} notes on confirmed clips`} - </h2> - <ul className="space-y-1.5"> - {corrections.map((c) => ( - <li - key={c.id} - data-correction={c.id} - data-correction-verdict={c.verdict} - className="text-[12px] leading-snug" - > - {/* A note on a CONFIRMED clip is not a defect, and a reader - who cannot tell the two apart goes off to fix a clip - nobody complained about. */} - {c.verdict !== "incorrect" && <Pill>note · confirmed</Pill>}{" "} - <Link - href={`/browse/${project.id}/clip/${c.id}`} - className="font-mono text-[11px] text-[var(--color-sel)] hover:underline" - > - {c.id} - </Link>{" "} - <span className="text-[11px] text-[var(--color-dim)]"> - {c.channel}/{c.video} @ {hms(c.at)} - </span>{" "} - <a - href={c.href} - target="_blank" - rel="noreferrer" - className="text-[11px] text-[var(--color-sel)] hover:underline" - > - the moment - </a> - <div className="text-[var(--color-dim)]">{c.text}</div> - </li> - ))} - </ul> - <p className="mt-2 text-[11px] text-[var(--color-dim)]"> - <code className="font-mono">umtool corrections {project.id}</code> prints the same - list as markdown, with the moment links, ready to paste into the next sweep. - </p> - </section> - )} - - {/* --- revisions ------------------------------------------------- */} - <section data-revisions="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> - <div className="mb-1 flex flex-wrap items-baseline gap-3"> - <h2 className="micro">revisions — {snapshots.length}</h2> - <span className="ml-auto"> - <SnapshotButton project={project.id} /> - </span> - </div> - {snapshots.length === 0 ? ( - <p className="text-[11px] text-[var(--color-dim)]"> - no snapshots. One copies <code className="font-mono">video.manifest.json</code> into{" "} - <code className="font-mono">revisions/</code>; a build that stamps a deliverable aside - takes one of the manifest that made it. - </p> - ) : ( - <ul className="space-y-1"> - {snapshots.map((sn, i) => { - const d = diffs[i]; - const summary = !d - ? "unreadable" - : d.same - ? "same timeline as now" - : Object.entries(d.counts).map(([k, n]) => `${n} ${k}`).join(" · "); - return ( - <li - key={sn.rel} - data-snapshot={sn.rel} - data-legacy={sn.legacy ? "1" : "0"} - data-diff={d ? d.changes.length : "x"} - className="text-[11px]" - > - <details> - <summary className="flex cursor-pointer flex-wrap items-baseline gap-2"> - <span className="font-mono text-[var(--color-text)]">{sn.rel}</span> - {sn.legacy && <Pill>legacy</Pill>} - {sn.label && !sn.legacy && <Pill>{sn.label}</Pill>} - <span className="num text-[var(--color-dim)]">{fmtAgo(sn.mtimeMs)}</span> - <span className={`num ml-auto ${d && !d.same ? "text-[var(--color-dirty)]" : "text-[var(--color-dim)]"}`}> - {summary} - </span> - </summary> - {d && !d.same && ( - <pre className="mt-1 max-h-56 overflow-auto rounded bg-[var(--color-ink)] p-2 font-mono text-[11px] text-[var(--color-dim)]"> - {d.changes.map((c) => formatChange(c)).join("\n")} - </pre> - )} - </details> - </li> - ); - })} - </ul> - )} - </section> - - {/* --- the upload's text (out/youtube.txt, or its preview) --------- */} - <YoutubeSection dir={project.dir} manifest={m as Record<string, unknown>} /> - - {/* --- exports --------------------------------------------------- */} - <section data-exports="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> - <h2 className="micro mb-1">export</h2> - {variants.length === 0 ? ( - <p className="text-[11px] text-[var(--color-dim)]"> - nothing built to export from — a TOC needs the build’s chapter offsets, and there is - no <code className="font-mono">chapters.ffmeta</code> and no segments under{" "} - <code className="font-mono">out/</code> - </p> - ) : ( - variants.map((v) => ( - <div key={v} className="flex flex-wrap items-center gap-1.5 text-[11px]" data-export-variant={v}> - <span className="w-14 font-mono text-[var(--color-dim)]">{v}</span> - {EXPORT_FORMATS.map((f) => ( - <CopyButton - key={f} - label={f} - title={`copy the ${f} for the ${v} cut`} - url={`/api/report/export?project=${encodeURIComponent(project.id)}&format=${f}&variant=${v}`} - /> - ))} - <PodcastExport - project={project.id} - variant={v} - files={podcasts.get(v) ?? { m4a: null, mp3: null, notes: null }} - /> - </div> - )) - )} - </section> - - {/* --- provenance, as written; prose under notes ------------------- */} - <section data-provenance=""> - <h2 className="micro mb-1.5">provenance</h2> - <dl className="grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2 text-[11px]"> - {scalars.map(([k, v]) => ( - <div key={k} className="contents"> - <dt className="micro">{k}</dt> - <dd className="num break-all text-[var(--color-dim)]"> - {typeof v === "string" && /^https?:\/\//.test(v) ? ( - <a href={v} target="_blank" rel="noreferrer" className="text-[var(--color-sel)] hover:underline"> - {v} - </a> - ) : ( - String(v) - )} - </dd> - </div> - ))} - {structured.map(([k, v]) => ( - <div key={k} className="contents"> - <dt className="micro">{k}</dt> - <dd className="font-mono text-[var(--color-dim)]">{JSON.stringify(v).slice(0, 200)}</dd> - </div> - ))} - </dl> - </section> - - {(prose.length > 0 || noteFiles.length > 0) && ( - <section data-notes=""> - <h2 className="micro mb-1.5">notes</h2> - <div className="space-y-2 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> - {prose.map(([k, v]) => ( - <div key={k} data-note={k}> - <div className="text-[12px] font-semibold text-[var(--color-text)]">{k}</div> - <p className="whitespace-pre-wrap text-[12px] leading-relaxed text-[var(--color-dim)]">{v}</p> - </div> - ))} - {noteFiles.map((n, i) => ( - <details key={n} data-note-file={n}> - <summary className="cursor-pointer font-mono text-[12px] text-[var(--color-sel)]">{n}</summary> - <div className="mt-1 max-h-[50vh] overflow-y-auto"> - <Markdown text={noteTexts[i]} /> - </div> - </details> - ))} - </div> - </section> - )} - </main> - </NotesProvider> + more={ + <> + <span className="px-2 pb-1 pt-0.5 font-mono text-[11px] text-muted">{project.id}</span> + <DeleteProject project={project.id} /> + </> + } + > + <NotesProvider target={{ project: project.id }}> + <main className="deck-main flex-1 space-y-4 p-4" data-piece-tab={tab}> + <GeneratedBanner generatedBy={typeof m.generatedBy === "string" ? m.generatedBy : null} /> + {tab === "overview" && <OverviewTab {...props} frame={frame} />} + {tab === "cut" && <CutTab {...props} />} + {tab === "media" && <MediaTab {...props} />} + {tab === "build" && <BuildTab {...props} />} + {tab === "deliver" && <DeliverTab {...props} />} + {tab === "sources" && <SourcesTab {...props} />} + {tab === "history" && <HistoryTab {...props} />} + </main> + </NotesProvider> + </PieceFrame> </div> ); } diff --git a/umtool/components/projects/ReviewPage.tsx b/umtool/components/projects/ReviewPage.tsx @@ -1,4 +1,5 @@ import BrowseHeader from "@/components/BrowseHeader"; +import { projectHref, projectsHref } from "@/lib/hrefs"; import { readManifest } from "@/lib/projects/report.mjs"; import { manifestToken } from "@/lib/report/manifest.mjs"; import { draftsView } from "@/lib/report/drafts.mjs"; @@ -19,8 +20,8 @@ export default async function ReviewPage({ project }: { project: ProjectRef }) { <div className="flex h-full flex-col"> <BrowseHeader crumbs={[ - { href: "/browse", label: "projects" }, - { href: `/browse/${project.id}`, label: project.id }, + { href: projectsHref(), label: "projects" }, + { href: projectHref(project.id), label: project.id }, { label: "review" }, ]} note={ diff --git a/umtool/components/projects/StructureEditors.tsx b/umtool/components/projects/StructureEditors.tsx @@ -193,7 +193,7 @@ function PostsEditor({ <div data-testid="posts-editor" className="space-y-1"> <div className="flex items-center gap-2"> <span className="micro">posts — {posts.length}</span> - <button type="button" data-testid="post-add" onClick={() => setAdding((a) => !a)} className="text-[11px] text-[var(--color-sel)] hover:underline"> + <button type="button" data-testid="post-add" onClick={() => setAdding((a) => !a)} className="ink-link text-[11px]"> + post </button> </div> diff --git a/umtool/components/projects/TakesPage.tsx b/umtool/components/projects/TakesPage.tsx @@ -24,7 +24,7 @@ export default async function TakesPage({ project }: { project: ProjectRef }) { rail="collapsed" crumbs={[ { href: browseHref(), label: "projects" }, - { href: projectHref(project.id), label: project.id }, + { href: projectHref(project.id, { tab: "cut" }), label: project.id }, { label: "takes" }, ]} note={takes.length ? `${takes.length} takes · ${judged} judged` : undefined} @@ -33,7 +33,7 @@ export default async function TakesPage({ project }: { project: ProjectRef }) { {takes.length === 0 ? ( <p data-takes-empty="" className="text-[12px] text-[var(--color-dim)]"> No takes yet.{" "} - <Link href={`/projects/${project.id}`} className="ink-link"> + <Link href={projectHref(project.id, { tab: "cut" })} className="ink-link"> back to {project.id} </Link> </p> diff --git a/umtool/components/projects/report/BuildTab.tsx b/umtool/components/projects/report/BuildTab.tsx @@ -0,0 +1,53 @@ +import Link from "next/link"; +import { fmtAgo, fmtBytes } from "@/lib/format"; +import { mixHref } from "@/lib/hrefs"; +import OnscreenSection from "../OnscreenSection"; +import ReportBuildChain from "../ReportBuildChain"; +import type { ReportTabProps } from "./shared"; + +// The Build tab: the final video, the build chain, and the on-screen panel -- +// OnscreenSection parked here WHOLE until P4b gives on-screen its own Media +// surface. Moved from ReportProject unchanged (P4a-1). + +export default function BuildTab({ project, detail }: ReportTabProps) { + const { manifest: m, build, entries } = detail; + return ( + <> + {build.built && ( + <div className="flex flex-wrap items-baseline gap-x-3 gap-y-1 text-[12px] text-[var(--color-dim)]" data-final-video=""> + <span className="micro">final video</span> + <span className="font-mono text-[var(--color-text)]">{build.slug}.mp4</span> + <span className="num"> + {fmtBytes(build.finalSize)} · {fmtAgo(build.finalMtimeMs)} + </span> + {/* No window: the whole thing is the point of a deliverable link. */} + <Link + href={mixHref({ body: build.finalPath, from: project.id })} + data-mix-deliverable="" + className="ink-link" + > + open in mix + </Link> + </div> + )} + {/* --- building it ---------------------------------------------- */} + <ReportBuildChain + project={project.id} + entries={entries.map((e) => ({ id: e.id, kind: e.kind }))} + /> + + {/* --- what is drawn over it --------------------------------------- */} + {/* The on-screen panel: its settings, its words and a live preview of + both. After the build chain, because "re-render on-screen" is a run + of that chain over segments it already built; before Deliver, + because the panel is part of the video that gets delivered. */} + <OnscreenSection + project={project.id} + generatedBy={typeof m.generatedBy === "string" ? m.generatedBy : null} + entries={entries.map((e) => ({ id: e.id, kind: e.kind, segment: !!e.segment }))} + built={!!build.built} + /> + + </> + ); +} diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx @@ -0,0 +1,341 @@ +import Link from "next/link"; +import path from "node:path"; +import { + correctionsOf, + reviewOf, + unfetchedNeedingJudgement, + walkReadiness, +} from "@/lib/projects/report.mjs"; +import { listTakes } from "@/lib/report/takes.mjs"; +import { buttonVariants } from "@/components/ui/button"; +import { clipBenchHref, mixHref as toolsMixHref, projectHref, takesHref } from "@/lib/hrefs"; +import FetchUnfetchedButton from "../FetchUnfetchedButton"; +import { RowControls, RowNotes, TimelineList } from "../TimelineEditor"; +import { Pill, TONE, hms, type ReportTabProps } from "./shared"; + +// The Cut tab: the timeline, read back -- the walk into it, its takes, every +// entry with what is wrong with it, and the corrections the walk collected. +// Moved from ReportProject unchanged (P4a-1). + +export default async function CutTab({ project, detail, search }: ReportTabProps) { + const { manifest: m, entries } = detail; + const corrections = correctionsOf(m) as { + id: string; + channel: string | null; + video: string; + at: number; + href: string; + text: string; + verdict: "confirmed" | "incorrect" | "unreviewed"; + }[]; + const clips = entries.filter((e) => e.kind === "clip"); + // How much of the cut has been walked. One definition, shared with the bench + // header and `umtool corrections`. + const review = reviewOf(m); + // And how much of it can be walked TODAY: the walk visits the clips that + // still need judgement and have something to play, so the gap between these + // two numbers is what is waiting on a download rather than on somebody. + const readiness = walkReadiness(clips); + // What the walk is waiting on: the same clips the rows below mark "not + // fetched yet". + const pendingFetch = unfetchedNeedingJudgement(clips) as string[]; + const walkStart = (readiness.readyIds[0] as string | undefined) ?? clips[0]?.id; + const showAll = search.all === "1"; + const takes = await listTakes(project.dir); + + // ---- what a clip's "mix" link opens --------------------------------------- + // + // The widest cached RAW window, not the built segment. Three reasons: it + // exists as soon as a clip has been fetched once (segments only exist after a + // build), it has NO CHROME burned in -- which is what a mix is looking at -- + // and it is the file the bench already has peaks for. The built segment is the + // fallback, and the link says which it is. + // + // start/end are the clip's window MINUS the file's own start, because a mix + // spec is relative to the file it names. The arithmetic is exact and known + // here; making the client do it would be a second place to get it wrong. + const mixHref = (e: { + id: string; + start: number; + end: number; + widest: { name: string; path: string; from: number } | null; + segment: string | null; + }): string | null => { + const q = new URLSearchParams(); + if (e.widest) { + // The window's own path, not a rebuild of it: the editor fetches into + // the corpus, so "out/clips-raw/<name>" is a file that is not there. + q.set("body", e.widest.path); + q.set("start", (e.start - e.widest.from).toFixed(2)); + q.set("end", (e.end - e.widest.from).toFixed(2)); + } else if (e.segment) { + q.set("body", path.join(project.dir, e.segment)); + } else { + return null; + } + q.set("from", project.id); + q.set("clip", e.id); + return `${toolsMixHref()}?${q}`; + }; + + return ( + <> + <div className="flex flex-wrap items-start gap-3"> + {/* ---- the way in ---- + Every clip row carries a bench link, which is the right control for + "go to that one" and the wrong one for "start". Reviewing a cut is + watching every clip in order, and the first clip is where that + begins -- so it is a button in the title bar rather than the + eleventh link on a page whose first screenful is decisions, + sources and the build chain. */} + {clips.length > 0 && ( + <div data-walk-cut="" className="flex flex-col items-start gap-1"> + {/* Where the walk STARTS is where the walk goes: the first clip + that still needs an answer and can be played. A cut whose + first clip is already judged (or not fetched) would otherwise + open on a clip `n` immediately leaves. */} + <Link + href={clipBenchHref(project.id, walkStart)} + data-walk-start={walkStart} + className={buttonVariants({ variant: "go", size: "lg" })} + > + Walk the cut → start at {walkStart} + </Link> + <span className="text-[11px] text-[var(--color-dim)]" data-walk-progress=""> + <kbd>p</kbd> / <kbd>n</kbd> move between clips · {review.reviewed} of {review.total}{" "} + reviewed{review.incorrect > 0 ? ` · ${review.incorrect} incorrect` : ""} + {" · "} + <span data-ready-count=""> + ready {readiness.ready} of {readiness.needing} needing judgement + </span> + </span> + </div> + )} + {/* Alternative renders of part of the cut, made elsewhere and judged + on their own page. Only when there is a takes/ to look at. */} + {takes.exists && ( + <Link + href={takesHref(project.id)} + data-takes-link={takes.takes.length} + className={buttonVariants({ size: "lg" })} + > + Takes — {takes.takes.length} + </Link> + )} + </div> + + {/* --- the timeline --------------------------------------------- */} + <section> + <h2 className="micro mb-1.5"> + the cut — {entries.length} entries, in array order + </h2> + {/* The gap between "ready" and "needing", closed in one press. Every + row below it that reads "not fetched yet" is one of these, and + closing them one bench page at a time was the loop this replaces. + The default pad is the fetch route's own (±20 s), so a clip + fetched here and a clip fetched from the bench land in the same + file. */} + {pendingFetch.length > 0 && ( + <div className="mb-1.5"> + <FetchUnfetchedButton + project={project.id} + pending={pendingFetch.map((id) => ({ id, padBefore: 20, padAfter: 20 }))} + /> + </div> + )} + <TimelineList project={project.id} count={entries.length}> + {entries.map((e, at) => { + // Anything that is not a CLIP renders generically. The timeline's + // vocabulary is open -- one real manifest carries `scroll` and + // `chart` beside its cards -- and a page that only knows two words + // either crashes on the third or silently drops it. + if (e.kind !== "clip") { + return ( + <li + key={`${e.id}@${at}`} + data-entry={e.id} + data-kind={e.kind} + data-at={at} + tabIndex={0} + className="flex flex-wrap items-baseline gap-2 rounded border border-dashed border-[var(--color-line)] px-3 py-1.5 text-[12px] outline-none focus:border-[var(--color-sel)]" + > + <RowControls id={e.id} at={at} /> + <span className="font-mono text-[var(--color-dim)]">{e.id}</span> + <Pill>{e.style ? `${e.kind} · ${e.style}` : e.kind}</Pill> + <span className="text-[var(--color-text)]"> + {e.heading ?? e.title ?? e.label ?? ""} + </span> + {e.seconds != null && <span className="num micro ml-auto">{e.seconds}s</span>} + <div className="basis-full"> + <RowNotes id={e.id} project={project.id} /> + </div> + </li> + ); + } + // `endsSentence === null` means the source has no punctuation to + // read, which is a different thing to say than "this cut is fine". + const midSentence = e.endsSentence === false && !e.lockEnd && !e.lock; + return ( + <li + key={`${e.id}@${at}`} + data-entry={e.id} + data-kind="clip" + data-at={at} + tabIndex={0} + data-cached={e.cached ? "1" : "0"} + data-fetched={e.fetched ? "1" : "0"} + data-mid-sentence={midSentence ? "1" : "0"} + className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-1.5 outline-none focus:border-[var(--color-sel)]" + > + <div className="flex flex-wrap items-baseline gap-2 text-[12px]"> + <RowControls id={e.id} at={at} /> + <span className="font-mono text-[var(--color-text)]">{e.id}</span> + <span className="num font-mono text-[11px] text-[var(--color-dim)]"> + {e.video} {hms(e.start)}–{hms(e.end)} ({(e.end - e.start).toFixed(1)}s) + </span> + {e.lock && <Pill>locked</Pill>} + {!e.lock && e.lockStart && <Pill>start pinned</Pill>} + {!e.lock && e.lockEnd && <Pill>end pinned</Pill>} + {/* The PLAYER's question, and the walk's: is this clip + watchable end to end right now. `data-cached` keeps the + BUILD's -- the padded window it would fetch -- because + the build chain reads it and they are different. */} + {e.fetched ? ( + <Pill>cached</Pill> + ) : ( + <Pill tone="open"> + not fetched yet + </Pill> + )} + {e.segment && <Pill>segment built</Pill>} + {!e.hasCues && ( + <Pill tone={TONE.blocking}>no cues</Pill> + )} + {midSentence && <Pill tone="open">ends mid-sentence</Pill>} + {e.noPunctuation && <Pill>source unpunctuated</Pill>} + {e.proposed && ( + <Pill tone="open"> + widener would move it + </Pill> + )} + <span className="ml-auto flex items-center gap-2"> + {mixHref(e) ? ( + <Link + href={mixHref(e)!} + data-mix-link={e.id} + className="ink-link text-[11px]" + > + mix + </Link> + ) : ( + // Never a dead link that 400s: a clip with nothing + // fetched has nothing to open. + <span className="micro" data-mix-link-disabled={e.id}> + fetch it first + </span> + )} + <Link + href={clipBenchHref(project.id, e.id)} + data-bench-link={e.id} + className="ink-link text-[11px]" + > + bench → + </Link> + <span className="micro">§{e.section ?? 0}</span> + </span> + </div> + {(showAll || midSentence || e.proposed) && e.quote && ( + <p className="mt-1 text-[11px] leading-snug text-[var(--color-dim)]"> + “{String(e.quote).slice(0, 240)} + {String(e.quote).length > 240 ? "…" : ""}” + </p> + )} + {midSentence && e.endCueText && ( + <p className="num mt-1 text-[11px] text-[var(--color-dirty)]"> + cut lands inside: “…{String(e.endCueText).trim().slice(-64)}” + </p> + )} + {e.proposed && ( + <p className="num mt-1 text-[11px] text-[var(--color-dirty)]"> + resolve-windows would make it {hms(e.proposed.start)}–{hms(e.proposed.end)} — + set <code className="font-mono">lock</code> if this window is deliberate + </p> + )} + <RowNotes id={e.id} project={project.id} /> + </li> + ); + })} + </TimelineList> + <div className="mt-2"> + <Link + href={projectHref(project.id, { tab: "cut", all: !showAll })} + className="ink-link text-[11px]" + > + {showAll ? "hide quotes" : "show every quote"} + </Link> + </div> + </section> + + {/* --- corrections ------------------------------------------------ */} + {/* + Not a decision and not a defect in the CUT: a correction says the + REPORT got something wrong -- wrong speaker, wrong addressee, wrong + date -- and the fix belongs to the next sweep, not to this manifest. + So it is collected here rather than filed in the inbox, in the same + shape `umtool corrections` prints, because the list's real destination + is somebody's next prompt. + */} + {corrections.length > 0 && ( + <section + data-corrections="" + className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2" + > + <h2 className="micro mb-1.5"> + corrections for the next pass —{" "} + {corrections.filter((c) => c.verdict === "incorrect").length} + {corrections.some((c) => c.verdict !== "incorrect") && + ` · ${corrections.filter((c) => c.verdict !== "incorrect").length} notes on confirmed clips`} + </h2> + <ul className="space-y-1.5"> + {corrections.map((c) => ( + <li + key={c.id} + data-correction={c.id} + data-correction-verdict={c.verdict} + className="text-[12px] leading-snug" + > + {/* A note on a CONFIRMED clip is not a defect, and a reader + who cannot tell the two apart goes off to fix a clip + nobody complained about. */} + {c.verdict !== "incorrect" && <Pill>note · confirmed</Pill>}{" "} + <Link + href={clipBenchHref(project.id, c.id)} + className="ink-link font-mono text-[11px]" + > + {c.id} + </Link>{" "} + <span className="text-[11px] text-[var(--color-dim)]"> + {c.channel}/{c.video} @ {hms(c.at)} + </span>{" "} + <a + href={c.href} + target="_blank" + rel="noreferrer" + className="ink-link text-[11px]" + > + the moment + </a> + <div className="text-[var(--color-dim)]">{c.text}</div> + </li> + ))} + </ul> + <p className="mt-2 text-[11px] text-[var(--color-dim)]"> + <code className="font-mono">umtool corrections {project.id}</code> prints the same + list as markdown, with the moment links, ready to paste into the next sweep. + </p> + </section> + )} + + </> + ); +} diff --git a/umtool/components/projects/report/DeliverTab.tsx b/umtool/components/projects/report/DeliverTab.tsx @@ -0,0 +1,65 @@ +import CopyButton from "@/components/CopyButton"; +import { EXPORT_FORMATS, exportableVariants } from "@/lib/report/export.mjs"; +import { podcastFor } from "@/lib/report/serve.mjs"; +import DeliverSection from "../DeliverSection"; +import PodcastExport from "../PodcastExport"; +import type { ReportTabProps } from "./shared"; + +// The Deliver tab: the deliver panel (cuts, share batches, rulings applied, +// the written report rebuilt) and the exports. Moved from ReportProject +// unchanged (P4a-1). + +export default async function DeliverTab({ project, detail }: ReportTabProps) { + const { manifest: m, entries } = detail; + const variants = await exportableVariants(project.dir); + // Each exportable cut's podcast files, as they are on disk (build-podcast.mjs). + const podcastOf = async (v: string) => { + const f = async (which: "m4a" | "mp3" | "notes") => { + const got = await podcastFor(project, m, v, which); + return got ? { size: got.size, mtimeMs: got.mtimeMs } : null; + }; + return { m4a: await f("m4a"), mp3: await f("mp3"), notes: await f("notes") }; + }; + const podcasts = new Map(await Promise.all(variants.map(async (v) => [v, await podcastOf(v)] as const))); + return ( + <> + {/* --- delivering it --------------------------------------------- */} + {/* After the build chain, because that is the order the work happens + in: the video is one deliverable and the written report with its + own clip files is the other, and both wait on the same walk. */} + <DeliverSection project={project} manifest={m} entries={entries} /> + + {/* --- exports --------------------------------------------------- */} + <section data-exports="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> + <h2 className="micro mb-1">export</h2> + {variants.length === 0 ? ( + <p className="text-[11px] text-[var(--color-dim)]"> + nothing built to export from — a TOC needs the build’s chapter offsets, and there is + no <code className="font-mono">chapters.ffmeta</code> and no segments under{" "} + <code className="font-mono">out/</code> + </p> + ) : ( + variants.map((v) => ( + <div key={v} className="flex flex-wrap items-center gap-1.5 text-[11px]" data-export-variant={v}> + <span className="w-14 font-mono text-[var(--color-dim)]">{v}</span> + {EXPORT_FORMATS.map((f) => ( + <CopyButton + key={f} + label={f} + title={`copy the ${f} for the ${v} cut`} + url={`/api/report/export?project=${encodeURIComponent(project.id)}&format=${f}&variant=${v}`} + /> + ))} + <PodcastExport + project={project.id} + variant={v} + files={podcasts.get(v) ?? { m4a: null, mp3: null, notes: null }} + /> + </div> + )) + )} + </section> + + </> + ); +} diff --git a/umtool/components/projects/report/HistoryTab.tsx b/umtool/components/projects/report/HistoryTab.tsx @@ -0,0 +1,145 @@ +import { readdir, readFile } from "node:fs/promises"; +import path from "node:path"; +import { fmtAgo } from "@/lib/format"; +import { Markdown } from "@/lib/markdown"; +import { diffManifests, formatChange } from "@/lib/report/manifest-diff.mjs"; +import { listSnapshots, readSnapshot } from "@/lib/report/snapshots.mjs"; +import SnapshotButton from "../SnapshotButton"; +import { Pill, type ReportTabProps } from "./shared"; + +// The History tab: the manifest's revisions with what changed since each, +// its provenance as written, and the notes beside it (prose fields and the +// sibling .md files). Moved from ReportProject unchanged (P4a-1). + +export default async function HistoryTab({ project, detail }: ReportTabProps) { + const { manifest: m } = detail; + const p = (m.provenance ?? {}) as Record<string, unknown>; + const snapshots = await listSnapshots(project.dir); + const diffs = await Promise.all( + snapshots.map(async (sn) => { + try { + return diffManifests(await readSnapshot(project.dir, sn.rel), m); + } catch { + return null; + } + }), + ); + // Sibling notes: every .md that is neither the report nor the README. + const names = await readdir(project.dir).catch(() => [] as string[]); + const noteFiles = names.filter((n) => /\.md$/i.test(n) && !/^readme\.md$/i.test(n) && n !== "sweep-report.md").sort(); + const noteTexts = await Promise.all(noteFiles.map((n) => readFile(path.join(project.dir, n), "utf8").catch(() => ""))); + + // Provenance splits by SHAPE: a scalar or a URL stays in the table; a long + // string, or one with a newline, is prose the author wrote and reads as a + // paragraph under Notes. No field is moved or rewritten. + const isProse = (v: unknown) => typeof v === "string" && (v.length > 120 || v.includes("\n")); + const scalars = Object.entries(p).filter(([, v]) => !isProse(v) && (typeof v !== "object" || v === null)); + const prose = Object.entries(p).filter(([, v]) => isProse(v)) as [string, string][]; + const structured = Object.entries(p).filter(([, v]) => typeof v === "object" && v !== null); + return ( + <> + {/* --- revisions ------------------------------------------------- */} + <section data-revisions="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> + <div className="mb-1 flex flex-wrap items-baseline gap-3"> + <h2 className="micro">revisions — {snapshots.length}</h2> + <span className="ml-auto"> + <SnapshotButton project={project.id} /> + </span> + </div> + {snapshots.length === 0 ? ( + <p className="text-[11px] text-[var(--color-dim)]"> + no snapshots. One copies <code className="font-mono">video.manifest.json</code> into{" "} + <code className="font-mono">revisions/</code>; a build that stamps a deliverable aside + takes one of the manifest that made it. + </p> + ) : ( + <ul className="space-y-1"> + {snapshots.map((sn, i) => { + const d = diffs[i]; + const summary = !d + ? "unreadable" + : d.same + ? "same timeline as now" + : Object.entries(d.counts).map(([k, n]) => `${n} ${k}`).join(" · "); + return ( + <li + key={sn.rel} + data-snapshot={sn.rel} + data-legacy={sn.legacy ? "1" : "0"} + data-diff={d ? d.changes.length : "x"} + className="text-[11px]" + > + <details> + <summary className="flex cursor-pointer flex-wrap items-baseline gap-2"> + <span className="font-mono text-[var(--color-text)]">{sn.rel}</span> + {sn.legacy && <Pill>legacy</Pill>} + {sn.label && !sn.legacy && <Pill>{sn.label}</Pill>} + <span className="num text-[var(--color-dim)]">{fmtAgo(sn.mtimeMs)}</span> + <span className={`num ml-auto ${d && !d.same ? "text-[var(--color-dirty)]" : "text-[var(--color-dim)]"}`}> + {summary} + </span> + </summary> + {d && !d.same && ( + <pre className="mt-1 max-h-56 overflow-auto rounded bg-[var(--color-ink)] p-2 font-mono text-[11px] text-[var(--color-dim)]"> + {d.changes.map((c) => formatChange(c)).join("\n")} + </pre> + )} + </details> + </li> + ); + })} + </ul> + )} + </section> + + {/* --- provenance, as written; prose under notes ------------------- */} + <section data-provenance=""> + <h2 className="micro mb-1.5">provenance</h2> + <dl className="grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2 text-[11px]"> + {scalars.map(([k, v]) => ( + <div key={k} className="contents"> + <dt className="micro">{k}</dt> + <dd className="num break-all text-[var(--color-dim)]"> + {typeof v === "string" && /^https?:\/\//.test(v) ? ( + <a href={v} target="_blank" rel="noreferrer" className="ink-link"> + {v} + </a> + ) : ( + String(v) + )} + </dd> + </div> + ))} + {structured.map(([k, v]) => ( + <div key={k} className="contents"> + <dt className="micro">{k}</dt> + <dd className="font-mono text-[var(--color-dim)]">{JSON.stringify(v).slice(0, 200)}</dd> + </div> + ))} + </dl> + </section> + + {(prose.length > 0 || noteFiles.length > 0) && ( + <section data-notes=""> + <h2 className="micro mb-1.5">notes</h2> + <div className="space-y-2 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> + {prose.map(([k, v]) => ( + <div key={k} data-note={k}> + <div className="text-[12px] font-semibold text-[var(--color-text)]">{k}</div> + <p className="whitespace-pre-wrap text-[12px] leading-relaxed text-[var(--color-dim)]">{v}</p> + </div> + ))} + {noteFiles.map((n, i) => ( + <details key={n} data-note-file={n}> + <summary className="cursor-pointer font-mono text-[12px] text-[var(--color-text-2)] hover:text-[var(--color-text)]">{n}</summary> + <div className="mt-1 max-h-[50vh] overflow-y-auto"> + <Markdown text={noteTexts[i]} /> + </div> + </details> + ))} + </div> + </section> + )} + </> + ); +} diff --git a/umtool/components/projects/report/MediaTab.tsx b/umtool/components/projects/report/MediaTab.tsx @@ -0,0 +1,70 @@ +import Link from "next/link"; +import { narrationsOf } from "umtool-report-to-video/narration"; +import { draftedFields, isCodeDraft } from "yt-dlp-transcript-common/lib/report/drafted.mjs"; +import { readAlternatives } from "@/lib/report/drafts.mjs"; +import { draftRowsOf, draftRuns, projectIteration } from "@/lib/articles/projectDraft"; +import { buttonVariants } from "@/components/ui/button"; +import { narrationHref, reviewHref } from "@/lib/hrefs"; +import DraftPanel from "../DraftPanel"; +import YoutubeSection from "../YoutubeSection"; +import type { ReportTabProps } from "./shared"; + +// The Media tab: release 28's drafts as they were on the project page -- the +// narration script and the drafts review, the "Draft with" panel, the upload's +// text. Moved from ReportProject unchanged (P4a-1); P4b absorbs them into one +// Media surface. + +export default async function MediaTab({ project, detail }: ReportTabProps) { + const { manifest: m } = detail; + const narrated = narrationsOf(m).length; + // The drafts review (release 28): drafted fields, and alternatives kept. + // (A field a code path made — the converter's timeline — is not a draft to review.) + const draftedCount = draftedFields(m).filter((d) => !isCodeDraft(d.provenance)).length; + const alternativesCount = (await readAlternatives(project.dir)).length; + // "Draft with" (release 28 M9): the iteration the project was made from, and + // each media task's last run here. + const draftLink = await projectIteration(project.dir); + const draftRunsNow = draftLink.ok ? await draftRuns(project.dir) : {}; + + return ( + <> + {(narrated > 0 || draftedCount > 0 || alternativesCount > 0) && ( + <div className="flex flex-wrap items-start gap-3"> + {/* The narration script, card by card, before synthesis -- only when + some card carries one. */} + {narrated > 0 && ( + <Link + href={narrationHref(project.id)} + data-narration-link={narrated} + className={buttonVariants({ size: "lg" })} + > + Narration — {narrated} + </Link> + )} + {/* Every drafted field, judged before a final build -- only when a + draft task wrote one, or kept an alternative. */} + {(draftedCount > 0 || alternativesCount > 0) && ( + <Link + href={reviewHref(project.id)} + data-review-link={draftedCount} + className={buttonVariants({ size: "lg" })} + > + Review drafts — {draftedCount} + </Link> + )} + </div> + )} + + {/* --- drafting it ----------------------------------------------- */} + {/* Each draftable section drafted by a model, as a step on the + iteration the project was made from. After the build chain (a + draft changes what the next build makes), before the sections it + writes into. */} + <DraftPanel project={project.id} link={draftLink} rows={draftRowsOf(m as Record<string, unknown>)} runs={draftRunsNow} /> + + {/* --- the upload's text (out/youtube.txt, or its preview) --------- */} + <YoutubeSection dir={project.dir} manifest={m as Record<string, unknown>} /> + + </> + ); +} diff --git a/umtool/components/projects/report/OverviewTab.tsx b/umtool/components/projects/report/OverviewTab.tsx @@ -0,0 +1,224 @@ +import { readFile } from "node:fs/promises"; +import path from "node:path"; +import Link from "next/link"; +import { Suspense } from "react"; +import NextCard, { NextCardShell } from "@/components/piece/NextCard"; +import { badgeVariants } from "@/components/ui/badge"; +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"; +import { TONE, hms, type ReportTabProps } from "./shared"; + +// The Overview tab (canvas "Piece · Overview"): the Next card, then the +// piece's decisions and -- when it is an article's video -- the article and +// its iterations beside the stats, then the author's README. The decisions and +// the README are ReportProject's sections, unchanged (P4a-1). + +const VIA: Record<string, string> = { + iteration: "made by its iteration", + manifest: "named by the manifest", + slug: "matched by name", +}; + +export default async function OverviewTab({ project, detail, frame }: ReportTabProps & { frame: PieceFrame }) { + const { manifest: m, build, entries } = detail; + const decisions = await decisionsForProject(project); + const readme = await readFile(path.join(project.dir, "README.md"), "utf8").catch(() => null); + const p = (m.provenance ?? {}) as Record<string, unknown>; + const clips = entries.filter((e) => e.kind === "clip"); + const nonClips = entries.filter((e) => e.kind !== "clip"); + const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0); + const article = frame.article; + const iterations = + article && article.site === ARTICLES_KEY ? await readArticleIterations(article.report).catch(() => null) : null; + + return ( + <> + <Suspense + fallback={ + <NextCardShell pending> + <span className="text-[12.5px] text-muted">Reading the Inbox…</span> + </NextCardShell> + } + > + <NextCard pieceId={frame.pieceId} title={frame.piece?.title ?? project.id} lifecycle={frame.lifecycle} /> + </Suspense> + + <div className="grid grid-cols-1 gap-[22px] lg:grid-cols-[minmax(0,1.25fr)_minmax(0,1fr)]"> + <div className="min-w-0 space-y-4"> + {/* --- what is wrong, first ------------------------------------- */} + {decisions.length > 0 && ( + <section data-project={project.id}> + <h2 className="micro mb-1.5"> + {decisions.filter((d) => d.severity !== "info").length} waiting of {decisions.length} + </h2> + <ul className="space-y-1"> + {decisions.map((d, i) => ( + <li + key={`${d.kind}-${d.target}-${i}`} + data-decision={d.kind} + data-severity={d.severity} + data-target={d.target} + className="flex flex-wrap items-baseline gap-2 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-1.5" + > + <span className={badgeVariants({ variant: TONE[d.severity], size: "sm" })}> + {d.severity} + </span> + <span className="font-mono text-[12px] text-[var(--color-text)]">{d.target}</span> + <span className="text-[12px] text-[var(--color-dim)]">{d.why}</span> + <span className="micro ml-auto">{d.kind}</span> + </li> + ))} + </ul> + </section> + )} + {decisions.length === 0 && ( + <p data-project-empty="" className="text-[12.5px] text-muted"> + No decisions on this project. + </p> + )} + + {iterations && iterations.iterations.length > 0 && article && ( + <section data-piece-iterations={iterations.iterations.length}> + <div className="mb-2 flex items-baseline gap-3"> + <h2 className="micro">Iterations</h2> + <Link + href={articleHref({ site: article.site, id: article.report }, { tab: "iterations" })} + prefetch={false} + className="ink-link ml-auto text-[12px]" + > + All iterations → + </Link> + </div> + <IterationsSummary rows={iterations.iterations.slice(0, 5)} /> + </section> + )} + </div> + + <div className="min-w-0 space-y-4"> + <section data-piece-stats=""> + <h2 className="micro mb-1.5">This video</h2> + {m.subtitle && <p className="text-[13px] text-text-2">{m.subtitle}</p>} + <ul className="mt-1 text-[13px] text-text-2"> + <li className="flex gap-2.5 border-b border-seam py-1.5"> + cut + <span className="ml-auto font-mono text-[11.5px] text-meter"> + {clips.length} clips{nonClips.length ? ` · ${nonClips.length} other` : ""} · {hms(runtime)} + </span> + </li> + <li className="flex gap-2.5 border-b border-seam py-1.5"> + final video + <span className="ml-auto font-mono text-[11.5px] text-text-2"> + {build.built ? `${build.slug}.mp4${build.stale ? " · out of date" : ""}` : "not built"} + </span> + </li> + {typeof p.channel === "string" && p.channel && ( + <li className="flex gap-2.5 border-b border-seam py-1.5"> + channel<span className="ml-auto text-text-2">{p.channel}</span> + </li> + )} + {m.generatedOn && ( + <li className="flex gap-2.5 border-b border-seam py-1.5"> + generated<span className="ml-auto font-mono text-[11.5px]">{m.generatedOn}</span> + </li> + )} + {typeof p.videosCited === "number" && ( + <li className="flex gap-2.5 border-b border-seam py-1.5"> + videos cited<span className="ml-auto font-mono text-[11.5px] text-meter">{p.videosCited}</span> + </li> + )} + {typeof p.enumeratedMatches === "number" && ( + <li className="flex gap-2.5 border-b border-seam py-1.5"> + enumerated matches<span className="ml-auto font-mono text-[11.5px] text-meter">{p.enumeratedMatches}</span> + </li> + )} + </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> + <Link href={articleHref({ site: article.site, id: article.report })} prefetch={false} className="ink-link text-[13px]"> + {article.title} + </Link> + <p className="text-[12px] text-muted"> + {article.site === ARTICLES_KEY ? "the article store" : article.site} · {VIA[article.via] ?? article.via} + {article.cut ? " · its Cut" : ""} + </p> + </section> + )} + </div> + </div> + + {/* --- the author's own account of the cut ------------------------- */} + {readme && ( + <section data-readme="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> + <div className="max-h-[40vh] overflow-y-auto"> + <Markdown text={readme} /> + </div> + </section> + )} + </> + ); +} + +/** The article's newest iterations (canvas `.itab`): number, kind, model, spend, time, checks, current. */ +function IterationsSummary({ rows }: { rows: IterationRow[] }) { + return ( + <Table> + <thead> + <tr> + <TH>#</TH> + <TH>Kind</TH> + <TH>Model</TH> + <TH className="text-right">Spend</TH> + <TH className="text-right">Time</TH> + <TH>Checks</TH> + <TH /> + </tr> + </thead> + <tbody> + {rows.map((r) => ( + <tr key={r.n} data-iteration={r.n}> + <TD numeric className="text-left"> + {r.n} + </TD> + <TD>{r.kind}</TD> + <TD className="truncate">{r.model}</TD> + <TD numeric className="text-meter"> + {r.usd > 0 ? `$${r.usd.toFixed(2)}` : "—"} + </TD> + <TD numeric>{r.minutes != null ? `${r.minutes.toFixed(1)} min` : "—"}</TD> + <TD> + {r.checks.length === 0 + ? "—" + : r.checks.map((c) => ( + <span key={c.name} title={c.detail ?? undefined} className={`mr-1.5 ${c.ok ? "text-kept-text" : "text-reject-text"}`}> + {c.ok ? "✓" : "✕"} {c.name} + </span> + ))} + </TD> + <TD className="text-text-2">{r.currentVideo || r.currentReport ? "current" : r.status}</TD> + </tr> + ))} + </tbody> + </Table> + ); +} diff --git a/umtool/components/projects/report/SourcesTab.tsx b/umtool/components/projects/report/SourcesTab.tsx @@ -0,0 +1,144 @@ +import Link from "next/link"; +import CheckSourcesButton from "@/components/dashboard/CheckSourcesButton"; +import { sourcesOf } from "@/lib/projects/report.mjs"; +import { clipBenchHref } from "@/lib/hrefs"; +import TagCitedButton from "../TagCitedButton"; +import { Pill, type ReportTabProps } from "./shared"; + +// The Sources tab: every recording the cut cites, its cues and coverage, when +// its availability was last checked, where its QR resolves, and tagging the +// lot in the archive. Moved from ReportProject unchanged (P4a-1). + +export default async function SourcesTab({ project, detail }: ReportTabProps) { + const { manifest: m, channelsDir, shadowExists } = detail; + const p = (m.provenance ?? {}) as Record<string, unknown>; + const sources = await sourcesOf(project.dir, { manifest: m }); + const days = (ms: number) => Math.floor((Date.now() - ms) / 86_400_000); + return ( + <> + {/* --- the sources ---------------------------------------------- */} + <section data-sources="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> + <div className="mb-1 flex flex-wrap items-baseline gap-3"> + <h2 className="micro"> + sources — {sources.rows.length} + </h2> + <span className="num text-[11px] text-[var(--color-dim)]" data-sources-checked={sources.checkedAtMs ? String(Math.round(sources.checkedAtMs)) : "never"}> + {sources.checkedAtMs + ? `availability checked ${days(sources.checkedAtMs)} d ago` + : "availability never checked"} + </span> + <span className="ml-auto"> + <CheckSourcesButton projects={[project.id]} label="re-check availability" /> + </span> + </div> + {/* Beside the sources, because these ARE the sources: tagging them in + the archive is a statement about the recordings this table lists, + and the count in the control is the count in its heading. */} + <div className="mt-1.5"> + <TagCitedButton project={project.id} /> + </div> + <div className="num text-[11px] text-[var(--color-dim)]"> + cues from <code className="font-mono">{channelsDir}</code> + {shadowExists && ( + <span className="ml-2 text-[var(--color-meter)]"> + (this project’s own shadow tree) + </span> + )} + {" · "}QR codes resolve to{" "} + <code className="font-mono">{String(p.siteOrigin ?? "") || "(nothing — siteOrigin is unset)"}</code> + </div> + {sources.rows.length > 0 && ( + <div className="mt-2 overflow-x-auto"> + <table className="w-full border-collapse text-[11px]"> + <thead> + <tr className="micro text-left"> + <th className="px-1.5 py-0.5">source</th> + <th className="px-1.5 py-0.5">clips</th> + <th className="px-1.5 py-0.5">cues</th> + <th className="px-1.5 py-0.5">coverage</th> + <th className="px-1.5 py-0.5">availability</th> + <th className="px-1.5 py-0.5">cite target</th> + </tr> + </thead> + <tbody> + {sources.rows.map((r) => { + const a = r.availability; + return ( + <tr + key={r.key} + data-source={r.key} + data-cues={r.cues} + data-cue-gap={r.coverageGap ? r.coverageGap.clip : ""} + data-availability={a ? a.state : "never"} + data-cite-override={r.cite.differs ? "1" : "0"} + className="border-t border-[var(--color-line)] align-top" + > + <td className="px-1.5 py-1"> + <a href={r.cite.override ?? r.cite.derived} target="_blank" rel="noreferrer" className="ink-link font-mono"> + {r.key} + </a> + {r.title && <div className="truncate text-[var(--color-dim)]" style={{ maxWidth: "24rem" }}>{r.title}</div>} + </td> + <td className="px-1.5 py-1 font-mono"> + {r.clips.map((c, i) => ( + <span key={c}> + {i > 0 && " "} + <Link href={clipBenchHref(project.id, c)} className="ink-link"> + {c} + </Link> + </span> + ))} + </td> + <td className="px-1.5 py-1"> + {r.cues === "missing" ? ( + <Pill tone="blocking">missing</Pill> + ) : r.cues === "no-punctuation" ? ( + <Pill>no punctuation</Pill> + ) : ( + <span className="text-[var(--color-dim)]">present</span> + )} + </td> + <td className="num px-1.5 py-1"> + {r.coverageGap ? ( + <span className="text-[var(--color-dirty)]"> + cues end {r.coverageGap.cuesEnd.toFixed(0)} s · {r.coverageGap.clip} needs {r.coverageGap.needs.toFixed(0)} s + </span> + ) : r.cuesEnd != null ? ( + <span className="text-[var(--color-dim)]">cues to {r.cuesEnd.toFixed(0)} s</span> + ) : ( + <span className="text-[var(--color-dim)]">—</span> + )} + </td> + <td className="num px-1.5 py-1"> + {a ? ( + <span className={a.ok ? "text-[var(--color-dim)]" : "text-[var(--color-bad)]"} title={a.error ?? undefined}> + {a.state} · {days(a.checkedAtMs)} d ago + </span> + ) : ( + <span className="text-[var(--color-dim)]">never checked</span> + )} + </td> + <td className="px-1.5 py-1"> + {r.cite.differs ? ( + <span className="text-[var(--color-dim)]"> + <Pill>citeUrl</Pill>{" "} + <a href={r.cite.override!} target="_blank" rel="noreferrer" className="ink-link font-mono"> + override + </a> + </span> + ) : ( + <span className="text-[var(--color-dim)]">derived</span> + )} + </td> + </tr> + ); + })} + </tbody> + </table> + </div> + )} + </section> + + </> + ); +} diff --git a/umtool/components/projects/report/shared.tsx b/umtool/components/projects/report/shared.tsx @@ -0,0 +1,35 @@ +import { badgeVariants, type BadgeVariants } from "@/components/ui/badge"; +import type { readClipDetail } from "@/lib/projects/report.mjs"; +import type { Severity } from "@/lib/decisions"; +import type { ProjectRef } from "@/lib/project-types"; + +// What every tab of a report video's piece page shares: the project, its +// parsed detail (the one expensive read, done once by the page), and the +// small helpers the sections were written with. + +export type ClipDetail = NonNullable<Awaited<ReturnType<typeof readClipDetail>>>; +export type ReportTabProps = { + project: ProjectRef; + detail: ClipDetail; + search: Record<string, string | undefined>; +}; + +export const hms = (t: number) => { + const s = Math.max(0, Math.floor(t)); + const h = Math.floor(s / 3600); + const m = Math.floor((s % 3600) / 60); + const sec = s % 60; + return h > 0 + ? `${h}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")}` + : `${m}:${String(sec).padStart(2, "0")}`; +}; + +export const TONE: Record<Severity, BadgeVariants["variant"]> = { + blocking: "blocking", + open: "open", + info: "info", +}; + +export function Pill({ tone, children }: { tone?: BadgeVariants["variant"]; children: React.ReactNode }) { + return <span className={badgeVariants({ variant: tone ?? "info", size: "sm" })}>{children}</span>; +} diff --git a/umtool/components/shell/AppHeader.tsx b/umtool/components/shell/AppHeader.tsx @@ -26,6 +26,7 @@ export default function AppHeader({ note, actions, meta, + below, variant = "page", className, }: { @@ -35,6 +36,8 @@ export default function AppHeader({ actions?: React.ReactNode; /** A line under the title (counts, a hint); muted. */ meta?: React.ReactNode; + /** A full-width row at the foot of the head (a piece's stage stepper). */ + below?: React.ReactNode; variant?: "page" | "bench"; className?: string; }) { @@ -100,6 +103,7 @@ export default function AppHeader({ {note && <div className="micro">{note}</div>} </div> )} + {below && <div className="basis-full">{below}</div>} </header> ); } diff --git a/umtool/components/shell/AppShell.tsx b/umtool/components/shell/AppShell.tsx @@ -22,6 +22,7 @@ export default function AppShell({ note, actions, meta, + below, rail = "open", }: { /** The rail entry that is lit. */ @@ -30,6 +31,8 @@ export default function AppShell({ note?: React.ReactNode; actions?: React.ReactNode; meta?: React.ReactNode; + /** A full-width row at the foot of the head (a piece's stage stepper). */ + below?: React.ReactNode; rail?: "open" | "collapsed"; }) { return ( @@ -40,6 +43,7 @@ export default function AppShell({ note={note} actions={actions} meta={meta} + below={below} variant={rail === "collapsed" ? "bench" : "page"} /> </> 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/components/ui/tabs.tsx b/umtool/components/ui/tabs.tsx @@ -5,6 +5,10 @@ import { cn } from "@/lib/utils"; // bookmarkable, the back button works, and a server page renders the right one // with no client state. The current one carries `aria-current="page"` and the // Signal underline; a count sits beside its label in Meter. +// +// No prefetch: every page here is dynamic, so a prefetched tab is a full server +// render of a page nobody asked for yet -- seven of them per piece page (P3 +// found the rail's prefetches keeping the server busy enough to fail specs). export type TabItem = { href: string; label: React.ReactNode; current?: boolean; count?: number | string; testid?: string }; export function Tabs({ @@ -19,6 +23,7 @@ export function Tabs({ <Link key={t.href} href={t.href} + prefetch={false} data-testid={t.testid} aria-current={t.current ? "page" : undefined} className={cn( diff --git a/umtool/e2e/article-delete.spec.ts b/umtool/e2e/article-delete.spec.ts @@ -136,6 +136,8 @@ test("a take the project's manifest is, is refused until forced; another take an expect(existsSync(path.join(PROJECT, "takes", "keep", "take.json"))).toBe(true); await page.goto("/browse/reports/delete-fixture"); + // Delete is in the piece head's ⋯ menu (P4a-1). + await page.getByRole("button", { name: "More" }).click(); await page.getByRole("button", { name: "Delete project" }).click(); const plan = page.getByRole("region", { name: "delete the project reports/delete-fixture" }); await expect(plan.getByRole("list", { name: "what goes" })).toContainText("reports/delete-fixture"); diff --git a/umtool/e2e/clip-bench.spec.ts b/umtool/e2e/clip-bench.spec.ts @@ -3,6 +3,7 @@ import { execFileSync } from "node:child_process"; import { copyFileSync, existsSync, mkdirSync, readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // The clip bench. @@ -271,7 +272,7 @@ test("a bench save shows up on the project page", async ({ page, request }) => { data: { project: PROJECT, clip: "c01", start: 3, end: 9, lockEnd: true, token: t }, }); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "timeline")); const row = page.locator("[data-entry=c01][data-kind]"); await expect(row).toContainText("end pinned"); // lockEnd is the acknowledgement, so the row's warning goes with it. @@ -402,7 +403,7 @@ test("a clip off the walk still opens by URL, and says why it is off it", async }); test("`ready N of M` counts the fetched clips that still need judgement", async ({ page }) => { - await page.goto(`/browse/${WALK}`); + await page.goto(urls.section(WALK, "timeline")); await expect(page.locator("[data-ready-count]")).toHaveText("ready 2 of 3 needing judgement"); // The pill is the same question the walk asks, per row. await expect(page.locator("[data-entry=w02][data-kind]")).toHaveAttribute("data-fetched", "0"); @@ -411,7 +412,7 @@ test("`ready N of M` counts the fetched clips that still need judgement", async // And the walk starts where the walk actually goes. await expect(page.locator("[data-walk-start=w01]")).toHaveAttribute( "href", - `/browse/${WALK}/clip/w01`, + urls.clipBenchHref(WALK, "w01"), ); await page.goto(walkBench("w01")); @@ -509,7 +510,7 @@ test("a correction is written for the next pass, and collected on the project pa // The project page lists it, because the list's real destination is somebody's // next prompt -- not this manifest, which cannot fix a defect in the report. - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "timeline")); const list = page.locator("[data-corrections]"); await expect(list).toBeVisible(); await expect(list.locator("[data-correction=c04]")).toContainText("not Destiny"); @@ -524,7 +525,7 @@ test("a correction is written for the next pass, and collected on the project pa await page.goto(bench("c04")); await setField(page, "correction", ""); await expect.poll(() => readClip("c04").correction).toBeUndefined(); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "timeline")); await expect(page.locator("[data-corrections]")).toHaveCount(0); }); @@ -770,7 +771,7 @@ test("a note written before `incorrect` existed still reads as incorrect", async await expect(page.locator("[data-verdict-state]")).toHaveText("incorrect"); await expect(page.locator("[data-bench=c02]")).toHaveAttribute("data-verdict", "incorrect"); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "timeline")); await expect(page.locator("[data-walk-progress]")).toContainText("incorrect"); await expect(page.locator("[data-correction=c02]")).toHaveAttribute( "data-correction-verdict", @@ -1109,14 +1110,14 @@ test("auto-audition plays the clip you walk onto", async ({ page, request }) => }); test("the project page opens the walk at the first clip", async ({ page }) => { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "timeline")); const cta = page.locator("[data-walk-cut]"); await expect(cta).toBeVisible(); await expect(cta).toContainText("Walk the cut"); // Named, so it is a promise about where it goes rather than a mystery. await expect(page.locator("[data-walk-start=c01]")).toHaveAttribute( "href", - `/browse/${PROJECT}/clip/c01`, + urls.clipBenchHref(PROJECT, "c01"), ); await page.locator("[data-walk-start=c01]").click(); await expect(page.locator("[data-bench=c01]")).toBeVisible(); diff --git a/umtool/e2e/deliver.spec.ts b/umtool/e2e/deliver.spec.ts @@ -3,6 +3,7 @@ import { execFileSync } from "node:child_process"; import { existsSync, readdirSync, readFileSync, statSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // DELIVER: what happens after the last clip is judged. @@ -47,7 +48,7 @@ async function waitForJob(page: import("@playwright/test").Page, timeout = 120_0 } test("the deliver panel counts verdicts and folds them by id prefix", async ({ page }) => { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); const panel = page.locator("[data-deliver]"); await expect(panel).toBeVisible(); @@ -76,7 +77,7 @@ test("the deliver panel counts verdicts and folds them by id prefix", async ({ p test("a confirmed clip with no cached window is listed as not fetched, not cut", async ({ page, }) => { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); const notFetched = page.locator("[data-not-fetched]"); await expect(notFetched).toBeVisible(); // a03's window is 30–33 s and the cache holds 0–24. Nothing here downloads @@ -96,7 +97,7 @@ test("cutting from cache writes clips/<id>.mp4 of exactly the clip's length", as page, }) => { test.setTimeout(180_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); await page.locator('[data-action="deliver-cut"]').click(); // `k of n` is the JOB's count -- one step per clip -- so the readout and the @@ -121,7 +122,7 @@ test("cutting from cache writes clips/<id>.mp4 of exactly the clip's length", as test("the share batch skips every id an existing LIST.md already shipped", async ({ page }) => { test.setTimeout(180_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); await page.locator("[data-batch-name]").fill("second"); await page.locator('[data-action="deliver-share"]').click(); const { state, log } = await waitForJob(page); @@ -171,7 +172,7 @@ test("apply rulings is refused while the walk is unfinished, and runs the report page, }) => { test.setTimeout(120_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); // b03 has never been judged. apply-manifest.py deletes the mp4 of every clip // whose window moved, so running it over a half-walked cut bakes "nobody has @@ -202,7 +203,7 @@ test("apply rulings is refused while the walk is unfinished, and runs the report test("the panel shows the prose lines citing a clip the walk ruled incorrect", async ({ page, }) => { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); const cited = page.locator('[data-incorrect="b02"]'); await expect(cited).toBeVisible(); await expect(cited).toContainText("content.py:6"); @@ -211,7 +212,7 @@ test("the panel shows the prose lines citing a clip the walk ruled incorrect", a test("rebuild runs build.py once per content variant present", async ({ page }) => { test.setTimeout(120_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); await page.locator('[data-action="deliver-rebuild"]').click(); const { state, log } = await waitForJob(page); expect(state, log).toBe("done"); @@ -251,7 +252,7 @@ test("Stop abandons the rest of the cut, and the next one resumes without re-cut page, }) => { test.setTimeout(240_000); - await page.goto("/browse/reports/deliver-stop-fixture"); + await page.goto(urls.section("reports/deliver-stop-fixture", "deliver")); await expect(page.locator("[data-deliver]")).toHaveAttribute("data-deliver-need-cut", "6"); expect(stopCuts()).toHaveLength(0); diff --git a/umtool/e2e/deliverables.spec.ts b/umtool/e2e/deliverables.spec.ts @@ -3,6 +3,7 @@ import { execFileSync, spawnSync } from "node:child_process"; import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync, renameSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // A report's deliverables behind the per-project switch (release 17, slice U2). @@ -113,7 +114,7 @@ test("the switch moves clips/ and every share-* to the media root, then says med test("the app cuts through the linked clips/, and the move waits for the cut", async ({ page, request }) => { test.setTimeout(180_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); await expect(page.locator("[data-deliverables]")).toHaveAttribute("data-deliverables", "media"); await expect(page.locator('[data-deliverable="clips"]')).toHaveAttribute("data-deliverable-state", "link"); const move = page.locator('[data-action="deliver-move"]'); @@ -146,7 +147,7 @@ test("the app cuts through the linked clips/, and the move waits for the cut", a test("a new batch: refused by an app with no media root, made as a link by a CLI with one", async ({ page, request }) => { test.setTimeout(180_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); // The app could only make share-<x>/ in the project, which is not where this // project's deliverables live: it says so rather than splitting them. await expect(page.locator('[data-action="deliver-share"]')).toBeDisabled(); @@ -194,7 +195,7 @@ test("an unplugged media root: check blocks, the panel refuses, nothing is made" ["share-second", "blocking", true], ]); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); await expect(page.locator('[data-deliverable="clips"]')).toHaveAttribute("data-deliverable-state", "dangling"); await expect(page.locator('[data-action="deliver-move"]')).toBeDisabled(); await expect(page.locator("[data-move-reason]")).toContainText("is the media drive mounted?"); @@ -215,7 +216,7 @@ test("an unplugged media root: check blocks, the panel refuses, nothing is made" test("the bench moves the deliverables home, and offers no move to media without a media root", async ({ page }) => { test.setTimeout(180_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "deliver")); const move = page.locator('[data-action="deliver-move"]'); await expect(move).toHaveText("Move deliverables to local"); await move.click(); diff --git a/umtool/e2e/draft-review.spec.ts b/umtool/e2e/draft-review.spec.ts @@ -2,6 +2,7 @@ import { test, expect, type APIRequestContext } from "@playwright/test"; import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // The drafts review (release 28, M0). A drafted field shows "drafted by @@ -29,10 +30,11 @@ const review = (dir = DIR): Record<string, { verdict: string | null; note: strin }; test("badges: drafted by <model>, approve, reject with a note; an edit makes the field the operator's", async ({ page }) => { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "review")); await expect(page.locator("[data-review-link]")).toHaveAttribute("data-review-link", "3"); // The On-screen table (folded: the deck is off) -- c02's title was drafted, c01's was not. + await page.goto(urls.section(PROJECT, "onscreen")); await page.getByTestId("onscreen-words-folded").locator("summary").click(); const c02 = page.locator('[data-draft-badge="onscreen/c02/onscreen"]'); await expect(c02).toHaveAttribute("data-state", "unreviewed"); @@ -64,7 +66,7 @@ test("badges: drafted by <model>, approve, reject with a note; an edit makes the }); test("the review page: every drafted field, the narration's badge, and Use this for the operator's field", async ({ page }) => { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "review")); await page.locator("[data-review-link]").click(); await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}/review$`)); // The narration and the teaser are drafted; a final build would refuse them. diff --git a/umtool/e2e/media-draft-e.spec.ts b/umtool/e2e/media-draft-e.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test"; import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // Release 28 lane E's media drafts, as umtool shows them (M6): the project @@ -24,7 +25,7 @@ const SOURCES = ["https://archive.example/?v=testchan%2Fvid1&t=3", "https://arch test("the YouTube text: a preview before the build, Copy, then out/youtube.txt with chapters and sources", async ({ page, request, context }) => { test.setTimeout(300_000); await context.grantPermissions(["clipboard-read", "clipboard-write"]); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "youtube")); const section = page.locator("[data-youtube]"); await expect(section).toHaveAttribute("data-youtube", "preview"); await expect(section.locator("[data-youtube-status]")).toContainText("chapters are added by the build"); diff --git a/umtool/e2e/media-surfaces.spec.ts b/umtool/e2e/media-surfaces.spec.ts @@ -3,6 +3,7 @@ import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { WARM_TIMEOUT, warm } from "./warm"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // Release 28 M9, the surfaces of the media drafts: @@ -37,7 +38,7 @@ test.beforeAll(async ({ playwright }) => { test("Draft with <model> per section: the job followed, the badge, the last run, an alternative and Use this", async ({ page }) => { test.setTimeout(180_000); - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "drafts")); const panel = page.getByRole("region", { name: "draft with a model" }); await expect(panel).toHaveAttribute("data-draft-panel", `${ARTICLE}/i1`); // Seven sections; flips and threads say why they cannot draft on this cut. @@ -91,7 +92,7 @@ test("Draft with <model> per section: the job followed, the badge, the last run, expect(manifestOf(1).drafted?.["publish.youtube"]).toBeUndefined(); // A project made from no iteration offers no draft, and says why. - await page.goto("/browse/reports/youtube-fixture"); + await page.goto(urls.section("reports/youtube-fixture", "drafts")); await expect(page.getByRole("region", { name: "draft with a model" }).locator("[data-draft-unlinked]")).toContainText("not made from an article's iteration"); }); diff --git a/umtool/e2e/mix.spec.ts b/umtool/e2e/mix.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test"; import { existsSync, mkdirSync, readdirSync, renameSync, rmSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // The mix bench, against SYNTHESISED tracks whose true answers are known in // advance (see make-fixture.mjs): @@ -228,7 +229,7 @@ test("the picker is grouped by project, and every project's media is in it", asy }); test("a clip row links into the bench with the window already set", async ({ page }) => { - await page.goto("/browse/reports/report-fixture"); + await page.goto(urls.section("reports/report-fixture", "timeline")); const link = page.locator("[data-mix-link=c01]"); await expect(link).toBeVisible(); @@ -265,7 +266,7 @@ test("a deep link outside the roots is REFUSED, not clamped to something else", test("a clip with nothing fetched offers no link at all, rather than a dead one", async ({ page, }) => { - await page.goto("/browse/reports/report-fixture"); + await page.goto(urls.section("reports/report-fixture", "timeline")); // c02's window has no cached file covering it, and a 400 on click would be // worse than saying so. await expect(page.locator("[data-mix-link-disabled=c02]")).toBeVisible(); diff --git a/umtool/e2e/narration-review.spec.ts b/umtool/e2e/narration-review.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test"; import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // The narration review (release 25, T5): a cut's narration script, card by @@ -35,7 +36,7 @@ const ttsAsks = (): { route?: string; text?: string }[] => { }; test("review the narration card by card: approve, reject with a note, edit un-approves, play asks the editor", async ({ page }) => { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "narration")); await page.locator("[data-narration-link]").click(); await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}/narration$`)); const k1 = page.locator('[data-narration-card="k01"]'); diff --git a/umtool/e2e/onscreen-posts.spec.ts b/umtool/e2e/onscreen-posts.spec.ts @@ -4,6 +4,7 @@ import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { deckGeometry, feedGeometry, postWindows, postsGeometry, shiftedFootage } from "umtool-report-to-video/deck"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // POSTS on the on-screen deck, as umtool edits them: the Posts table under the @@ -120,7 +121,7 @@ const backdropMatrix = (page: Page) => }); async function openSection(page: Page) { - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "onscreen")); await expect(page.getByTestId("onscreen-section")).toHaveAttribute("data-onscreen", "on"); await expect(page.getByTestId("onscreen-post-row")).toHaveCount(3); } diff --git a/umtool/e2e/onscreen.spec.ts b/umtool/e2e/onscreen.spec.ts @@ -3,6 +3,7 @@ import { execFileSync } from "node:child_process"; import { existsSync, readFileSync, statSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // ON-SCREEN: the report cut's deck (render.chrome), as umtool edits it. @@ -85,7 +86,7 @@ async function putOnscreen( /** The section, read and settled: the manifest loaded and the table filled. */ async function openSection(page: Page, project = PROJECT) { - await page.goto(`/browse/${project}`); + await page.goto(urls.section(project, "onscreen")); const section = page.getByTestId("onscreen-section"); await expect(section).toHaveAttribute("data-onscreen", /on|off/); await expect(page.getByTestId("onscreen-row").first()).toBeAttached(); @@ -272,7 +273,6 @@ test("the preview is the composition: it reports ready, and typing reaches it be const teaserTitle = "Next Season — The Big Build in the Valley — Spring 2027 ?"; await expect(frame.locator('[data-seg="t01"]')).toHaveCount(1); expect(await row(page, "t01").getByTestId("onscreen-title").getAttribute("placeholder")).toBe(teaserTitle); - await expect(page.locator('li[data-entry="t01"][data-kind="teaser"]')).toContainText(teaserTitle); // Typing is patched into the frame by postMessage: nothing is saved. await fillSure(row(page, "c02").getByTestId("onscreen-title"), "Typed, not saved"); @@ -289,6 +289,10 @@ test("the preview is the composition: it reports ready, and typing reaches it be await request.post("/api/report/chrome/preview", { data: { project: PROJECT } }) ).json()) as { schedule: { total: number } }; expect(max).toBeCloseTo(pv.schedule.total, 3); + + // The same teaser on the report page's timeline (the piece page's Cut tab). + await page.goto(urls.section(PROJECT, "timeline")); + await expect(page.locator('li[data-entry="t01"][data-kind="teaser"]')).toContainText(teaserTitle); }); test("a true still is the render browser's PNG of the deck region", async ({ page, request }) => { diff --git a/umtool/e2e/piece.spec.ts b/umtool/e2e/piece.spec.ts @@ -0,0 +1,215 @@ +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 +// page is a frame -- the head (title, lifecycle chip, ⋯), the stage stepper, +// the Next card on the Overview, seven link tabs -- around ONE tab of its +// sections. The tab is the URL's `?tab=`; `1`–`7` switch tabs and `n` runs the +// Next card's action once the page has hydrated. +// --------------------------------------------------------------------------- + +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}`); +const keysReady = (page: Page) => expect(page.locator("[data-piece-keys=ready]")).toBeAttached(); + +test("the frame: title, trail, stepper at Video, the Next card, seven tabs with the Overview lit", async ({ page }) => { + const res = await page.goto(urls.projectHref(PROJECT)); + expect(res?.status()).toBe(200); + const crumbs = page.getByRole("navigation", { name: "Breadcrumb" }); + await expect(crumbs.locator("h1")).toHaveText("The Report Fixture"); + await expect(crumbs).toContainText(PROJECT); + // The status line is still the head's last .micro. + await expect(page.locator("header .micro").last()).toHaveText(/4 clips · 2 other · 0:12 · not built/i); + + // A project no article claims is its own piece; unbuilt, it is at Video. + 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.nth(2)).toHaveAttribute("aria-current", "step"); + // 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"); + await expect(tabs).toHaveText([/^Overview/, /^Cut/, /^Media/, /^Build/, /^Deliver/, /^Sources/, /^History/]); + await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page"); + await expect(tab(page, "cut")).toHaveText("Cut4"); + await expect(tab(page, "sources")).toHaveText("Sources2"); + + // The Overview: the Next card, the project's decisions, its stats -- and none + // of the other tabs' sections. + await expect(page.locator("[data-next]:visible")).toBeVisible(); + await expect(page.locator(`[data-project="${PROJECT}"]`)).toBeVisible(); + await expect(page.locator("[data-piece-stats]")).toContainText("4 clips"); + await expect(page.locator("[data-entry][data-kind]")).toHaveCount(0); + await expect(page.locator("[data-sources]")).toHaveCount(0); + await expect(page.getByTestId("onscreen-section")).toHaveCount(0); +}); + +test("the Next card is the piece's top Inbox call, and its one action goes where the Inbox's does", async ({ page, request }) => { + const inbox = (await (await request.get("/api/browse/decisions")).json()) as { + groups: { id: string; cards: { piece: string | null; kind: string; action: { label: string; href: string } }[] }[]; + }; + const top = inbox.groups.filter((g) => g.id !== "quiet").flatMap((g) => g.cards).find((c) => c.piece === PIECE); + expect(top, "the fixture's report has a call waiting").toBeTruthy(); + + await page.goto(urls.projectHref(PROJECT)); + const next = page.locator("[data-next]:visible"); + await expect(next.locator("[data-next-kind]")).toHaveAttribute("data-next-kind", top!.kind); + const action = next.locator("[data-next-action] > a:visible"); + await expect(action).toHaveText(top!.action.label); + await expect(action).toHaveAttribute("href", top!.action.href); + await action.click(); + await expect(page).toHaveURL(new RegExp(`${top!.action.href.replace(/[?]/g, "\\?")}$`)); +}); + +test("the tab is the URL: ?tab=, ?all=1 on the Cut, a bad tab the Overview, and the old address lands", async ({ page }) => { + await page.goto(urls.section(PROJECT, "sources")); + await expect(tab(page, "sources")).toHaveAttribute("aria-current", "page"); + await expect(page.locator("[data-sources]")).toBeVisible(); + await expect(page.locator("[data-next]")).toHaveCount(0); + + await page.goto(urls.projectHref(PROJECT, { all: true })); + await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page"); + await expect(page.locator("[data-entry=c01][data-kind]")).toBeVisible(); + + await page.goto(`${urls.projectHref(PROJECT)}?tab=nonsense`); + await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page"); + + // /browse/<project> (before P3) rides the redirect to the Overview. + await page.goto(`/browse/${PROJECT}`); + await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}$`)); + await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page"); + + // Clicking a tab is a link: the address changes, the section is there. + await tab(page, "history").click(); + await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}\\?tab=history$`)); + await expect(page.locator("[data-provenance]")).toBeVisible(); +}); + +test("a note's link opens the tab its anchor is drawn on", async ({ page, request }) => { + const add = await request.post(`/api/notes?project=${PROJECT}`, { + data: { op: { op: "add", text: "this row is long", anchor: { kind: "entry", entry: "c02" } } }, + }); + expect(add.status()).toBe(200); + const id = ((await add.json()) as { note: { id: string } }).note.id; + try { + await page.goto(urls.projectHref(PROJECT, { note: id })); + await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page"); + await expect(page.locator("[data-anchored-notes='c02']")).toHaveAttribute("data-open-notes", "1"); + } finally { + await request.post(`/api/notes?project=${PROJECT}`, { data: { op: { op: "delete", id } } }); + } +}); + +test("the lifecycle chip: Park, then Reactivate, each a round trip through the store", async ({ page, request }) => { + const life = async () => + ((await (await request.get("/api/pieces")).json()) as { pieces: { id: string; lifecycle: string }[] }).pieces.find((p) => p.id === PIECE) + ?.lifecycle; + try { + await page.goto(urls.projectHref(PROJECT)); + const chip = page.locator("[data-lifecycle-chip]"); + await expect(chip).toHaveAttribute("data-lifecycle-chip", "active"); + await chip.getByRole("button", { name: "Lifecycle: Active" }).click(); + await chip.getByRole("button", { name: "Park" }).click(); + await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "parked"); + await expect(page.locator(`[data-undo="${PIECE}"]`)).toContainText("Parked"); + expect(await life()).toBe("parked"); + // Parked, the piece's calls are hidden: the Next card offers the way back. + await expect(page.locator("[data-next-kind=lifecycle]")).toContainText("Parked"); + await expect(page.locator("[data-next-action] > button:visible")).toHaveText("Reactivate"); + + const chip2 = page.locator("[data-lifecycle-chip]"); + await chip2.getByRole("button", { name: "Lifecycle: Parked" }).click(); + await chip2.getByRole("button", { name: "Reactivate" }).click(); + await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "active"); + expect(await life()).toBe("active"); + } finally { + await request.post("/api/pieces/lifecycle", { data: { piece: PIECE, state: "active" } }); + } +}); + +test("keys: 1–7 open the tabs, n runs the Next card's action; typing in a field is left alone", async ({ page }) => { + await page.goto(urls.projectHref(PROJECT)); + await keysReady(page); + await page.keyboard.press("2"); + await expect(page).toHaveURL(/\?tab=cut$/); + await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page"); + await keysReady(page); + await page.keyboard.press("7"); + await expect(page).toHaveURL(/\?tab=history$/); + await keysReady(page); + // The snapshot label is a field: a digit typed there is a digit. + const label = page.locator("[data-revisions] input").first(); + await label.fill(""); + await label.press("3"); + await expect(label).toHaveValue("3"); + await expect(page).toHaveURL(/\?tab=history$/); + await label.evaluate((el: HTMLElement) => el.blur()); + await page.keyboard.press("1"); + await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page"); + + await keysReady(page); + const href = await page.locator("[data-next-action] > a:visible").getAttribute("href"); + await page.keyboard.press("n"); + await expect(page).toHaveURL(new RegExp(`${href!.replace(/[?]/g, "\\?")}$`)); +}); + +test("an article's video: the stepper and the lifecycle are the article's, and the head links it", async ({ page }) => { + await page.goto(urls.projectHref("gen-projects/zeta/i1")); + await expect(page.locator("[data-piece-frame='a:articles/zeta']")).toBeVisible(); + const link = page.locator("[data-piece-article='articles/zeta'] a"); + await expect(link).toHaveAttribute("href", urls.articleHref({ site: "articles", id: "zeta" })); + // Its iterations, summarised on the Overview, with a way to all of them. + await expect(page.locator("[data-piece-iterations]")).toBeVisible(); + await expect(page.locator("[data-piece-linked-article='articles/zeta']")).toContainText("made by its iteration"); +}); + +test("fits 1366×768: the head, the tabs and the Next card's action without a horizontal scroll", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 768 }); + await page.goto(urls.projectHref(PROJECT)); + await expect(page.locator("[data-next-action] > a:visible")).toBeInViewport(); + await expect(tab(page, "history")).toBeInViewport(); + 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/e2e/projects.spec.ts b/umtool/e2e/projects.spec.ts @@ -509,7 +509,7 @@ test("a timeline entry of an unknown type renders, rather than crashing the page // beside its cards; code that assumed card-or-clip put `undefined` into // path.join() and 500'd the project page. The rule is that a CLIP is // `type === "clip"` and everything else renders generically. - const res = await page.goto("/browse/reports/report-fixture"); + const res = await page.goto(urls.section("reports/report-fixture", "timeline")); expect(res?.status()).toBe(200); // The TIMELINE's entries, which carry a kind. The On-screen section's table diff --git a/umtool/e2e/report-fetch-via-editor.spec.ts b/umtool/e2e/report-fetch-via-editor.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test"; import { existsSync, readFileSync, statSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // Fetching a clip window BY ASKING THE EDITOR. @@ -129,7 +130,7 @@ test("the fetch route asks the editor, carries the provenance, and runs no yt-dl expect(ytdlpCalls()).toBe(ytdlpBefore); // The page reads the corpus window as cached, so the walk stops skipping it. - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "timeline")); await expect(page.locator('[data-entry="e01"][data-kind]')).toHaveAttribute( "data-fetched", "1", @@ -154,7 +155,7 @@ test("the project page fetches the unfetched clips one at a time, and Stop halts test.setTimeout(120_000); const ytdlpBefore = ytdlpCalls(); - await page.goto(`/browse/${MANY}`); + await page.goto(urls.section(MANY, "timeline")); await expect(page.locator("[data-ready-count]")).toContainText("ready 0 of 2"); const button = page.getByRole("button", { name: /fetch 2 unfetched clips/i }); await expect(button).toBeVisible(); @@ -211,7 +212,7 @@ test("a clip the previous fetch already covers does not abort the sweep", async // and the predicate is containment, so a sweep down a timeline routinely // finds its next clip already paid for. Treating it as a refusal stopped the // run on its own success and left the counter short. - await page.goto(`/browse/${REUSE}`); + await page.goto(urls.section(REUSE, "timeline")); await expect(page.locator("[data-ready-count]")).toContainText("ready 0 of 2"); await page.getByRole("button", { name: /fetch 2 unfetched clips/i }).click(); diff --git a/umtool/e2e/report-longform.spec.ts b/umtool/e2e/report-longform.spec.ts @@ -3,6 +3,7 @@ import { execFileSync } from "node:child_process"; import { existsSync, readFileSync, rmSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // The long-form pass: sources, revisions, notes and exports of a report video. @@ -31,7 +32,7 @@ const umtool = (args: string[]) => execFileSync("node", ["bin/umtool.mjs", ...args], { cwd: UMTOOL, encoding: "utf8", env: cliEnv }); test("a clip that outruns its transcript is a cue gap, on the page and in the inbox", async ({ page }) => { - await page.goto("/browse/reports/longform-fixture"); + await page.goto(urls.section("reports/longform-fixture", "sources")); const row = page.locator("[data-source='testchan/short1']"); await expect(row).toHaveAttribute("data-cue-gap", "c02"); await expect(row).toContainText("cues end 6 s · c02 needs 12 s"); @@ -40,6 +41,7 @@ test("a clip that outruns its transcript is a cue gap, on the page and in the in await expect(page.locator("[data-source='testchan/vid1']")).toHaveAttribute("data-cite-override", "0"); await expect(page.locator("[data-source='testchan/vid1']")).toHaveAttribute("data-cue-gap", ""); + await page.goto(urls.section("reports/longform-fixture", "decisions")); await expect(page.locator("[data-decision='clip-cue-gap'][data-target=c02]")).toHaveCount(1); await expect(page.locator("[data-decision='clip-cue-gap'][data-target=c02]")).toHaveAttribute("data-severity", "open"); }); @@ -55,7 +57,7 @@ test("umtool show prints the same sources table", () => { }); test("a legacy .bak is listed as a snapshot and diffed, never renamed", async ({ page }) => { - await page.goto("/browse/reports/longform-fixture"); + await page.goto(urls.section("reports/longform-fixture", "revisions")); const bak = page.locator("[data-snapshot='video.manifest.json.bak']"); await expect(bak).toHaveAttribute("data-legacy", "1"); // The .bak had c02 ending at 9; the manifest has 12: exactly one change. @@ -66,7 +68,7 @@ test("a legacy .bak is listed as a snapshot and diffed, never renamed", async ({ }); test("README and sibling notes render, and long provenance reads as prose", async ({ page }) => { - await page.goto("/browse/reports/longform-fixture"); + await page.goto(urls.section("reports/longform-fixture", "notes")); await expect(page.locator("[data-note=coverage]")).toContainText("well over one hundred and twenty"); await expect(page.locator("[data-note-file='build-notes.md']")).toBeVisible(); await page.locator("[data-note-file='build-notes.md'] summary").click(); @@ -95,7 +97,7 @@ test("snapshot, then a window edit, then the diff shows that one change", async expect(d.changes[0].from.end).toBe(12); expect(d.changes[0].to.end).toBe(13); - await page.goto(`/browse/${project}`); + await page.goto(urls.section(project, "revisions")); const row = page.locator(`[data-snapshot="${rel}"]`); await expect(row).toHaveAttribute("data-diff", "1"); await expect(row).toHaveAttribute("data-legacy", "0"); diff --git a/umtool/e2e/report-narration.spec.ts b/umtool/e2e/report-narration.spec.ts @@ -3,6 +3,7 @@ import { execFileSync, spawnSync } from "node:child_process"; import { existsSync, readFileSync, readdirSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // A narrated card (release 25, T2), built through the driver. @@ -110,7 +111,7 @@ test("a narrated card speaks, its length is the narration's, the plain card is s // --------------------------------------------------------------------------- test("the export row renders the cut as a podcast and offers the files", async ({ page, request }) => { - await page.goto("/browse/reports/narration-fixture"); + await page.goto(urls.section("reports/narration-fixture", "exports")); const row = page.locator('[data-export-variant="sourced"]'); const podcast = row.locator('[data-podcast="sourced"]'); await expect(podcast.getByRole("button", { name: "podcast" })).toBeVisible(); diff --git a/umtool/e2e/report-tag-via-editor.spec.ts b/umtool/e2e/report-tag-via-editor.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test"; import { readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // "Tag cited videos as …" — handing a walked report's judgement to the archive. @@ -117,7 +118,7 @@ test("a section is its own scope, and the control on the project page uses it", // And through the page, which is where an operator actually does it. const asksBeforeUi = tagAsks().length; - await page.goto(`/browse/${PROJECT}`); + await page.goto(urls.section(PROJECT, "tag")); const control = page.locator("[data-tag-cited]"); await expect(control).toBeVisible(); await control.locator("[data-tag-cited-tag]").selectOption("eva-collab"); diff --git a/umtool/e2e/takes.spec.ts b/umtool/e2e/takes.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test"; import { readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // Takes: alternative renders of part of a cut, side by side, judged. @@ -22,12 +23,12 @@ test("a project with no takes/ says so, and its page has no takes link", async ( expect(res?.status()).toBe(200); await expect(page.locator("[data-takes-empty]")).toContainText("No takes yet"); - await page.goto("/browse/reports/report-fixture"); + await page.goto(urls.section("reports/report-fixture", "takes")); await expect(page.locator("[data-takes-link]")).toHaveCount(0); }); test("takes are grouped and ordered; the skipped one says why; a work dir is not a take", async ({ page }) => { - await page.goto("/browse/reports/takes-fixture"); + await page.goto(urls.section("reports/takes-fixture", "takes")); const link = page.locator("[data-takes-link]"); await expect(link).toHaveAttribute("data-takes-link", "4"); await link.click(); diff --git a/umtool/e2e/timeline-edit.spec.ts b/umtool/e2e/timeline-edit.spec.ts @@ -2,6 +2,7 @@ import { test, expect, type Page } from "@playwright/test"; import { copyFileSync, existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // Structural edits to a report video (lib/report/manifest.mjs "STRUCTURE", @@ -20,7 +21,7 @@ const HERE = path.dirname(fileURLToPath(import.meta.url)); const DIR = path.join(HERE, "..", ".e2e-song", "reports", "timeline-fixture"); const MANIFEST = path.join(DIR, "video.manifest.json"); const PRISTINE = path.join(DIR, "video.manifest.pristine"); -const PAGE = "/browse/reports/timeline-fixture"; +const PROJECT = "reports/timeline-fixture"; type Entry = Record<string, unknown> & { id: string }; const manifest = () => JSON.parse(readFileSync(MANIFEST, "utf8")) as { timeline: Entry[]; posts?: Entry[]; render: Record<string, unknown> }; @@ -37,9 +38,11 @@ test.beforeEach(() => { rmSync(path.join(DIR, "notes.json"), { force: true }); }); -async function open(page: Page) { - await page.goto(PAGE); - await expect(page.getByTestId("timeline-undo")).toBeEnabled(); +/** The project page on the tab that holds `name`: the timeline (the Cut), or the on-screen panel's structure editors (Build). */ +async function open(page: Page, name: "timeline" | "onscreen" = "timeline") { + await page.goto(urls.section(PROJECT, name)); + if (name === "timeline") await expect(page.getByTestId("timeline-undo")).toBeEnabled(); + else await expect(page.getByTestId("structure-folded")).toBeVisible(); // The list has read its token once the page is hydrated. await page.waitForLoadState("networkidle"); } @@ -94,7 +97,7 @@ test("the row menu duplicates, removes, inserts — and a refusal is in the buil }); test("the teaser's lines and beat, edited in place; an empty teaser is refused", async ({ page }) => { - await open(page); + await open(page, "onscreen"); await page.getByTestId("structure-folded").locator("summary").click(); await page.getByTestId("teaser-lines-t1").fill("THE PROMISE\nAND WHAT HAPPENED"); await page.getByTestId("teaser-beat-t1").fill("1.2"); @@ -113,7 +116,7 @@ test("a post added, then removed; the fact-check's labels once the deck is on", m.render.chrome = { engine: "hyperframes", layout: "deck" }; writeFileSync(MANIFEST, JSON.stringify(m, null, 2) + "\n"); - await open(page); + await open(page, "onscreen"); await page.getByTestId("structure-folded").locator("summary").click(); await page.getByTestId("post-add").click(); const fresh = page.locator("[data-post-row='new']"); diff --git a/umtool/e2e/urls.ts b/umtool/e2e/urls.ts @@ -7,5 +7,18 @@ // // Assertions on hrefs (`toHaveAttribute("href", …)`) should build the expected // value here too, so a URL change is one edit in lib/hrefs.ts. +import { projectHref } from "../lib/hrefs"; +import { tabOfSection } from "../lib/pieces/tabs.mjs"; + export * from "../lib/hrefs"; export { REDIRECTS } from "../redirects.mjs"; + +/** + * The piece page's tab that holds `name` (lib/pieces/tabs.mjs SECTION_TAB): + * `section("reports/x", "deliver")` is `/projects/reports/x?tab=deliver`. A + * project page is tabs since P4a-1, and a spec that opened it to reach one + * section says which, so a section moving tab is one edit in that table. + */ +export function section(project: string, name: string, q: { all?: boolean; note?: string } = {}): string { + return projectHref(project, { tab: tabOfSection(name), ...q }); +} diff --git a/umtool/e2e/video-notes.spec.ts b/umtool/e2e/video-notes.spec.ts @@ -2,6 +2,7 @@ import { test, expect, type Locator, type Page } from "@playwright/test"; import { copyFileSync, existsSync, readFileSync, rmSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; // --------------------------------------------------------------------------- // Notes on a report video (lib/annotations, components/notes): @@ -67,7 +68,7 @@ test("the generated banner is on the project page and the clip bench", async ({ }); test("a timed note on the built cut resolves to the entry on screen and its source", async ({ page }) => { - await page.goto(PAGE); + await page.goto(urls.section(PROJECT, "onscreen")); const video = page.getByTestId("onscreen-final-video"); await expect(video).toBeVisible(); const scope = page.locator("[data-timed-notes='out/video-notes-fixture.mp4']"); @@ -139,7 +140,7 @@ test("an edit to a generated manifest leaves one edit note, coalesced, gone when }); test("a row note on the project page, counted on the row and kept across a reload", async ({ page }) => { - await page.goto(PAGE); + await page.goto(urls.section(PROJECT, "timeline")); const row = page.locator("[data-anchored-notes='n02']"); await row.locator("[data-action='toggle-notes']").click(); await page.getByTestId("note-input-n02").fill("check the date on this one"); diff --git a/umtool/lib/hrefs.test.mjs b/umtool/lib/hrefs.test.mjs @@ -39,6 +39,10 @@ test("empty, null and false values are left out; true is 1", () => { assert.equal(H.workHref({}), "/work"); assert.equal(H.workHref({ kind: "", state: undefined, q: "x y" }), "/work?q=x+y"); assert.equal(H.projectHref("p", { all: false }), "/projects/p"); + // A piece page's tab: first, the Overview never written, a note still last. + assert.equal(H.projectHref("a/b", { tab: "build" }), "/projects/a/b?tab=build"); + assert.equal(H.projectHref("a/b", { tab: "overview" }), "/projects/a/b"); + assert.equal(H.projectHref("a/b", { tab: "cut", all: true, note: "n1" }), "/projects/a/b?tab=cut&all=1¬e=n1"); assert.equal(H.projectsHref({ kind: "k1", new: false }), "/projects?kind=k1"); assert.equal(H.projectsHref({ new: true }), "/projects?new=1"); assert.equal(H.homeHref({ hidden: true }), "/?hidden=1"); diff --git a/umtool/lib/hrefs.ts b/umtool/lib/hrefs.ts @@ -230,10 +230,13 @@ export function articleCompareHref(id: string, q: { a?: string; b?: string } = { // ── projects ──────────────────────────────────────────────────────────────── -/** A project's page. `all` shows every row of a long list. */ -export function projectHref(id: string, q: { all?: boolean } & NoteOpt = {}): string { - const { note, ...rest } = q; - return withQuery(`/projects/${encodePath(id)}`, rest, note); +/** + * A project's page. `tab` opens one of the piece page's tabs (lib/pieces/tabs.mjs; + * absent, or `overview`, is the Overview); `all` shows every row of the cut's long list. + */ +export function projectHref(id: string, q: { tab?: string; all?: boolean } & NoteOpt = {}): string { + const { note, tab, ...rest } = q; + return withQuery(`/projects/${encodePath(id)}`, { ...(tab && tab !== "overview" ? { tab } : {}), ...rest }, note); } /** A project by its path, for an id that a tool page shadows at its own URL. */ diff --git a/umtool/lib/inbox/what.mjs b/umtool/lib/inbox/what.mjs @@ -0,0 +1,46 @@ +// What a decision kind is, in a few words after the piece's title: the Inbox's +// card line ("Quartering diet · claims never ruled") and a piece page's Next +// card. Pure, browser-safe. + +/** @type {Record<string, string>} */ +export const WHAT = { + "research-proposal": "research proposal", + "iteration-failed": "run failed", + "iteration-ready": "iteration ready", + "drafts-unreviewed": "drafts to review", + "open-note": "open notes", + "unreadable-notes": "notes.json does not read", + "link-ambiguous": "video not linked", + "looks-done": "looks done", + "claim-unadjudicated": "claims never ruled", + "claim-incoherent": "claims that don't hold together", + "clip-no-cues": "clips with no cues", + "clip-unfetchable": "clips can't be fetched", + "clip-mid-sentence": "clips end mid-sentence", + "clip-cue-gap": "clips over a cue gap", + "clip-cut-outside": "cuts outside the window", + "window-overlap": "windows overlap", + "no-punctuation": "windows without punctuation", + "manifest-invalid": "manifest invalid", + "stale-build": "video out of date", + unbuilt: "never built", + "storage-unreachable": "media drive unreachable", + "storage-mismatch": "storage disagrees", + "unjudged-variant": "variants not judged", + "missing-cut": "cuts missing", + "stale-recipe": "recipes out of date", + "no-recipe": "no recipe", + "spec-problem": "spec problem", + "no-plan": "plans unnamed", + unattributed: "variants unattributed", + "thumb-unaccepted": "no cover accepted", + loudness: "loudness off target", + "shadowed-name": "no address of its own", + "unroutable-name": "no address of its own", + "ambiguous-project": "two kinds match", + "machine-tool": "a required tool is missing", + "machine-disk": "disk nearly full", +}; + +/** A kind's words; an unknown kind reads as its id with spaces. */ +export const whatOf = (kind) => WHAT[kind] ?? kind.replace(/-/g, " "); 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 @@ -0,0 +1,132 @@ +import { readInbox, type GroupSummary } from "../inbox"; +import { summarizeGroups } from "../inbox/groups.mjs"; +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 { 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"; + +// --------------------------------------------------------------------------- +// A PIECE PAGE's frame, as data (plans/umtool-redesign.md, P4a-1): which piece +// a project page is, where it is on the four stages, its lifecycle, and its +// Next call -- the top of the Inbox, narrowed to this piece. +// +// A project is the page; the PIECE is what the Inbox and Work list. A project +// no article claims is its own piece (`p:<id>`); one an article claims (its +// iteration's projectDir, its manifest's `article`, a unique slug) is part of +// that article's piece, so the stage, the lifecycle and the Next call are the +// article's. P4a-2 renders that project AS the article's piece; until then the +// project page says whose it is and links it. +// +// SERVER ONLY. The graph is lib/pieces' (memoised 15 s); the lifecycle is read +// fresh, as everywhere. +// --------------------------------------------------------------------------- + +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). */ + piece: Piece | null; + pieceId: string; + /** The piece is an article's, and this project is one of its videos. */ + article: { title: string; site: string; report: string; href: string; via: string; cut: boolean } | null; + lifecycle: LifecycleState; + lifecycleError: string | null; + 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 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, 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); + const own = piece?.projects.find((p) => p.id === project.id) ?? null; + const article = + piece && piece.kind === "article" && piece.site && piece.report + ? { title: piece.title, site: piece.site, report: piece.report, href: piece.href, via: own?.via ?? "slug", cut: own?.cut ?? false } + : null; + const stage = piece + ? stageOf({ kind: piece.kind, stage: piece.stage, looksDone: piece.looksDone, projectState: piece.kind === "project" ? piece.stage : null }) + : "video"; + 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 = { + kind: string; + /** What it is, in a few words ("claims never ruled", "Narration draft · 5 fields"). */ + what: string; + why: string; + count: number; + severity: string; + group: string; + action: { label: string; href: string }; + /** The action is the lifecycle's (Mark done / Reactivate), a POST rather than a link. */ + lifecycleTo: LifecycleState | null; + /** More calls on this piece after this one. */ + more: number; +}; + +/** + * The piece's Next call: its top Inbox card (lib/inbox, ranked and grouped the + * Inbox's way), or -- for a parked or done piece, whose calls are hidden -- + * the way back. Null when nothing is waiting. + */ +export async function readNextCall(pieceId: string, lifecycle: LifecycleState): Promise<NextCall | null> { + const inbox = await readInbox(); + const mine = inbox.items.filter((d: Decision) => d.piece === pieceId); + if (lifecycle !== "active") { + const waiting = mine.filter((d) => d.hiddenBy === lifecycle).length; + return { + kind: "lifecycle", + what: lifecycle === "parked" ? "Parked" : "Marked done", + why: waiting ? `${waiting} call${waiting === 1 ? "" : "s"} hidden while it is ${lifecycle}` : "nothing hidden", + count: waiting, + severity: "info", + group: "hidden", + action: { label: "Reactivate", href: "" }, + lifecycleTo: "active", + more: 0, + }; + } + const groups = summarizeGroups(mine.filter((d) => !d.hidden)) as GroupSummary[]; + // Quiet is facts, not calls: a Next card never offers one. + const cards = groups.filter((g) => g.id !== "quiet").flatMap((g) => g.cards.map((c) => ({ g, c }))); + const top = cards[0]; + if (!top) return null; + const { g, c } = top; + const what = c.what ?? whatOf(c.kind); + return { + kind: c.kind, + what, + why: c.what && c.why.startsWith(c.what) ? c.why.slice(c.what.length).replace(/^ · /, "") : c.why, + count: c.count, + severity: c.severity, + group: g.id, + action: c.action, + lifecycleTo: c.kind === "looks-done" ? "done" : null, + more: cards.length - 1, + }; +} diff --git a/umtool/lib/pieces/tabs.mjs b/umtool/lib/pieces/tabs.mjs @@ -0,0 +1,147 @@ +// A PIECE PAGE's tabs (plans/umtool-redesign.md, P4a): which tab a project- +// rooted piece opens on, which section lives in which tab, and the key that +// switches to each. Pure, no imports: the page, a client component and an e2e +// spec (e2e/urls.ts `section`) read the same table. +// +// The tab is the URL's `?tab=` -- the canvas's address (`…?tab=media`) and the +// article page's own key (`/articles/<id>?tab=iterations`), so P4a-2's merged +// article piece keeps one spelling. Not a path segment: a project id is a path +// resolved longest-prefix, and what is left after it is a VIEW the kind declares +// (`clip/<id>`, `takes`, `review` …), so `/projects/a/b/build` could just as well +// be a project called `build`. +// +// An address with no `tab` opens the Overview -- except the two the page always +// answered that only make sense on one tab: `?all=1` (the cut's "show every +// quote") opens the Cut, and `?note=<id>` opens the tab its anchor is drawn on +// (a timeline row's note on the Cut, a timed note on the final video on Build). + +/** The stepper's four stages, by Work's buckets (lib/work/facets.mjs STAGES). */ +export const STAGE_STEPS = [ + { id: "research", label: "Research" }, + { id: "article", label: "Article" }, + { id: "video", label: "Video" }, + { id: "deliver", label: "Deliver" }, +]; + +/** + * The stepper, lit for one bucket: the stages before it done, it current, the + * 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 + * @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, na = {}) { + const at = STAGE_STEPS.findIndex((s) => s.id === bucket); + 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. */ +export const PIECE_TABS = [ + { id: "overview", label: "Overview" }, + { id: "cut", label: "Cut" }, + { id: "media", label: "Media" }, + { id: "build", label: "Build" }, + { id: "deliver", label: "Deliver" }, + { id: "sources", label: "Sources" }, + { id: "history", label: "History" }, +]; + +export const PIECE_TAB_IDS = PIECE_TABS.map((t) => t.id); + +/** + * Every section ReportProject draws, by the name a spec says, and the tab it + * is on. The names are the sections' own data attributes where they have one. + */ +export const SECTION_TAB = { + // Overview: the Next card, the piece's decisions, the stats, the linked + // article and its iterations, and the author's README. + next: "overview", + decisions: "overview", + readme: "overview", + stats: "overview", + article: "overview", + iterations: "overview", + // Cut: the timeline, the walk, takes, corrections for the next pass. + walk: "cut", + timeline: "cut", + cut: "cut", + takes: "cut", + corrections: "cut", + // Media: r28's drafts (the panel, the review and narration links) and the upload's text. + drafts: "media", + review: "media", + narration: "media", + youtube: "media", + // Build: the build chain, the on-screen panel (parked whole until P4b), the final mp4. + build: "build", + onscreen: "build", + final: "build", + // Deliver: the deliver panel and the exports. + deliver: "deliver", + exports: "deliver", + // Sources: the source table, availability, tagging the cited recordings. + sources: "sources", + tag: "sources", + // History: revisions, provenance, notes. + revisions: "history", + provenance: "history", + notes: "history", +}; + +/** The tab a section is on; throws on a name nobody declared (a spec's typo should fail loudly). */ +export function tabOfSection(name) { + const tab = SECTION_TAB[name]; + if (!tab) throw new Error(`no section "${name}" on a piece page (lib/pieces/tabs.mjs SECTION_TAB)`); + return tab; +} + +/** Where a note's anchor is drawn: a row's on the Cut, a timed note on the final video on Build. */ +export function tabOfNoteAnchor(kind) { + if (kind === "entry" || kind === "edit") return "cut"; + if (kind === "moment") return "build"; + return "overview"; +} + +/** + * The tab an address opens. + * + * @param {{ tab?: string, all?: string, note?: string }} search + * @param {{ noteTab?: string | null }} [opts] the tab the `note`'s anchor is on, when the page looked it up + */ +export function tabOf(search, { noteTab = null } = {}) { + const t = search?.tab; + if (t && PIECE_TAB_IDS.includes(t)) return t; + if (search?.note && noteTab && PIECE_TAB_IDS.includes(noteTab)) return noteTab; + if (search?.all === "1") return "cut"; + return "overview"; +} + +/** The tab a number key opens (`1` … `7`), or null. */ +export function tabOfKey(key) { + const n = Number(key); + return Number.isInteger(n) && n >= 1 && n <= PIECE_TABS.length ? PIECE_TABS[n - 1].id : null; +} diff --git a/umtool/lib/pieces/tabs.test.mjs b/umtool/lib/pieces/tabs.test.mjs @@ -0,0 +1,63 @@ +// A piece page's tabs: the address decides the tab, every section has one. +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, 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"]); + assert.equal(tabOfKey("1"), "overview"); + assert.equal(tabOfKey("7"), "history"); + for (const k of ["0", "8", "n", "", "1.5"]) assert.equal(tabOfKey(k), null, k); + assert.equal(PIECE_TABS.length, 7); +}); + +test("the address picks the tab: ?tab= first, then a note's anchor, then ?all=1, else the Overview", () => { + assert.equal(tabOf({}), "overview"); + assert.equal(tabOf({ tab: "build" }), "build"); + assert.equal(tabOf({ tab: "nonsense" }), "overview"); + assert.equal(tabOf({ all: "1" }), "cut"); + assert.equal(tabOf({ tab: "sources", all: "1" }), "sources"); + assert.equal(tabOf({ note: "n1" }, { noteTab: "build" }), "build"); + assert.equal(tabOf({ note: "n1" }), "overview"); + assert.equal(tabOf({ tab: "media", note: "n1" }, { noteTab: "cut" }), "media"); +}); + +test("a note opens where its anchor is drawn", () => { + assert.equal(tabOfNoteAnchor("entry"), "cut"); + assert.equal(tabOfNoteAnchor("edit"), "cut"); + assert.equal(tabOfNoteAnchor("moment"), "build"); + assert.equal(tabOfNoteAnchor("whole"), "overview"); +}); + +test("every section is on a real tab; an unknown one throws", () => { + for (const [name, tab] of Object.entries(SECTION_TAB)) assert.ok(PIECE_TAB_IDS.includes(tab), name); + assert.equal(tabOfSection("onscreen"), "build"); + assert.equal(tabOfSection("deliver"), "deliver"); + assert.throws(() => tabOfSection("nope"), /no section "nope"/); +}); + +test("the stepper: before the bucket done, it current, after it to do; a done piece walked them all", () => { + assert.deepEqual(STAGE_STEPS.map((s) => s.id), STAGES); + assert.deepEqual(stepsOf("video", "active").map((s) => s.state), ["done", "done", "current", "todo"]); + assert.deepEqual(stepsOf("research", "parked").map((s) => s.state), ["current", "todo", "todo", "todo"]); + assert.deepEqual(stepsOf("deliver", "active").map((s) => s.state), ["done", "done", "done", "current"]); + 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"]); +}); diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs @@ -781,6 +781,22 @@ export const REPORT_DECISION_KINDS = [ "storage-mismatch", ]; +/** + * The piece page's tab a project-wide decision is settled on, or null for the + * Overview. Plain names, not imported from lib/pieces/tabs.mjs: this file is + * the CLI's too, and the tab ids are part of the page's URL contract. + * + * @param {string} kind + * @param {string} target + */ +export function decisionTab(kind, target) { + if (kind === "stale-build" || kind === "unbuilt") return "build"; + if (kind === "storage-unreachable" || kind === "storage-mismatch") return target === "out" ? "build" : "deliver"; + if (kind === "manifest-invalid" && target === "storage.deliverables") return "deliver"; + if (kind === "no-punctuation") return "sources"; + return null; +} + export async function reportDecisions(ctx, summary) { const { id, dir } = ctx; const s = summary ?? (await summariseReport(ctx)); @@ -791,8 +807,14 @@ export async function reportDecisions(ctx, summary) { const out = []; if (!m) return out; - const add = (kind, target, why, severity, extra = {}) => - out.push({ kind, project: id, target, why, href, severity, at, ...extra }); + // A decision about the project as a whole links the piece page's tab that + // settles it (lib/pieces/tabs.mjs): a build on Build, the deliverables' + // storage on Deliver, an unpunctuated source on Sources; the rest the + // Overview. A clip's or a claim's links its bench. + const add = (kind, target, why, severity, extra = {}) => { + const tab = decisionTab(kind, target); + out.push({ kind, project: id, target, why, href: tab ? `${href}?tab=${tab}` : href, severity, at, ...extra }); + }; const shadowExists = await hasShadowChannels(dir); const channelsDir = channelsDirFor(dir, m, { shadowExists });