Public: anyone can read this; the crew can change it.
The changelog groups entries under a month heading, newest first, with the month in the page's anchor #13559
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/13545-the-changelog-groups-entries-under-a-mon → main 4 commits fork 2 threads · 2 unresolved
7 files
changed +157
−25
docs/features/changelog.md +6
| @@ -44,6 +44,12 @@ The terminal's Changelog screen tells the same story from the same code (`releas | ||
| 44 | 44 | |
| 45 | 45 | The page's `ETag` holds one aggregate query (`chapterStamp`: chapter count, newest close, repository visibility, the item count and newest item, and a hash of which chapter holds each item, so moving an item between chapters moves the tag); the per-repository chapter reads run only after the tag has missed, so a 304 costs one query. The browser's day regrouping (`localDaysJs`) leaves a page with chapters alone. `test/changelog-timing.test.ts` holds the page to its budget with 500 pulls in chapters. |
| 46 | 46 | |
| 47 | ## Months (#13545) | |
| 48 | ||
| 49 | Days sit under month headings, newest first: an `<h2>` such as "November 2026" with the id `2026-11`, its days `<h3>` beneath it, so a screen reader navigating by heading finds days inside their month. The heading is a link to itself: `/changelog#2026-11` scrolls to that month, and the link copies as a shareable URL. A month with no landing has no heading. Months are UTC, and the browser's day regrouping keeps one heading per month, in front of its days. | |
| 50 | ||
| 51 | Chapter-grouped views (see Chapters) carry no month headings, so `/changelog#2026-11` finds nothing there and stays at the top; the chapter and day rows are the way in. The terminal's Changelog screen prints the same month line ("November 2026", with its release count) over its releases, newest first; `/` drops a month whose releases no longer match, and Enter on a month line does nothing. In chapters the terminal shows chapter lines instead, as the page does. | |
| 52 | ||
| 47 | 53 | ## Older releases (#12987) |
| 48 | 54 | |
| 49 | 55 | `/changelog` reads the newest 30 live releases, so the first page stays small however many have shipped (under 40 KB with 500 pulls; the first page answered in about 11 ms median in `test/changelog-window.test.ts`). Below them, inside the live region, a plain link reads "Older releases, before 12 Mar" (the UTC day of the last release shown): it goes to `?before=owner/name#number`, the last pull shown, and that page holds the next 30 older ones. Follow it until it is gone; the last page has no link. Nothing is on its way past the first page. |
src/release/month.ts added +11
| @@ -0,0 +1,11 @@ | ||
| 1 | /** | |
| 2 | * A month as the changelog names it: "2026-11" is "November 2026", the page's heading and anchor | |
| 3 | * and the terminal's line. | |
| 4 | */ | |
| 5 | ||
| 6 | export const MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] as const; | |
| 7 | ||
| 8 | /** `month` is `YYYY-MM`. */ | |
| 9 | export function monthLabel(month: string): string { | |
| 10 | return `${MONTH_NAMES[+month.slice(5, 7) - 1]} ${month.slice(0, 4)}`; | |
| 11 | } |
src/tui/screens/changelog.ts +38 −10
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | import { chapterOfPulls, listChapters } from "../../core/chapters.ts"; |
| 9 | 9 | import { groupByChapter, type ChapterEntry, type Group } from "../../release/chapter_groups.ts"; |
| 10 | 10 | import { gather, plainTitle } from "../../story/gather.ts"; |
| 11 | import { monthLabel } from "../../release/month.ts"; | |
| 11 | 12 | import { forgeChangelog, type ReleaseEntry } from "../../release/changelog.ts"; |
| 12 | 13 | import { readLandings, type Landing } from "../../release/landings.ts"; |
| 13 | 14 | import { nearMilestones, nearWords, type Near } from "../../web/pages/milestones_near.ts"; |
| @@ -38,7 +39,7 @@ export function changelogRows(entries: readonly ReleaseEntry[]): ListRow[] { | ||
| 38 | 39 | })); |
| 39 | 40 | } |
| 40 | 41 | |
| 41 | /** One line of the list: a release, a chapter heading, or a pull under one. */ | |
| 42 | /** One line of the list: a release, a month or chapter heading, or a pull under one. */ | |
| 42 | 43 | export interface Line { |
| 43 | 44 | readonly row: ListRow; |
| 44 | 45 | readonly entry?: ReleaseEntry; |
| @@ -48,7 +49,8 @@ export interface Line { | ||
| 48 | 49 | /** |
| 49 | 50 | * The landed pulls told in chapters, as the page tells them (`release/chapter_groups.ts` decides |
| 50 | 51 | * membership): a heading line per chapter, newest first, with its closing day or "open", then its |
| 51 | * pulls, one line each; pulls that served none sit under "Between chapters". `keep` narrows the pulls. | |
| 52 | * pulls, one line each; pulls that served none sit under "Between chapters". `keep` narrows the | |
| 53 | * pulls. | |
| 52 | 54 | */ |
| 53 | 55 | export function chapterLines(groups: readonly Group[], keep: (l: Landing) => boolean = () => true, filtering = false): Line[] { |
| 54 | 56 | const out: Line[] = []; |
| @@ -65,7 +67,19 @@ export function chapterLines(groups: readonly Group[], keep: (l: Landing) => boo | ||
| 65 | 67 | |
| 66 | 68 | /** The releases as lines, for a repository with no chapter to tell them in. */ |
| 67 | 69 | export function changelogLines(entries: readonly ReleaseEntry[]): Line[] { |
| 68 | return entries.map((e) => ({ row: changelogRows([e])[0]!, entry: e })); | |
| 70 | const out: Line[] = []; | |
| 71 | let month = ""; | |
| 72 | for (const e of entries) { | |
| 73 | // A month's heading line comes before its first release, as on the page (UTC month, newest | |
| 74 | // first as the releases are). | |
| 75 | if (e.date.slice(0, 7) !== month) { | |
| 76 | month = e.date.slice(0, 7); | |
| 77 | const n = entries.filter((x) => x.date.slice(0, 7) === month).length; | |
| 78 | out.push({ row: { title: monthLabel(month), meta: `${n} ${n === 1 ? "release" : "releases"}` } }); | |
| 79 | } | |
| 80 | out.push({ row: changelogRows([e])[0]!, entry: e }); | |
| 81 | } | |
| 82 | return out; | |
| 69 | 83 | } |
| 70 | 84 | |
| 71 | 85 | /** The open milestones as lines above the releases: "name N of M done", at most `MOST` of them. */ |
| @@ -76,7 +90,10 @@ export function nearLines(near: readonly Near[]): string[] { | ||
| 76 | 90 | |
| 77 | 91 | type Repo = { owner: string; name: string }; |
| 78 | 92 | |
| 79 | /** Who built a pull, in plain words: "by Scout, with Claude Sonnet 5.5"; empty when the commit says nothing. */ | |
| 93 | /** | |
| 94 | * Who built a pull, in plain words: "by Scout, with Claude Sonnet 5.5"; empty when the commit says | |
| 95 | * nothing. | |
| 96 | */ | |
| 80 | 97 | export function creditWords(by: string | undefined, withNames: readonly string[] | undefined): string { |
| 81 | 98 | const parts = [by === undefined ? "" : `by ${by}`, withNames === undefined || withNames.length === 0 ? "" : `with ${withNames.join(", ")}`]; |
| 82 | 99 | return parts.filter((p) => p !== "").join(", "); |
| @@ -84,7 +101,10 @@ export function creditWords(by: string | undefined, withNames: readonly string[] | ||
| 84 | 101 | |
| 85 | 102 | type Pull = ReleaseEntry["pulls"][number]; |
| 86 | 103 | |
| 87 | /** A release's pulls as lines: pulls of one shape gathered ("Keys on … · 9 pulls"), the rest `#N title`. */ | |
| 104 | /** | |
| 105 | * A release's pulls as lines: pulls of one shape gathered ("Keys on … · 9 pulls"), the rest | |
| 106 | * `#N title`. | |
| 107 | */ | |
| 88 | 108 | export function pullLines(pulls: readonly Pull[], credits: ReadonlyMap<number, string>): { row: ListRow; pulls: readonly Pull[] }[] { |
| 89 | 109 | return gather(pulls).map((g) => |
| 90 | 110 | g.landings.length === 1 |
| @@ -93,7 +113,10 @@ export function pullLines(pulls: readonly Pull[], credits: ReadonlyMap<number, s | ||
| 93 | 113 | ); |
| 94 | 114 | } |
| 95 | 115 | |
| 96 | /** One release's pulls; Enter opens a pull as the changelog's Enter once did, and a gathered line lists its own pulls. */ | |
| 116 | /** | |
| 117 | * One release's pulls; Enter opens a pull as the changelog's Enter once did, and a gathered line | |
| 118 | * lists its own pulls. | |
| 119 | */ | |
| 97 | 120 | function releasePulls(f: Session, ctx: Ctx, repoRef: Repo, entry: ReleaseEntry, credits: ReadonlyMap<number, string>, title = entry.version): Screen { |
| 98 | 121 | const state = new ListState(); |
| 99 | 122 | const lines = pullLines(entry.pulls, credits); |
| @@ -132,6 +155,11 @@ export function changelogScreen(f: Session, ctx: Ctx): Screen { | ||
| 132 | 155 | let groups: Group[] = []; |
| 133 | 156 | const lines = (): Line[] => |
| 134 | 157 | groups.length > 0 ? chapterLines(groups, (l) => filter.matches(`${plainTitle(l.title)}\n#${l.number}`), filter.query !== "") : changelogLines(shown()); |
| 158 | // In releases the cursor starts on the first release, not on the month line above it. | |
| 159 | const home = (): void => { | |
| 160 | state.clamp(lines().length); | |
| 161 | if (groups.length === 0 && lines()[state.index]?.entry === undefined) state.key({ key: "j" } as never, lines().length); | |
| 162 | }; | |
| 135 | 163 | const shown = (): ReleaseEntry[] => entries.filter((e) => releaseMatches(filter, e)); |
| 136 | 164 | return { |
| 137 | 165 | title: "Changelog", |
| @@ -170,7 +198,7 @@ export function changelogScreen(f: Session, ctx: Ctx): Screen { | ||
| 170 | 198 | groups = groupByChapter(live, entries); |
| 171 | 199 | } |
| 172 | 200 | near = nearLines(nearMilestones(f.app, f.app.config.forgeRepo, f.user)?.near ?? []); |
| 173 | state.clamp(entries.length); | |
| 201 | home(); | |
| 174 | 202 | loaded = true; |
| 175 | 203 | ctx.invalidate(); |
| 176 | 204 | }, |
| @@ -188,7 +216,7 @@ export function changelogScreen(f: Session, ctx: Ctx): Screen { | ||
| 188 | 216 | near.forEach((line, i) => s.text(ms!.x, ms!.y + i, truncate(line, ms!.w), style(c.fg, c.bg), ms!.x + ms!.w)); |
| 189 | 217 | const noun = groups.length > 0 ? "pulls" : "releases"; |
| 190 | 218 | const total = groups.length > 0 ? groups.reduce((n, g) => n + g.landings.length, 0) : entries.length; |
| 191 | const matching = list.filter((l) => (groups.length > 0 ? l.pull !== undefined : true)).length; | |
| 219 | const matching = list.filter((l) => (groups.length > 0 ? l.pull !== undefined : l.entry !== undefined)).length; | |
| 192 | 220 | const count = filter.query === "" ? `${total} ${noun}` : `${matching} of ${total} ${noun} match`; |
| 193 | 221 | s.text(head!.x, head!.y, truncate(count, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
| 194 | 222 | ctx.setCursor(filter.on ? filter.render(s, box!, c, groups.length > 0 ? "find a pull" : "find a version or pull") : null); |
| @@ -200,12 +228,12 @@ export function changelogScreen(f: Session, ctx: Ctx): Screen { | ||
| 200 | 228 | }, |
| 201 | 229 | key(e) { |
| 202 | 230 | if (filter.key(e)) { |
| 203 | state.clamp(lines().length); | |
| 231 | home(); | |
| 204 | 232 | return true; |
| 205 | 233 | } |
| 206 | 234 | if (e.key === "esc" && filter.query !== "") { |
| 207 | 235 | filter.query = ""; |
| 208 | state.clamp(lines().length); | |
| 236 | home(); | |
| 209 | 237 | } else if (e.key === "esc" || e.key === "q") ctx.pop(); |
| 210 | 238 | else if (e.key === "enter") { |
| 211 | 239 | const line = lines()[state.index]; |
src/web/pages/changelog.ts +31 −5
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * a new commit. Public and server-rendered. |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | import { MONTH_NAMES, monthLabel } from "../../release/month.ts"; | |
| 9 | 10 | import { notePhase, takeSessionTime, timePhaseAsync } from "../../core/route_timing.ts"; |
| 10 | 11 | import type { Ctx } from "../../http/context.ts"; |
| 11 | 12 | import { betNamesOfPulls } from "../../core/bets.ts"; |
| @@ -152,9 +153,17 @@ function betweenSection(g: Extract<Group, { kind: "between" }>, own: string | un | ||
| 152 | 153 | function byDay(list: readonly Landing[], own: string | undefined, showRepo: boolean, zone: string, today: string, target?: string): Html[] { |
| 153 | 154 | const days = new Map<string, Landing[]>(); |
| 154 | 155 | for (const l of list) days.set(dayOf(l.at, zone), [...(days.get(dayOf(l.at, zone)) ?? []), l]); |
| 155 | return [...days].map(([day, items]) => | |
| 156 | html`<section class="mt" data-day="${day}"><h2><time datetime="${day}">${dayHeading(day, today)}</time>${zone === "UTC" ? html` <span data-zone>${badge("UTC", { variant: "outline" })}</span>` : null} ${badge(String(items.length))}</h2><ul class="list setting-list">${gather(items).map((g) => (g.landings.length === 1 ? landingRow(g.landings[0]!, own, showRepo) : gatheredRow(g, own, showRepo, day, target)))}</ul></section>`, | |
| 157 | ); | |
| 156 | let month = ""; | |
| 157 | return [...days].map(([day, items]) => { | |
| 158 | // One pass: a month's heading comes before its first day, newest first as the days are. | |
| 159 | const head = day.slice(0, 7) === month ? null : monthHeading((month = day.slice(0, 7))); | |
| 160 | return html`${head}<section class="mt" data-day="${day}"><h3><time datetime="${day}">${dayHeading(day, today)}</time>${zone === "UTC" ? html` <span data-zone>${badge("UTC", { variant: "outline" })}</span>` : null} ${badge(String(items.length))}</h3><ul class="list setting-list">${gather(items).map((g) => (g.landings.length === 1 ? landingRow(g.landings[0]!, own, showRepo) : gatheredRow(g, own, showRepo, day, target)))}</ul></section>`; | |
| 161 | }); | |
| 162 | } | |
| 163 | ||
| 164 | /** "November 2026" as a heading and a link target `#2026-11`; `month` is `YYYY-MM`. */ | |
| 165 | export function monthHeading(month: string): Html { | |
| 166 | return html`<h2 class="mt" id="${month}" data-month><a href="#${month}">${monthLabel(month)}</a></h2>`; | |
| 158 | 167 | } |
| 159 | 168 | |
| 160 | 169 | /** |
| @@ -187,12 +196,15 @@ export const localDaysJs = /* js */ ` | ||
| 187 | 196 | function count(list) { return list.reduce(function (n, li) { return n + (Number(li.getAttribute('data-count')) || 1); }, 0); } |
| 188 | 197 | if (cards.length) { |
| 189 | 198 | var proto = cards[0]; |
| 199 | var heads = root.querySelectorAll('[data-month]'); | |
| 200 | var head0 = heads.length ? heads[0].cloneNode(true) : null; | |
| 201 | heads.forEach(function (h) { h.parentNode.removeChild(h); }); | |
| 190 | 202 | var after = proto.previousSibling; |
| 191 | 203 | var parent = proto.parentNode; |
| 192 | 204 | var made = order.map(function (d) { |
| 193 | 205 | var c = proto.cloneNode(true); |
| 194 | 206 | c.setAttribute('data-day', d); |
| 195 | var tm = c.querySelector('h2 time'); | |
| 207 | var tm = c.querySelector('h3 time'); | |
| 196 | 208 | tm.setAttribute('datetime', d); |
| 197 | 209 | tm.textContent = dayHeading(d, today); |
| 198 | 210 | var z = c.querySelector('[data-zone]'); |
| @@ -206,7 +218,21 @@ export const localDaysJs = /* js */ ` | ||
| 206 | 218 | }); |
| 207 | 219 | cards.forEach(function (c) { parent.removeChild(c); }); |
| 208 | 220 | var ref = after ? after.nextSibling : parent.firstChild; |
| 209 | made.forEach(function (c) { parent.insertBefore(c, ref); }); | |
| 221 | var names = ${JSON.stringify(MONTH_NAMES)}; | |
| 222 | var month = ''; | |
outdated
This duplicates MONTH_NAMES from line 163. Inject the one array into the script with JSON.stringify so the two cannot drift. |
||
| 223 | made.forEach(function (c) { | |
| 224 | var d = c.getAttribute('data-day'); | |
| 225 | if (head0 && d.slice(0, 7) !== month) { | |
| 226 | month = d.slice(0, 7); | |
| 227 | var h = head0.cloneNode(true); | |
| 228 | h.id = month; | |
| 229 | var a = h.querySelector('a'); | |
| 230 | a.setAttribute('href', '#' + month); | |
| 231 | a.textContent = names[Number(month.slice(5, 7)) - 1] + ' ' + month.slice(0, 4); | |
| 232 | parent.insertBefore(h, ref); | |
| 233 | } | |
| 234 | parent.insertBefore(c, ref); | |
| 235 | }); | |
| 210 | 236 | } |
| 211 | 237 | // An empty #shipped-today with no cards is the server saying nothing has ever shipped: |
| 212 | 238 | // writing the count here would bring back the second empty state. |
test/changelog-months.test.ts added +44
| @@ -0,0 +1,44 @@ | ||
| 1 | /** | |
| 2 | * The changelog groups days under "November 2026" headings, newest first, each a link target | |
| 3 | * #2026-11. | |
| 4 | */ | |
| 5 | import { expect, test } from "bun:test"; | |
| 6 | import { Window } from "happy-dom"; | |
| 7 | import type { Landing, Landings } from "../src/release/landings.ts"; | |
| 8 | import { localDaysJs, monthHeading, shippedRegion } from "../src/web/pages/changelog.ts"; | |
| 9 | ||
| 10 | const land = (number: number, at: string): Landing => ({ repo: "a/b", number, title: `Pull ${number}`, at, live: true }); | |
| 11 | const read = (live: Landing[]): Landings => ({ own: "a/b", version: "v1", commit: null, live, onItsWay: [] }) as unknown as Landings; | |
| 12 | const NOW = new Date("2026-11-12T12:00:00Z"); | |
| 13 | const doc = (live: Landing[]) => { | |
| 14 | const d = new Window().document as any; | |
| 15 | d.body.innerHTML = `<div id="shipped">${shippedRegion(read(live), "a/b", NOW)}</div>`; | |
| 16 | return d; | |
| 17 | }; | |
| 18 | ||
| 19 | test("days sit under month headings, newest first, each with the id 2026-11 style", () => { | |
| 20 | const d = doc([land(4, "2026-11-10T10:00:00Z"), land(3, "2026-11-02T10:00:00Z"), land(2, "2026-10-30T10:00:00Z"), land(1, "2025-12-31T10:00:00Z")]); | |
| 21 | const heads = [...d.querySelectorAll("[data-month]")]; | |
| 22 | expect(heads.map((h: any) => h.textContent)).toEqual(["November 2026", "October 2026", "December 2025"]); | |
| 23 | expect(heads.map((h: any) => h.id)).toEqual(["2026-11", "2026-10", "2025-12"]); | |
| 24 | expect(heads[0].querySelector("a").getAttribute("href")).toBe("#2026-11"); | |
| 25 | const order = [...d.querySelectorAll("[data-month], [data-day]")].map((e: any) => e.getAttribute("data-month") !== null ? e.id : e.getAttribute("data-day")); | |
| 26 | expect(order).toEqual(["2026-11", "2026-11-10", "2026-11-02", "2026-10", "2026-10-30", "2025-12", "2025-12-31"]); | |
| 27 | }); | |
| 28 | ||
| 29 | test("a month with nothing in it never shows", () => { | |
| 30 | const d = doc([land(2, "2026-11-10T10:00:00Z"), land(1, "2026-08-10T10:00:00Z")]); | |
| 31 | expect([...d.querySelectorAll("[data-month]")].map((h: any) => h.id)).toEqual(["2026-11", "2026-08"]); | |
| 32 | expect(doc([]).querySelectorAll("[data-month]").length).toBe(0); | |
| 33 | }); | |
| 34 | ||
| 35 | test("the heading is escaped markup of one shape", () => { | |
| 36 | expect(monthHeading("2026-11").toString()).toContain('id="2026-11"'); | |
| 37 | }); | |
| 38 | ||
| 39 | test("regrouping into the reader's days keeps one heading per month, before its days", () => { | |
| 40 | const d = doc([land(2, "2026-11-10T10:00:00Z"), land(1, "2026-10-30T10:00:00Z")]); | |
| 41 | new Function("document", localDaysJs)(d); | |
| 42 | const order = [...d.querySelectorAll("[data-month], [data-day]")].map((e: any) => e.getAttribute("data-month") !== null ? e.id : e.getAttribute("data-day")); | |
| 43 | expect(order).toEqual(["2026-11", "2026-11-10", "2026-10", "2026-10-30"]); | |
| 44 | }); |
test/changelog.test.ts +10 −8
| @@ -254,7 +254,7 @@ describe("changelog page", () => { | ||
| 254 | 254 | doc.querySelectorAll("script").forEach((s) => s.remove()); |
| 255 | 255 | const days = [...doc.querySelectorAll("#shipped section[data-day]")]; |
| 256 | 256 | expect(days.length).toBe(1); |
| 257 | expect(days[0]!.querySelector("h2 time")!.getAttribute("datetime")).toBe(new Date().toISOString().slice(0, 10)); | |
| 257 | expect(days[0]!.querySelector("h3 time")!.getAttribute("datetime")).toBe(new Date().toISOString().slice(0, 10)); | |
| 258 | 258 | expect([...days[0]!.querySelectorAll("li .row-title")].map((t) => t.textContent)).toEqual(["Second thing", "First <b>thing</b>"]); |
| 259 | 259 | expect(doc.getElementById("shipped-today")!.textContent).toBe("2 shipped today (UTC)."); |
| 260 | 260 | }); |
| @@ -340,7 +340,7 @@ describe("the browser regroups the changelog into the reader's days", () => { | ||
| 340 | 340 | new Function("document", localDaysJs)(doc); |
| 341 | 341 | const cards = [...doc.querySelectorAll("[data-day]")]; |
| 342 | 342 | expect(cards.map((c) => c.getAttribute("data-day"))).toEqual(["2026-11-02", "2026-11-01"]); |
| 343 | expect(cards.map((c) => c.querySelector("h2 time")!.textContent)).toEqual(["Today", "Yesterday"]); | |
| 343 | expect(cards.map((c) => c.querySelector("h3 time")!.textContent)).toEqual(["Today", "Yesterday"]); | |
| 344 | 344 | expect(cards.map(titles)).toEqual([["Three", "Two"], ["One"]]); |
| 345 | 345 | expect(cards.map((c) => c.querySelector(".badge")!.textContent)).toEqual(["2", "1"]); |
| 346 | 346 | expect(doc.getElementById("shipped-today")!.textContent).toBe("2 shipped today."); |
| @@ -465,7 +465,7 @@ describe("changelog rows, not boxes (#9688)", () => { | ||
| 465 | 465 | return doc; |
| 466 | 466 | }; |
| 467 | 467 | |
| 468 | test("each day is a section with an h2 over a list, and nothing is a card", async () => { | |
| 468 | test("each day is a section with an h3 over a list, and nothing is a card", async () => { | |
| 469 | 469 | const { shippedRegion } = await import("../src/web/pages/changelog.ts"); |
| 470 | 470 | const doc = await parse(String(shippedRegion(sample, "all", new Date("2026-11-02T10:00:00.000Z")))); |
| 471 | 471 | expect(doc.querySelectorAll(".card, .card-head").length).toBe(0); |
| @@ -473,7 +473,7 @@ describe("changelog rows, not boxes (#9688)", () => { | ||
| 473 | 473 | expect(days.map((d) => d.getAttribute("data-day"))).toEqual(["2026-11-02", "2026-11-01"]); |
| 474 | 474 | for (const d of days) { |
| 475 | 475 | // The heading, then the list, and nothing else. |
| 476 | expect([...d.children].map((c) => `${c.tagName}.${c.className}`)).toEqual(["H2.", "UL.list setting-list"]); | |
| 476 | expect([...d.children].map((c) => `${c.tagName}.${c.className}`)).toEqual(["H3.", "UL.list setting-list"]); | |
| 477 | 477 | } |
| 478 | 478 | // On its way is the same shape: a heading over the same list. |
| 479 | 479 | const way = [...doc.querySelectorAll("h2")].find((h) => h.textContent === "On its way")!; |
| @@ -483,14 +483,15 @@ describe("changelog rows, not boxes (#9688)", () => { | ||
| 483 | 483 | test("each heading holds what localDaysJs reads, in its order: the day, the UTC mark, then the one count badge", async () => { |
| 484 | 484 | const { shippedRegion, localDaysJs } = await import("../src/web/pages/changelog.ts"); |
| 485 | 485 | const doc = await parse(String(shippedRegion(sample, "all", new Date("2026-11-02T10:00:00.000Z")))); |
| 486 | const heads = [...doc.querySelectorAll("section[data-day] > h2")]; | |
| 486 | const heads = [...doc.querySelectorAll("section[data-day] > h3")]; | |
| 487 | 487 | expect(heads.length).toBe(2); |
| 488 | 488 | const shape = heads.map((h) => [...h.children].map((c) => (c.tagName === "TIME" ? `time ${c.getAttribute("datetime")}` : c.hasAttribute("data-zone") ? `zone ${c.textContent}` : `${c.className} ${c.textContent}`))); |
| 489 | 489 | expect(shape).toEqual([ |
| 490 | 490 | ["time 2026-11-02", "zone UTC", "badge 1"], |
| 491 | 491 | ["time 2026-11-01", "zone UTC", "badge 1"], |
| 492 | 492 | ]); |
| 493 | // The script's first .badge in a section, once the zone mark is gone, is the count: a row's bet badge sits under the list. | |
| 493 | // The script's first .badge in a section, once the zone mark is gone, is the count: a row's bet | |
| 494 | // badge sits under the list. | |
| 494 | 495 | for (const h of heads) { |
| 495 | 496 | h.querySelector("[data-zone]")!.remove(); |
| 496 | 497 | expect(h.parentElement!.querySelector(".badge")!.textContent).toBe("1"); |
| @@ -498,7 +499,7 @@ describe("changelog rows, not boxes (#9688)", () => { | ||
| 498 | 499 | // In the reader's own zone there is no mark at all. |
| 499 | 500 | const local = await parse(String(shippedRegion(sample, "all", new Date("2026-11-02T10:00:00.000Z"), "America/Chicago"))); |
| 500 | 501 | expect(local.querySelectorAll("[data-zone]").length).toBe(0); |
| 501 | for (const sel of ["[data-day]", "h2 time", "[data-zone]", ".badge"]) expect(localDaysJs).toContain(`'${sel}'`); | |
| 502 | for (const sel of ["[data-day]", "h3 time", "[data-zone]", ".badge"]) expect(localDaysJs).toContain(`'${sel}'`); | |
| 502 | 503 | expect(localDaysJs.indexOf("[data-zone]")).toBeLessThan(localDaysJs.indexOf("c.querySelector('.badge')")); |
| 503 | 504 | }); |
| 504 | 505 | |
| @@ -514,7 +515,8 @@ describe("changelog rows, not boxes (#9688)", () => { | ||
| 514 | 515 | const { shippedRegion } = await import("../src/web/pages/changelog.ts"); |
| 515 | 516 | const many = Array.from({ length: 100 }, (_, i) => landing(i + 1, new Date(Date.UTC(2026, 10, 1) - i * 7_200_000).toISOString())); |
| 516 | 517 | const out = String(shippedRegion(landings(many), "all")); |
| 517 | // Work, not a stopwatch: about 100 bytes of markup per row beyond its title, a day section per two rows. | |
| 518 | // Work, not a stopwatch: about 100 bytes of markup per row beyond its title, a day section per | |
| 519 | // two rows. | |
| 518 | 520 | expectWork(out.length, { max: 100 * 700 }); |
| 519 | 521 | const doc = await parse(out); |
| 520 | 522 | expect(doc.querySelectorAll("section[data-day] li").length).toBe(100); |
test/tui-changelog.test.ts +17 −2
| @@ -1,4 +1,7 @@ | ||
| 1 | /** The changelog in the terminal: the palette offers it to a guest, and the screen lists the page's releases. */ | |
| 1 | /** | |
| 2 | * The changelog in the terminal: the palette offers it to a guest, and the screen lists the page's | |
| 3 | * releases. | |
| 4 | */ | |
| 2 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 6 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 7 | import { tmpdir } from "node:os"; |
| @@ -83,6 +86,8 @@ test("a guest is offered the changelog and sees the releases newest first", asyn | ||
| 83 | 86 | expect(text.indexOf("0.2.0")).toBeGreaterThan(-1); |
| 84 | 87 | expect(text.indexOf("0.2.0")).toBeLessThan(text.indexOf("0.1.0")); |
| 85 | 88 | expect(text).toContain("#2 Newer thing"); |
| 89 | // The month heading line sits over the releases, and the cursor starts on a release. | |
| 90 | expect(text.indexOf("November 2026")).toBeLessThan(text.indexOf("0.2.0")); | |
| 86 | 91 | }); |
| 87 | 92 | |
| 88 | 93 | test("a private forge repository leaves the terminal's screen empty", async () => { |
| @@ -138,5 +143,15 @@ test("the terminal tells pulls in chapters, open first, then between chapters; w | ||
| 138 | 143 | expect(lines.filter((l) => l.pull !== undefined).map((l) => l.pull)).toEqual([4, 3, 1, 2]); |
| 139 | 144 | // Narrowed, a heading with no pull left goes. |
| 140 | 145 | expect(chapterLines(groups, (l) => l.number === 1, true).map((l) => l.row.title)).toEqual(["Chapter v1", " #1 Pull 1"]); |
| 141 | expect(changelogLines([{ version: "0.4.0", date: "2026-10-30T00:00:00Z", pulls: [] }]).map((l) => l.row.title)).toEqual(["0.4.0"]); | |
| 146 | expect(changelogLines([{ version: "0.4.0", date: "2026-10-30T00:00:00Z", pulls: [] }]).map((l) => l.row.title)).toEqual(["October 2026", "0.4.0"]); | |
| 147 | }); | |
| 148 | ||
| 149 | test("releases sit under a month heading line, newest first, one per month; a heading is no release", () => { | |
| 150 | const e = (version: string, date: string) => ({ version, date, pulls: [] }); | |
| 151 | const lines = changelogLines([e("0.6.0", "2026-11-10T00:00:00Z"), e("0.5.0", "2026-11-02T00:00:00Z"), e("0.4.0", "2026-10-30T00:00:00Z"), e("0.1.0", "2025-12-31T00:00:00Z")]); | |
| 152 | expect(lines.map((l) => l.row.title)).toEqual(["November 2026", "0.6.0", "0.5.0", "October 2026", "0.4.0", "December 2025", "0.1.0"]); | |
| 153 | expect(lines[0]!.row.meta).toContain("2 releases"); | |
| 154 | expect(lines[3]!.row.meta).toContain("1 release"); | |
| 155 | expect(lines.filter((l) => l.entry === undefined).length).toBe(3); | |
| 156 | expect(changelogLines([])).toEqual([]); | |
| 142 | 157 | }); |
new above
offline
Principle 1/8 and structure: the month is an h2 and the day section is also an h2. Make the day an h3 so the month heads its days. Update the tests and the regrouping script that depend on it.