Public: anyone can read this; the crew can change it.
The waves list is keyboard-first: j/k move between rows, enter opens one #10411
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/10402-the-waves-list-is-keyboard-first-j-k-mov → main 2 commits fork
2 files
changed +82
−0
src/web/pages/waves.ts +2
| @@ -47,6 +47,7 @@ export function waveRow(w: Wave, href: string, visible: number) { | ||
| 47 | 47 | const why = w.highlights[0]?.why; |
| 48 | 48 | return row({ |
| 49 | 49 | href, |
| 50 | nav: true, | |
| 50 | 51 | title: w.headline, |
| 51 | 52 | ...(why === undefined || why === "" ? {} : { meta: html`${why}` }), |
| 52 | 53 | trail: html`<span class="muted small">${w.version} · ${w.date} · ${visible} ${visible === 1 ? "pull" : "pulls"}</span>`, |
| @@ -79,6 +80,7 @@ export async function wavesPage(ctx: Ctx): Promise<Response> { | ||
| 79 | 80 | ) |
| 80 | 81 | : row({ |
| 81 | 82 | href: fileHref(e.file), |
| 83 | nav: true, | |
| 82 | 84 | title: e.file, |
| 83 | 85 | meta: html`Not a wave: ${e.reason}`, |
| 84 | 86 | }), |
test/keys-waves.test.ts added +80
| @@ -0,0 +1,80 @@ | ||
| 1 | /** The waves list joins the shell's j/k row traversal: one data-nav per linked row, none on the empty page. */ | |
| 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 { createSession } from "../src/core/sessions.ts"; | |
| 9 | import { createUser } from "../src/core/users.ts"; | |
| 10 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 11 | import { writeWave } from "../src/story/wave.ts"; | |
| 12 | ||
| 13 | const must = <T>(r: { ok: true; value: T } | { ok: false; error: unknown }): T => { | |
| 14 | if (!r.ok) throw new Error(JSON.stringify(r.error)); | |
| 15 | return r.value; | |
| 16 | }; | |
| 17 | ||
| 18 | let dataDir: string; | |
| 19 | let app: App; | |
| 20 | let servers: Servers; | |
| 21 | let cookie = ""; | |
| 22 | ||
| 23 | const wave = (version: string): string => | |
| 24 | must( | |
| 25 | writeWave({ | |
| 26 | version, | |
| 27 | date: "2026-03-05", | |
| 28 | headline: `Headline ${version}`, | |
| 29 | highlights: [1, 2, 3].map((n) => ({ title: `Thing ${n}`, why: "because" })), | |
| 30 | pulls: [], | |
| 31 | }), | |
| 32 | ); | |
| 33 | ||
| 34 | beforeAll(async () => { | |
| 35 | dataDir = await mkdtemp(join(tmpdir(), "forge-keys-waves-")); | |
| 36 | app = createApp({ dataDir, port: 0 }); | |
| 37 | servers = await serve(app); | |
| 38 | const alice = must( | |
| 39 | await createUser(app.db, { | |
| 40 | origin: "seed", trusted: true, username: "alice", email: "[email protected]", | |
| 41 | password: "a-good-passphrase", adminIfFirst: true, | |
| 42 | }), | |
| 43 | ); | |
| 44 | cookie = `forge_session=${createSession(app.db, alice.id).token}; forge_mode=dev`; | |
| 45 | const empty = must(await createRepo(app, alice, { name: "none", visibility: "public" })); | |
| 46 | must(await commitToBranch(app, alice, empty, { message: "init", files: [{ path: "README.md", content: "hi\n" }] })); | |
| 47 | const full = must(await createRepo(app, alice, { name: "some", visibility: "public" })); | |
| 48 | must( | |
| 49 | await commitToBranch(app, alice, full, { | |
| 50 | message: "waves", | |
| 51 | files: [ | |
| 52 | { path: "waves/1.0.0.md", content: wave("1.0.0") }, | |
| 53 | { path: "waves/1.1.0.md", content: wave("1.1.0") }, | |
| 54 | { path: "waves/notes.md", content: "not a wave\n" }, | |
| 55 | ], | |
| 56 | }), | |
| 57 | ); | |
| 58 | }, 60_000); | |
| 59 | ||
| 60 | afterAll(async () => { | |
| 61 | await servers.stop(); | |
| 62 | app.close(); | |
| 63 | await rm(dataDir, { recursive: true, force: true }); | |
| 64 | }); | |
| 65 | ||
| 66 | const get = async (name: string) => | |
| 67 | (await fetch(`${servers.url}/alice/${name}/waves`, { headers: { cookie } })).text(); | |
| 68 | const NAV = /class="row"[^>]*data-nav tabindex="-1"/g; | |
| 69 | ||
| 70 | test("each linked wave row, including a file that is not a wave, is one data-nav row", async () => { | |
| 71 | const text = await get("some"); | |
| 72 | expect(text.match(NAV)?.length).toBe(3); | |
| 73 | expect(text).toContain("Headline 1.1.0"); | |
| 74 | }); | |
| 75 | ||
| 76 | test("the empty waves page draws no data-nav row", async () => { | |
| 77 | const text = await get("none"); | |
| 78 | expect(text).toContain("No waves yet"); | |
| 79 | expect(text).not.toMatch(/class="row"[^>]*data-nav tabindex="-1"/); | |
| 80 | }); |