Public: anyone can read this; the crew can change it.

A wave on /changelog says how many of its changes are live on production and how many wait to ship #13189

Merged opened this

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

Merged

mason/forge:mason/13164-a-wave-on-changelog-says-how-many-of-its → main 12 commits fork

  • Merged. mason/13164-a-wave-on-changelog-says-how-many-of-its was merged into main as 87b13d4.

Review

Sign in to review this change.
10 files changed +265 −50
docs/features/README.md +1
@@ -146,6 +146,7 @@ Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
146146 - [The week's pace](week-pace.md)
147147 - [Walking a wave](wave-walk.md)
148148 - [The wave-standing line](wave-standing.md)
149 - [How many of a wave's changes are live and waiting to ship](wave-landing.md)
149150 - [What became of the first ask](ask-status.md)
150151 - [When a setting or a permission stands in the way](blocked-by.md)
151152 - [The map's growth line](map-growth.md)
docs/features/wave-landing.md added +11
@@ -0,0 +1,11 @@
1 # Waves: live and waiting to ship
2
3 Each wave on the waves list says how many of its changes are live and how many are still waiting to ship: `2 live, 1 waiting to ship`.
4
5 - **Live** changes have reached production; **waiting to ship** ones are merged and in the release queue.
6 - Pulls the reader may not see are not counted, as in the size words beside it.
7 - The web list shows it in the muted trail under each wave; the terminal's waves list shows it in the meta column.
8
9 Both doors build the words with `shippedOf` and `shippedWords` in `src/story/wave_moved.ts`, so they say the same thing.
10
11 A process that has not yet read what waits (just after a boot, before anyone opens /changelog) says nothing rather than call every change live: the page and the atom leave the count out, the API returns `null` for both.
src/contract/openapi/routes/getApiV1ReposOwnerNameWaves.ts +1 −1
@@ -1,3 +1,3 @@
11 import { REPO, type Route } from "../shared.ts";
22
3 export const route: Route = { method: "get", path: `${REPO}/waves`, summary: "Takes no query parameters (the list is not paged: next_cursor is always null). List what shipped, newest first, as { items: [{ version, date, headline }], next_cursor: null }; a file that is not a wave is left out; a private repository needs a token", auth: false, role: "anonymous", reply: { items: "array", next_cursor: "null" }, refusals: { not_found: "404: no such repository, or it is not readable" } };
3 export const route: Route = { method: "get", path: `${REPO}/waves`, summary: "Takes no query parameters (the list is not paged: next_cursor is always null). List what shipped, newest first, as { items: [{ version, date, headline, pulls, apps, live, waiting }]; live and waiting count the wave's merged pulls the caller may read that are live on production and that wait to ship (both null when this process has not yet read what waits), next_cursor: null }; a file that is not a wave is left out; a private repository needs a token", auth: false, role: "anonymous", reply: { items: "array", next_cursor: "null" }, refusals: { not_found: "404: no such repository, or it is not readable" } };
src/http/api.ts +16 −12
@@ -303,6 +303,8 @@ import { blobForRender, commitLog, listRefs, listTree, refTip } from "../git/rea
303303 import { repoDir } from "../git/repos.ts";
304304 import { holds, weakEtag } from "./etag.ts";
305305 import { carriedPulls, pullPath } from "../story/wave_pulls.ts";
306 import { waitingKeys } from "../release/landings.ts";
307 import { shippedOf } from "../story/wave_moved.ts";
306308 import { pullRefs, readWave, readWaves, waveSize } from "../story/waves.ts";
307309 import { originForRepo, type OriginRepoRow } from "../core/origins.ts";
308310 import { subscribe as subscribeJob, type MirrorJob } from "../origins/jobs.ts";
@@ -2330,20 +2332,22 @@ export function apiRoutes(router: Router<Handler>): void {
23302332 readWaves(repoDir(ctx.app.reposRoot, repo.ownerName, repo.name), repo.defaultBranch),
23312333 );
23322334 // Sized over the pulls this viewer can read, as the page does.
2335 const waiting = waitingKeys(ctx.app.db);
23332336 return timePhase(ctx.request, "render", () =>
23342337 json({
2335 items: entries.flatMap((e) =>
2336 e.ok
2337 ? [
2338 {
2339 version: e.wave.version,
2340 date: e.wave.date,
2341 headline: e.wave.headline,
2342 ...waveSize(carriedPulls(ctx.app.db, pullRefs(e.wave), ctx.auth.user)),
2343 },
2344 ]
2345 : [],
2346 ),
2338 items: entries.flatMap((e) => {
2339 if (!e.ok) return [];
2340 const carried = carriedPulls(ctx.app.db, pullRefs(e.wave), ctx.auth.user);
2341 return [
2342 {
2343 version: e.wave.version,
2344 date: e.wave.date,
2345 headline: e.wave.headline,
2346 ...waveSize(carried),
2347 ...(shippedOf(carried, waiting) ?? { live: null, waiting: null }),
2348 },
2349 ];
2350 }),
23472351 next_cursor: null,
23482352 }),
23492353 );
src/release/landings.ts +46 −10
@@ -30,11 +30,16 @@ export interface Landing {
3030 readonly live: boolean;
3131 /** The bet whose scopes this pull built (#8713), set by the page that shows it. */
3232 readonly bet?: string;
33 /** `account@host` when a trusted source's work folded in (#8937), set by the page that shows it. */
33 /**
34 * `account@host` when a trusted source's work folded in (#8937), set by the page that shows it.
35 */
3436 readonly from?: string;
3537 /** Who built it: the author of the landed commit (a crew member or a person). */
3638 readonly by?: string;
37 /** Others credited on the landed commit (`Co-authored-by`: the models, people), beyond whoever landed or wrote it. */
39 /**
40 * Others credited on the landed commit (`Co-authored-by`: the models, people), beyond whoever
41 * landed or wrote it.
42 */
3843 readonly with?: readonly string[];
3944 }
4045
@@ -68,7 +73,10 @@ export interface Window {
6873
6974 const CURSOR = /^[A-Za-z0-9_.-]{1,64}\/[A-Za-z0-9_.-]{1,100}#[0-9]{1,9}$/;
7075
71 /** Which repository the reader asked for: "" for this forge's own, "all", or one named in the list; anything else is the default. */
76 /**
77 * Which repository the reader asked for: "" for this forge's own, "all", or one named in the list;
78 * anything else is the default.
79 */
7280 export function chosenRepo(asked: string | null, all: readonly { readonly repo: string }[], own: string | undefined): string {
7381 if (asked === "all") return "all";
7482 if (asked !== null && all.some((l) => l.repo === asked)) return asked;
@@ -142,9 +150,14 @@ interface LiveState {
142150 readonly at: number;
143151 /** The running commit these were asked of. */
144152 readonly commit: string;
145 /** The tip of the forge's own default branch as the last read found it, read from the ref files. */
153 /**
154 * The tip of the forge's own default branch as the last read found it, read from the ref files.
155 */
146156 readonly head?: string;
147 /** Commits in `head` and not in `commit` (`git rev-list --count commit..head`), asked once per pair. */
157 /**
158 * Commits in `head` and not in `commit` (`git rev-list --count commit..head`), asked once per
159 * pair.
160 */
148161 readonly ahead?: number;
149162 }
150163 /**
@@ -191,7 +204,10 @@ export function split(rows: readonly MergedRow[], state: LiveState | undefined):
191204 return out;
192205 }
193206
194 /** The merged pulls still on their way and when the oldest merged, from what the last read kept; undefined when none or nothing was read. */
207 /**
208 * The merged pulls still on their way and when the oldest merged, from what the last read kept;
209 * undefined when none or nothing was read.
210 */
195211 export function waiting(db: Database): { readonly since: string; readonly count: number } | undefined {
196212 const kept = keeps.get(db);
197213 if (kept === undefined) return undefined;
@@ -200,7 +216,10 @@ export function waiting(db: Database): { readonly since: string; readonly count:
200216 return oldest === undefined ? undefined : { since: oldest.at, count: onItsWay.length };
201217 }
202218
203 /** The merged pulls not yet in the running commit, oldest first, with their merge commits; empty when nothing was read (#11507). */
219 /**
220 * The merged pulls not yet in the running commit, oldest first, with their merge commits; empty
221 * when nothing was read (#11507).
222 */
204223 export function waitingRows(db: Database): MergedRow[] {
205224 const kept = keeps.get(db);
206225 if (kept === undefined) return [];
@@ -209,10 +228,26 @@ export function waitingRows(db: Database): MergedRow[] {
209228 return rows.filter((r) => way.has(`${r.repo}#${r.number}`)).reverse();
210229 }
211230
212 /** How long a miss is believed: a repository can turn public, or merge its first pull, after boot. */
231 /**
232 * The pulls on their way as `owner/name#number`, lowercased, from what the last
233 * read kept: one query, no git. A wave counts these against its pulls, so a
234 * pull is live unless it is in here. Undefined when nothing was read yet (a cold process): then
235 * nothing is known about what waits, and no count is told.
236 */
237 export function waitingKeys(db: Database): Set<string> | undefined {
238 if (keeps.get(db) === undefined) return undefined;
239 return new Set(waitingRows(db).map((r) => `${r.repo}#${r.number}`.toLowerCase()));
240 }
241
242 /**
243 * How long a miss is believed: a repository can turn public, or merge its first pull, after boot.
244 */
213245 const MISS_MS = 60_000;
214246
215 /** The repository the running commit was built from, per running commit; "" when none held it at `at`. */
247 /**
248 * The repository the running commit was built from, per running commit; "" when none held it at
249 * `at`.
250 */
216251 const founds = new WeakMap<Database, Map<string, { repo: string; at: number }>>();
217252
218253 /**
@@ -240,7 +275,8 @@ async function ownRepo(app: App, rows: readonly MergedRow[], now = Date.now()):
240275 found.set(commit, { repo: named, at: now });
241276 return repo;
242277 }
243 // A miss is kept a minute so requests cost no git; with no merged pulls yet there is nothing to remember.
278 // A miss is kept a minute so requests cost no git; with no merged pulls yet there is nothing to
279 // remember.
244280 if (rows.length > 0) found.set(commit, { repo: "", at: now });
245281 else found.delete(commit);
246282 return undefined;
src/story/wave_moved.ts +40 −1
@@ -11,7 +11,7 @@ import type { Plan } from "../core/milestones.ts";
1111 import type { Repo } from "../core/repos.ts";
1212 import { mayView } from "../core/sealed.ts";
1313 import type { User } from "../core/users.ts";
14 import { closesOfMerged } from "./wave_pulls.ts";
14 import { closesOfMerged, type CarriedPull } from "./wave_pulls.ts";
1515 import type { PullRef } from "./waves.ts";
1616
1717 export interface MovedMilestone {
@@ -155,3 +155,42 @@ export function movedWithPulls(input: {
155155 })
156156 .map((m) => ({ ...m, pulls: carried.get(m.number) ?? [] }));
157157 }
158
159 /** How many of a wave's merged pulls are live on production and how many wait to ship. */
160 export interface Shipped {
161 live: number;
162 waiting: number;
163 }
164
165 /**
166 * Counts a wave's merged pulls (the ones the viewer may see, as `carriedPulls`
167 * returns them) against `waiting`, the pulls on their way as lowercase
168 * `owner/name#number` (`release/landings.ts`). A pull that is not merged is
169 * neither live nor waiting. Null when `waiting` is undefined: nothing has been
170 * read of production yet, so every pull would wrongly look live. Plain data in,
171 * plain data out: no query here.
172 */
173 export function shippedOf(
174 pulls: readonly Pick<CarriedPull, "owner" | "name" | "number" | "mergedAt">[],
175 waiting: ReadonlySet<string> | undefined,
176 ): Shipped | null {
177 if (waiting === undefined) return null;
178 let wait = 0;
179 let live = 0;
180 for (const p of pulls) {
181 if (p.mergedAt === null) continue;
182 if (waiting.has(`${p.owner}/${p.name}#${p.number}`.toLowerCase())) wait++;
183 else live++;
184 }
185 return { live, waiting: wait };
186 }
187
188 /**
189 * The words for it: `3 live, 1 waiting to ship`, or only `live` when nothing waits;
190 * empty when the wave has no merged pull to speak of or nothing is known.
191 */
192 export function shippedWords(s: Shipped | null): string {
193 if (s === null) return "";
194 if (s.waiting === 0) return s.live === 0 ? "" : "live";
195 return `${s.live} live, ${s.waiting} waiting to ship`;
196 }
src/tui/screens/waves.ts +13 −4
@@ -9,9 +9,10 @@ import { cutWaveFor, planCutFor } from "../../actions/cut_wave.ts";
99 import { canRead, getRepo } from "../../core/repos.ts";
1010 import { nearMilestones, standingLine } from "../../web/pages/milestones_near.ts";
1111 import { VERSION } from "../../story/wave.ts";
12 import { movedWithPulls, waveProgress, type MovedMilestone } from "../../story/wave_moved.ts";
12 import { movedWithPulls, shippedOf, shippedWords, waveProgress, type MovedMilestone } from "../../story/wave_moved.ts";
1313 import { milestonePath, planNow } from "../../story/wave_plan.ts";
1414 import { repoBase } from "../../web/chrome.ts";
15 import { waitingKeys } from "../../release/landings.ts";
1516 import { carriedPulls, pullPath, type CarriedPull } from "../../story/wave_pulls.ts";
1617 import { pullRefs, readWave, readWaves, sizeWords, waveLine, waveSize, type WaveEntry } from "../../story/waves.ts";
1718 import { NO_WAVES, waveSentence } from "../../story/words.ts";
@@ -31,13 +32,13 @@ import { local, localRepo, sourceName, whereRows, whereStrip } from "./where.ts"
3132 * One line per wave, as the screen draws it, sized as the page sizes it: `sizeOf` counts the pulls
3233 * this viewer can see.
3334 */
34 export function waveRows(entries: WaveEntry[], sizeOf: (e: WaveEntry & { ok: true }) => { pulls: number; apps: number }) {
35 export function waveRows(entries: WaveEntry[], sizeOf: (e: WaveEntry & { ok: true }) => { pulls: number; apps: number }, shipped: (e: WaveEntry & { ok: true }) => string = () => "") {
3536 return entries.map((e) =>
3637 e.ok
3738 ? {
3839 title: plain(waveLine(e.wave, sizeOf(e))),
3940 secondary: "",
40 meta: "",
41 meta: plain(shipped(e)),
4142 }
4243 : { title: e.file, secondary: `Not a wave: ${e.reason}`, meta: "" },
4344 );
@@ -172,6 +173,8 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
172173 let entries: WaveEntry[] = [];
173174 /** Each wave's size by file, counted once per load with the page's gate on each pull. */
174175 let sizes = new Map<string, { pulls: number; apps: number }>();
176 /** Each wave's "N live, M landing" by file, as the page's trail says it. */
177 let shipped = new Map<string, string>();
175178 let loaded = false;
176179 const state = new ListState();
177180
@@ -219,6 +222,12 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
219222 sizes = new Map(
220223 entries.flatMap((e) => (e.ok ? [[e.file, waveSize(carriedPulls(f.db, pullRefs(e.wave), f.user))] as const] : [])),
221224 );
225 const waiting = waitingKeys(f.db);
226 shipped = new Map(
227 entries.flatMap((e) =>
228 e.ok ? [[e.file, shippedWords(shippedOf(carriedPulls(f.db, pullRefs(e.wave), f.user), waiting))] as const] : [],
229 ),
230 );
222231 loaded = true;
223232 ctx.invalidate();
224233 };
@@ -304,7 +313,7 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
304313 });
305314 return;
306315 }
307 const rows = waveRows(entries, (e) => sizes.get(e.file) ?? { pulls: 0, apps: 0 });
316 const rows = waveRows(entries, (e) => sizes.get(e.file) ?? { pulls: 0, apps: 0 }, (e) => shipped.get(e.file) ?? "");
308317 drawList(s, body!, c, state, rows);
309318 hitList(ctx, body!, state, rows.length, { open: openAt });
310319 },
src/web/pages/waves.ts +22 −20
@@ -8,13 +8,14 @@
88
99 import { canAdmin, canRead, getRepo } from "../../core/repos.ts";
1010 import { notFound } from "../../http/respond.ts";
11 import { waitingKeys } from "../../release/landings.ts";
1112 import { holds, stamp, xml } from "../feeds.ts";
1213 import { STARTED } from "../started.ts";
1314 import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../core/route_timing.ts";
1415 import { repoDir } from "../../git/repos.ts";
1516 import type { Ctx } from "../../http/context.ts";
1617 import { VERSION, type Wave } from "../../story/wave.ts";
17 import { movedWithPulls, waveProgress } from "../../story/wave_moved.ts";
18 import { movedWithPulls, shippedOf, shippedWords, waveProgress } from "../../story/wave_moved.ts";
1819 import { carriedPulls, pullPath } from "../../story/wave_pulls.ts";
1920 import { fromWave, pullRefs, readWave, readWaves, sizeWords, waveSize } from "../../story/waves.ts";
2021 import { NO_WAVES, waveSentence } from "../../story/words.ts";
@@ -42,14 +43,14 @@ const WHAT_A_WAVE =
4243 * One wave on the list: its headline, the first highlight's why as the one sentence under it, and
4344 * version, date and pull count as a muted trail.
4445 */
45 export function waveRow(w: Wave, href: string, size: { pulls: number; apps: number }) {
46 export function waveRow(w: Wave, href: string, size: { pulls: number; apps: number }, shipped = "") {
4647 const why = w.highlights[0]?.why;
4748 return row({
4849 href,
4950 nav: true,
5051 title: w.headline,
5152 ...(why === undefined || why === "" ? {} : { meta: html`${why}` }),
52 trail: html`<span class="muted small">${w.version} · ${w.date} · <span data-wave-size>${sizeWords(size)}</span></span>`,
53 trail: html`<span class="muted small">${w.version} · ${w.date} · <span data-wave-size>${sizeWords(size)}</span>${shipped === "" ? "" : html` · <span data-wave-shipped>${shipped}</span>`}</span>`,
5354 });
5455 }
5556
@@ -69,21 +70,19 @@ export async function wavesPage(ctx: Ctx): Promise<Response> {
6970 ? `${repoBase(repo)}/waves/${encodeURIComponent(file.slice(0, -3))}`
7071 : `${repoBase(repo)}/blob/${encodeURIComponent(branch)}/waves/${encodeURIComponent(file)}`;
7172
72 const rows = entries.map((e) =>
73 e.ok
74 ? waveRow(
75 e.wave,
76 fileHref(e.file),
77 // The wave's own page lists these same pulls, so the two agree.
78 waveSize(carriedPulls(ctx.app.db, pullRefs(e.wave), ctx.auth.user)),
79 )
80 : row({
81 href: fileHref(e.file),
82 nav: true,
83 title: e.file,
84 meta: html`Not a wave: ${e.reason}`,
85 }),
86 );
73 const waiting = waitingKeys(ctx.app.db);
74 const rows = entries.map((e) => {
75 if (!e.ok)
76 return row({
77 href: fileHref(e.file),
78 nav: true,
79 title: e.file,
80 meta: html`Not a wave: ${e.reason}`,
81 });
82 // The wave's own page lists these same pulls, so the two agree.
83 const carried = carriedPulls(ctx.app.db, pullRefs(e.wave), ctx.auth.user);
84 return waveRow(e.wave, fileHref(e.file), waveSize(carried), shippedWords(shippedOf(carried, waiting)));
85 });
8786
8887 const body = html`${scopeHeader(ctx, scope, "none", { compact: true })}
8988 <div class="mt" data-waves>
@@ -139,7 +138,9 @@ export async function wavesAtom(ctx: Ctx): Promise<Response> {
139138 const updatedAt = (date: string): string => stamp(`${date}T00:00:00`);
140139 // The newest wave names the tag; the content hash covers edits to it.
141140 const newest = waves[0];
142 const shown = Bun.hash(JSON.stringify([repo.ownerName, repo.name, repo.description, waves]))
141 // What waits to ship changes without a wave file changing, so it is in the tag.
142 const waiting = waitingKeys(ctx.app.db);
143 const shown = Bun.hash(JSON.stringify([repo.ownerName, repo.name, repo.description, waves, waiting === undefined ? null : [...waiting].sort()]))
143144 .toString(36);
144145 const etag = `W/"${newest?.version ?? "none"}.${shown}"`;
145146 const cacheControl = repo.visibility === "public" ? "public, max-age=300" : "private, no-store";
@@ -148,7 +149,8 @@ export async function wavesAtom(ctx: Ctx): Promise<Response> {
148149 return new Response(null, { status: 304, headers: { etag, "cache-control": cacheControl, vary } });
149150 const renderStart = performance.now();
150151 const entries = waves.map((w) => {
151 const summary = `<ul>${w.highlights
152 const words = shippedWords(shippedOf(carriedPulls(ctx.app.db, pullRefs(w), ctx.auth.user), waiting));
153 const summary = `${words === "" ? "" : `<p>${escapeHtml(words)}</p>`}<ul>${w.highlights
152154 .map((h) => `<li><strong>${escapeHtml(h.title)}</strong> — ${escapeHtml(h.why)}</li>`)
153155 .join("")}</ul>`;
154156 const link = `${base}/waves/${encodeURIComponent(w.version)}`;
test/api-waves.test.ts +2 −2
@@ -123,8 +123,8 @@ test("the list is newest first by version, not by name", async () => {
123123 expect(got.status).toBe(200);
124124 expect(JSON.parse(got.body)).toEqual({
125125 items: [
126 { version: "0.10.0", date: "2026-02-01", headline: "Tenth", pulls: 0, apps: 0 },
127 { version: "0.9.0", date: "2026-01-01", headline: "Ninth", pulls: 0, apps: 0 },
126 { version: "0.10.0", date: "2026-02-01", headline: "Tenth", pulls: 0, apps: 0, live: null, waiting: null },
127 { version: "0.9.0", date: "2026-01-01", headline: "Ninth", pulls: 0, apps: 0, live: null, waiting: null },
128128 ],
129129 next_cursor: null,
130130 });
test/wave-live-count.test.ts added +113
@@ -0,0 +1,113 @@
1 /** A wave says how many of its changes are live and how many wait to ship (#13164). */
2 import { afterAll, beforeAll, expect, test } from "bun:test";
3 import { mkdtemp, rm } from "node:fs/promises";
4 import { tmpdir } from "node:os";
5 import { join } from "node:path";
6 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
7 import { createApp, type App } from "../src/app.ts";
8 import { forgetLive, keepLive } from "../src/release/landings.ts";
9 import { createUser } from "../src/core/users.ts";
10 import { serve, type Servers } from "../src/http/server.ts";
11 import { waveRows } from "../src/tui/screens/waves.ts";
12 import type { Wave } from "../src/story/wave.ts";
13 import type { WaveEntry } from "../src/story/waves.ts";
14 import { shippedOf, shippedWords } from "../src/story/wave_moved.ts";
15 import { quietLogs } from "./helpers/globals.ts";
16 import { mergedPull, waveNaming } from "./helpers/wave-pulls.ts";
17
18 quietLogs();
19
20 test("words: 'N live, M waiting to ship', or only 'live' when nothing waits", () => {
21 expect(shippedWords({ live: 2, waiting: 1 })).toBe("2 live, 1 waiting to ship");
22 expect(shippedWords({ live: 0, waiting: 3 })).toBe("0 live, 3 waiting to ship");
23 expect(shippedWords({ live: 4, waiting: 0 })).toBe("live");
24 expect(shippedWords({ live: 0, waiting: 0 })).toBe("");
25 });
26
27 test("nothing read of production is no count, not 'live'", () => {
28 const p = { owner: "al", name: "r", number: 1, mergedAt: "x" };
29 expect(shippedOf([p], undefined)).toBeNull();
30 });
31
32 test("the terminal's waves list carries the words in its meta column", () => {
33 const wave: Wave = { version: "0.2.0", date: "2026-03-06", headline: "Two", highlights: [], pulls: [] };
34 const entries: WaveEntry[] = [{ ok: true, file: "0.2.0.md", wave }];
35 const rows = waveRows(entries, () => ({ pulls: 2, apps: 0 }), () => "1 live, 1 waiting to ship");
36 expect(rows[0]!.meta).toBe("1 live, 1 waiting to ship");
37 expect(waveRows(entries, () => ({ pulls: 2, apps: 0 }))[0]!.meta).toBe("");
38 });
39
40 test("counting: unmerged pulls are neither; the waiting set decides", () => {
41 const p = (number: number, mergedAt: string | null) => ({ owner: "Al", name: "r", number, mergedAt });
42 expect(shippedOf([p(1, "x"), p(2, "x"), p(3, null)], new Set(["al/r#2"]))).toEqual({ live: 1, waiting: 1 });
43 });
44
45 let dataDir: string;
46 let app: App;
47 let servers: Servers;
48
49 beforeAll(async () => {
50 dataDir = await mkdtemp(join(tmpdir(), "forge-wave-live-"));
51 app = createApp({ dataDir, port: 0 });
52 servers = await serve(app);
53 const made = await createUser(app.db, {
54 origin: "seed", trusted: true, username: "alice", email: "[email protected]",
55 password: "a-good-passphrase", adminIfFirst: true,
56 });
57 if (!made.ok) throw new Error(String(made.error));
58 const alice = made.value;
59 const r = await createRepo(app, alice, { name: "mix", visibility: "public" });
60 if (!r.ok) throw new Error(String(r.error));
61 const init = await commitToBranch(app, alice, r.value, { message: "init", files: [{ path: "README.md", content: "hi\n" }] });
62 if (!init.ok) throw new Error(JSON.stringify(init.error));
63 const one = await mergedPull(app, alice, r.value, "Old work");
64 const two = await mergedPull(app, alice, r.value, "Newer work");
65 app.db
66 .query("UPDATE pull SET merged_at = '2026-03-06T10:00:00.000Z' WHERE issue_id = (SELECT id FROM issue WHERE repo_id = ? AND number = ?)")
67 .run(r.value.id, two);
68 const files = [
69 { path: "waves/0.1.0.md", content: waveNaming("0.1.0", [{ owner: "alice", name: "mix", number: one }]) },
70 { path: "waves/0.2.0.md", content: waveNaming("0.2.0", [{ owner: "alice", name: "mix", number: one }, { owner: "alice", name: "mix", number: two }]) },
71 ];
72 const c = await commitToBranch(app, alice, r.value, { message: "waves", files });
73 if (!c.ok) throw new Error(JSON.stringify(c.error));
74 // Production runs a commit made on 5 March: the first pull is in it, the second is not.
75 keepLive(app.db, "alice/mix", [], Date.parse("2026-03-05T00:00:00Z"));
76 });
77
78 afterAll(async () => {
79 forgetLive(app.db);
80 await servers.stop();
81 app.close();
82 await rm(dataDir, { recursive: true, force: true });
83 });
84
85 const read = async (path: string) => (await fetch(`${servers.url}${path}`)).text();
86
87 test("the list page prints the count on each wave row", async () => {
88 const body = await read("/alice/mix/waves");
89 const shipped = [...body.matchAll(/data-wave-shipped>([^<]*)</g)].map((m) => m[1]);
90 // Newest first: 0.2.0 has one live and one landing; 0.1.0 has nothing waiting.
91 expect(shipped).toEqual(["1 live, 1 waiting to ship", "live"]);
92 });
93
94 test("the API and the atom carry the same counts", async () => {
95 const api = JSON.parse(await read("/api/v1/repos/alice/mix/waves"));
96 expect(api.items.map((i: { version: string; live: number; waiting: number }) => [i.version, i.live, i.waiting])).toEqual([
97 ["0.2.0", 1, 1],
98 ["0.1.0", 1, 0],
99 ]);
100 const atom = await read("/alice/mix/waves.atom");
101 expect(atom).toContain("1 live, 1 waiting to ship");
102 expect(atom).toContain("&lt;p&gt;live&lt;/p&gt;");
103 });
104
105 test("a cold process says nothing of what waits: no 'live' on the page, null in the API, none in the atom", async () => {
106 forgetLive(app.db);
107 const body = await read("/alice/mix/waves");
108 expect(body).not.toContain("data-wave-shipped");
109 const api = JSON.parse(await read("/api/v1/repos/alice/mix/waves"));
110 expect(api.items.map((i: { live: unknown; waiting: unknown }) => [i.live, i.waiting])).toEqual([[null, null], [null, null]]);
111 const atom = await read("/alice/mix/waves.atom");
112 expect(atom).not.toContain("&lt;p&gt;live&lt;/p&gt;");
113 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs