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

The backups list is keyboard-first: j/k move between rows, enter opens one #10475

Parked opened this
Closed without merging

scout/forge:scout/10428-the-backups-list-is-keyboard-first-j-k-m → main 5 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
3 files changed +64 −1
scripts/unreached-allow.json −1
@@ -15,7 +15,6 @@
1515 "src/flow/review_rounds.ts",
1616 "src/flow/shared_red.ts",
1717 "src/flow/stale_fold.ts",
18 "src/kernel/why_now.ts",
1918 "src/spawn/pod.ts",
2019 "src/tui/gallery.ts",
2120 "src/tui/ui/qr.ts",
src/web/pages/backups.ts +3
@@ -226,6 +226,7 @@ function domainsCard(ctx: Ctx): Html | null {
226226 ? "Says nothing yet."
227227 : d.says.map((s) => `“${s}”`).join(" · ");
228228 return row({
229 nav: true,
229230 lead: icon("activity"),
230231 title: html`${d.name}`,
231232 meta: html`${d.breaks}<br />${says}<br />${drilled(d)}`,
@@ -387,6 +388,7 @@ async function movingPart(
387388 <ul class="list setting-list" id="snapshots">
388389 ${snapshots.map((m) =>
389390 row({
391 nav: true,
390392 lead: icon("download"),
391393 title: m.name,
392394 meta: html`${time(m.finishedAt)} · forge ${m.version} ·
@@ -623,6 +625,7 @@ export function lanesCard(ctx: Ctx): Html | "" {
623625 <ul id="backup-lanes" class="list setting-list">
624626 ${lanes.map((l) =>
625627 row({
628 nav: true,
626629 lead: html`<span aria-hidden="true">${mark[l.state]}</span>`,
627630 state: lead[l.state],
628631 title: l.says,
test/keys-backups.test.ts added +61
@@ -0,0 +1,61 @@
1 /** The backups list joins the shell's j/k row traversal: one data-nav per snapshot row, none on an empty list. */
2 import { afterAll, beforeAll, expect, test } from "bun:test";
3 import { mkdtempSync, rmSync } from "node:fs";
4 import { tmpdir } from "node:os";
5 import { join } from "node:path";
6 import { createApp, type App } from "../src/app.ts";
7 import { createUser } from "../src/core/users.ts";
8 import { serve, type Servers } from "../src/http/server.ts";
9 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
10 import { dirStore } from "../src/snapshot/store.ts";
11 import { quietLogs } from "./helpers/globals.ts";
12
13 quietLogs();
14
15 let root = "";
16 let app: App;
17 let svc: SnapshotsHandle;
18 let servers: Servers;
19 let cookie = "";
20
21 beforeAll(async () => {
22 root = mkdtempSync(join(tmpdir(), "forge-keys-backups-"));
23 app = createApp({ dataDir: root, port: 0 });
24 const u = await createUser(app.db, {
25 origin: "seed", trusted: true, username: "alice", email: "[email protected]",
26 password: "a-good-passphrase", adminIfFirst: true,
27 });
28 if (!u.ok) throw new Error(u.error);
29 svc = startSnapshots(app, dirStore(join(root, "store")), { version: "t", nightly: false });
30 servers = await serve(app);
31 const r = await fetch(`${servers.url}/signin`, {
32 method: "POST",
33 headers: { origin: servers.url },
34 body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }),
35 redirect: "manual",
36 });
37 cookie = (r.headers.get("set-cookie") ?? "").split(";")[0]!;
38 });
39 afterAll(async () => {
40 servers.stop();
41 await svc.stop();
42 app.close();
43 rmSync(root, { recursive: true, force: true });
44 });
45
46 const get = async (): Promise<string> =>
47 (await fetch(`${servers.url}/settings/backups`, { headers: { cookie } })).text();
48 const section = (page: string): string => {
49 const at = page.indexOf('id="snapshots"');
50 return at < 0 ? "" : page.slice(at, page.indexOf("</ul>", at));
51 };
52
53 test("with no snapshot there is no snapshot row to walk", async () => {
54 expect(section(await get())).toBe("");
55 });
56
57 test("each snapshot row is one data-nav row", async () => {
58 await svc.now();
59 const list = section(await get());
60 expect(list.match(/class="row"[^>]*data-nav tabindex="-1"/g)?.length).toBe(1);
61 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs