Public: anyone can read this; the crew can change it.
A story wave page shows how many of its milestone's issues are done as 'N of M' with one bar drawn in CSS #13479
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/13462-a-story-wave-page-shows-how-many-of-its → main 5 commits fork 2 threads · 2 unresolved
6 files
changed +76
−11
docs/features/wave-walk.md +1 −1
| @@ -13,7 +13,7 @@ The `from` value is checked against the shape of a wave address before it is use | ||
| 13 | 13 | |
| 14 | 14 | ## How far the wave got |
| 15 | 15 | |
| 16 | When a wave's pulls closed issues under a milestone, the wave opens as its headline, then one progress line (`<milestone>: 1 of 2 done`, the widest milestone it moved), then the highlights. Under **Moved** each change is a closed fold: tap it to see the pulls of this wave that moved it, and a link to the milestone. Pulls no fold holds (another repository's, or ones that closed no milestone issue) are listed under **Pulls**; each pull is said once. A wave that moved no milestone has no progress line. The MCP `waves` tool says the same line as `progress`, and the terminal prints it under the date, with each moved milestone's pulls beneath it. Tested in `test/wave-folds.test.ts` and `test/tui-waves.test.ts`. | |
| 16 | When a wave's pulls closed issues under a milestone, the wave opens as its headline, then one progress line (`<milestone>: 1 of 2 done`, the widest milestone it moved), then the highlights. Under **Moved** each change is a closed fold: tap it to see the pulls of this wave that moved it, and a link to the milestone. Pulls no fold holds (another repository's, or ones that closed no milestone issue) are listed under **Pulls**; each pull is said once. On the page the line is followed by a bar on its own row, a native `<progress>` at a fixed width (no script, no inline style, no layout shift at 360px), full when it says `3 of 3 done`. A milestone with nothing under it says `no issues yet` and draws no bar. A wave that moved no milestone has no progress line. The terminal prints the same words but draws no bar. The MCP `waves` tool says the same line as `progress`, and the terminal prints it under the date, with each moved milestone's pulls beneath it. Tested in `test/wave-folds.test.ts`, `test/wave-bar.test.ts` and `test/tui-waves.test.ts`. | |
| 17 | 17 | |
| 18 | 18 | ## In the terminal |
| 19 | 19 |
src/story/wave_moved.ts +9 −2
| @@ -23,16 +23,23 @@ export interface MovedMilestone { | ||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** The words for how far a milestone is; the page, the card and the API say it alike. */ |
| 26 | export const doneWords = (m: Pick<MovedMilestone, "done" | "total">): string => `${m.done} of ${m.total} done`; | |
| 26 | export const doneWords = (m: Pick<MovedMilestone, "done" | "total">): string => | |
| 27 | m.total === 0 ? "no issues yet" : `${m.done} of ${m.total} done`; | |
| 27 | 28 | |
| 28 | 29 | /** |
| 29 | 30 | * The one progress line a wave opens with: its widest moved milestone, named |
| 30 | 31 | * with how far it is. Empty when the wave moved none, so no line is drawn. |
| 31 | 32 | */ |
| 32 | 33 | export function waveProgress(moved: readonly MovedMilestone[]): string { |
| 34 | const widest = widestMoved(moved); | |
| 35 | return widest === undefined ? "" : `${widest.title}: ${doneWords(widest)}`; | |
| 36 | } | |
| 37 | ||
| 38 | /** The moved milestone with the most issues under it: the one the wave leads with. */ | |
| 39 | export function widestMoved(moved: readonly MovedMilestone[]): MovedMilestone | undefined { | |
| 33 | 40 | let widest: MovedMilestone | undefined; |
| 34 | 41 | for (const m of moved) if (widest === undefined || m.total > widest.total) widest = m; |
| 35 | return widest === undefined ? "" : `${widest.title}: ${doneWords(widest)}`; | |
| 42 | return widest; | |
| 36 | 43 | } |
| 37 | 44 | |
| 38 | 45 | /** |
src/web/pages/waves.ts +17 −7
| @@ -15,16 +15,16 @@ import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../cor | ||
| 15 | 15 | import { repoDir } from "../../git/repos.ts"; |
| 16 | 16 | import type { Ctx } from "../../http/context.ts"; |
| 17 | 17 | import { VERSION, type Wave } from "../../story/wave.ts"; |
| 18 | import { movedWithPulls, shippedOf, shippedWords, waveProgress } from "../../story/wave_moved.ts"; | |
| 18 | import { movedWithPulls, type MovedMilestone, shippedOf, shippedWords, waveProgress, widestMoved } from "../../story/wave_moved.ts"; | |
| 19 | 19 | import { carriedPulls, pullPath } from "../../story/wave_pulls.ts"; |
| 20 | 20 | import { fromWave, pullRefs, readWave, readWaves, sizeWords, waveSize } from "../../story/waves.ts"; |
| 21 | 21 | import { NO_WAVES, waveSentence } from "../../story/words.ts"; |
| 22 | 22 | import { loadRepo, notFoundPage, repoBase, scopeHeader } from "../chrome.ts"; |
| 23 | import { escapeHtml, html } from "../html.ts"; | |
| 23 | import { escapeHtml, html, type Html } from "../html.ts"; | |
| 24 | 24 | import { page } from "../layout.ts"; |
| 25 | 25 | import { btn, empty, listCard, row } from "../ui.ts"; |
| 26 | 26 | import { localScope } from "../scope.ts"; |
| 27 | import { milestoneHref, planFor } from "./milestones.ts"; | |
| 27 | import { milestoneHref, planFor, progress } from "./milestones.ts"; | |
| 28 | 28 | import { nearMilestones, standingLine } from "./milestones_near.ts"; |
| 29 | 29 | |
| 30 | 30 | /** |
| @@ -229,7 +229,6 @@ export async function wavePage(ctx: Ctx): Promise<Response> { | ||
| 229 | 229 | /** Each pull is said once: those a change's fold holds are not listed again below. */ |
| 230 | 230 | const folded = new Set(moved.flatMap((m) => m.pulls)); |
| 231 | 231 | const unfolded = carried.filter((p) => !(p.owner === repo.ownerName && p.name === repo.name && folded.has(p.number))); |
| 232 | const line = waveProgress(moved); | |
| 233 | 232 | // The stored plan, read through the same cache the milestones page uses. |
| 234 | 233 | const standing = entry.ok |
| 235 | 234 | ? standingLine( |
| @@ -242,9 +241,7 @@ export async function wavePage(ctx: Ctx): Promise<Response> { | ||
| 242 | 241 | ? html`<h1>${entry.wave.headline}</h1> |
| 243 | 242 | <p data-wave-sentence>${waveSentence(carried.filter((p) => p.mergedAt !== null).map((p) => p.title))}</p> |
| 244 | 243 | <p class="muted">${entry.wave.version} · ${entry.wave.date} · <span data-wave-size>${sizeWords(waveSize(carried))}</span> · <span data-wave-standing>${standing}</span></p> |
| 245 | ${line === "" | |
| 246 | ? "" | |
| 247 | : html`<p class="muted" data-wave-progress>${line}</p>`} | |
| 244 | ${waveProgressRow(moved)} | |
| 248 | 245 | <h2>Highlights</h2> |
| 249 | 246 | <ul> |
| 250 | 247 | ${entry.wave.highlights.map( |
| @@ -292,3 +289,16 @@ export async function wavePage(ctx: Ctx): Promise<Response> { | ||
| 292 | 289 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 293 | 290 | return response; |
| 294 | 291 | } |
| 292 | ||
| 293 | /** | |
| 294 | * The wave's progress: the words in a muted line, the bar on its own row below at a fixed width so | |
| 295 | * nothing shifts at 360px. Nothing when no milestone moved; words only (no bar) at zero issues. | |
| 296 | */ | |
| 297 | export function waveProgressRow(moved: readonly MovedMilestone[]): Html { | |
| 298 | const line = waveProgress(moved); | |
| 299 | if (line === "") return html``; | |
| 300 | const widest = widestMoved(moved); | |
| 301 | return html`<p class="muted" data-wave-progress>${line}</p>${widest === undefined || widest.total === 0 | |
| 302 | ? "" | |
| 303 | : html`<div data-wave-bar>${progress(widest.done, widest.total, "Progress")}</div>`}`; | |
| 304 | } |
src/web/style/components.ts +1
| @@ -269,6 +269,7 @@ a.label:hover { color: color-mix(in srgb, var(--label) 90%, var(--fg)); } | ||
| 269 | 269 | .pill[data-tone="danger"] { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); } |
| 270 | 270 | |
| 271 | 271 | progress { display: block; width: 100%; height: 4px; margin: 6px 0; appearance: none; border: 0; border-radius: var(--radius-sm); background: var(--border); overflow: hidden; } |
| 272 | [data-wave-bar] { width: 12rem; max-width: 100%; height: 16px; } | |
| 272 | 273 | progress::-webkit-progress-bar { background: var(--border); } |
| 273 | 274 | progress::-webkit-progress-value { background: var(--success); } |
| 274 | 275 | progress::-moz-progress-bar { background: var(--success); } |
test/wave-bar.test.ts added +42
| @@ -0,0 +1,42 @@ | ||
| 1 | /** | |
| 2 | * The wave's progress line: 'N of M done' for partial and complete, 'no issues yet' and no bar for | |
| 3 | * zero. | |
| 4 | */ | |
| 5 | import { describe, expect, test } from "bun:test"; | |
| 6 | import { waveProgressRow } from "../src/web/pages/waves.ts"; | |
| 7 | import { doneWords, waveProgress, widestMoved } from "../src/story/wave_moved.ts"; | |
| 8 | ||
| 9 | const m = (done: number, total: number) => ({ number: 1, title: "Faster pages", done, total }); | |
| 10 | ||
| 11 | describe("wave progress words", () => { | |
| 12 | test("zero issues says so", () => { | |
| 13 | expect(doneWords(m(0, 0))).toBe("no issues yet"); | |
| 14 | expect(waveProgress([m(0, 0)])).toBe("Faster pages: no issues yet"); | |
| 15 | }); | |
| 16 | test("partial and complete", () => { | |
| 17 | expect(waveProgress([m(1, 3)])).toBe("Faster pages: 1 of 3 done"); | |
| 18 | expect(waveProgress([m(3, 3)])).toBe("Faster pages: 3 of 3 done"); | |
| 19 | }); | |
| 20 | test("the widest milestone leads", () => { | |
| 21 | expect(widestMoved([m(0, 0), m(2, 5), m(1, 2)])?.total).toBe(5); | |
| 22 | expect(widestMoved([])).toBeUndefined(); | |
| 23 | }); | |
| 24 | }); | |
| 25 | ||
| 26 | describe("wave progress row", () => { | |
| 27 | const row = (d: number, t: number) => String(waveProgressRow([m(d, t)])); | |
| 28 | test("zero issues: the words, no <progress>", () => { | |
| 29 | const out = row(0, 0); | |
| 30 | expect(out).toContain("Faster pages: no issues yet"); | |
| 31 | expect(out).not.toContain("<progress"); | |
| 32 | }); | |
| 33 | test("complete: value equals max, on its own row", () => { | |
| 34 | const out = row(3, 3); | |
| 35 | expect(out).toMatch(/<progress[^>]*max="3"[^>]*value="3"/); | |
| 36 | expect(out).toContain("<div data-wave-bar>"); | |
| 37 | expect(out).toContain('aria-label="Progress"'); | |
| 38 | }); | |
| 39 | test("no milestone, no row", () => { | |
| 40 | expect(String(waveProgressRow([]))).toBe(""); | |
| 41 | }); | |
| 42 | }); |
test/wave-folds.test.ts +6 −1
| @@ -1,4 +1,7 @@ | ||
| 1 | /** A wave opens as headline, then its progress, then its changes (one closed fold each, its pulls inside); the MCP card says the same. */ | |
| 1 | /** | |
| 2 | * A wave opens as headline, then its progress, then its changes (one closed fold each, its pulls | |
| 3 | * inside); the MCP card says the same. | |
| 4 | */ | |
| 2 | 5 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 3 | 6 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 7 | import { tmpdir } from "node:os"; |
| @@ -87,6 +90,8 @@ describe("wave folds", () => { | ||
| 87 | 90 | }; |
| 88 | 91 | const progress = at("Faster pages: 1 of 2 done"); |
| 89 | 92 | expect(at("<h1>Mixed</h1>")).toBeLessThan(progress); |
| 93 | // the bar is the native element beside it: no script, no inline style | |
| 94 | expect(text).toMatch(/data-wave-progress>Faster pages: 1 of 2 done<\/p>\s*<div data-wave-bar>\s*<progress[^>]*max="2"[^>]*value="1"/); | |
| 90 | 95 | const fold1 = at('<details id="change-' + m1.number + '"'); |
| 91 | 96 | const fold2 = at('<details id="change-' + m2.number + '"'); |
| 92 | 97 | expect(progress).toBeLessThan(fold1); |
new above
offline
Only words are tested; add rendered-page coverage for 0 (no <progress>) and complete (value equals max).