commit 8520e2e0b873ff596a693bfecb1c1e819e47909f
parent 789ab7445b00f9accc3d01c66cb5512994c46dd1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 11:33:36 -0400
Merge main (P4a-3 LIVE, 590cf959) into ux/p4b
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
27 files changed, 1562 insertions(+), 306 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -72,6 +72,9 @@
- **The generation policy is a chip on the article's page.** Its preset, the API model and the day's spend against the daily cap, linking `/settings/generation`.
- **umtool: an article's "+ note", its citations and "+ whole article" wait until the page is ready.** A click before then did nothing; they are now disabled until it is.
- **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.
+- **umtool: a song's page is a piece page.** `/projects/<song>` has the head — the title, **Active ▾**, **⋯** and the stage stepper **Spec → Cuts → Done** (Spec with a `spec.json`, Cuts with one cut built, Done with all four, which is also when the song looks done) — then five tabs: **Overview** (the **Next** card, the song's decisions, its four cut slots, what it is, **copy this song**, the README, and links to the song piles, find, mix, sources and the hook trimmer, which stay in Tools), **Cuts** (the cut cards, their verdicts, notes and variants, and what matches no cut), **Spec** (the spec sheet and the plans), **Cover** (the cover bench) and **Notes** (the note on the song and every other note on it, each linking its tab). `1`–`5` open the tabs and `n` runs the Next card. A cut's page, `/projects/<song>/<cut>`, keeps its address and is drawn inside the song with **Cuts** current and the four cuts beside the title. `?tab=` picks the tab and `?note=<target>` opens the tab that note is written on; `/browse/<song>` lands on the Overview.
+- **A song's calls open where they are settled.** A spec problem or an unnamed plan opens **Spec**, a variant that matches no cut **Cuts**, an unaccepted cover **Cover**; a cut's calls still open the cut's page.
+- **Work files a song by its own stepper.** A song's row shows its three steps (spec, cuts, done) and the stage facet files it with the stage its step stands for: Spec with Article, Cuts with Video, Done with Deliver, the same rule its page lights.
- **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
@@ -183,10 +183,13 @@ Each phase: its own branch from `main` (or the current integration branch), gate
```
NOW (beside r28) AFTER r28 IS ON main
-P0 design ─► P1 foundation ─┬─► P3 inbox/work/tools/URLs ─┬─► P2b jobs+drafts ─► P4a-1 ─► P4a-2 ─► P4a-3 ─► P4b ─► P6
- P2a engine ────┘ ├─► P5 create+settings (after P3)
- └─► R1 research: search+reader+inventory ─► R2 boards ─► R3 transparent runs (after r28)
+P0 design ─► P1 foundation ─┬─► P3 inbox/work/tools/URLs ─┬─► P2b jobs+drafts ─► P4a-1 ─► P4a-2 ─► P4a-3 ─► P4b ─┐
+ P2a engine ────┘ ├─► P5 create+settings (after P3) ├─► P6
+ └─► R1 research: search+reader+inventory ─► R2 boards ─► R3 transparent runs ─► R4 refresh ─► R5 recurring ─► R6 triage ─┘
```
+R4, R5 and R6 were added 2026-10-14 at the operator's request (see their sections), and the operator approved
+building all three and the co-host pilot. R4 runs beside P4a-3/P4b; its Iterations-tab entry waits for P4b. R5 builds
+on R4 and on P5's Create; R6 on R4 and R5. The pilot runs after R6.
### P0 — Design (no app code; operator sign-off gates P1)
- Use the frontend-design skill:
@@ -297,6 +300,84 @@ P0 design ─► P1 foundation ─┬─► P3 inbox/work/tools/URLs ─┬─
- on-screen (moved out of Build), narration, and "Draft with <model>" / "Draft everything" per section.
- One `JobProgress` for chain and editor jobs.
+### R4 — Refresh: re-fetch, see what changed, update (operator, 2026-10-14)
+A report iteration that is "fetch what's new, check it, update" — cheap and deterministic until something changed.
+- **Where:** a **Refresh** action on the article piece (head ⋯ menu; the Next card when a refresh is suggested; the
+ Iterations tab once P4b lands), and `umtool refresh <article>` / `pnpm ops report-draft {"task":"refresh"}`.
+- **Stage 1 — fetch (Archilyzer, no model).** Scope: the current report's iteration scope (channels, from/to) plus every
+ channel its citations touch. Plan, then the editor's own paced actions: `sync` per video channel, `fetch-posts` per
+ posts channel, `transcribe-bucket` for what lands — refused for a platform held or cooling down (polite scraping);
+ then a **local build** of the site whose build holds those channels (build only, never a deploy — through the publish
+ lock; Candace and other local-only channels stay local), because `report-draft` reads a composed build
+ (`corpusSource.ts`) and fresh videos are invisible to it until a build includes them (the research run's
+ `autoContinue: held` already waits on the same thing). The jobs show in the Running list.
+- **Stage 2 — what changed (deterministic, no model).** Re-run the original enumerate with the iteration's recorded
+ terms and scope (R3's trace `scope`/`terms`/`enumerate.ids`; a pre-R3 iteration: its question + channels, with the
+ citations as the old set) → **new** recordings (ids not matched before, including old videos that only now have a
+ transcript) and **changed** ones; re-verify every cited quote against today's transcript (R2's verify: changed words,
+ `en` vs `en-orig`, deleted sources). Written as the new iteration's `refresh.json`; shown as "4 new recordings
+ match · 2 quotes changed · 1 source deleted". **Nothing changed → the iteration ends "no change", $0.**
+- **Stage 3 — update (model) runs on its own** (operator ruling 2026-10-14) when stage 2 found anything, within the
+ policy's caps (per-job cap, daily cap; a cap refusal becomes a **Your call** card with the delta and the estimate).
+ Engine: `report-draft {"task":"refresh","article","iteration"}` = a sweep restricted to the new ids (a new
+ `ids` restriction on the sweep — channels and dates alone would miss late transcripts) over the parent's question,
+ then a revision of the parent report with those findings and the drift fixes, keeping everything still verified.
+ The result is a new iteration and an **iteration-ready** Review card — making it current stays the operator's call.
+- **Optional suggestion (operator: include it):** a cheap daily check per active or published article (stage 2's
+ enumerate only — no fetch, no model) → a `refresh-available` Inbox card "3 new recordings mention this since
+ <date>" whose action is **Refresh**. Muted/parked/done pieces are skipped.
+- Gates: common + editor tests and builds (the engine change), the full editor e2e at merge, an editor restart at ship.
+
+### R5 — Recurring reports (operator, 2026-10-14)
+The same topic, updated at an interval — e.g. a daily or weekly report of co-host updates.
+- **Create → "A recurring report"**: topic/question, scope (channels or a board's scope), cadence (daily · weekly on
+ <day> · every N days, at a time), and one of two shapes, each one sentence on the form:
+ - **Living report** — one article kept current: each tick runs R4's Refresh (stages 1–3) and lands an
+ iteration-ready card. Optionally "make current automatically" per series (default off).
+ - **Series** — a new dated **edition** each tick covering only the window since the previous edition
+ ("Co-host updates · week of 2026-10-13"): a sweep with `from` = the last edition's window end, after R4's stage 1
+ fetch + build. An empty window is recorded as a quiet edition (no article, $0). Editions belong to a series piece
+ `s:<series>` with its own page (editions newest first, the next tick, pause/resume, cadence) and one Work row.
+- **Scheduler: the editor**, the always-on process with the heartbeat, the caps, the pause gate and
+ `ARCHILYZER_IDLE_BOOT` — a `report-schedule` runner lane; the schedule is stored beside the article/series in the
+ article store, written only through an ops action (`pnpm ops report-schedule`). umtool shows and edits it; it never
+ runs a timer itself.
+- Surfaces: a cadence chip in the piece head ("weekly · next Mon 06:00", pause/resume); Work's "recurring" facet; each
+ finished edition or refresh → a Review card; a failed tick → Your call; spend per tick in the Running list.
+- The existing hand-kept co-host timeline (`quartering-leads`, `cohosts/UPDATE.md`) is the first candidate series — a
+ pilot after R5 ships, with the operator's go.
+
+### R6 — Triage first: a cheap pass that flags what is worth researching (operator, 2026-10-14)
+A consistent fetch, a cheap or local model that flags what is worth a look, and the better model with tools only on
+what it flags. Facts it builds on (surveyed 2026-10-14): per-video **digests** already exist (chapters + topic tags,
+local `qwen2.5:7b`, the `digest` lane yielding the GPU to transcription; `ai-digest.json`); the **local sweep pipeline**
+(`sweep-pipeline.ts`) is code around a small local model that already judges each window `relevant`/`on_topic`; the API
+sweep already splits a cheap extractor (`models.extractor`, Haiku) under the main model; there is no watch/saved-search
+concept and no standing relevance filter yet.
+- **Tier 0 — code, $0:** after R4's fetch + local build, the candidates are the recordings new since the last tick in
+ scope that match the watch's terms/aliases (enumerate) OR whose digest topic tags match the watch's topics.
+- **Tier 1 — the local model, $0 marginal:** the sweep pipeline's window judge, run over the candidates' matching
+ windows only (`draft:local`, through the GPU arbiter, yielding to transcription; ticks default to overnight). Each
+ flag: recording, window, a verbatim line (code-checked), a score and one-line reason. Dismissals are kept too.
+- **Escalation rule:** any flag at or above the watch's threshold (default: one strong flag, or N weak ones) → **Tier 2:
+ the better model with tools** — an API sweep restricted to the flagged ids (R4's `ids` restriction), within the caps,
+ running on its own (the operator's R4 ruling). Below threshold → the tick ends with its triage log, $0 API spend.
+- **Where the result goes**, per shape: a **living report** → R4's update (an iteration-ready card); a **series** → the
+ edition; a **watch** (R5's third shape: no article until something is found) → an Inbox **"Worth researching"** card
+ with the flags and the escalated findings, plus a board (R2 case) with the flags pinned `by: "triage"`, whose
+ hand-offs make an article or a video.
+- **Transparent and tunable:** the run page (R3) shows the tiers — candidates, each flag and dismissal with its reason,
+ what escalated and why, the spend per tier. The operator can mark a flag right or wrong; the watch keeps its precision
+ and suggests a threshold. Settings: the triage model (local by default; `models.extractor` allowed), the threshold, the
+ daily escalation cap.
+- **Engine:** a `report-draft` step `triage` (the window judge as a standalone pass over given ids, structured flags),
+ reused by R5's scheduler; `trace.jsonl` gains `triage {candidates, flagged, dismissed}`.
+
+**Pilot (operator-approved 2026-10-14), after R6:** the hand-kept co-host timeline (`quartering-leads`,
+`cohosts/UPDATE.md`; the co-host attribution hazard applies — a triage flag on a co-host line is a speaker check, not a
+finding) becomes a weekly **series** with triage first: one tick run end to end on the live corpus, its triage log and
+edition reviewed with the operator before the schedule is left on.
+
### P6 — Cleanup, docs, audit
- Redirects become 308.
- Delete `/drafts`, `BrowseHeader`, the dashboard panels and dead components.
@@ -354,11 +435,15 @@ P0 design ─► P1 foundation ─┬─► P3 inbox/work/tools/URLs ─┬─
| R2 research boards | `ux/r2` → `main` `b8561669` | LIVE 2026-10-14 (editor N0OAYPyM…, umtool 9lPefuiS…) |
| P4a-1 piece frame | `ux/p4a` → `main` `a92251aa` | LIVE 2026-10-14 (umtool ErWqdPdg…) |
| P5 create + settings | `ux/p5` → `main` `20ee628a` | LIVE 2026-10-14 (umtool ZfQXZuNF…) |
-| P4a-2 article-rooted merge | `ux/p4a2` | shipped on the branch |
-| P4a-3 song pieces | — | after P4a-2 |
+| P4a-2 article-rooted merge | `ux/p4a2` → `main` `d84cf4d7` | LIVE 2026-10-14 (umtool UFg8z3yd…) |
+| P4a-3 song pieces | `ux/p4a3` → `main` `3d69d6c6` | LIVE 2026-10-14 (umtool oN73I6F3…) |
| R3 transparent runs | `ux/r3` → `main` `6362cf40` | LIVE 2026-10-14 (editor HqcZW4aJ…, umtool 85Ultdj2…) |
-| P4b benches + Media | `ux/p4b` | shipped on the branch |
-| P6 | — | after all |
+| P4b benches + Media | `ux/p4b` | shipped on the branch (review follow-up in) |
+| R4 refresh | `ux/r4` | in progress |
+| R5 recurring reports | — | after R4 |
+| R6 triage first | — | after R5 |
+| Co-host pilot | — | after R6 (operator-approved) |
+| P6 cleanup, docs, audit | — | after P4a-3, P4b, R4–R6 |
### P2a, as shipped
@@ -1941,6 +2026,152 @@ the r28 session: editor built (53 s) and restarted (`scripts/r3-editor-{build,re
`/research/runs`, `/research/runs/piratesoftware-ai-friends/1` (the real turns.jsonl fallback, the question as title),
`/research`, `/work`, `/` 200; editor 200.
+### P4a-2 rollout (orchestrator, 2026-10-14)
+
+Rulings: Overview is every article's default tab; ONE policy href (`generationPolicyHref()` → `/settings/generation`);
+ONE stage rule for the stepper and Work's facet (`pieceSteps`/`stageOfPiece`; the furthest stage reached is current);
+the reader's note and citation buttons wait for hydration; the Iterations tab links a sweep's run page (R3's
+`runHref`). Gates on `243d2494` (R3 merged): full umtool e2e 431 passed, 0 failed, 6 skipped (9.7 min); test:scripts
+995 pass, 0 fail; capped build ok. `main` (R3's records merged, plan-only conflict resolved) fast-forwarded to
+`d84cf4d7`; umtool built (41 s) and restarted (`scripts/p4a2-umtool.sh`). Live: `/articles/piratesoftware-ai-friends`
+and its `?tab=iterations|cut|media` 200; the claimed project `/projects/articles/piratesoftware-ai-friends/i1?tab=cut`
+307 → the article's Cut tab; its clip bench stays 200 at the project URL; the Iterations tab links
+`/research/runs/piratesoftware-ai-friends/1`; decisions API 828 rows, notes' hrefs intact.
+
+### P4a-3, as shipped
+
+**What.** A song's page (`/projects/<song>`) is a piece page: the P4a frame around one of five tabs, Overview · Cuts ·
+Spec · Cover · Notes, with the stepper **Spec → Cuts → Done**. A cut's page (`/projects/<song>/<cut>`) keeps its address
+and is drawn inside the song with Cuts current. The song deck and the `/tools/song/<mode>` piles stay in Tools; the
+Overview links them.
+
+- **The frame** (`components/projects/song/SongFrame.tsx`) hands P4a-1's kind-blind `PieceFrame` the trail (`projects /
+ <project id>`, the title as the `<h1>`), the five tabs with their `?tab=` addresses (`projectHref(project.id, { tab })`),
+ the counts in Meter (Cuts: cuts built; Cover: covers on offer; Notes: notes written), the status line
+ (`4/4 cuts · 3 variants`, the old header's) and **⋯** (the project id; a song had no Delete before and has none now).
+ The lifecycle chip, the Undo bar, `1`–`5` and `n` come with the frame unchanged.
+- **One stage rule, a song's flow** (`lib/pieces/song-tabs.mjs`, pure, unit-tested). The song kind declares its stepper
+ in the registry (`lib/projects/kinds.mjs` `piece: { flow: SONG_FLOW, reached: songReached }`, `kindPieceFlow`); the
+ pieces graph copies the flow onto the piece (`Piece.flow`: `article`, `project`, or a kind's) with the facts that light
+ it (`Reached` gains `spec`, `cuts`, `done`). **`pieceSteps` and `stageOfPiece` switch on it** (`lib/pieces/tabs.mjs`,
+ an additive kind switch: `songSteps`, `bucketOfSongStep(songStepOf)`), and `stepOfPiece` is the frame's
+ `data-piece-stage` (a song's `spec` / `cuts` / `done`; the four-stage pieces' unchanged). The rule is the one rule: the
+ furthest stage reached is current, a skipped one is to do with its reason ("no spec.json"), a piece marked done has done
+ them all. Spec is reached with a `spec.json`, Cuts with one cut built, Done with all four (the derived `shipped`, which
+ is also P2a's looks-done suggestion: Done is current, Signal-ringed, until the operator marks it done).
+- **Work agrees.** `stageOf` reads the piece's flow: a song's bucket is the one its current step stands for — **Spec →
+ article, Cuts → video, Done → deliver** (the spec is a song's written stage, as an article is a report video's) — and
+ `stageBar` (`lib/work/facets.mjs`) draws a song's own three steps on its row with the step's word (`cuts`, `done`)
+ where a project's state used to be. The four-stage rows are unchanged. Unit-tested: for every combination of facts the
+ stepper's current step, `stepOfPiece`, `stageOf`'s bucket, `stageOfPiece` and the bar agree.
+- **The page reads its own facts fresh**: `readPieceFrame(project, { reached })` takes the song's facts from the
+ `readSong` the page did anyway (one stat for `spec.json`), over the graph's 15 s memo, so a promote shows at once; a song
+ the graph has not listed yet still walks the song's stepper (`kindPieceFlow`).
+- **The Next card** is P4a-1's, kind-blind: the song's top Inbox card (an unnamed plan, an unjudged variant, a missing cut,
+ a stale recipe … or **Mark done** when looking done is all that is left).
+- **A song's calls open their tab** (`lib/decisions.ts`, by `songTabOfSection`): `spec-problem` and `no-plan` → Spec,
+ `unattributed` → Cuts, `thumb-unaccepted` → Cover (`/projects/<song>?tab=…`); a cut's calls (`missing-cut`,
+ `unjudged-variant` with its `?v=`, `stale-recipe`, `no-recipe`, `loudness`) keep the cut page's href.
+- **Addresses.** No `tab` is the Overview; a bad `tab` is the Overview; `?note=<target>` opens the tab that note is
+ written on (a song's notes are keyed by target, `lib/notes.ts`): `song` → Notes; `cut:`, `file:`, `moment:`,
+ `source:`, `clip:` → Cuts; `plan:` → Spec; `thumb:` → Cover. `/browse/<song>` rides P3's redirect to the Overview,
+ `/browse/<song>/<cut>` to the cut's page. The cut page's own keys (`?v=`, `?plan=`, `?notes=all`) are unchanged.
+
+**Section → tab** (SongProject's two columns and head row, CutPage's body; `SONG_SECTION_TAB` names each for
+`e2e/urls.ts` `songSection(song, name)`):
+
+| Section (its attribute) | Tab |
+|---|---|
+| Header: crumbs `songs / <id>`, note `N/4 cuts · N variants` | head (trail `projects / <id>`, the title, the same status line) |
+| Head row: the song's note (`NoteField target="song"`) | Notes |
+| Head row: **copy this song** (`CopyButton`, `/api/browse/context?song=`) | Overview (`data-song-copy`) |
+| Left: the four cut cards (`data-cut`, `data-present`, `data-variant`, `data-variant-tag`, `VerdictChip`, the slot's and the file's notes) | Cuts |
+| Left: matches no cut name (`data-unattributed`, new attribute) | Cuts |
+| Aside: `ThumbBench` (`data-judge-faces` …) | Cover (says "No cover generated" when the bench would draw nothing) |
+| Aside: `SpecSheet` (`data-op` …) | Spec |
+| Aside: README | Overview (`data-readme`) |
+| Aside: plans, their notes, clips.csv (`data-song-plans`, new) | Spec |
+| CutPage: `CutBench`, `LoudnessTable`, `ProvenancePanel` | Cuts (the cut's page, a view of it; `bare`, unpadded as before) |
+| CutPage: crumbs `songs / <id> / <cut>`, note duration · bytes | head: trail with the id linking the song, the four cuts beside the title (`data-song-cut-picker`), the same note |
+| new: the Next card, the song's decisions (P4a-1's `ProjectDecisions`), the four cut slots (`data-song-slot`), This song (cuts, variants, verdicts, plans, cover, looks done — `data-song-looks-done`), Song tools (`data-song-pile`, `data-song-trim`, song piles, find, mix, sources) | Overview |
+| new: every other note on the song, each linking its tab (`data-song-notes`, `data-song-note-target`) | Notes |
+
+The sections live in `components/projects/song/{SongFrame,OverviewTab,CutsTab,SpecTab,CoverTab,NotesTab}.tsx`;
+`SongProject.tsx` reads the song once, picks the tab and renders the frame; `CutPage.tsx` keeps its body and draws it
+through `SongFrame`. `ProjectView`'s song case hands both the project (it handed the basename). Only the tab on show is
+read: the Cuts tab's ffprobes and the spec's validation cost nothing on the Overview. A cut card's name is an ink link
+(it wore Signal on hover). `[data-nav-group=song]` and every `data-testid` are untouched.
+
+**Shared files, additive only.** `lib/pieces/tabs.mjs`: the import, the kind switch in `pieceSteps` and
+`stageOfPiece`, the new `stepOfPiece`. `PieceFrame`: no change. `lib/pieces/frame.ts`: `readPieceFrame`'s optional
+`reached`, the flow from the piece or the registry, `stepOfPiece` for `stage`. `lib/pieces.ts`: `Piece.flow`, `Reached`,
+a project piece's declared facts. `lib/work.ts`/`lib/work/facets.mjs`/`app/work/page.tsx`: the flow, `stageBar`, the
+row's `steps`. `lib/projects/kinds.mjs`: the song's `piece`, `kindPieceFlow`; `lib/projects/song.mjs`: `songReached`.
+`lib/decisions.ts`: the song-wide hrefs' tab. `e2e/urls.ts`: `songSection`.
+
+| sha | what |
+|---|---|
+| `aa8739d9` | the song piece: `lib/pieces/song-tabs.mjs` (+ unit tests), the flow switch in `pieceSteps`/`stageOfPiece`, `stepOfPiece`, the registry's `piece` and `songReached`, `Piece.flow`/`Reached`, `readPieceFrame`'s fresh facts, Work's `stageBar`, `components/projects/song/*`, `SongProject`/`CutPage` through `SongFrame`, the song-wide hrefs' tab |
+| `56a1fe72` | specs: `browse`/`faces`/`projects` through `urls.songSection`, `e2e/song-piece.spec.ts` (9); a cut card's name an ink link |
+
+**Gates** (at `56a1fe72`).
+
+| Gate | Result |
+|---|---|
+| repo-wide `tsc --noEmit` | clean at both commits (umtool typecheck clean) |
+| umtool unit (`node --test umtool/lib/*.test.mjs umtool/lib/*/*.test.mjs umtool/report-to-video/*.test.mjs`) | 850 tests, 848 pass, 2 skipped, 0 fail (new: `song-tabs.test.mjs` 4 — the tabs and sections, the address → tab rules and `?note=<target>`, the stepper by what exists, the stepper against Work's facet and bar) |
+| `pnpm --filter umtool test` | 24/24 |
+| `pnpm run test:scripts` (reads the capped build's traces) | 1001 tests, 999 pass, 2 skipped, 0 fail |
+| capped umtool `next build` (corpus linked, `MemoryMax=5G`) | exit 0, compiled 12.4 s, 39 s wall, 1.48 GB max RSS; the link removed |
+| song specs, dev mode (`E2E_MODE=dev`, the song specs' filter) | 102 tests: 96 passed, 1 failed, 5 skipped, 6.4 min; `song-piece.spec` 9/9. Red: `projects.spec:219` (the tool pages under `/browse`: a dev-mode `ERR_ABORTED` on first compile; green in both start-mode runs) |
+| full umtool e2e, run 1 (`56a1fe72`) | 446 tests: 437 passed, 3 failed, 6 skipped. Reds: `board.spec:102` (`e` did not focus the claim field) and the two after it that build on its sections (`:164`, `:186`) — the run started after 12 minutes waiting at the heavy slot for memory (a sibling dev server at 3.8 GB, 2.2–3.4 GB available); `board.spec` + `song-piece.spec` alone: 16/16 |
+| full umtool e2e, run 2 (`56a1fe72`) | **446 tests: 440 passed, 0 failed, 6 skipped** (the song-data capability skips), 10.9 min; `song-piece.spec` 9/9 |
+
+**Spec churn:** `browse.spec` (6 gotos through `urls.songSection`: the cut cards, verdicts and a hole on Cuts, the trim
+operation on Spec), `faces.spec` (the bench on Cover), `projects.spec` ("the song URLs that already existed": `/browse/alpha`
+is the Overview with the cut slots, the Cuts tab has the cards, `/browse/alpha/wide` is the cut's page with Cuts current,
+the canonical path is the Overview). No `data-testid` renamed. New `e2e/song-piece.spec.ts` (9): the frame (title, trail,
+status line, stepper at Done, five tabs, the Overview alone); a song with a hole at Cuts and Work's row (bucket, word,
+looks done) agreeing with both steppers; the Next card = the Inbox's top card for the song; a song's calls' hrefs; the
+tab as the URL (`?tab=`, a bad tab, `?note=song|plan:|cut:`, `/browse/alpha`); the cut's page (frame, picker, the
+loudness table, the trail back, a hop to `wide-short`); the keys (`2`, `5`, `1`, `n`); marked done (all done, the
+suggestion gone, the Next card's Reactivate); 1366×768 with no horizontal scroll on four addresses.
+
+**Screenshots** (job scratch `p4a3-shots/final/`, 17): `alpha` (all four cuts, at Done) on Overview, Cuts and Spec at
+1366×768 and 1440×900, dark and light; and, dark at 1366×768, the cut page `alpha/wide`, Cover, Notes, `beta`'s Overview
+(at Cuts, two holes) and Work filtered to songs — on the e2e start build over the fixture. Against the canvas's Piece ·
+Overview, in a song's words: the head (title in Archivo, the chip and ⋯ on the right, the status line), the three-step
+stepper with Done Signal-ringed, the five tabs with Meter counts and the Signal underline, the Next card with its Signal
+edge and one filled action ("Name the plan" → Spec), the two columns (decisions and the four cut slots | This song and
+the song tools), the README under them. Work's row for Mortal Kombat in the canvas reads step 2 "Cuts"; a song's row now
+reads its own three bars with `cuts` lit second, as drawn there.
+
+**Found and left.**
+- **On the real reports** (a read-only listing): all five songs have a `spec.json`; `mario-rpg`, `metal-slug`,
+ `mortal-kombat` and `yoshi` have three of the four cuts and stand at Cuts, `pokemon` has all four and stands at Done
+ with P2a's looks-done suggestion. The fixture's alpha has no `spec.json` until browse.spec writes one, so its Spec
+ reads to do ("no spec.json") on a fresh fixture.
+- **Spec → article** in Work's stage facet is a ruling to confirm: a song with a spec and no cut is filed under Article
+ (the written stage). The alternatives were Video (a song is a video piece) or Research; Article keeps the three steps
+ on three different buckets, so a song moves along the facet as it moves along its stepper.
+- **`urls.songSection`, not `urls.section`**: a song's section names overlap the report's (`notes`, `readme`,
+ `decisions`, `next`) on different tabs, so the song has its own table and builder rather than a fall-through.
+- The song bench's own controls (CutBench, ProvenancePanel, LoudnessTable, SpecSheet, ThumbBench, NoteField, VerdictChip)
+ keep P1's Signal-outline `primary` buttons and their Signal states; only the cut card's name link changed. They live
+ outside `components/projects/` and were moved, not restyled.
+
+### P4a-3 rollout (orchestrator, 2026-10-14)
+
+Rulings: a song with a spec and no cut sits under Article in Work's stage facet; specs use `urls.songSection`; Work
+draws a song's three bars, as its stepper does (one stage rule over the canvas mock's four); the song benches' Signal-outline
+buttons stay until P6's audit. Gates on `56a1fe72` (the merge of `main` brought plan text only): full umtool e2e 440
+passed, 0 failed, 6 skipped (10.9 min); test:scripts 999 pass, 0 fail; capped build ok. `main` fast-forwarded to
+`3d69d6c6`; umtool built (171 s) and restarted (`scripts/p4a3-umtool.sh`). Live: the five songs under
+`/projects/quartering-uh-song/videos/`, pokemon at Done and mario-rpg at Cuts; pokemon's five tabs and four cut pages 200;
+`/browse/quartering-uh-song/videos/pokemon` 307 → the Overview; decisions API 828 rows, notes' hrefs end `note=<id>`.
+P6 audit: a cut card links `/projects/<song id>/<cut>` (the short id) while the song's page is the full path — both
+resolve; P6 picks one canonical address. The ochre `OPEN` chips on a song's decisions are a verdict colour on a state.
+
### P4b, as shipped
**What.** The human-piloted walks are one bench shell, a report video's drafted fields are one Media surface, and
diff --git a/umtool/app/work/page.tsx b/umtool/app/work/page.tsx
@@ -263,7 +263,7 @@ function Row({ r }: { r: WorkRow }) {
</LitActions>
</div>
<span className="flex items-center gap-[3px]" title={r.looksDone.join("; ") || undefined}>
- {[1, 2, 3, 4].map((i) => (
+ {Array.from({ length: r.steps }, (_, k) => k + 1).map((i) => (
<i
key={i}
className={cn("h-1 w-[22px] rounded-[1px]", i < r.step ? "bg-text-2" : i === r.step ? "bg-signal" : "bg-seam-2")}
diff --git a/umtool/components/projects/CutPage.tsx b/umtool/components/projects/CutPage.tsx
@@ -1,6 +1,5 @@
import Link from "next/link";
import { notFound } from "next/navigation";
-import BrowseHeader from "@/components/BrowseHeader";
import CutBench from "@/components/CutBench";
import ProvenancePanel from "@/components/ProvenancePanel";
import { isCutName, probeAll, readSong } from "@/lib/browse";
@@ -13,21 +12,32 @@ import LoudnessTable from "@/components/LoudnessTable";
import { cachedLoudness } from "@/lib/loudness";
import { DEFAULT_TARGET } from "@/lib/loudness-types";
import { readSpec } from "@/lib/spec";
-import { resolveRendition } from "@/lib/browse";
+import { resolveRendition, thumbAliasesFor } from "@/lib/browse";
+import { cutHref, projectHref } from "@/lib/hrefs";
+import { thumbView } from "@/lib/thumbs";
+import type { ProjectRef } from "@/lib/project-types";
+import SongFrame, { readSongFrame, songCounts } from "./song/SongFrame";
// Moved out of app/browse/[song]/[cut]/page.tsx unchanged. `/browse/<song>/wide`
// is now a project id plus a VIEW, resolved by the registry rather than by a
// route segment -- the URL is byte-identical either way, which is the point.
+//
+// Since P4a-3 a cut's page is a view of the song piece's Cuts tab: the song's
+// frame (components/projects/song/SongFrame.tsx) with Cuts current, the four
+// cuts beside the title, and the bench, the loudness and the provenance under
+// it, unchanged.
export default async function CutPage({
- id,
+ project,
cutName,
search,
}: {
- id: string;
+ project: ProjectRef;
cutName: string;
search: { v?: string; plan?: string; notes?: string };
}) {
+ // Keyed by BASENAME, as every song route is (lib/browse.ts songDir).
+ const id = project.name;
const { v, plan, notes: notesParam } = search;
if (!isCutName(cutName)) notFound();
@@ -68,26 +78,44 @@ export default async function CutPage({
truePeak: spec.loudness?.truePeak ?? DEFAULT_TARGET.truePeak,
};
+ const [frame, thumbs] = await Promise.all([readSongFrame(project, song), thumbView(id, thumbAliasesFor(id))]);
+
return (
- <div className="flex h-full flex-col">
- <BrowseHeader
- crumbs={[
- { href: "/projects", label: "songs" },
- { href: `/projects/${song.id}`, label: song.id },
- { label: cutName },
- ]}
- note={
- cut.shipped
- ? `${fmtDur(durations[cut.shipped.rel] ?? 0)} · ${fmtBytes(cut.shipped.size)}`
- : "not built"
- }
- />
- <main className="deck-main flex-1">
+ <SongFrame
+ project={project}
+ song={song}
+ frame={frame}
+ tab="cuts"
+ bare
+ idHref={projectHref(project.id)}
+ counts={songCounts(song, notes, thumbs.candidates.length)}
+ note={
+ cut.shipped
+ ? `${fmtDur(durations[cut.shipped.rel] ?? 0)} · ${fmtBytes(cut.shipped.size)}`
+ : "not built"
+ }
+ meta={
+ <span className="flex flex-wrap items-baseline gap-x-2.5" data-song-cut-picker={cutName}>
+ <span className="micro">cut</span>
+ {song.cuts.map((c) =>
+ c.name === cutName ? (
+ <span key={c.name} aria-current="page" className="font-mono text-[12.5px] font-semibold text-text">
+ {c.name}
+ </span>
+ ) : (
+ <Link key={c.name} href={cutHref(project.id, c.name)} prefetch={false} className="ink-link font-mono text-[12.5px]">
+ {c.name}
+ </Link>
+ ),
+ )}
+ </span>
+ }
+ >
{!cut.shipped && cut.variants.length === 0 ? (
<div className="p-4 text-[12px] text-[var(--color-dim)]">
Nothing here yet — no <code className="font-mono">{cutName}.mp4</code> and no variants
named for it.{" "}
- <Link href={`/projects/${song.id}`} className="ink-link">
+ <Link href={projectHref(project.id, { tab: "cuts" })} className="ink-link">
back to {song.id}
</Link>
</div>
@@ -119,7 +147,6 @@ export default async function CutPage({
</div>
</>
)}
- </main>
- </div>
+ </SongFrame>
);
}
diff --git a/umtool/components/projects/ProjectView.tsx b/umtool/components/projects/ProjectView.tsx
@@ -36,8 +36,9 @@ export default async function ProjectView({
}) {
switch (project.kind) {
case "song": {
- if (rest.length === 0) return <SongProject id={project.name} />;
- if (rest.length === 1) return <CutPage id={project.name} cutName={rest[0]} search={search} />;
+ // The song piece (P4a-3), and a cut's page: a view of its Cuts tab.
+ if (rest.length === 0) return <SongProject project={project} search={search} />;
+ if (rest.length === 1) return <CutPage project={project} cutName={rest[0]} search={search} />;
return notFound();
}
case "report-video": {
diff --git a/umtool/components/projects/SongProject.tsx b/umtool/components/projects/SongProject.tsx
@@ -1,255 +1,67 @@
-import Link from "next/link";
import { notFound } from "next/navigation";
-import BrowseHeader from "@/components/BrowseHeader";
-import VerdictChip from "@/components/VerdictChip";
-import SpecSheet from "@/components/SpecSheet";
-import NoteField from "@/components/NoteField";
-import CopyButton from "@/components/CopyButton";
-import { readSong, probeAll, thumbAliasesFor, type Cut, type Song } from "@/lib/browse";
-import ThumbBench from "@/components/ThumbBench";
+import { readSong, thumbAliasesFor } from "@/lib/browse";
import { thumbView } from "@/lib/thumbs";
-import { fmtAgo, fmtBytes, fmtDur } from "@/lib/format";
-import { Markdown } from "@/lib/markdown";
-import { operationsFor, readSpec, validateSpec } from "@/lib/spec";
-import { readNotes, type NoteMap } from "@/lib/notes";
-import { TRIM_SETS } from "@/lib/trim";
+import { readNotes } from "@/lib/notes";
+import { songTabOf } from "@/lib/pieces/song-tabs.mjs";
+import type { ProjectRef } from "@/lib/project-types";
+import SongFrame, { readSongFrame, songCounts } from "./song/SongFrame";
+import OverviewTab from "./song/OverviewTab";
+import CutsTab from "./song/CutsTab";
+import SpecTab from "./song/SpecTab";
+import CoverTab from "./song/CoverTab";
+import NotesTab from "./song/NotesTab";
-// Moved out of app/browse/[song]/page.tsx unchanged, because [song] and
-// [...path] cannot both be dynamic segments at the same level. The dispatcher
-// in ProjectView.tsx hands it an id; nothing else about the page differs.
+// ---------------------------------------------------------------------------
+// A song, as a PIECE PAGE (plans/umtool-redesign.md, P4a-3).
+//
+// Moved out of app/browse/[song]/page.tsx unchanged in P3, because [song] and
+// [...path] cannot both be dynamic segments at the same level; the dispatcher
+// in ProjectView.tsx hands it the project. Since P4a-3 it is the piece frame
+// (components/projects/song/SongFrame.tsx: head, Spec → Cuts → Done stepper,
+// lifecycle, Next card, tabs, keys) around ONE tab, and the sections it drew in
+// two columns live in the tabs (components/projects/song/*), moved unchanged:
+//
+// head row: the song's note → Notes; "copy this song" → Overview
+// the cut cards, what matches no cut → Cuts
+// the cover bench → Cover
+// the spec sheet, the plans → Spec
+// the README → Overview
+//
+// Which section is on which tab is lib/pieces/song-tabs.mjs SONG_SECTION_TAB.
+// Only the tab on show is read: the Cuts tab's ffprobes and the spec's
+// validation cost nothing on the Overview.
+// ---------------------------------------------------------------------------
-export default async function SongProject({ id }: { id: string }) {
+export default async function SongProject({
+ project,
+ search,
+}: {
+ project: ProjectRef;
+ search: Record<string, string | undefined>;
+}) {
+ // Keyed by BASENAME, as every song route is (lib/browse.ts songDir).
+ const id = project.name;
const song = await readSong(id);
if (!song) notFound();
- // Durations are worth an ffprobe HERE but not on the index: this page is a
- // handful of files and "which of these is the short cut" is exactly the
- // question it answers. Memoised by mtime in lib/browse.ts.
- const rels = [
- ...song.cuts.flatMap((c) => [c.shipped?.rel, ...c.variants.map((v) => v.rel)]),
- ...song.unattributed.map((v) => v.rel),
- ].filter((r): r is string => !!r);
- const info = await probeAll(id, rels);
-
- const spec = await readSpec(id);
- const problems = await validateSpec(spec);
- const notes = await readNotes(id);
- // Two small JSON reads, no probing -- the bench draws what the manifests say.
- const thumbs = await thumbView(id, thumbAliasesFor(id));
+ const tab = songTabOf(search);
+ // Two small JSON reads each, no probing.
+ const [frame, notes, thumbs] = await Promise.all([readSongFrame(project, song), readNotes(id), thumbView(id, thumbAliasesFor(id))]);
return (
- <div className="flex h-full flex-col">
- <BrowseHeader
- crumbs={[{ href: "/projects", label: "songs" }, { label: song.id }]}
- note={`${song.present}/${song.cuts.length} cuts · ${song.variantCount} variants`}
- />
- <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">
- {/* The one obvious place to write about the song, open by default --
- everything else on the page is collapsed until asked for. */}
- <NoteField song={id} target="song" initial={notes.song ?? null} label="notes on this song" />
- </div>
- <CopyButton
- label="copy this song"
- title="this song as markdown — spec, cuts, verdicts, notes and resolved marks"
- url={`/api/browse/context?song=${encodeURIComponent(id)}`}
- />
- </div>
- <main className="deck-main flex-1">
- <div className="grid gap-4 p-4 xl:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]">
- <div className="space-y-3">
- {song.cuts.map((cut) => (
- <CutCard key={cut.name} song={song} cut={cut} info={info} notes={notes} />
- ))}
-
- {song.unattributed.length > 0 && (
- <section className="rounded border border-[var(--color-dirty)]/40 bg-[var(--color-panel)] p-3">
- <div className="micro mb-2">
- matches no cut name — attribute by renaming, never by guessing
- </div>
- <ul className="space-y-1">
- {song.unattributed.map((v) => (
- <li key={v.rel} className="num text-[12px] text-[var(--color-dim)]">
- <span className="font-mono text-[var(--color-text)]">{v.rel}</span>{" "}
- {fmtBytes(v.size)}
- </li>
- ))}
- </ul>
- </section>
- )}
- </div>
-
- <aside className="space-y-4">
- <ThumbBench song={song.id} view={thumbs} notes={notes} />
- <SpecSheet
- song={song.id}
- initial={spec}
- problems={problems}
- operations={operationsFor(spec, song)}
- plans={song.plans.map((p) => p.name)}
- trimSets={Object.values(TRIM_SETS).map((t) => ({ id: t.id, label: t.label }))}
- />
- {song.readme && (
- <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3">
- <Markdown text={song.readme} />
- </section>
- )}
- <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3">
- <div className="micro mb-2">plans</div>
- {song.plans.length === 0 ? (
- <p className="text-[12px] text-[var(--color-dim)]">no plan/ directory</p>
- ) : (
- <ul className="space-y-0.5">
- {song.plans.map((p) => (
- <li key={p.name} className="num text-[11px] text-[var(--color-dim)]">
- <span className="flex gap-2">
- <span className="truncate font-mono text-[var(--color-text)]">{p.name}</span>
- <span className="ml-auto shrink-0">{fmtBytes(p.size)}</span>
- </span>
- <NoteField
- song={song.id}
- target={`plan:${p.name}`}
- initial={notes[`plan:${p.name}`] ?? null}
- label="what this plan is"
- rows={3}
- />
- </li>
- ))}
- </ul>
- )}
- {song.hasClipsCsv && <div className="micro mt-2">clips.csv present</div>}
- </section>
- </aside>
- </div>
- </main>
- </div>
- );
-}
-
-function CutCard({
- song,
- cut,
- info,
- notes,
-}: {
- song: Song;
- cut: Cut;
- info: Record<string, { duration: number; width: number; height: number }>;
- notes: NoteMap;
-}) {
- const shipped = cut.shipped;
- const live = cut.variants.filter((v) => !v.retired);
- const retired = cut.variants.filter((v) => v.retired);
-
- return (
- <section
- data-cut={cut.name}
- data-present={shipped ? "1" : "0"}
- className="rounded border border-[var(--color-line)] bg-[var(--color-panel)]"
+ <SongFrame
+ project={project}
+ song={song}
+ frame={frame}
+ tab={tab}
+ counts={songCounts(song, notes, thumbs.candidates.length)}
+ note={`${song.present}/${song.cuts.length} cuts · ${song.variantCount} variants`}
>
- <div className="flex items-start gap-3 p-3">
- {shipped ? (
- /* eslint-disable-next-line @next/next/no-img-element */
- <img
- src={`/api/browse/poster?song=${encodeURIComponent(song.id)}&rel=${encodeURIComponent(shipped.rel)}&w=320`}
- alt=""
- width={160}
- height={90}
- className="w-40 shrink-0 rounded bg-[var(--color-panel-2)] object-cover"
- />
- ) : (
- <div className="flex h-[90px] w-40 shrink-0 items-center justify-center rounded border border-dashed border-[var(--color-line)] text-[11px] text-[var(--color-dim)]">
- not built
- </div>
- )}
-
- <div className="min-w-0 flex-1 space-y-1">
- <div className="flex flex-wrap items-baseline gap-2">
- <Link
- href={`/projects/${song.id}/${cut.name}`}
- className="font-mono text-[13px] text-[var(--color-text)] hover:text-[var(--color-sel)]"
- >
- {cut.name}
- </Link>
- {shipped ? (
- <span className="num text-[11px] text-[var(--color-meter)]">
- {fmtDur(info[shipped.rel]?.duration ?? 0)}
- </span>
- ) : (
- <span className="text-[11px] text-[var(--color-dim)]">— a hole in the set</span>
- )}
- {shipped && info[shipped.rel] && (
- <span className="num text-[11px] text-[var(--color-dim)]">
- {info[shipped.rel].width}×{info[shipped.rel].height}
- </span>
- )}
- <span className="num ml-auto text-[11px] text-[var(--color-dim)]">
- {shipped ? `${fmtBytes(shipped.size)} · ${fmtAgo(shipped.mtimeMs)}` : ""}
- </span>
- </div>
-
- {shipped && (
- <VerdictChip song={song.id} rel={shipped.rel} initial={shipped.verdict} />
- )}
-
- {/* Two different notes, deliberately. The `cut:` one is about the SLOT
- -- it survives a promote and can be written about a cut that has
- not been built. The `file:` one is about these bytes. */}
- <NoteField
- song={song.id}
- target={`cut:${cut.name}`}
- initial={notes[`cut:${cut.name}`] ?? null}
- label={`notes on ${cut.name}`}
- rows={3}
- />
- {shipped && (
- <NoteField
- song={song.id}
- target={`file:${shipped.rel}`}
- initial={notes[`file:${shipped.rel}`] ?? null}
- label="notes on this file"
- rows={3}
- />
- )}
-
- {live.length > 0 && (
- <ul className="space-y-1 pt-1">
- {live.map((v) => (
- <li
- key={v.rel}
- data-variant={v.rel}
- data-variant-tag={v.tag}
- className="flex flex-wrap items-center gap-2 rounded bg-[var(--color-panel-2)] px-2 py-1"
- >
- <span className="font-mono text-[12px] text-[var(--color-text)]">{v.tag}</span>
- <span className="num text-[11px] text-[var(--color-meter)]">
- {fmtDur(info[v.rel]?.duration ?? 0)}
- </span>
- <span className="num text-[11px] text-[var(--color-dim)]">{fmtBytes(v.size)}</span>
- <div className="ml-auto">
- <VerdictChip song={song.id} rel={v.rel} initial={v.verdict} />
- </div>
- <div className="w-full">
- <NoteField
- song={song.id}
- target={`file:${v.rel}`}
- initial={notes[`file:${v.rel}`] ?? null}
- label={`notes on ${v.tag}`}
- rows={3}
- />
- </div>
- </li>
- ))}
- </ul>
- )}
-
- {retired.length > 0 && (
- <div className="micro pt-1" data-retired={retired.length}>
- {retired.length} retired: {retired.map((v) => v.tag).join(", ")}
- </div>
- )}
- </div>
- </div>
- </section>
+ {tab === "overview" && <OverviewTab project={project} song={song} frame={frame} covers={thumbs} />}
+ {tab === "cuts" && <CutsTab song={song} notes={notes} />}
+ {tab === "spec" && <SpecTab song={song} notes={notes} />}
+ {tab === "cover" && <CoverTab song={song} view={thumbs} notes={notes} />}
+ {tab === "notes" && <NotesTab projectId={project.id} song={song} notes={notes} />}
+ </SongFrame>
);
}
diff --git a/umtool/components/projects/song/CoverTab.tsx b/umtool/components/projects/song/CoverTab.tsx
@@ -0,0 +1,24 @@
+import ThumbBench from "@/components/ThumbBench";
+import type { Song } from "@/lib/browse";
+import type { NoteMap } from "@/lib/notes";
+import type { ThumbView } from "@/lib/thumbs";
+
+// The Cover tab: the cover-art bench -- the candidates, the corners each would
+// spend, accepting one, the way to the face judger -- SongProject's aside,
+// moved unchanged (P4a-3). The bench draws nothing when there is nothing to
+// judge, so the tab says so.
+
+export default function CoverTab({ song, view, notes }: { song: Song; view: ThumbView; notes: NoteMap }) {
+ if (!view.candidates.length && !view.accepted) {
+ return (
+ <p className="text-[12.5px] text-muted" data-song-cover-empty="">
+ No cover generated for {song.id} yet — nothing in the thumb manifest names it.
+ </p>
+ );
+ }
+ return (
+ <div className="max-w-[1100px]">
+ <ThumbBench song={song.id} view={view} notes={notes} />
+ </div>
+ );
+}
diff --git a/umtool/components/projects/song/CutsTab.tsx b/umtool/components/projects/song/CutsTab.tsx
@@ -0,0 +1,174 @@
+import Link from "next/link";
+import VerdictChip from "@/components/VerdictChip";
+import NoteField from "@/components/NoteField";
+import { probeAll, type Cut, type Song } from "@/lib/browse";
+import { fmtAgo, fmtBytes, fmtDur } from "@/lib/format";
+import type { NoteMap } from "@/lib/notes";
+
+// The Cuts tab: the four cut cards (poster, verdicts, the slot's and the
+// file's notes, the variants) and what matches no cut -- SongProject's left
+// column, moved unchanged (P4a-3). A cut's own page (/projects/<song>/<cut>,
+// CutPage) is this tab's view of one cut.
+
+export default async function CutsTab({ song, notes }: { song: Song; notes: NoteMap }) {
+ // Durations are worth an ffprobe HERE but not on the index: this page is a
+ // handful of files and "which of these is the short cut" is exactly the
+ // question it answers. Memoised by mtime in lib/browse.ts.
+ const rels = [
+ ...song.cuts.flatMap((c) => [c.shipped?.rel, ...c.variants.map((v) => v.rel)]),
+ ...song.unattributed.map((v) => v.rel),
+ ].filter((r): r is string => !!r);
+ const info = await probeAll(song.id, rels);
+
+ return (
+ <div className="max-w-[1100px] space-y-3" data-song-cuts="">
+ {song.cuts.map((cut) => (
+ <CutCard key={cut.name} song={song} cut={cut} info={info} notes={notes} />
+ ))}
+
+ {song.unattributed.length > 0 && (
+ <section className="rounded border border-[var(--color-dirty)]/40 bg-[var(--color-panel)] p-3" data-unattributed={song.unattributed.length}>
+ <div className="micro mb-2">
+ matches no cut name — attribute by renaming, never by guessing
+ </div>
+ <ul className="space-y-1">
+ {song.unattributed.map((v) => (
+ <li key={v.rel} className="num text-[12px] text-[var(--color-dim)]">
+ <span className="font-mono text-[var(--color-text)]">{v.rel}</span>{" "}
+ {fmtBytes(v.size)}
+ </li>
+ ))}
+ </ul>
+ </section>
+ )}
+ </div>
+ );
+}
+
+function CutCard({
+ song,
+ cut,
+ info,
+ notes,
+}: {
+ song: Song;
+ cut: Cut;
+ info: Record<string, { duration: number; width: number; height: number }>;
+ notes: NoteMap;
+}) {
+ const shipped = cut.shipped;
+ const live = cut.variants.filter((v) => !v.retired);
+ const retired = cut.variants.filter((v) => v.retired);
+
+ return (
+ <section
+ data-cut={cut.name}
+ data-present={shipped ? "1" : "0"}
+ className="rounded border border-[var(--color-line)] bg-[var(--color-panel)]"
+ >
+ <div className="flex items-start gap-3 p-3">
+ {shipped ? (
+ /* eslint-disable-next-line @next/next/no-img-element */
+ <img
+ src={`/api/browse/poster?song=${encodeURIComponent(song.id)}&rel=${encodeURIComponent(shipped.rel)}&w=320`}
+ alt=""
+ width={160}
+ height={90}
+ className="w-40 shrink-0 rounded bg-[var(--color-panel-2)] object-cover"
+ />
+ ) : (
+ <div className="flex h-[90px] w-40 shrink-0 items-center justify-center rounded border border-dashed border-[var(--color-line)] text-[11px] text-[var(--color-dim)]">
+ not built
+ </div>
+ )}
+
+ <div className="min-w-0 flex-1 space-y-1">
+ <div className="flex flex-wrap items-baseline gap-2">
+ <Link
+ href={`/projects/${song.id}/${cut.name}`}
+ className="ink-link font-mono text-[13px]"
+ >
+ {cut.name}
+ </Link>
+ {shipped ? (
+ <span className="num text-[11px] text-[var(--color-meter)]">
+ {fmtDur(info[shipped.rel]?.duration ?? 0)}
+ </span>
+ ) : (
+ <span className="text-[11px] text-[var(--color-dim)]">— a hole in the set</span>
+ )}
+ {shipped && info[shipped.rel] && (
+ <span className="num text-[11px] text-[var(--color-dim)]">
+ {info[shipped.rel].width}×{info[shipped.rel].height}
+ </span>
+ )}
+ <span className="num ml-auto text-[11px] text-[var(--color-dim)]">
+ {shipped ? `${fmtBytes(shipped.size)} · ${fmtAgo(shipped.mtimeMs)}` : ""}
+ </span>
+ </div>
+
+ {shipped && (
+ <VerdictChip song={song.id} rel={shipped.rel} initial={shipped.verdict} />
+ )}
+
+ {/* Two different notes, deliberately. The `cut:` one is about the SLOT
+ -- it survives a promote and can be written about a cut that has
+ not been built. The `file:` one is about these bytes. */}
+ <NoteField
+ song={song.id}
+ target={`cut:${cut.name}`}
+ initial={notes[`cut:${cut.name}`] ?? null}
+ label={`notes on ${cut.name}`}
+ rows={3}
+ />
+ {shipped && (
+ <NoteField
+ song={song.id}
+ target={`file:${shipped.rel}`}
+ initial={notes[`file:${shipped.rel}`] ?? null}
+ label="notes on this file"
+ rows={3}
+ />
+ )}
+
+ {live.length > 0 && (
+ <ul className="space-y-1 pt-1">
+ {live.map((v) => (
+ <li
+ key={v.rel}
+ data-variant={v.rel}
+ data-variant-tag={v.tag}
+ className="flex flex-wrap items-center gap-2 rounded bg-[var(--color-panel-2)] px-2 py-1"
+ >
+ <span className="font-mono text-[12px] text-[var(--color-text)]">{v.tag}</span>
+ <span className="num text-[11px] text-[var(--color-meter)]">
+ {fmtDur(info[v.rel]?.duration ?? 0)}
+ </span>
+ <span className="num text-[11px] text-[var(--color-dim)]">{fmtBytes(v.size)}</span>
+ <div className="ml-auto">
+ <VerdictChip song={song.id} rel={v.rel} initial={v.verdict} />
+ </div>
+ <div className="w-full">
+ <NoteField
+ song={song.id}
+ target={`file:${v.rel}`}
+ initial={notes[`file:${v.rel}`] ?? null}
+ label={`notes on ${v.tag}`}
+ rows={3}
+ />
+ </div>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ {retired.length > 0 && (
+ <div className="micro pt-1" data-retired={retired.length}>
+ {retired.length} retired: {retired.map((v) => v.tag).join(", ")}
+ </div>
+ )}
+ </div>
+ </div>
+ </section>
+ );
+}
diff --git a/umtool/components/projects/song/NotesTab.tsx b/umtool/components/projects/song/NotesTab.tsx
@@ -0,0 +1,51 @@
+import Link from "next/link";
+import NoteField from "@/components/NoteField";
+import type { Song } from "@/lib/browse";
+import { projectHref } from "@/lib/hrefs";
+import type { NoteMap } from "@/lib/notes";
+import { SONG_PIECE_TABS, songTabOfNote } from "@/lib/pieces/song-tabs.mjs";
+
+// The Notes tab: the note on the song as a whole -- the one obvious place to
+// write about it, SongProject's head row, moved unchanged (P4a-3) -- and, under
+// it, every other note on the song, each linking the tab it is written on (a
+// cut's, a file's or a mark's on Cuts, a plan's on Spec, a cover's on Cover).
+
+const TAB_LABEL = Object.fromEntries(SONG_PIECE_TABS.map((t) => [t.id, t.label]));
+
+export default function NotesTab({ projectId, song, notes }: { projectId: string; song: Song; notes: NoteMap }) {
+ const others = Object.entries(notes)
+ .filter(([target, n]) => target !== "song" && n && typeof n.note === "string" && n.note.trim())
+ .sort(([a], [b]) => a.localeCompare(b));
+ return (
+ <div className="max-w-[900px] space-y-5">
+ <section data-song-note="">
+ <NoteField song={song.id} target="song" initial={notes.song ?? null} label="notes on this song" />
+ </section>
+
+ <section data-song-notes={others.length}>
+ <h2 className="micro mb-1.5">
+ Every other note · <span className="font-mono text-meter">{others.length}</span>
+ </h2>
+ {others.length === 0 ? (
+ <p className="text-[12.5px] text-muted">None yet. Notes on a cut, a file, a plan or a cover show here.</p>
+ ) : (
+ <ul className="divide-y divide-seam border-y border-seam">
+ {others.map(([target, n]) => {
+ const tab = songTabOfNote(target);
+ const first = n.note.split("\n").find((l) => l.trim()) ?? "";
+ return (
+ <li key={target} data-song-note-target={target} className="flex items-baseline gap-3 py-1.5 text-[12.5px]">
+ <span className="w-[260px] shrink-0 truncate font-mono text-[11.5px] text-text-2">{target}</span>
+ <span className="min-w-0 flex-1 truncate text-text">{first}</span>
+ <Link href={projectHref(projectId, { tab })} prefetch={false} className="ink-link shrink-0 text-[12px]">
+ {TAB_LABEL[tab] ?? tab}
+ </Link>
+ </li>
+ );
+ })}
+ </ul>
+ )}
+ </section>
+ </div>
+ );
+}
diff --git a/umtool/components/projects/song/OverviewTab.tsx b/umtool/components/projects/song/OverviewTab.tsx
@@ -0,0 +1,189 @@
+import Link from "next/link";
+import { Suspense } from "react";
+import CopyButton from "@/components/CopyButton";
+import NextCard, { NextCardShell } from "@/components/piece/NextCard";
+import { ProjectDecisions } from "@/components/projects/report/OverviewTab";
+import { PILE_WHAT } from "@/components/dashboard/ToolList";
+import { CUT_NAMES, type Song } from "@/lib/browse";
+import { decisionsForProject } from "@/lib/projects";
+import { fmtBytes } from "@/lib/format";
+import { cutHref, findHref, mixHref, pileHref, projectHref, songToolsHref, sourcesHref, trimHref } from "@/lib/hrefs";
+import { Markdown } from "@/lib/markdown";
+import type { PieceFrame } from "@/lib/pieces/frame";
+import type { ProjectRef } from "@/lib/project-types";
+import { readSpec } from "@/lib/spec";
+import { MODES } from "@/lib/types";
+import type { ThumbView } from "@/lib/thumbs";
+
+// The Overview tab of a song piece (P4a-3; canvas "Piece · Overview" in a
+// song's words): the Next card -- the song's top Inbox call, an unjudged
+// variant, a missing cut, a stale recipe -- then the song's decisions and its
+// four cut slots beside what the song is, the paste ("copy this song", from
+// SongProject's head row), and the song tools, which stay in Tools (the four
+// judging piles, find, mix, sources, the hook trimmer). The README is
+// SongProject's, unchanged.
+
+export default async function OverviewTab({
+ project,
+ song,
+ frame,
+ covers,
+}: {
+ project: ProjectRef;
+ song: Song;
+ frame: PieceFrame;
+ covers: ThumbView;
+}) {
+ const [decisions, spec] = await Promise.all([decisionsForProject(project), readSpec(song.id)]);
+ const looksDone = (frame.piece?.looksDone ?? []).map((w) => w.replace(`${project.id}: `, ""));
+ if (!looksDone.length && song.present === CUT_NAMES.length) looksDone.push("every cut shipped");
+ const trimSet = spec.hooks?.trimSet ?? 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 ?? song.title} 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 ------------------------------------- */}
+ <ProjectDecisions project={project.id} decisions={decisions} />
+
+ <section data-song-slots={song.present}>
+ <div className="mb-1.5 flex items-baseline gap-3">
+ <h2 className="micro">
+ Cuts · <span className="font-mono text-meter">{song.present}</span> of {song.cuts.length}
+ </h2>
+ <Link href={projectHref(project.id, { tab: "cuts" })} prefetch={false} className="ink-link ml-auto text-[12px]">
+ All cuts →
+ </Link>
+ </div>
+ <ul className="border-y border-seam">
+ {song.cuts.map((cut) => {
+ const live = cut.variants.filter((v) => !v.retired).length;
+ return (
+ <li
+ key={cut.name}
+ data-song-slot={cut.name}
+ data-present={cut.shipped ? "1" : "0"}
+ className="flex items-baseline gap-3 border-b border-seam py-1.5 text-[13px] last:border-b-0"
+ >
+ <Link href={cutHref(project.id, cut.name)} prefetch={false} className="ink-link font-mono text-[12.5px]">
+ {cut.name}
+ </Link>
+ <span className="text-[12px] text-muted">
+ {cut.shipped ? `built · ${fmtBytes(cut.shipped.size)}` : "a hole in the set"}
+ </span>
+ <span className="ml-auto font-mono text-[11.5px] text-meter">
+ {live ? `${live} variant${live === 1 ? "" : "s"}` : ""}
+ </span>
+ </li>
+ );
+ })}
+ </ul>
+ </section>
+ </div>
+
+ <div className="min-w-0 space-y-4">
+ <section data-piece-stats="">
+ <div className="mb-1.5 flex items-baseline gap-3">
+ <h2 className="micro">This song</h2>
+ <span className="ml-auto" data-song-copy="">
+ <CopyButton
+ label="copy this song"
+ title="this song as markdown — spec, cuts, verdicts, notes and resolved marks"
+ url={`/api/browse/context?song=${encodeURIComponent(song.id)}`}
+ />
+ </span>
+ </div>
+ <ul className="text-[13px] text-text-2">
+ <li className="flex gap-2.5 border-b border-seam py-1.5">
+ cuts built
+ <span className="ml-auto font-mono text-[11.5px] text-meter">
+ {song.present} / {song.cuts.length}
+ {song.missing.length ? ` · no ${song.missing.join(", ")}` : ""}
+ </span>
+ </li>
+ <li className="flex gap-2.5 border-b border-seam py-1.5">
+ variants
+ <span className="ml-auto font-mono text-[11.5px] text-meter">{song.variantCount}</span>
+ </li>
+ <li className="flex gap-2.5 border-b border-seam py-1.5">
+ verdicts
+ <span className="ml-auto font-mono text-[11.5px] text-meter">
+ {song.counts.keep} keep · {song.counts.reject} reject · {song.counts.undecided} undecided
+ </span>
+ </li>
+ <li className="flex gap-2.5 border-b border-seam py-1.5">
+ plans
+ <span className="ml-auto font-mono text-[11.5px] text-meter">{song.plans.length}</span>
+ </li>
+ <li className="flex gap-2.5 border-b border-seam py-1.5">
+ cover
+ <span className="ml-auto text-[12px] text-text-2">
+ {covers.accepted ? `accepted · ${covers.accepted.name}` : covers.candidates.length ? `${covers.candidates.length} on offer, none accepted` : "none generated"}
+ </span>
+ </li>
+ {looksDone.length > 0 && frame.lifecycle === "active" && (
+ <li className="flex gap-2.5 border-b border-seam py-1.5" data-song-looks-done="">
+ looks done
+ <span className="ml-auto text-[12px] text-muted">{looksDone.join("; ")}</span>
+ </li>
+ )}
+ </ul>
+ </section>
+
+ <section data-song-tools="">
+ <h2 className="micro mb-1.5">Song tools</h2>
+ <ul className="text-[13px]">
+ {MODES.map((m) => (
+ <li key={m} className="flex gap-2.5 border-b border-seam py-1.5">
+ <Link href={pileHref(m)} prefetch={false} className="ink-link" data-song-pile={m}>
+ {m}
+ </Link>
+ <span className="ml-auto truncate text-[12px] text-muted">{PILE_WHAT[m]}</span>
+ </li>
+ ))}
+ {trimSet && (
+ <li className="flex gap-2.5 border-b border-seam py-1.5">
+ <Link href={trimHref(trimSet)} prefetch={false} className="ink-link" data-song-trim={trimSet}>
+ trim {trimSet}
+ </Link>
+ <span className="ml-auto truncate text-[12px] text-muted">the hook trimmer, for the spec's hooks</span>
+ </li>
+ )}
+ </ul>
+ <p className="mt-1.5 flex flex-wrap gap-x-3 text-[12px]">
+ <Link href={songToolsHref()} prefetch={false} className="ink-link">
+ song piles
+ </Link>
+ <Link href={findHref()} prefetch={false} className="ink-link">
+ find
+ </Link>
+ <Link href={mixHref()} prefetch={false} className="ink-link">
+ mix
+ </Link>
+ <Link href={sourcesHref()} prefetch={false} className="ink-link">
+ sources
+ </Link>
+ </p>
+ </section>
+ </div>
+ </div>
+
+ {/* --- the song's own account of itself ---------------------------- */}
+ {song.readme && (
+ <section data-readme="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3">
+ <Markdown text={song.readme} />
+ </section>
+ )}
+ </>
+ );
+}
diff --git a/umtool/components/projects/song/SongFrame.tsx b/umtool/components/projects/song/SongFrame.tsx
@@ -0,0 +1,95 @@
+import { stat } from "node:fs/promises";
+import PieceFrame from "@/components/piece/PieceFrame";
+import type { Crumb } from "@/components/shell/AppHeader";
+import { CUT_NAMES, type Song } from "@/lib/browse";
+import { projectHref, projectsHref } from "@/lib/hrefs";
+import type { NoteMap } from "@/lib/notes";
+import { readPieceFrame, type PieceFrame as Frame } from "@/lib/pieces/frame";
+import { SONG_PIECE_TABS } from "@/lib/pieces/song-tabs.mjs";
+import { specFile } from "@/lib/spec";
+import type { ProjectRef } from "@/lib/project-types";
+
+// ---------------------------------------------------------------------------
+// A SONG PIECE's frame (plans/umtool-redesign.md, P4a-3): the P4a frame
+// (components/piece/PieceFrame.tsx -- head, stepper, lifecycle, Next, tabs,
+// keys) around one of a song's five tabs, Overview · Cuts · Spec · Cover ·
+// Notes (lib/pieces/song-tabs.mjs). The song page and a cut's page (a view of
+// the Cuts tab) both draw through it.
+//
+// The stepper is Spec → Cuts → Done, by the one stage rule (lib/pieces/tabs.mjs
+// pieceSteps on the flow the song kind declares). The page has the song in
+// hand, so the facts that light it are read fresh here (a promote shows at
+// once); Work's facet reads the same facts off the pieces graph.
+// ---------------------------------------------------------------------------
+
+/** What a song piece has reached, from the song the page already read (one stat for spec.json). */
+export async function songReachedNow(song: Song): Promise<{ spec: boolean; cuts: boolean; done: boolean }> {
+ const spec = await stat(specFile(song.id)).then(
+ () => true,
+ () => false,
+ );
+ return { spec, cuts: song.present > 0, done: song.present === CUT_NAMES.length };
+}
+
+export async function readSongFrame(project: ProjectRef, song: Song): Promise<Frame> {
+ return readPieceFrame(project, { reached: await songReachedNow(song) });
+}
+
+/** A song tab's count, in Meter: cuts built, covers on offer, notes written. */
+export function songCounts(song: Song, notes: NoteMap, covers: number): Partial<Record<string, number>> {
+ const written = Object.values(notes).filter((n) => n && typeof n.note === "string" && n.note.trim()).length;
+ return { cuts: song.present, cover: covers, notes: written };
+}
+
+export default function SongFrame({
+ project,
+ song,
+ frame,
+ tab,
+ counts,
+ note,
+ meta,
+ idHref,
+ bare = false,
+ children,
+}: {
+ project: ProjectRef;
+ song: Song;
+ frame: Frame;
+ tab: string;
+ counts: Partial<Record<string, number>>;
+ /** The head's status line. */
+ note?: React.ReactNode;
+ /** A line beside the title (a cut's page: which cut). */
+ meta?: React.ReactNode;
+ /** Link the trail's project id (a cut's page: back to the song). */
+ idHref?: string;
+ /** The body pads itself (a cut's page: the bench is edge to edge). */
+ bare?: boolean;
+ children: React.ReactNode;
+}) {
+ const title = frame.piece?.title ?? song.title;
+ const crumbs: Crumb[] = [
+ { href: projectsHref(), label: "projects" },
+ { label: project.id, ...(idHref ? { href: idHref } : {}) },
+ { label: title },
+ ];
+ return (
+ <div className="flex h-full flex-col" data-song-piece={song.id}>
+ <PieceFrame
+ crumbs={crumbs}
+ frame={frame}
+ tab={tab}
+ tabs={SONG_PIECE_TABS.map((t) => ({ ...t, href: projectHref(project.id, { tab: t.id }) }))}
+ counts={counts}
+ note={note}
+ meta={meta}
+ more={<span className="px-2 pb-1 pt-0.5 font-mono text-[11px] text-muted">{project.id}</span>}
+ >
+ <main className={bare ? "deck-main flex-1" : "deck-main flex-1 space-y-4 p-4"} data-piece-tab={tab}>
+ {children}
+ </main>
+ </PieceFrame>
+ </div>
+ );
+}
diff --git a/umtool/components/projects/song/SpecTab.tsx b/umtool/components/projects/song/SpecTab.tsx
@@ -0,0 +1,57 @@
+import SpecSheet from "@/components/SpecSheet";
+import NoteField from "@/components/NoteField";
+import type { Song } from "@/lib/browse";
+import { fmtBytes } from "@/lib/format";
+import type { NoteMap } from "@/lib/notes";
+import { operationsFor, readSpec, validateSpec } from "@/lib/spec";
+import { TRIM_SETS } from "@/lib/trim";
+
+// The Spec tab: the spec sheet (what the song is made of, and so the
+// operations it can run) and the plans in plan/ with their notes --
+// SongProject's aside, moved unchanged (P4a-3).
+
+export default async function SpecTab({ song, notes }: { song: Song; notes: NoteMap }) {
+ const spec = await readSpec(song.id);
+ const problems = await validateSpec(spec);
+ return (
+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]">
+ <div className="min-w-0">
+ <SpecSheet
+ song={song.id}
+ initial={spec}
+ problems={problems}
+ operations={operationsFor(spec, song)}
+ plans={song.plans.map((p) => p.name)}
+ trimSets={Object.values(TRIM_SETS).map((t) => ({ id: t.id, label: t.label }))}
+ />
+ </div>
+ <div className="min-w-0">
+ <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-song-plans={song.plans.length}>
+ <div className="micro mb-2">plans</div>
+ {song.plans.length === 0 ? (
+ <p className="text-[12px] text-[var(--color-dim)]">no plan/ directory</p>
+ ) : (
+ <ul className="space-y-0.5">
+ {song.plans.map((p) => (
+ <li key={p.name} className="num text-[11px] text-[var(--color-dim)]">
+ <span className="flex gap-2">
+ <span className="truncate font-mono text-[var(--color-text)]">{p.name}</span>
+ <span className="ml-auto shrink-0">{fmtBytes(p.size)}</span>
+ </span>
+ <NoteField
+ song={song.id}
+ target={`plan:${p.name}`}
+ initial={notes[`plan:${p.name}`] ?? null}
+ label="what this plan is"
+ rows={3}
+ />
+ </li>
+ ))}
+ </ul>
+ )}
+ {song.hasClipsCsv && <div className="micro mt-2">clips.csv present</div>}
+ </section>
+ </div>
+ </div>
+ );
+}
diff --git a/umtool/e2e/browse.spec.ts b/umtool/e2e/browse.spec.ts
@@ -1,5 +1,6 @@
import { test, expect } from "@playwright/test";
import { caps, NO_SONG_DATA } from "./capabilities";
+import * as urls from "./urls";
// The browse pages, against the synthesised videos/ tree in make-fixture.mjs:
//
@@ -33,7 +34,7 @@ test("the index lists both songs, and says which cuts are missing", async ({ pag
// to `wide-short`; a plain startsWith() over an unordered cut list binds it to
// `wide`, and then every short's variants collect under the long one.
test("a variant binds to the LONGEST matching cut name", async ({ page }) => {
- await page.goto("/browse/alpha");
+ await page.goto(urls.songSection("alpha", "variants"));
const wide = page.locator("[data-cut=wide]");
const wideShort = page.locator("[data-cut='wide-short']");
@@ -55,7 +56,7 @@ test("a variant binds to the LONGEST matching cut name", async ({ page }) => {
});
test("a song with a hole shows the hole", async ({ page }) => {
- await page.goto("/browse/beta");
+ await page.goto(urls.songSection("beta", "cuts"));
await expect(page.locator("[data-cut=wide]")).toHaveAttribute("data-present", "1");
await expect(page.locator("[data-cut=vertical]")).toHaveAttribute("data-present", "0");
await expect(page.locator("[data-cut='vertical-short']")).toHaveAttribute("data-present", "0");
@@ -97,7 +98,7 @@ test("a verdict round-trips and survives a reload", async ({ page, request }) =>
});
expect(post.ok()).toBe(true);
- await page.goto("/browse/alpha");
+ await page.goto(urls.songSection("alpha", "verdicts"));
const chip = page.locator("[data-verdict-for='variants/wide-nokit.mp4']");
await expect(chip.locator("[data-verdict=keep]")).toHaveAttribute("data-on", "1");
await expect(chip.getByText("the kit is wrong")).toBeVisible();
@@ -132,7 +133,7 @@ test("promote MOVES, and the outgoing cut survives as a variant", async ({ reque
test("the demoted cut comes back under the SAME cut, with the right length", async ({ page }) => {
// Runs after the promote above (the suite is serial, workers: 1).
- await page.goto("/browse/alpha");
+ await page.goto(urls.songSection("alpha", "cuts"));
const wideShort = page.locator("[data-cut='wide-short']");
// The shipped file is now the 4s variant...
@@ -243,7 +244,7 @@ test("the song page links to the trim editor once hooks are declared", async ({
await request.put("/api/browse/spec", {
data: { song: "alpha", spec: { version: 1, song: "alpha", hooks: { trimSet: "mk-hooks" } } },
});
- await page.goto("/browse/alpha");
+ await page.goto(urls.songSection("alpha", "operations"));
await expect(page.locator("[data-op=trim-hooks]")).toHaveAttribute("data-blocked", "0");
await page.locator("[data-op=trim-hooks]").getByRole("link").click();
await expect(page).toHaveURL(/\/tools\/trim\/mk-hooks/);
@@ -346,7 +347,7 @@ test("a new song gets the shape but NO cut files", async ({ request, page }) =>
expect(r.ok()).toBe(true);
expect((await r.json()).href).toBe("/projects/gamma");
- await page.goto("/browse/gamma");
+ await page.goto(urls.songSection("gamma", "cuts"));
// Every cut must read as a hole. A zero-byte wide.mp4 would read as built.
for (const cut of ["wide", "wide-short", "vertical", "vertical-short"]) {
await expect(page.locator(`[data-cut=${cut}]`)).toHaveAttribute("data-present", "0");
diff --git a/umtool/e2e/faces.spec.ts b/umtool/e2e/faces.spec.ts
@@ -3,6 +3,7 @@ import { readFileSync } from "node:fs";
import path from "node:path";
import { autoCrop, scaleOf, CORNER_PX, SHOVE_FLOOR, type Box } from "../lib/face-types";
import { caps, NO_FACEDET, NO_SOURCE_MEDIA } from "./capabilities";
+import * as urls from "./urls";
// The face judger, against the REAL episodes the fixture symlinks -- make-fixture
// derives its cover corners from media/ precisely so the frame and detect routes
@@ -95,7 +96,8 @@ test("/browse/faces is the face judger, at /tools/faces", async ({ page }) => {
// The way in is the cover-art bench, not a tenth nav item -- AppNav is at nine
// and says a tenth wraps the header on a laptop.
test("the bench links to the judger and the nav does not", async ({ page }) => {
- await page.goto("/browse/alpha");
+ // The cover bench is the song piece's Cover tab (P4a-3).
+ await page.goto(urls.songSection("alpha", "faces"));
const link = page.locator("[data-judge-faces]").first();
await expect(link).toBeVisible();
const cover = (await link.getAttribute("data-judge-faces")) ?? "";
diff --git a/umtool/e2e/projects.spec.ts b/umtool/e2e/projects.spec.ts
@@ -194,7 +194,12 @@ test("the song URLs that already existed still mean the same thing", async ({ pa
test.skip(!caps.song, NO_SONG_DATA);
// A project id is a path now, but /browse/alpha and /browse/alpha/wide are
// the URLs in every decision href, every spec, and whatever anybody has open.
+ // The song is a piece page since P4a-3: the bare address is its Overview,
+ // with the cut set at a glance; the cut cards are the Cuts tab.
await page.goto("/browse/alpha");
+ await expect(page).toHaveURL(/\/projects\/alpha$/);
+ await expect(page.locator("[data-song-slot=wide]")).toBeVisible();
+ await page.goto(urls.songSection("alpha", "cuts"));
await expect(page.locator("[data-cut=wide]")).toBeVisible();
await page.goto("/browse/alpha/wide");
// The old address rides its redirect to the same view.
@@ -203,9 +208,12 @@ test("the song URLs that already existed still mean the same thing", async ({ pa
// resolved rather than the project page having been served for both URLs.
await expect(page.getByText(/^every note \(\d+\)$/)).toBeVisible();
+ // The cut's page is a view of the Cuts tab.
+ await expect(page.locator("[data-piece-tabs]")).toHaveAttribute("data-piece-tabs", "cuts");
+
// And the canonical path works too.
await page.goto("/browse/reports/videos/alpha");
- await expect(page.locator("[data-cut=wide]")).toBeVisible();
+ await expect(page.locator("[data-song-slot=wide]")).toBeVisible();
});
test("every tool page that was under /browse still answers, at /tools", async ({ page }) => {
diff --git a/umtool/e2e/song-piece.spec.ts b/umtool/e2e/song-piece.spec.ts
@@ -0,0 +1,207 @@
+import { test, expect, type Page } from "@playwright/test";
+import * as urls from "./urls";
+import { SONG_SECTION_TAB } from "../lib/pieces/song-tabs.mjs";
+
+// ---------------------------------------------------------------------------
+// The song piece (plans/umtool-redesign.md, P4a-3): a song's page is the P4a
+// frame -- the head, the Spec → Cuts → Done stepper, the lifecycle chip, the
+// Next card -- around ONE of five tabs, Overview · Cuts · Spec · Cover · Notes,
+// and a cut's page is a view of the Cuts tab. Against make-fixture.mjs's songs:
+//
+// alpha all four cuts (the derived `shipped`: Done, and it looks done)
+// beta wide and wide-short only (at Cuts)
+//
+// browse.spec runs first and promotes, notes and re-specs alpha; nothing here
+// depends on which file ships, only on the set being whole.
+// ---------------------------------------------------------------------------
+
+const ALPHA = "reports/videos/alpha";
+const BETA = "reports/videos/beta";
+const PIECE = `p:${ALPHA}`;
+
+const tab = (page: Page, id: string) => page.getByTestId(`piece-tab-${id}`);
+const keysReady = (page: Page) => expect(page.locator("[data-piece-keys=ready]")).toBeAttached();
+const steps = (page: Page) => page.getByRole("list", { name: "Stage" }).locator("li");
+
+test("the frame: title, trail, the Spec → Cuts → Done stepper, five tabs, the Overview alone", async ({ page }) => {
+ const res = await page.goto(urls.projectHref("alpha"));
+ expect(res?.status()).toBe(200);
+ const crumbs = page.getByRole("navigation", { name: "Breadcrumb" });
+ await expect(crumbs.locator("h1")).toHaveText(/Alpha/);
+ await expect(crumbs).toContainText(ALPHA);
+ await expect(page.locator("header .micro").last()).toHaveText(/4\/4 cuts · \d+ variants/i);
+
+ // Every cut built: at Done (a suggestion -- the lifecycle is still Active).
+ const frame = page.locator(`[data-piece-frame="${PIECE}"]`);
+ await expect(frame).toHaveAttribute("data-piece-stage", "done");
+ await expect(frame).toHaveAttribute("data-piece-lifecycle", "active");
+ await expect(steps(page)).toHaveText([/^Spec/, /^Cuts/, /^Done/]);
+ await expect(steps(page).nth(2)).toHaveAttribute("aria-current", "step");
+ await expect(steps(page).nth(1)).toHaveAttribute("data-step", "done");
+
+ const tabs = page.getByRole("navigation", { name: "Piece" }).getByRole("link");
+ await expect(tabs).toHaveText([/^Overview/, /^Cuts/, /^Spec/, /^Cover/, /^Notes/]);
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+ await expect(tab(page, "cuts")).toHaveText("Cuts4");
+ await expect(tab(page, "cuts")).toHaveAttribute("href", urls.projectHref(ALPHA, { tab: "cuts" }));
+
+ // The Overview: the Next card, the decisions, the cut set at a glance, the
+ // looks-done suggestion, the song tools -- and none of the other tabs' sections.
+ await expect(page.locator("[data-next]:visible")).toBeVisible();
+ await expect(page.locator("[data-song-slot]")).toHaveCount(4);
+ await expect(page.locator("[data-song-slot][data-present='0']")).toHaveCount(0);
+ await expect(page.locator("[data-song-looks-done]")).toContainText("every cut shipped");
+ await expect(page.locator("[data-song-pile=sort]")).toHaveAttribute("href", urls.pileHref("sort"));
+ await expect(page.locator("[data-song-copy]")).toBeVisible();
+ await expect(page.locator("[data-cut]")).toHaveCount(0);
+ await expect(page.locator("[data-op]")).toHaveCount(0);
+ await expect(page.locator("[data-note-for=song]")).toHaveCount(0);
+});
+
+test("a song with a hole is at Cuts, and Work files it where its stepper says", async ({ page }) => {
+ await page.goto(urls.projectHref(BETA));
+ await expect(page.locator(`[data-piece-frame="p:${BETA}"]`)).toHaveAttribute("data-piece-stage", "cuts");
+ await expect(steps(page).nth(1)).toHaveAttribute("aria-current", "step");
+ await expect(steps(page).nth(2)).toHaveAttribute("data-step", "todo");
+ await expect(page.locator("[data-song-slot=vertical]")).toHaveAttribute("data-present", "0");
+ await expect(page.locator("[data-song-looks-done]")).toHaveCount(0);
+
+ // Work: the song's own three steps on its bar; its bucket is the one the step stands in for.
+ await page.goto(urls.workHref({ life: "all" }));
+ const beta = page.locator(`[data-lit-line][data-piece='p:${BETA}']`);
+ await expect(beta).toHaveAttribute("data-stage", "video");
+ await expect(beta).toContainText("cuts");
+ const alpha = page.locator(`[data-lit-line][data-piece='${PIECE}']`);
+ await expect(alpha).toHaveAttribute("data-stage", "deliver");
+ await expect(alpha).toContainText("done");
+ await expect(alpha).toContainText("looks done");
+});
+
+test("the Next card is the song'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 alpha has a call waiting").toBeTruthy();
+
+ await page.goto(urls.projectHref(ALPHA));
+ 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] > :is(a, button):visible");
+ await expect(action).toHaveText(top!.action.label);
+});
+
+test("a song's calls land on their tab: the spec's on Spec, a cover's on Cover, a cut's on its page", async ({ request }) => {
+ const items = ((await (await request.get("/api/browse/decisions?project=alpha")).json()) as { items: { kind: string; href: string }[] }).items;
+ const WHERE: Record<string, string> = { "spec-problem": "spec", "no-plan": "spec", unattributed: "cuts", "thumb-unaccepted": "cover" };
+ const songWide = items.filter((d) => WHERE[d.kind]);
+ expect(songWide.length, "alpha names no plan, so at least that call").toBeGreaterThan(0);
+ for (const d of songWide) expect(d.href, d.kind).toBe(`/projects/alpha?tab=${WHERE[d.kind]}`);
+ for (const d of items.filter((x) => x.kind === "unjudged-variant" || x.kind === "stale-recipe")) {
+ expect(d.href, d.kind).toMatch(/^\/projects\/alpha\/(wide|wide-short|vertical|vertical-short)(\?|$)/);
+ }
+});
+
+test("the tab is the URL: ?tab=, a note's target, a bad tab the Overview, and the old addresses land", async ({ page }) => {
+ // Every section a spec names is on the tab the table says.
+ expect(SONG_SECTION_TAB.cuts).toBe("cuts");
+
+ await page.goto(urls.songSection("alpha", "cuts"));
+ await expect(tab(page, "cuts")).toHaveAttribute("aria-current", "page");
+ await expect(page.locator("[data-cut]")).toHaveCount(4);
+ await expect(page.locator("[data-song-slot]")).toHaveCount(0);
+
+ await page.goto(urls.songSection("alpha", "spec"));
+ await expect(page.locator("[data-op=trim-hooks]")).toBeVisible();
+ await expect(page.locator("[data-song-plans]")).toBeVisible();
+
+ await page.goto(urls.songSection("alpha", "cover"));
+ await expect(page.locator("[data-judge-faces]").first()).toBeVisible();
+
+ await page.goto(urls.songSection("alpha", "notes"));
+ await expect(page.locator("[data-note-for=song]").first()).toBeVisible();
+ await expect(page.locator("[data-song-notes]")).toBeVisible();
+
+ await page.goto(urls.projectHref(ALPHA, { tab: "nonsense" }));
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+
+ // A song's notes are keyed by target: `?note=` opens the tab it is written on.
+ await page.goto(urls.projectHref("alpha", { note: "song" }));
+ await expect(tab(page, "notes")).toHaveAttribute("aria-current", "page");
+ await page.goto(urls.projectHref("alpha", { note: "plan:alpha.plan.json" }));
+ await expect(tab(page, "spec")).toHaveAttribute("aria-current", "page");
+ await page.goto(urls.projectHref("alpha", { note: "cut:vertical" }));
+ await expect(tab(page, "cuts")).toHaveAttribute("aria-current", "page");
+
+ // The old address rides P3's redirect to the Overview.
+ await page.goto("/browse/alpha");
+ await expect(page).toHaveURL(/\/projects\/alpha$/);
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+});
+
+test("a cut's page is a view of the Cuts tab: the frame, the four cuts beside the title, the bench under it", async ({ page }) => {
+ const res = await page.goto("/browse/alpha/wide");
+ expect(res?.status()).toBe(200);
+ await expect(page).toHaveURL(/\/projects\/alpha\/wide$/);
+ await expect(tab(page, "cuts")).toHaveAttribute("aria-current", "page");
+ await expect(page.locator(`[data-piece-frame="${PIECE}"]`)).toBeVisible();
+ const picker = page.locator("[data-song-cut-picker=wide]");
+ await expect(picker.locator("[aria-current=page]")).toHaveText("wide");
+ await expect(page.locator("[data-loudness='wide.mp4']")).toBeVisible();
+ // The trail's project id is the way back to the song.
+ await expect(page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: ALPHA })).toHaveAttribute(
+ "href",
+ urls.projectHref(ALPHA),
+ );
+ await picker.getByRole("link", { name: "wide-short" }).click();
+ await expect(page).toHaveURL(new RegExp(`/projects/${ALPHA}/wide-short$`));
+ await expect(page.locator("[data-song-cut-picker=wide-short]")).toBeVisible();
+});
+
+test("keys: 1–5 open the tabs, n runs the Next card's action", async ({ page }) => {
+ await page.goto(urls.projectHref(ALPHA));
+ await keysReady(page);
+ await page.keyboard.press("2");
+ await expect(page).toHaveURL(/\?tab=cuts$/);
+ await keysReady(page);
+ await page.keyboard.press("5");
+ await expect(page).toHaveURL(/\?tab=notes$/);
+ await expect(tab(page, "notes")).toHaveAttribute("aria-current", "page");
+ await keysReady(page);
+ await page.keyboard.press("1");
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+
+ await keysReady(page);
+ const action = page.locator("[data-next-action] > a:visible");
+ if ((await action.count()) > 0) {
+ const href = await action.getAttribute("href");
+ await page.keyboard.press("n");
+ await expect(page).toHaveURL(new RegExp(`${href!.replace(/[?]/g, "\\?")}$`));
+ }
+});
+
+test("marked done, every stage is done; the lifecycle chip says so", async ({ page, request }) => {
+ try {
+ expect((await request.post("/api/pieces/lifecycle", { data: { piece: PIECE, state: "done" } })).ok()).toBe(true);
+ await page.goto(urls.projectHref(ALPHA));
+ await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "done");
+ for (let i = 0; i < 3; i += 1) await expect(steps(page).nth(i)).toHaveAttribute("data-step", "done");
+ // The suggestion is spent once the piece is marked done.
+ await expect(page.locator("[data-song-looks-done]")).toHaveCount(0);
+ await expect(page.locator("[data-next-kind=lifecycle]")).toContainText("Marked done");
+ } finally {
+ await request.post("/api/pieces/lifecycle", { data: { piece: PIECE, state: "active" } });
+ }
+});
+
+test("fits 1366×768: the head, the five tabs and the Next card's action without a horizontal scroll", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 768 });
+ for (const href of [urls.projectHref(ALPHA), urls.projectHref(ALPHA, { tab: "cuts" }), urls.projectHref(ALPHA, { tab: "spec" }), "/projects/alpha/wide"]) {
+ await page.goto(href);
+ await expect(tab(page, "notes")).toBeInViewport();
+ const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
+ expect(overflow, href).toBeLessThanOrEqual(0);
+ }
+ await page.goto(urls.projectHref(ALPHA));
+ await expect(page.locator("[data-next-action] > :is(a, button):visible")).toBeInViewport();
+});
diff --git a/umtool/e2e/urls.ts b/umtool/e2e/urls.ts
@@ -9,6 +9,7 @@
// 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";
+import { songTabOfSection } from "../lib/pieces/song-tabs.mjs";
export * from "../lib/hrefs";
export { REDIRECTS } from "../redirects.mjs";
@@ -22,3 +23,12 @@ export { REDIRECTS } from "../redirects.mjs";
export function section(project: string, name: string, q: { all?: boolean; note?: string } = {}): string {
return projectHref(project, { tab: tabOfSection(name), ...q });
}
+
+/**
+ * A song piece's tab that holds `name` (lib/pieces/song-tabs.mjs
+ * SONG_SECTION_TAB): `songSection("alpha", "cuts")` is `/projects/alpha?tab=cuts`.
+ * The song counterpart of `section` -- a song's sections are its own (P4a-3).
+ */
+export function songSection(song: string, name: string, q: { note?: string } = {}): string {
+ return projectHref(song, { tab: songTabOfSection(name), ...q });
+}
diff --git a/umtool/lib/decisions.ts b/umtool/lib/decisions.ts
@@ -7,6 +7,7 @@ import { readNotes, type NoteMap } from "./notes";
import { listNotesFiles } from "./annotations/targets.mjs";
import { acceptedFor, readThumbAccepted, readThumbManifest, thumbNamesFor } from "./thumbs";
import { articleHrefOf } from "./articles/href";
+import { songTabOfSection } from "./pieces/song-tabs.mjs";
// ---------------------------------------------------------------------------
// Everything undecided, in one worklist.
@@ -135,7 +136,10 @@ export async function decisionsForSong(id: string): Promise<Decision[]> {
]);
const out: Decision[] = [];
- const songHref = `/projects/${id}`;
+ // A song-wide call opens the song piece's tab its section is on (P4a-3,
+ // lib/pieces/song-tabs.mjs): the spec's on Spec, a stray variant on Cuts, a
+ // cover on Cover. A cut's call opens the cut's page (the Cuts tab's view).
+ const songHref = (section: string) => `/projects/${id}?tab=${songTabOfSection(section)}`;
const cutHref = (cut: string) => `/projects/${id}/${cut}`;
const target = {
lufs: spec.loudness?.targetLufs ?? DEFAULT_TARGET.lufs,
@@ -149,7 +153,7 @@ export async function decisionsForSong(id: string): Promise<Decision[]> {
project: id,
target: p.where,
why: p.message,
- href: songHref,
+ href: songHref("spec"),
// `pending` is the sheet being right about a file you have not rendered
// yet, which is a normal state to save from -- so it is not a decision.
severity: p.level === "error" ? "blocking" : "info",
@@ -254,7 +258,7 @@ export async function decisionsForSong(id: string): Promise<Decision[]> {
project: id,
target: v.rel,
why: "matches no cut name — attribute it by renaming, never by guessing",
- href: songHref,
+ href: songHref("unattributed"),
severity: "open",
at: v.mtimeMs,
});
@@ -268,7 +272,7 @@ export async function decisionsForSong(id: string): Promise<Decision[]> {
project: id,
target: named,
why: `spec names plan/${named}, which is not there — provenance cannot resolve`,
- href: songHref,
+ href: songHref("plans"),
severity: "open",
at: song.newestMtimeMs,
});
@@ -280,7 +284,7 @@ export async function decisionsForSong(id: string): Promise<Decision[]> {
why:
`${song.plans.length} plan${song.plans.length > 1 ? "s" : ""} in plan/ and none named — ` +
"which one shipped is not recorded, so it is not guessed",
- href: songHref,
+ href: songHref("plans"),
// Three of the five songs here have a 2-voice and a 3-voice arrangement
// of the same tune. Nothing on disk says which shipped; only a person
// can, and until they do every provenance figure is unattributed.
@@ -297,7 +301,7 @@ export async function decisionsForSong(id: string): Promise<Decision[]> {
project: id,
target: candidates.join(", "),
why: `${candidates.length} generated cover${candidates.length > 1 ? "s" : ""}, none accepted`,
- href: songHref,
+ href: songHref("cover"),
severity: "info",
at: song.newestMtimeMs,
});
diff --git a/umtool/lib/pieces.ts b/umtool/lib/pieces.ts
@@ -13,6 +13,7 @@ import { lifecycleOf, readLifecycle, type LifecycleRead, type LifecycleState } f
import { boardOfArticle, boardOfProject } from "./pieces/board.mjs";
import { readCases } from "./pieces/cases";
import { stageOfPiece } from "./pieces/tabs.mjs";
+import { kindById } from "./projects/kinds.mjs";
import type { Decision } from "./decisions";
export { articlePieceId, casePieceId, formatPieceId, isPieceId, parsePieceId, projectPieceId } from "./pieces/ids.mjs";
@@ -74,8 +75,14 @@ export type Piece = {
* facet reads `reached` for it too.
*/
stage: string;
+ /**
+ * The stepper the piece walks (lib/pieces/tabs.mjs pieceSteps' `kind`): `article`,
+ * `project` (a report video's four stages), or the flow its project's kind
+ * declares (a song's Spec → Cuts → Done, lib/pieces/song-tabs.mjs).
+ */
+ flow: string;
/** What the piece has reached, the one stage rule's facts (lib/pieces/tabs.mjs pieceSteps). */
- reached: { research: boolean; article: boolean; video: boolean; deliver: boolean };
+ reached: Reached;
projects: PieceProject[];
/** Slug matches nobody has chosen between (link-ambiguous). */
possible: { id: string; title: string }[];
@@ -86,6 +93,17 @@ export type Piece = {
newestMs: number;
};
+/** The one stage rule's facts: the four stages, and a song's own three (lib/pieces/song-tabs.mjs). */
+export type Reached = {
+ research: boolean;
+ article: boolean;
+ video: boolean;
+ deliver: boolean;
+ spec?: boolean;
+ cuts?: boolean;
+ done?: boolean;
+};
+
export type PieceWithLifecycle = Piece & { lifecycle: LifecycleState; lifecycleAt: string | null; lifecycleBy: string | null };
export type PieceGraph = {
@@ -292,6 +310,7 @@ async function buildGraph(): Promise<PieceGraph> {
pieces.push({
id,
kind: "article",
+ flow: "article",
title: a.title,
site: a.site,
report: a.id,
@@ -312,9 +331,14 @@ async function buildGraph(): Promise<PieceGraph> {
for (const p of summaries) {
if (pieceOfProject.has(p.id)) continue;
const why = await looksDoneOf(p.id);
+ // The stepper the project's kind declares (a song's Spec → Cuts → Done) and
+ // the facts that light it; else a report video's four stages.
+ const declared = (kindById(p.kind) as { piece?: { flow: string; reached?: (s: ProjectSummary) => Promise<Partial<Reached>> } } | null)?.piece;
+ const own = declared?.reached ? await declared.reached(p).catch(() => ({})) : {};
pieces.push({
id: projectPieceId(p.id),
kind: "project",
+ flow: declared?.flow ?? "project",
title: p.title,
site: null,
report: null,
@@ -323,7 +347,7 @@ async function buildGraph(): Promise<PieceGraph> {
status: null,
audience: null,
stage: p.state,
- reached: { research: !!boardOfProject(p.id, cases), article: false, video: true, deliver: !!why || p.state === "shipped" },
+ reached: { research: !!boardOfProject(p.id, cases), article: false, video: true, deliver: !!why || p.state === "shipped", ...own },
projects: [],
possible: [],
unreachable: [],
diff --git a/umtool/lib/pieces/frame.ts b/umtool/lib/pieces/frame.ts
@@ -3,7 +3,9 @@ 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 { pieceSteps, stageOfPiece } from "./tabs.mjs";
+import { pieceSteps, stepOfPiece } from "./tabs.mjs";
+import { kindPieceFlow } from "../projects/kinds.mjs";
+import type { Reached } from "../pieces";
import { boardOfProject } from "./board.mjs";
import { readCases } from "./cases";
import type { Decision } from "../decisions";
@@ -37,7 +39,7 @@ export type PieceFrame = {
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). */
+ /** The step the stepper has current (research … deliver; a song's spec, cuts or done). */
stage: string;
};
@@ -48,7 +50,15 @@ async function boardOf(projectId: string): Promise<PieceFrame["board"]> {
return boardOfProject(projectId, await readCases());
}
-export async function readPieceFrame(project: { id: string; state?: string | null }): Promise<PieceFrame> {
+/**
+ * @param project the project the page is
+ * @param opts.reached facts the page read fresh (a song page reads the song
+ * anyway), over the graph's memoised ones -- a promote shows at once
+ */
+export async function readPieceFrame(
+ project: { id: string; kind?: string; state?: string | null },
+ opts: { reached?: Partial<Reached> } = {},
+): 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;
@@ -60,11 +70,14 @@ export async function readPieceFrame(project: { id: string; state?: string | nul
: null;
// The one stage rule (lib/pieces/tabs.mjs pieceSteps): the graph's facts, so
// the stepper here and Work's stage facet read the same answer.
- const kind = piece?.kind ?? "project";
+ // The stepper is the piece's flow: an article's, a report video's, or the one
+ // its project's kind declares (a song's), also for a project the graph has
+ // not listed yet (one scaffolded within the memo's 15 s).
+ const kind = piece?.flow ?? (project.kind ? kindPieceFlow(project.kind) : null) ?? "project";
// The board is read fresh (the graph is memoised): a board's hand-off shows at once.
- const reached = { ...(piece?.reached ?? { video: true }), ...(board ? { research: true } : {}) };
+ const reached = { ...(piece?.reached ?? { video: true }), ...opts.reached, ...(board ? { research: true } : {}) };
const steps = pieceSteps({ kind, reached, lifecycle }) as PieceFrame["steps"];
- const stage = stageOfPiece({ kind, reached });
+ const stage = stepOfPiece({ kind, reached });
return { piece, pieceId, article, board, lifecycle, lifecycleError: life.error ?? null, steps, stage };
}
diff --git a/umtool/lib/pieces/song-tabs.mjs b/umtool/lib/pieces/song-tabs.mjs
@@ -0,0 +1,149 @@
+// A SONG PIECE's tabs and stepper (plans/umtool-redesign.md, P4a-3). Pure, no
+// imports, beside lib/pieces/tabs.mjs (the report video's and the article's):
+// the page, Work's facet and an e2e spec (e2e/urls.ts `songSection`) read the
+// same table.
+//
+// A song walks its own three stages, Spec → Cuts → Done, not the report's four.
+// The registry declares which stepper a kind walks (lib/projects/kinds.mjs, the
+// song kind's `piece.flow`), so nothing here branches on a kind id: the flow is
+// a name the pieces graph copies onto the piece.
+//
+// The tab is the URL's `?tab=`, as on every piece page. A song's cut page
+// (`/projects/<song>/<cut>`, the CutBench, its loudness and provenance) is a
+// VIEW of the Cuts tab: the frame draws it with Cuts current.
+
+/** The stepper a kind declares to walk Spec → Cuts → Done. */
+export const SONG_FLOW = "song";
+
+/**
+ * A song's three stages, each with the Work bucket (lib/work/facets.mjs STAGES)
+ * it stands in for, so Work's stage facet and the song's stepper agree: the
+ * spec is a song's written stage (a report video's article), its cuts its
+ * video, and a full set of cuts its delivery.
+ */
+export const SONG_STEPS = [
+ { id: "spec", label: "Spec", bucket: "article" },
+ { id: "cuts", label: "Cuts", bucket: "video" },
+ { id: "done", label: "Done", bucket: "deliver" },
+];
+
+const SKIPPED = { spec: "no spec.json", cuts: "no cut built" };
+
+/**
+ * The song's stepper, by the one stage rule (lib/pieces/tabs.mjs pieceSteps):
+ * the furthest stage reached is current, the ones before it done (or to do with
+ * the reason, when skipped), a piece marked done has done them all.
+ *
+ * Spec reached with a spec.json
+ * Cuts reached with one cut built
+ * Done reached with every cut built (the song's derived `shipped`, which is
+ * also its looks-done suggestion, lib/pieces.ts)
+ *
+ * @param {{ reached: { spec?: boolean, cuts?: boolean, done?: boolean }, lifecycle: string }} p
+ * @returns {{ id: string, label: string, state: "done" | "current" | "todo", title?: string }[]}
+ */
+export function songSteps({ reached, lifecycle }) {
+ const has = reached ?? {};
+ let at = 0;
+ SONG_STEPS.forEach((s, i) => {
+ if (has[s.id]) at = i;
+ });
+ return SONG_STEPS.map((s, i) => {
+ if (lifecycle === "done") return { id: s.id, label: s.label, state: "done" };
+ if (i === at) return { id: s.id, label: s.label, state: "current" };
+ if (i < at && has[s.id]) return { id: s.id, label: s.label, state: "done" };
+ if (i < at) return { id: s.id, label: s.label, state: "todo", title: SKIPPED[s.id] };
+ return { id: s.id, label: s.label, state: "todo" };
+ });
+}
+
+/** The song stage that is current (lifecycle aside): `spec`, `cuts` or `done`. */
+export function songStepOf({ reached }) {
+ return songSteps({ reached, lifecycle: "active" }).find((s) => s.state === "current")?.id ?? "spec";
+}
+
+/** The Work bucket a song stage stands in for. */
+export function bucketOfSongStep(step) {
+ return SONG_STEPS.find((s) => s.id === step)?.bucket ?? "video";
+}
+
+/** The tabs of a song piece, in order; the key that opens each is its position (`1`–`5`). */
+export const SONG_PIECE_TABS = [
+ { id: "overview", label: "Overview" },
+ { id: "cuts", label: "Cuts" },
+ { id: "spec", label: "Spec" },
+ { id: "cover", label: "Cover" },
+ { id: "notes", label: "Notes" },
+];
+
+export const SONG_PIECE_TAB_IDS = SONG_PIECE_TABS.map((t) => t.id);
+
+/**
+ * Every section the song page drew (components/projects/SongProject.tsx and
+ * CutPage.tsx before P4a-3), by the name a spec says, and the tab it is on.
+ */
+export const SONG_SECTION_TAB = {
+ // Overview: the Next card, the song's decisions, the cut set at a glance,
+ // the paste, the README, the song tools.
+ next: "overview",
+ decisions: "overview",
+ slots: "overview",
+ copy: "overview",
+ readme: "overview",
+ tools: "overview",
+ // Cuts: the four cut cards (poster, verdicts, notes, variants), what matches
+ // no cut, and a cut's own page (the bench, loudness, provenance).
+ cuts: "cuts",
+ variants: "cuts",
+ verdicts: "cuts",
+ unattributed: "cuts",
+ bench: "cuts",
+ loudness: "cuts",
+ provenance: "cuts",
+ // Spec: the spec sheet and its operations, the plans.
+ spec: "spec",
+ operations: "spec",
+ plans: "spec",
+ // Cover: the cover-art bench (and its way to the face judger).
+ cover: "cover",
+ thumbs: "cover",
+ faces: "cover",
+ // Notes: the note on the song as a whole, and every other note on it.
+ notes: "notes",
+};
+
+/** The tab a song section is on; throws on a name nobody declared (a spec's typo should fail loudly). */
+export function songTabOfSection(name) {
+ const tab = SONG_SECTION_TAB[name];
+ if (!tab) throw new Error(`no section "${name}" on a song piece (lib/pieces/song-tabs.mjs SONG_SECTION_TAB)`);
+ return tab;
+}
+
+/**
+ * Where a song note is drawn (lib/notes.ts: a song's notes are keyed by their
+ * TARGET): the song's own on Notes, a cut's, a file's, a mark's, a source's or
+ * a clip's with the cuts, a plan's on Spec, a cover's on Cover.
+ *
+ * @param {string | undefined | null} target
+ */
+export function songTabOfNote(target) {
+ const t = String(target ?? "");
+ if (t === "song") return "notes";
+ if (/^(cut|file|moment|source|clip):/.test(t)) return "cuts";
+ if (t.startsWith("plan:")) return "spec";
+ if (t.startsWith("thumb:")) return "cover";
+ return "overview";
+}
+
+/**
+ * The tab a song piece's address opens: `?tab=`; else a `?note=<target>` where
+ * that note is drawn; else the Overview.
+ *
+ * @param {{ tab?: string, note?: string }} search
+ */
+export function songTabOf(search) {
+ const t = search?.tab;
+ if (t && SONG_PIECE_TAB_IDS.includes(t)) return t;
+ if (search?.note) return songTabOfNote(search.note);
+ return "overview";
+}
diff --git a/umtool/lib/pieces/song-tabs.test.mjs b/umtool/lib/pieces/song-tabs.test.mjs
@@ -0,0 +1,98 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import {
+ SONG_FLOW,
+ SONG_PIECE_TAB_IDS,
+ SONG_STEPS,
+ bucketOfSongStep,
+ songStepOf,
+ songSteps,
+ songTabOf,
+ songTabOfNote,
+ songTabOfSection,
+} from "./song-tabs.mjs";
+import { STAGE_STEPS, pieceSteps, stageOfPiece, stepOfPiece } from "./tabs.mjs";
+import { STAGES, stageBar, stageOf } from "../work/facets.mjs";
+
+const states = (steps) => steps.map((s) => s.state);
+
+test("a song piece: five tabs, Overview first; every section on one of them", () => {
+ assert.deepEqual(SONG_PIECE_TAB_IDS, ["overview", "cuts", "spec", "cover", "notes"]);
+ assert.equal(songTabOfSection("cuts"), "cuts");
+ assert.equal(songTabOfSection("unattributed"), "cuts");
+ assert.equal(songTabOfSection("bench"), "cuts");
+ assert.equal(songTabOfSection("operations"), "spec");
+ assert.equal(songTabOfSection("plans"), "spec");
+ assert.equal(songTabOfSection("faces"), "cover");
+ assert.equal(songTabOfSection("notes"), "notes");
+ assert.equal(songTabOfSection("slots"), "overview");
+ assert.equal(songTabOfSection("tools"), "overview");
+ assert.throws(() => songTabOfSection("timeline"), /no section "timeline" on a song piece/);
+});
+
+test("a song piece's address picks the tab: ?tab=, else a note's target where it is drawn, else the Overview", () => {
+ assert.equal(songTabOf({}), "overview");
+ assert.equal(songTabOf({ tab: "spec" }), "spec");
+ assert.equal(songTabOf({ tab: "build" }), "overview");
+ assert.equal(songTabOf({ tab: "cover", note: "song" }), "cover");
+ assert.equal(songTabOf({ note: "song" }), "notes");
+ for (const t of ["cut:vertical", "file:wide.mp4", "file:variants/wide-nokit.mp4", "moment:wide.mp4@2.00", "source:abc123", "clip:abc@1.5"]) {
+ assert.equal(songTabOfNote(t), "cuts", t);
+ assert.equal(songTabOf({ note: t }), "cuts", t);
+ }
+ assert.equal(songTabOf({ note: "plan:alpha.plan.json" }), "spec");
+ assert.equal(songTabOf({ note: "thumb:alpha-1" }), "cover");
+ assert.equal(songTabOf({ note: "n-1234" }), "overview");
+});
+
+test("a song walks Spec → Cuts → Done by the one stage rule", () => {
+ assert.deepEqual(SONG_STEPS.map((s) => s.label), ["Spec", "Cuts", "Done"]);
+ // Scaffolded: a spec.json, no cut yet.
+ assert.deepEqual(states(songSteps({ reached: { spec: true }, lifecycle: "active" })), ["current", "todo", "todo"]);
+ // Nothing at all (a directory with only verdicts.json): the Spec is where it starts.
+ assert.deepEqual(states(songSteps({ reached: {}, lifecycle: "active" })), ["current", "todo", "todo"]);
+ // Some cuts built.
+ assert.deepEqual(states(songSteps({ reached: { spec: true, cuts: true }, lifecycle: "active" })), ["done", "current", "todo"]);
+ // Cuts with no spec.json: the Spec is to do, and says why.
+ const nospec = songSteps({ reached: { cuts: true }, lifecycle: "active" });
+ assert.deepEqual(states(nospec), ["todo", "current", "todo"]);
+ assert.equal(nospec[0].title, "no spec.json");
+ // Every cut built (the derived `shipped`): at Done -- a suggestion, not the lifecycle.
+ assert.deepEqual(states(songSteps({ reached: { spec: true, cuts: true, done: true }, lifecycle: "active" })), ["done", "done", "current"]);
+ // Marked done: every stage done.
+ assert.deepEqual(states(songSteps({ reached: { cuts: true }, lifecycle: "done" })), ["done", "done", "done"]);
+ // The shared rule switches on the flow the kind declares.
+ assert.deepEqual(pieceSteps({ kind: SONG_FLOW, reached: { spec: true, cuts: true }, lifecycle: "active" }).map((s) => s.id), ["spec", "cuts", "done"]);
+ // ...and the four-stage pieces are untouched by it.
+ assert.deepEqual(pieceSteps({ kind: "project", reached: { video: true }, lifecycle: "active" }).map((s) => s.id), STAGE_STEPS.map((s) => s.id));
+});
+
+test("the song's stepper and Work's stage facet give the same answer", () => {
+ for (const reached of [
+ { spec: true },
+ { spec: true, cuts: true },
+ { cuts: true },
+ { spec: true, cuts: true, done: true },
+ { research: false, article: false, video: true, deliver: true, spec: true, cuts: true, done: true },
+ ]) {
+ const piece = { kind: SONG_FLOW, reached };
+ const current = pieceSteps({ ...piece, lifecycle: "active" }).find((s) => s.state === "current").id;
+ assert.equal(songStepOf(piece), current);
+ assert.equal(stepOfPiece(piece), current);
+ // Work's bucket is the one the song's current step stands in for -- from the piece page's rule.
+ const bucket = stageOf({ kind: SONG_FLOW, stage: "built", looksDone: [], reached });
+ assert.equal(bucket, bucketOfSongStep(current));
+ assert.equal(stageOfPiece(piece), bucket);
+ assert.ok(STAGES.includes(bucket));
+ // Work's bar is the song's own: three steps, the current one lit, its word.
+ const bar = stageBar(piece, bucket);
+ assert.equal(bar.steps, 3);
+ assert.equal(SONG_STEPS[bar.step - 1].id, current);
+ assert.equal(bar.label, SONG_STEPS[bar.step - 1].label.toLowerCase());
+ }
+ assert.equal(stageOf({ kind: SONG_FLOW, stage: "draft", looksDone: [], reached: { spec: true } }), "article");
+ assert.equal(stageOf({ kind: SONG_FLOW, stage: "built", looksDone: [], reached: { spec: true, cuts: true } }), "video");
+ assert.equal(stageOf({ kind: SONG_FLOW, stage: "shipped", looksDone: ["x: every cut shipped"], reached: { cuts: true, done: true } }), "deliver");
+ // A four-stage piece's bar is unchanged: four bars at its bucket, the caller's word.
+ assert.deepEqual(stageBar({ kind: "project", reached: { video: true } }, "video"), { step: 3, steps: 4, label: null });
+});
diff --git a/umtool/lib/pieces/tabs.mjs b/umtool/lib/pieces/tabs.mjs
@@ -14,6 +14,12 @@
// 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).
+//
+// A SONG walks its own stepper and has its own tabs (lib/pieces/song-tabs.mjs,
+// P4a-3); pieceSteps and stageOfPiece switch to it on the flow the registry
+// declares, so the one stage rule stays one function.
+
+import { SONG_FLOW, bucketOfSongStep, songStepOf, songSteps } from "./song-tabs.mjs";
/** The stepper's four stages, by Work's buckets (lib/work/facets.mjs STAGES). */
export const STAGE_STEPS = [
@@ -45,10 +51,14 @@ export const STAGE_STEPS = [
* nor a board (a site's hand-written report) has no Research recorded here. A
* piece marked done has done every stage that applies.
*
- * @param {{ kind: string, reached: { research?: boolean, article?: boolean, video?: boolean, deliver?: boolean }, lifecycle: string }} p
+ * A song (`kind` the flow its kind declares, SONG_FLOW) walks Spec → Cuts →
+ * Done by the same rule (lib/pieces/song-tabs.mjs songSteps).
+ *
+ * @param {{ kind: string, reached: { research?: boolean, article?: boolean, video?: boolean, deliver?: boolean, spec?: boolean, cuts?: boolean, done?: boolean }, lifecycle: string }} p
* @returns {{ id: string, label: string, state: "done" | "current" | "todo" | "na", title?: string }[]}
*/
export function pieceSteps({ kind, reached, lifecycle }) {
+ if (kind === SONG_FLOW) return songSteps({ reached, lifecycle });
const project = kind !== "article";
const has = { ...reached, ...(project ? { video: true, article: false } : {}) };
const na = project
@@ -74,14 +84,29 @@ export function pieceSteps({ kind, reached, lifecycle }) {
/**
* A piece's stage: the step that is current, by the one rule (lifecycle aside --
- * a parked or done piece keeps the stage it is at).
+ * a parked or done piece keeps the stage it is at). Always one of Work's four
+ * buckets: a song's stage is the bucket its step stands in for (Spec → article,
+ * Cuts → video, Done → deliver).
*
- * @param {{ kind: string, reached: { research?: boolean, article?: boolean, video?: boolean, deliver?: boolean } }} p
+ * @param {{ kind: string, reached: { research?: boolean, article?: boolean, video?: boolean, deliver?: boolean, spec?: boolean, cuts?: boolean, done?: boolean } }} p
*/
export function stageOfPiece({ kind, reached }) {
+ if (kind === SONG_FLOW) return bucketOfSongStep(songStepOf({ reached }));
return pieceSteps({ kind, reached, lifecycle: "active" }).find((s) => s.state === "current")?.id ?? "video";
}
+/**
+ * The step a piece's stepper has current, by its own ids (lifecycle aside): one
+ * of the four stages, or a song's `spec` / `cuts` / `done`. The piece page's
+ * `data-piece-stage`.
+ *
+ * @param {{ kind: string, reached: object }} p
+ */
+export function stepOfPiece({ kind, reached }) {
+ if (kind === SONG_FLOW) return songStepOf({ reached });
+ return stageOfPiece({ kind, reached });
+}
+
/** 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" },
diff --git a/umtool/lib/projects/kinds.mjs b/umtool/lib/projects/kinds.mjs
@@ -16,7 +16,8 @@
// rule, and it is what stops `if (kind === "report-video")` appearing in a page.
import { BRAND_CHOICES } from "umtool-report-to-video/brand-ids";
import { MANIFEST_NAME, REPORT_DECISION_KINDS, reportDecisions, reportSignature, summariseReport } from "./report.mjs";
-import { CUT_NAMES, songSignature, summariseSong } from "./song.mjs";
+import { CUT_NAMES, songReached, songSignature, summariseSong } from "./song.mjs";
+import { SONG_FLOW } from "../pieces/song-tabs.mjs";
import { sweepSignature, summariseSweep } from "./sweep.mjs";
/**
@@ -143,6 +144,10 @@ export const PROJECT_KINDS = [
// `/browse/<song>/wide` -- today's cut page, unchanged.
views: CUT_NAMES,
scaffold: { fields: [] },
+ // Its piece walks Spec → Cuts → Done, not the report's four stages
+ // (lib/pieces/song-tabs.mjs, P4a-3): the flow its stepper and Work's stage
+ // facet read, and the facts that light it, from the project's summary.
+ piece: { flow: SONG_FLOW, reached: songReached },
},
{
id: "sweep-report",
@@ -194,6 +199,12 @@ export const kindById = (id) => PROJECT_KINDS.find((k) => k.id === id) ?? null;
/** Does a project of this kind keep a notes.json (lib/annotations)? Declared on the kind, never branched on its id. */
export const kindTakesNotes = (id) => kindById(id)?.notes === true;
+/**
+ * The stepper a project piece of this kind walks (lib/pieces/tabs.mjs
+ * pieceSteps): its declared `piece.flow`, else a report video's.
+ */
+export const kindPieceFlow = (id) => kindById(id)?.piece?.flow ?? null;
+
/** Can a project of this kind be an article's video (lib/articles/links.mjs)? Declared on the kind. */
export const kindLinksArticles = (id) => kindById(id)?.linksArticles === true;
diff --git a/umtool/lib/projects/song.mjs b/umtool/lib/projects/song.mjs
@@ -105,3 +105,15 @@ export async function summariseSong(ctx) {
};
}
+/**
+ * What a song piece has reached, for its Spec → Cuts → Done stepper
+ * (lib/pieces/song-tabs.mjs songSteps): a spec.json (one stat), a cut built,
+ * every cut built (the derived `shipped`).
+ *
+ * @param {{ dir: string, state?: string | null, attrs?: Record<string, string> }} p a song's summary
+ */
+export async function songReached(p) {
+ const spec = !!(await stat0(path.join(p.dir, "spec.json")));
+ const built = Number(p.attrs?.cuts ?? 0);
+ return { spec, cuts: built > 0 || p.state === "built" || p.state === "shipped", done: p.state === "shipped" };
+}
diff --git a/umtool/lib/work.ts b/umtool/lib/work.ts
@@ -2,7 +2,7 @@ import { readInbox, type Inbox } from "./inbox";
import { readLifecycle } from "./lifecycle";
import { KINDS, listProjects } from "./projects";
import { listPieces, type PieceWithLifecycle } from "./pieces";
-import { stageOf, stepOf } from "./work/facets.mjs";
+import { stageBar, stageOf } from "./work/facets.mjs";
// ---------------------------------------------------------------------------
// WORK, AS DATA: every piece (lib/pieces.ts) as one row for the Work list --
@@ -32,7 +32,9 @@ export type PieceCounts = {
export type WorkRow = PieceWithLifecycle & {
/** research | article | video | deliver. */
bucket: string;
+ /** The current step on the row's stage bar, 1-based, of `steps` (four, or a song's three). */
step: number;
+ steps: number;
/** What the stage bar says: an article's stage, a project's own state. */
stageLabel: string;
/** `article` and/or project kind ids. */
@@ -89,12 +91,15 @@ export async function readWork(): Promise<{ rows: WorkRow[]; lifecycleError?: st
: "article"
: (projectKinds.map((k) => label.get(k) ?? k).join(", ") || "project");
const projectState = own?.state ?? null;
- const bucket = stageOf({ kind: p.kind, stage: p.stage, looksDone: p.looksDone, projectState, reached: p.reached });
+ // The piece's flow, so a song's bucket is its own stepper's (Spec → Cuts → Done).
+ const bucket = stageOf({ kind: p.flow, stage: p.stage, looksDone: p.looksDone, projectState, reached: p.reached });
+ const bar = stageBar({ kind: p.flow, reached: p.reached }, bucket);
return {
...p,
bucket,
- step: stepOf(bucket),
- stageLabel: p.kind === "article" ? bucket : (projectState ?? p.stage),
+ step: bar.step,
+ steps: bar.steps,
+ stageLabel: bar.label ?? (p.kind === "article" ? bucket : (projectState ?? p.stage)),
kinds,
kindLabel,
templates: [...new Set(mine.map((x) => x.template))],
diff --git a/umtool/lib/work/facets.mjs b/umtool/lib/work/facets.mjs
@@ -16,7 +16,8 @@
// of every project linked to it, a project piece is its project's kind. So the
// old `/browse?kind=<a video kind>` still finds the article whose video it is.
-import { stageOfPiece } from "../pieces/tabs.mjs";
+import { pieceSteps, stageOfPiece } from "../pieces/tabs.mjs";
+import { SONG_FLOW } from "../pieces/song-tabs.mjs";
/** The four stages a piece walks, in order (canvas "Work", the stage bar). */
export const STAGES = ["research", "article", "video", "deliver"];
@@ -31,7 +32,10 @@ export const LIFECYCLES = ["active", "parked", "done"];
* article's own stage; a project's `deliver` when it looks done (or ships),
* else `video`.
*
- * @param {{ kind: string, stage: string, looksDone: string[], projectState?: string | null, reached?: { research: boolean, article: boolean, video: boolean, deliver: boolean } }} p
+ * `kind` is the piece's flow (lib/pieces.ts `flow`): `article`, `project`, or
+ * a song's, whose bucket is the one its current step stands in for.
+ *
+ * @param {{ kind: string, stage: string, looksDone: string[], projectState?: string | null, reached?: { research: boolean, article: boolean, video: boolean, deliver: boolean, spec?: boolean, cuts?: boolean, done?: boolean } }} p
*/
export function stageOf(p) {
if (p.reached) return stageOfPiece({ kind: p.kind, reached: p.reached });
@@ -43,6 +47,25 @@ export function stageOf(p) {
/** 1-based position on the stage bar. */
export const stepOf = (bucket) => STAGES.indexOf(bucket) + 1;
+/**
+ * A row's stage bar: how many steps it has, which is current, and its word. A
+ * piece on the four stages is its bucket on four bars; a song (P4a-3) is its
+ * own stepper, Spec → Cuts → Done, on three -- the same steps its page draws,
+ * while its bucket (`stageOf`) is the one Work's stage facet files it under.
+ *
+ * @param {{ kind: string, reached?: object }} p `kind` the piece's flow
+ * @param {string} bucket
+ * @returns {{ step: number, steps: number, label: string | null }} `label` null: the caller's own word
+ */
+export function stageBar(p, bucket) {
+ if (p.kind === SONG_FLOW && p.reached) {
+ const steps = pieceSteps({ kind: p.kind, reached: p.reached, lifecycle: "active" });
+ const at = steps.findIndex((s) => s.state === "current");
+ return { step: at + 1, steps: steps.length, label: steps[at]?.label.toLowerCase() ?? null };
+ }
+ return { step: stepOf(bucket), steps: STAGES.length, label: null };
+}
+
/** `life`: one of the three, `all`, or (absent) active. */
export function lifeFilter(life) {
if (life === "all") return null;