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
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/13164-a-wave-on-changelog-says-how-many-of-its → main 12 commits fork
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). | ||
| 146 | 146 | - [](week-pace.md) |
| 147 | 147 | - [](wave-walk.md) |
| 148 | 148 | - [](wave-standing.md) |
| 149 | - [](wave-landing.md) | |
| 149 | 150 | - [](ask-status.md) |
| 150 | 151 | - [](blocked-by.md) |
| 151 | 152 | - [](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 @@ | ||
| 1 | 1 | import { REPO, type Route } from "../shared.ts"; |
| 2 | 2 | |
| 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 | ||
| 303 | 303 | import { repoDir } from "../git/repos.ts"; |
| 304 | 304 | import { holds, weakEtag } from "./etag.ts"; |
| 305 | 305 | import { carriedPulls, pullPath } from "../story/wave_pulls.ts"; |
| 306 | import { waitingKeys } from "../release/landings.ts"; | |
| 307 | import { shippedOf } from "../story/wave_moved.ts"; | |
| 306 | 308 | import { pullRefs, readWave, readWaves, waveSize } from "../story/waves.ts"; |
| 307 | 309 | import { originForRepo, type OriginRepoRow } from "../core/origins.ts"; |
| 308 | 310 | import { subscribe as subscribeJob, type MirrorJob } from "../origins/jobs.ts"; |
| @@ -2330,20 +2332,22 @@ export function apiRoutes(router: Router<Handler>): void { | ||
| 2330 | 2332 | readWaves(repoDir(ctx.app.reposRoot, repo.ownerName, repo.name), repo.defaultBranch), |
| 2331 | 2333 | ); |
| 2332 | 2334 | // Sized over the pulls this viewer can read, as the page does. |
| 2335 | const waiting = waitingKeys(ctx.app.db); | |
| 2333 | 2336 | return timePhase(ctx.request, "render", () => |
| 2334 | 2337 | 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 | }), | |
| 2347 | 2351 | next_cursor: null, |
| 2348 | 2352 | }), |
| 2349 | 2353 | ); |
src/release/landings.ts +46 −10
| @@ -30,11 +30,16 @@ export interface Landing { | ||
| 30 | 30 | readonly live: boolean; |
| 31 | 31 | /** The bet whose scopes this pull built (#8713), set by the page that shows it. */ |
| 32 | 32 | 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 | */ | |
| 34 | 36 | readonly from?: string; |
| 35 | 37 | /** Who built it: the author of the landed commit (a crew member or a person). */ |
| 36 | 38 | 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 | */ | |
| 38 | 43 | readonly with?: readonly string[]; |
| 39 | 44 | } |
| 40 | 45 | |
| @@ -68,7 +73,10 @@ export interface Window { | ||
| 68 | 73 | |
| 69 | 74 | const CURSOR = /^[A-Za-z0-9_.-]{1,64}\/[A-Za-z0-9_.-]{1,100}#[0-9]{1,9}$/; |
| 70 | 75 | |
| 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 | */ | |
| 72 | 80 | export function chosenRepo(asked: string | null, all: readonly { readonly repo: string }[], own: string | undefined): string { |
| 73 | 81 | if (asked === "all") return "all"; |
| 74 | 82 | if (asked !== null && all.some((l) => l.repo === asked)) return asked; |
| @@ -142,9 +150,14 @@ interface LiveState { | ||
| 142 | 150 | readonly at: number; |
| 143 | 151 | /** The running commit these were asked of. */ |
| 144 | 152 | 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 | */ | |
| 146 | 156 | 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 | */ | |
| 148 | 161 | readonly ahead?: number; |
| 149 | 162 | } |
| 150 | 163 | /** |
| @@ -191,7 +204,10 @@ export function split(rows: readonly MergedRow[], state: LiveState | undefined): | ||
| 191 | 204 | return out; |
| 192 | 205 | } |
| 193 | 206 | |
| 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 | */ | |
| 195 | 211 | export function waiting(db: Database): { readonly since: string; readonly count: number } | undefined { |
| 196 | 212 | const kept = keeps.get(db); |
| 197 | 213 | if (kept === undefined) return undefined; |
| @@ -200,7 +216,10 @@ export function waiting(db: Database): { readonly since: string; readonly count: | ||
| 200 | 216 | return oldest === undefined ? undefined : { since: oldest.at, count: onItsWay.length }; |
| 201 | 217 | } |
| 202 | 218 | |
| 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 | */ | |
| 204 | 223 | export function waitingRows(db: Database): MergedRow[] { |
| 205 | 224 | const kept = keeps.get(db); |
| 206 | 225 | if (kept === undefined) return []; |
| @@ -209,10 +228,26 @@ export function waitingRows(db: Database): MergedRow[] { | ||
| 209 | 228 | return rows.filter((r) => way.has(`${r.repo}#${r.number}`)).reverse(); |
| 210 | 229 | } |
| 211 | 230 | |
| 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 | */ | |
| 213 | 245 | const MISS_MS = 60_000; |
| 214 | 246 | |
| 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 | */ | |
| 216 | 251 | const founds = new WeakMap<Database, Map<string, { repo: string; at: number }>>(); |
| 217 | 252 | |
| 218 | 253 | /** |
| @@ -240,7 +275,8 @@ async function ownRepo(app: App, rows: readonly MergedRow[], now = Date.now()): | ||
| 240 | 275 | found.set(commit, { repo: named, at: now }); |
| 241 | 276 | return repo; |
| 242 | 277 | } |
| 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. | |
| 244 | 280 | if (rows.length > 0) found.set(commit, { repo: "", at: now }); |
| 245 | 281 | else found.delete(commit); |
| 246 | 282 | return undefined; |
src/story/wave_moved.ts +40 −1
| @@ -11,7 +11,7 @@ import type { Plan } from "../core/milestones.ts"; | ||
| 11 | 11 | import type { Repo } from "../core/repos.ts"; |
| 12 | 12 | import { mayView } from "../core/sealed.ts"; |
| 13 | 13 | import type { User } from "../core/users.ts"; |
| 14 | import { closesOfMerged } from "./wave_pulls.ts"; | |
| 14 | import { closesOfMerged, type CarriedPull } from "./wave_pulls.ts"; | |
| 15 | 15 | import type { PullRef } from "./waves.ts"; |
| 16 | 16 | |
| 17 | 17 | export interface MovedMilestone { |
| @@ -155,3 +155,42 @@ export function movedWithPulls(input: { | ||
| 155 | 155 | }) |
| 156 | 156 | .map((m) => ({ ...m, pulls: carried.get(m.number) ?? [] })); |
| 157 | 157 | } |
| 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"; | ||
| 9 | 9 | import { canRead, getRepo } from "../../core/repos.ts"; |
| 10 | 10 | import { nearMilestones, standingLine } from "../../web/pages/milestones_near.ts"; |
| 11 | 11 | 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"; | |
| 13 | 13 | import { milestonePath, planNow } from "../../story/wave_plan.ts"; |
| 14 | 14 | import { repoBase } from "../../web/chrome.ts"; |
| 15 | import { waitingKeys } from "../../release/landings.ts"; | |
| 15 | 16 | import { carriedPulls, pullPath, type CarriedPull } from "../../story/wave_pulls.ts"; |
| 16 | 17 | import { pullRefs, readWave, readWaves, sizeWords, waveLine, waveSize, type WaveEntry } from "../../story/waves.ts"; |
| 17 | 18 | import { NO_WAVES, waveSentence } from "../../story/words.ts"; |
| @@ -31,13 +32,13 @@ import { local, localRepo, sourceName, whereRows, whereStrip } from "./where.ts" | ||
| 31 | 32 | * One line per wave, as the screen draws it, sized as the page sizes it: `sizeOf` counts the pulls |
| 32 | 33 | * this viewer can see. |
| 33 | 34 | */ |
| 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 = () => "") { | |
| 35 | 36 | return entries.map((e) => |
| 36 | 37 | e.ok |
| 37 | 38 | ? { |
| 38 | 39 | title: plain(waveLine(e.wave, sizeOf(e))), |
| 39 | 40 | secondary: "", |
| 40 | meta: "", | |
| 41 | meta: plain(shipped(e)), | |
| 41 | 42 | } |
| 42 | 43 | : { title: e.file, secondary: `Not a wave: ${e.reason}`, meta: "" }, |
| 43 | 44 | ); |
| @@ -172,6 +173,8 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen { | ||
| 172 | 173 | let entries: WaveEntry[] = []; |
| 173 | 174 | /** Each wave's size by file, counted once per load with the page's gate on each pull. */ |
| 174 | 175 | 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>(); | |
| 175 | 178 | let loaded = false; |
| 176 | 179 | const state = new ListState(); |
| 177 | 180 | |
| @@ -219,6 +222,12 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen { | ||
| 219 | 222 | sizes = new Map( |
| 220 | 223 | entries.flatMap((e) => (e.ok ? [[e.file, waveSize(carriedPulls(f.db, pullRefs(e.wave), f.user))] as const] : [])), |
| 221 | 224 | ); |
| 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 | ); | |
| 222 | 231 | loaded = true; |
| 223 | 232 | ctx.invalidate(); |
| 224 | 233 | }; |
| @@ -304,7 +313,7 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen { | ||
| 304 | 313 | }); |
| 305 | 314 | return; |
| 306 | 315 | } |
| 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) ?? ""); | |
| 308 | 317 | drawList(s, body!, c, state, rows); |
| 309 | 318 | hitList(ctx, body!, state, rows.length, { open: openAt }); |
| 310 | 319 | }, |
src/web/pages/waves.ts +22 −20
| @@ -8,13 +8,14 @@ | ||
| 8 | 8 | |
| 9 | 9 | import { canAdmin, canRead, getRepo } from "../../core/repos.ts"; |
| 10 | 10 | import { notFound } from "../../http/respond.ts"; |
| 11 | import { waitingKeys } from "../../release/landings.ts"; | |
| 11 | 12 | import { holds, stamp, xml } from "../feeds.ts"; |
| 12 | 13 | import { STARTED } from "../started.ts"; |
| 13 | 14 | import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../core/route_timing.ts"; |
| 14 | 15 | import { repoDir } from "../../git/repos.ts"; |
| 15 | 16 | import type { Ctx } from "../../http/context.ts"; |
| 16 | 17 | 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"; | |
| 18 | 19 | import { carriedPulls, pullPath } from "../../story/wave_pulls.ts"; |
| 19 | 20 | import { fromWave, pullRefs, readWave, readWaves, sizeWords, waveSize } from "../../story/waves.ts"; |
| 20 | 21 | import { NO_WAVES, waveSentence } from "../../story/words.ts"; |
| @@ -42,14 +43,14 @@ const WHAT_A_WAVE = | ||
| 42 | 43 | * One wave on the list: its headline, the first highlight's why as the one sentence under it, and |
| 43 | 44 | * version, date and pull count as a muted trail. |
| 44 | 45 | */ |
| 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 = "") { | |
| 46 | 47 | const why = w.highlights[0]?.why; |
| 47 | 48 | return row({ |
| 48 | 49 | href, |
| 49 | 50 | nav: true, |
| 50 | 51 | title: w.headline, |
| 51 | 52 | ...(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>`, | |
| 53 | 54 | }); |
| 54 | 55 | } |
| 55 | 56 | |
| @@ -69,21 +70,19 @@ export async function wavesPage(ctx: Ctx): Promise<Response> { | ||
| 69 | 70 | ? `${repoBase(repo)}/waves/${encodeURIComponent(file.slice(0, -3))}` |
| 70 | 71 | : `${repoBase(repo)}/blob/${encodeURIComponent(branch)}/waves/${encodeURIComponent(file)}`; |
| 71 | 72 | |
| 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 | }); | |
| 87 | 86 | |
| 88 | 87 | const body = html`${scopeHeader(ctx, scope, "none", { compact: true })} |
| 89 | 88 | <div class="mt" data-waves> |
| @@ -139,7 +138,9 @@ export async function wavesAtom(ctx: Ctx): Promise<Response> { | ||
| 139 | 138 | const updatedAt = (date: string): string => stamp(`${date}T00:00:00`); |
| 140 | 139 | // The newest wave names the tag; the content hash covers edits to it. |
| 141 | 140 | 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()])) | |
| 143 | 144 | .toString(36); |
| 144 | 145 | const etag = `W/"${newest?.version ?? "none"}.${shown}"`; |
| 145 | 146 | const cacheControl = repo.visibility === "public" ? "public, max-age=300" : "private, no-store"; |
| @@ -148,7 +149,8 @@ export async function wavesAtom(ctx: Ctx): Promise<Response> { | ||
| 148 | 149 | return new Response(null, { status: 304, headers: { etag, "cache-control": cacheControl, vary } }); |
| 149 | 150 | const renderStart = performance.now(); |
| 150 | 151 | 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 | |
| 152 | 154 | .map((h) => `<li><strong>${escapeHtml(h.title)}</strong> — ${escapeHtml(h.why)}</li>`) |
| 153 | 155 | .join("")}</ul>`; |
| 154 | 156 | 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 () => { | ||
| 123 | 123 | expect(got.status).toBe(200); |
| 124 | 124 | expect(JSON.parse(got.body)).toEqual({ |
| 125 | 125 | 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 }, | |
| 128 | 128 | ], |
| 129 | 129 | next_cursor: null, |
| 130 | 130 | }); |
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("<p>live</p>"); | |
| 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("<p>live</p>"); | |
| 113 | }); |
new above
offline