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

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

opened this

Check · Review · Land · Live — It conflicts with its base. Next: builder, it conflicts with its base.

Conflicts with main

revert-13189 → main 1 commit

Review

Sign in to review this change.
10 files changed +50 −265
docs/features/README.md −1
@@ -149,7 +149,6 @@ Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
149149 - [The week's pace](week-pace.md)
150150 - [Walking a wave](wave-walk.md)
151151 - [The wave-standing line](wave-standing.md)
152 - [How many of a wave's changes are live and waiting to ship](wave-landing.md)
153152 - [What became of the first ask](ask-status.md)
154153 - [When a setting or a permission stands in the way](blocked-by.md)
155154 - [The map's growth line](map-growth.md)
docs/features/wave-landing.md deleted −11
@@ -1,11 +0,0 @@
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, 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" } };
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" } };
src/http/api.ts +12 −16
@@ -303,8 +303,6 @@ 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";
308306 import { pullRefs, readWave, readWaves, waveSize } from "../story/waves.ts";
309307 import { originForRepo, type OriginRepoRow } from "../core/origins.ts";
310308 import { subscribe as subscribeJob, type MirrorJob } from "../origins/jobs.ts";
@@ -2338,22 +2336,20 @@ export function apiRoutes(router: Router<Handler>): void {
23382336 readWaves(repoDir(ctx.app.reposRoot, repo.ownerName, repo.name), repo.defaultBranch),
23392337 );
23402338 // Sized over the pulls this viewer can read, as the page does.
2341 const waiting = waitingKeys(ctx.app.db);
23422339 return timePhase(ctx.request, "render", () =>
23432340 json({
2344 items: entries.flatMap((e) => {
2345 if (!e.ok) return [];
2346 const carried = carriedPulls(ctx.app.db, pullRefs(e.wave), ctx.auth.user);
2347 return [
2348 {
2349 version: e.wave.version,
2350 date: e.wave.date,
2351 headline: e.wave.headline,
2352 ...waveSize(carried),
2353 ...(shippedOf(carried, waiting) ?? { live: null, waiting: null }),
2354 },
2355 ];
2356 }),
2341 items: entries.flatMap((e) =>
2342 e.ok
2343 ? [
2344 {
2345 version: e.wave.version,
2346 date: e.wave.date,
2347 headline: e.wave.headline,
2348 ...waveSize(carriedPulls(ctx.app.db, pullRefs(e.wave), ctx.auth.user)),
2349 },
2350 ]
2351 : [],
2352 ),
23572353 next_cursor: null,
23582354 }),
23592355 );
src/release/landings.ts +10 −46
@@ -30,16 +30,11 @@ 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 /**
34 * `account@host` when a trusted source's work folded in (#8937), set by the page that shows it.
35 */
33 /** `account@host` when a trusted source's work folded in (#8937), set by the page that shows it. */
3634 readonly from?: string;
3735 /** Who built it: the author of the landed commit (a crew member or a person). */
3836 readonly by?: string;
39 /**
40 * Others credited on the landed commit (`Co-authored-by`: the models, people), beyond whoever
41 * landed or wrote it.
42 */
37 /** Others credited on the landed commit (`Co-authored-by`: the models, people), beyond whoever landed or wrote it. */
4338 readonly with?: readonly string[];
4439 }
4540
@@ -73,10 +68,7 @@ export interface Window {
7368
7469 const CURSOR = /^[A-Za-z0-9_.-]{1,64}\/[A-Za-z0-9_.-]{1,100}#[0-9]{1,9}$/;
7570
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 */
71 /** Which repository the reader asked for: "" for this forge's own, "all", or one named in the list; anything else is the default. */
8072 export function chosenRepo(asked: string | null, all: readonly { readonly repo: string }[], own: string | undefined): string {
8173 if (asked === "all") return "all";
8274 if (asked !== null && all.some((l) => l.repo === asked)) return asked;
@@ -150,14 +142,9 @@ interface LiveState {
150142 readonly at: number;
151143 /** The running commit these were asked of. */
152144 readonly commit: string;
153 /**
154 * The tip of the forge's own default branch as the last read found it, read from the ref files.
155 */
145 /** The tip of the forge's own default branch as the last read found it, read from the ref files. */
156146 readonly head?: string;
157 /**
158 * Commits in `head` and not in `commit` (`git rev-list --count commit..head`), asked once per
159 * pair.
160 */
147 /** Commits in `head` and not in `commit` (`git rev-list --count commit..head`), asked once per pair. */
161148 readonly ahead?: number;
162149 }
163150 /**
@@ -204,10 +191,7 @@ export function split(rows: readonly MergedRow[], state: LiveState | undefined):
204191 return out;
205192 }
206193
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 */
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. */
211195 export function waiting(db: Database): { readonly since: string; readonly count: number } | undefined {
212196 const kept = keeps.get(db);
213197 if (kept === undefined) return undefined;
@@ -216,10 +200,7 @@ export function waiting(db: Database): { readonly since: string; readonly count:
216200 return oldest === undefined ? undefined : { since: oldest.at, count: onItsWay.length };
217201 }
218202
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 */
203 /** The merged pulls not yet in the running commit, oldest first, with their merge commits; empty when nothing was read (#11507). */
223204 export function waitingRows(db: Database): MergedRow[] {
224205 const kept = keeps.get(db);
225206 if (kept === undefined) return [];
@@ -228,26 +209,10 @@ export function waitingRows(db: Database): MergedRow[] {
228209 return rows.filter((r) => way.has(`${r.repo}#${r.number}`)).reverse();
229210 }
230211
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 */
212 /** How long a miss is believed: a repository can turn public, or merge its first pull, after boot. */
245213 const MISS_MS = 60_000;
246214
247 /**
248 * The repository the running commit was built from, per running commit; "" when none held it at
249 * `at`.
250 */
215 /** The repository the running commit was built from, per running commit; "" when none held it at `at`. */
251216 const founds = new WeakMap<Database, Map<string, { repo: string; at: number }>>();
252217
253218 /**
@@ -275,8 +240,7 @@ async function ownRepo(app: App, rows: readonly MergedRow[], now = Date.now()):
275240 found.set(commit, { repo: named, at: now });
276241 return repo;
277242 }
278 // A miss is kept a minute so requests cost no git; with no merged pulls yet there is nothing to
279 // remember.
243 // A miss is kept a minute so requests cost no git; with no merged pulls yet there is nothing to remember.
280244 if (rows.length > 0) found.set(commit, { repo: "", at: now });
281245 else found.delete(commit);
282246 return undefined;
src/story/wave_moved.ts +1 −40
@@ -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, type CarriedPull } from "./wave_pulls.ts";
14 import { closesOfMerged } from "./wave_pulls.ts";
1515 import type { PullRef } from "./waves.ts";
1616
1717 export interface MovedMilestone {
@@ -155,42 +155,3 @@ 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 +4 −13
@@ -9,10 +9,9 @@ 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, shippedOf, shippedWords, waveProgress, type MovedMilestone } from "../../story/wave_moved.ts";
12 import { movedWithPulls, 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";
1615 import { carriedPulls, pullPath, type CarriedPull } from "../../story/wave_pulls.ts";
1716 import { pullRefs, readWave, readWaves, sizeWords, waveLine, waveSize, type WaveEntry } from "../../story/waves.ts";
1817 import { NO_WAVES, waveSentence } from "../../story/words.ts";
@@ -32,13 +31,13 @@ import { local, localRepo, sourceName, whereRows, whereStrip } from "./where.ts"
3231 * One line per wave, as the screen draws it, sized as the page sizes it: `sizeOf` counts the pulls
3332 * this viewer can see.
3433 */
35 export function waveRows(entries: WaveEntry[], sizeOf: (e: WaveEntry & { ok: true }) => { pulls: number; apps: number }, shipped: (e: WaveEntry & { ok: true }) => string = () => "") {
34 export function waveRows(entries: WaveEntry[], sizeOf: (e: WaveEntry & { ok: true }) => { pulls: number; apps: number }) {
3635 return entries.map((e) =>
3736 e.ok
3837 ? {
3938 title: plain(waveLine(e.wave, sizeOf(e))),
4039 secondary: "",
41 meta: plain(shipped(e)),
40 meta: "",
4241 }
4342 : { title: e.file, secondary: `Not a wave: ${e.reason}`, meta: "" },
4443 );
@@ -173,8 +172,6 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
173172 let entries: WaveEntry[] = [];
174173 /** Each wave's size by file, counted once per load with the page's gate on each pull. */
175174 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>();
178175 let loaded = false;
179176 const state = new ListState();
180177
@@ -222,12 +219,6 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
222219 sizes = new Map(
223220 entries.flatMap((e) => (e.ok ? [[e.file, waveSize(carriedPulls(f.db, pullRefs(e.wave), f.user))] as const] : [])),
224221 );
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 );
231222 loaded = true;
232223 ctx.invalidate();
233224 };
@@ -313,7 +304,7 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
313304 });
314305 return;
315306 }
316 const rows = waveRows(entries, (e) => sizes.get(e.file) ?? { pulls: 0, apps: 0 }, (e) => shipped.get(e.file) ?? "");
307 const rows = waveRows(entries, (e) => sizes.get(e.file) ?? { pulls: 0, apps: 0 });
317308 drawList(s, body!, c, state, rows);
318309 hitList(ctx, body!, state, rows.length, { open: openAt });
319310 },
src/web/pages/waves.ts +20 −22
@@ -8,14 +8,13 @@
88
99 import { canAdmin, canRead, getRepo } from "../../core/repos.ts";
1010 import { notFound } from "../../http/respond.ts";
11 import { waitingKeys } from "../../release/landings.ts";
1211 import { holds, stamp, xml } from "../feeds.ts";
1312 import { STARTED } from "../started.ts";
1413 import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../core/route_timing.ts";
1514 import { repoDir } from "../../git/repos.ts";
1615 import type { Ctx } from "../../http/context.ts";
1716 import { VERSION, type Wave } from "../../story/wave.ts";
18 import { movedWithPulls, shippedOf, shippedWords, waveProgress } from "../../story/wave_moved.ts";
17 import { movedWithPulls, waveProgress } from "../../story/wave_moved.ts";
1918 import { carriedPulls, pullPath } from "../../story/wave_pulls.ts";
2019 import { fromWave, pullRefs, readWave, readWaves, sizeWords, waveSize } from "../../story/waves.ts";
2120 import { NO_WAVES, waveSentence } from "../../story/words.ts";
@@ -43,14 +42,14 @@ const WHAT_A_WAVE =
4342 * One wave on the list: its headline, the first highlight's why as the one sentence under it, and
4443 * version, date and pull count as a muted trail.
4544 */
46 export function waveRow(w: Wave, href: string, size: { pulls: number; apps: number }, shipped = "") {
45 export function waveRow(w: Wave, href: string, size: { pulls: number; apps: number }) {
4746 const why = w.highlights[0]?.why;
4847 return row({
4948 href,
5049 nav: true,
5150 title: w.headline,
5251 ...(why === undefined || why === "" ? {} : { meta: html`${why}` }),
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>`,
52 trail: html`<span class="muted small">${w.version} · ${w.date} · <span data-wave-size>${sizeWords(size)}</span></span>`,
5453 });
5554 }
5655
@@ -70,19 +69,21 @@ export async function wavesPage(ctx: Ctx): Promise<Response> {
7069 ? `${repoBase(repo)}/waves/${encodeURIComponent(file.slice(0, -3))}`
7170 : `${repoBase(repo)}/blob/${encodeURIComponent(branch)}/waves/${encodeURIComponent(file)}`;
7271
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 });
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 );
8687
8788 const body = html`${scopeHeader(ctx, scope, "none", { compact: true })}
8889 <div class="mt" data-waves>
@@ -138,9 +139,7 @@ export async function wavesAtom(ctx: Ctx): Promise<Response> {
138139 const updatedAt = (date: string): string => stamp(`${date}T00:00:00`);
139140 // The newest wave names the tag; the content hash covers edits to it.
140141 const newest = waves[0];
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()]))
142 const shown = Bun.hash(JSON.stringify([repo.ownerName, repo.name, repo.description, waves]))
144143 .toString(36);
145144 const etag = `W/"${newest?.version ?? "none"}.${shown}"`;
146145 const cacheControl = repo.visibility === "public" ? "public, max-age=300" : "private, no-store";
@@ -149,8 +148,7 @@ export async function wavesAtom(ctx: Ctx): Promise<Response> {
149148 return new Response(null, { status: 304, headers: { etag, "cache-control": cacheControl, vary } });
150149 const renderStart = performance.now();
151150 const entries = waves.map((w) => {
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
151 const summary = `<ul>${w.highlights
154152 .map((h) => `<li><strong>${escapeHtml(h.title)}</strong> — ${escapeHtml(h.why)}</li>`)
155153 .join("")}</ul>`;
156154 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, live: null, waiting: null },
127 { version: "0.9.0", date: "2026-01-01", headline: "Ninth", pulls: 0, apps: 0, live: null, waiting: null },
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 },
128128 ],
129129 next_cursor: null,
130130 });
test/wave-live-count.test.ts deleted −113
@@ -1,113 +0,0 @@
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