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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/13462-a-story-wave-page-shows-how-many-of-its → main 5 commits fork 2 threads · 2 unresolved

  • Merged. torque/13462-a-story-wave-page-shows-how-many-of-its was merged into main as 6d0822a.

Review

Sign in to review this change.
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
1313
1414 ## How far the wave got
1515
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`.
1717
1818 ## In the terminal
1919
src/story/wave_moved.ts +9 −2
@@ -23,16 +23,23 @@ export interface MovedMilestone {
2323 }
2424
2525 /** 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`;
2728
2829 /**
2930 * The one progress line a wave opens with: its widest moved milestone, named
3031 * with how far it is. Empty when the wave moved none, so no line is drawn.
3132 */
3233 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 {
3340 let widest: MovedMilestone | undefined;
3441 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;
3643 }
3744
3845 /**
src/web/pages/waves.ts +17 −7
@@ -15,16 +15,16 @@ import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../cor
1515 import { repoDir } from "../../git/repos.ts";
1616 import type { Ctx } from "../../http/context.ts";
1717 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";
1919 import { carriedPulls, pullPath } from "../../story/wave_pulls.ts";
2020 import { fromWave, pullRefs, readWave, readWaves, sizeWords, waveSize } from "../../story/waves.ts";
2121 import { NO_WAVES, waveSentence } from "../../story/words.ts";
2222 import { loadRepo, notFoundPage, repoBase, scopeHeader } from "../chrome.ts";
23 import { escapeHtml, html } from "../html.ts";
23 import { escapeHtml, html, type Html } from "../html.ts";
2424 import { page } from "../layout.ts";
2525 import { btn, empty, listCard, row } from "../ui.ts";
2626 import { localScope } from "../scope.ts";
27 import { milestoneHref, planFor } from "./milestones.ts";
27 import { milestoneHref, planFor, progress } from "./milestones.ts";
2828 import { nearMilestones, standingLine } from "./milestones_near.ts";
2929
3030 /**
@@ -229,7 +229,6 @@ export async function wavePage(ctx: Ctx): Promise<Response> {
229229 /** Each pull is said once: those a change's fold holds are not listed again below. */
230230 const folded = new Set(moved.flatMap((m) => m.pulls));
231231 const unfolded = carried.filter((p) => !(p.owner === repo.ownerName && p.name === repo.name && folded.has(p.number)));
232 const line = waveProgress(moved);
233232 // The stored plan, read through the same cache the milestones page uses.
234233 const standing = entry.ok
235234 ? standingLine(
@@ -242,9 +241,7 @@ export async function wavePage(ctx: Ctx): Promise<Response> {
242241 ? html`<h1>${entry.wave.headline}</h1>
243242 <p data-wave-sentence>${waveSentence(carried.filter((p) => p.mergedAt !== null).map((p) => p.title))}</p>
244243 <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)}
248245 <h2>Highlights</h2>
249246 <ul>
250247 ${entry.wave.highlights.map(
@@ -292,3 +289,16 @@ export async function wavePage(ctx: Ctx): Promise<Response> {
292289 notePhase(ctx.request, "render", performance.now() - rendering);
293290 return response;
294291 }
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)); }
269269 .pill[data-tone="danger"] { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
270270
271271 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; }
272273 progress::-webkit-progress-bar { background: var(--border); }
273274 progress::-webkit-progress-value { background: var(--success); }
274275 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 });
outdated

Only words are tested; add rendered-page coverage for 0 (no <progress>) and complete (value equals max).

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 */
25 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
36 import { mkdtemp, rm } from "node:fs/promises";
47 import { tmpdir } from "node:os";
@@ -87,6 +90,8 @@ describe("wave folds", () => {
8790 };
8891 const progress = at("Faster pages: 1 of 2 done");
8992 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"/);
9095 const fold1 = at('<details id="change-' + m1.number + '"');
9196 const fold2 = at('<details id="change-' + m2.number + '"');
9297 expect(progress).toBeLessThan(fold1);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs