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

In /space a tap or hover on any body shows what it is and one link to open it #15602

Merged opened this

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

Merged

scout/forge:scout/15590-in-space-a-tap-or-hover-on-any-body-show → main 0 commits fork 5 threads · 5 unresolved

  • Merged. scout/15590-in-space-a-tap-or-hover-on-any-body-show was merged into main as 60dfb58.

Review

Sign in to review this change.
9 files changed +236 −31
docs/design/size-budget.json +1 −1
@@ -24,7 +24,7 @@
2424 "css": 47872
2525 },
2626 "/:owner/:name/space": {
27 "js": 29696,
27 "js": 30208,
2828 "css": 48640
2929 },
3030 "/:owner/:name/space.json": {
docs/features/space.md +1
@@ -11,6 +11,7 @@ is `/:owner/:name/space.json`, the same plane for an agent. In the terminal it i
1111 ## Use
1212
1313 - **Move.** Drag (or two fingers) to pan; pinch, wheel or `+`/`-` (also with ⌘/Ctrl) to zoom; arrows pan; `0` or **Fit** shows the whole plane; `n` or **Now** returns to live. `/` focuses the finder (when you are not typing in a field); type a number or part of a title and **Enter** flies to the first match that exists at the time shown and selects it, or says "No issue matches"; **Esc** clears it. In the terminal, `/` opens the same find, Enter shows the first match's facts and link, Esc clears. No page scroll fights it (`touch-action: none`).
14 - **The card.** A tap, a mouse hover, or `]` / `[` on the canvas opens a card on a body: its name, pillar, state, its pull when it has one, who is on it, when it last moved, and one link, "Open issue #N" (Enter opens it too). A tap or a key holds the card, so a hover elsewhere does not take it; Esc (or a tap on empty space) closes it. The facts are also written into an always-present polite status region, so a screen reader hears them. In the terminal, finding an issue prints the same facts and its link. To try it: open the sample space at `/preview-admin/sample/space`.
1415 - **Semantic zoom.** Out: pillars are regions whose area follows open work, with a progress bar (landed ÷ open + landed over the week) and whether they moved. In: each region's issues sit in clusters by state (ready, building, in review, waiting, landed). Further in: an issue is a card with its title, then its pull, checks and the crew member on it. Words are set at a fixed pixel size at every level; detail is added, nothing shrinks.
1516 - **Time.** The scrubber replays the last 7 days: issues appear when opened, slide from "in review" to "landed" when they close, and crew members sit on what they were running then. **Play** runs the week in 20 seconds. At **Now** the view is live: any run, issue or pull event of the repository fetches the plane again.
1617 - **Crew.** Their avatars sit on the issue they are working; tap one (or its name in the bar) to see what they are on.
src/tui/screens/space.ts +5 −1
@@ -14,7 +14,7 @@ import type { Session } from "../session.ts";
1414 import { style } from "../term/style.ts";
1515 import { wrap } from "../term/width.ts";
1616 import { Filter, Scroll } from "./common.ts";
17 import { firstFound } from "../../web/space_view.ts";
17 import { agoText, firstFound } from "../../web/space_view.ts";
1818
1919 const NAMES: Record<State, string> = { ready: "Ready", building: "Building", review: "In review", waiting: "Waiting", landed: "Landed" };
2020
@@ -69,9 +69,13 @@ export function foundLines(space: Record<string, unknown>, query: string, link:
6969 const c = clusters[row[1]];
7070 const state = c === undefined ? "" : NAMES[states[c[1]!]!];
7171 const pillar = c === undefined ? "" : (regions[c[0]]?.name ?? "");
72 const on = (space.crew as { name: string; runs: number[][] }[])
73 .filter((m) => m.runs.some((r) => r[0] === row[0] && r[2] === 0))
74 .map((m) => m.name);
7275 return [
7376 ...wrap(`#${row[0]} ${row[6]}`, width),
7477 ` ${[state, pillar].filter((x) => x !== "").join(" in ")}`,
78 ` on it: ${on.length ? on.join(", ") : "nobody"}; last moved ${agoText(Math.max(0, (space.now as number) - row[13]))}`,
7579 ...(row[7] ? [` Pull #${row[7]}${row[12] ? `, checks ${row[12]}` : ""}`] : []),
7680 ` ${link(row[0])}`,
7781 ];
src/web/pages/space.ts +2 −1
@@ -71,7 +71,7 @@ export function spacePage(ctx: Ctx): Response {
7171 id="space-cv"
7272 tabindex="0"
7373 role="img"
74 aria-label="${repo.name}: ${regions.length} pillars, drawn by open work. Zoom in for issues."
74 aria-label="${repo.name}: ${regions.length} pillars, drawn by open work. Zoom in for issues. Press ] or [ to step through them; Enter opens the one shown."
7575 ></canvas>
7676 <div class="space-bar">
7777 ${btn("Map", { href: `${base}/map`, variant: "outline", size: "sm" })}
@@ -91,6 +91,7 @@ export function spacePage(ctx: Ctx): Response {
9191 <span id="space-crew"></span>
9292 </div>
9393 <aside class="space-panel" id="space-panel" hidden></aside>
94 <p class="sr-only" id="space-say" role="status" aria-live="polite"></p>
9495 <div class="space-foot">
9596 <details class="space-legend" id="space-legend">
9697 <summary>Legend</summary>
src/web/space_client.ts +49 −24
@@ -78,6 +78,7 @@ ${viewJs}
7878 var repo = root.getAttribute('data-repo');
7979 var dataUrl = root.getAttribute('data-src');
8080 var panel = document.getElementById('space-panel');
81 var say = document.getElementById('space-say');
8182 var slider = document.getElementById('space-t');
8283 var clock = document.getElementById('space-clock');
8384 var finder = document.getElementById('space-find');
@@ -100,13 +101,8 @@ ${viewJs}
100101 var sans = style.fontFamily || 'system-ui, sans-serif';
101102 var picked = null; // {kind:'issue'|'crew', ...}
102103
103 function ago(ms) {
104 var m = Math.round(ms / 60000);
105 if (m < 1) return 'just now';
106 if (m < 90) return m + ' min ago';
107 var h = Math.round(m / 60);
108 return h < 48 ? h + ' h ago' : Math.round(h / 24) + ' d ago';
109 }
104 var ago = agoText;
105 var pinned = false; // a tap or a key holds the card; a hover only borrows it
110106
111107 // ---- data ----
112108 function load(first) {
@@ -320,13 +316,14 @@ ${viewJs}
320316 cv.addEventListener('pointerdown', function (e) {
321317 cv.setPointerCapture(e.pointerId);
322318 pointers[e.pointerId] = { x: e.offsetX, y: e.offsetY };
323 flight = null;
319 flight = null; hovering = false;
324320 if (count() === 1) { moved = 0; downAt = e.timeStamp; downPos = { x: e.offsetX, y: e.offsetY }; }
325321 if (count() === 2) gesture = pinchState();
326322 });
323 var hovering = false;
327324 cv.addEventListener('pointermove', function (e) {
328325 var p = pointers[e.pointerId];
329 if (!p) return;
326 if (!p) { if (e.pointerType !== 'touch') hover(e.offsetX, e.offsetY); return; }
330327 var dx = e.offsetX - p.x, dy = e.offsetY - p.y;
331328 p.x = e.offsetX; p.y = e.offsetY;
332329 moved += Math.abs(dx) + Math.abs(dy);
@@ -349,6 +346,9 @@ ${viewJs}
349346 if (had && e.type === 'pointerup' && moved < 8 && e.timeStamp - downAt < 600) tap(downPos.x, downPos.y);
350347 }
351348 }
349 cv.addEventListener('pointerleave', function () {
350 if (hovering && !pinned) closeCard();
351 });
352352 cv.addEventListener('pointerup', up);
353353 cv.addEventListener('pointercancel', up);
354354 cv.addEventListener('wheel', function (e) {
@@ -363,6 +363,10 @@ ${viewJs}
363363 else if (key === '-' || key === '_') zoomAt(W / 2, H / 2, 1 / 1.4);
364364 else if (!mod && key === '0') fit();
365365 else if (!mod && key === 'n') goNow();
366 else if (key === ']') stepBody(1);
367 else if (key === '[') stepBody(-1);
368 else if (key === 'Enter' && picked && picked.kind === 'issue') location.href = base + '/issues/' + picked.number;
outdated

Escape hides the panel but never sets dirty = true, so the highlight stays on the canvas. Also clear pinned/hovering state consistently.

369 else if (key === 'Escape' && picked) closeCard();
366370 else if (key === 'ArrowLeft') view.x -= step;
367371 else if (key === 'ArrowRight') view.x += step;
368372 else if (key === 'ArrowUp') view.y -= step;
@@ -373,15 +377,37 @@ ${viewJs}
373377 window.addEventListener('resize', resize);
374378
375379 // ---- picking ----
380 // Hover: the card follows the pointer over a body, unless a tap holds one.
381 function hover(sx, sy) {
382 if (!S || pinned) return;
383 var w = toWorld(sx, sy), best = pickIssue(rows, S.clusters, T, w[0], w[1]);
384 if (!best) { if (hovering) closeCard(); return; }
385 if (picked && picked.number === best[0]) return;
386 hovering = true; picked = { kind: 'issue', number: best[0] }; refreshPanel(); dirty = true;
387 }
388 // Keyboard: ] and [ walk the bodies that exist at the time shown, in the order of the rows.
389 function stepBody(dir) {
390 if (!S) return;
391 var here = -1, i, live2 = [];
392 for (i = 0; i < rows.length; i++) if (at(rows[i])) live2.push(rows[i]);
393 if (!live2.length) return;
394 for (i = 0; i < live2.length; i++) if (picked && live2[i][0] === picked.number) here = i;
395 var next = live2[((here < 0 ? (dir > 0 ? -1 : 0) : here) + dir + live2.length) % live2.length];
396 pinned = true; hovering = false; pick({ kind: 'issue', number: next[0] });
397 var pos = at(next); fly({ x: pos[0], y: pos[1], k: Math.max(view.k, fitK * 24) });
398 }
376399 function tap(sx, sy) {
400 pinned = true; hovering = false;
377401 for (var i = 0; i < lastCrew.length; i++) {
378402 var m = lastCrew[i];
379403 if (Math.hypot(sx - m.sx, sy - m.sy) <= 16) { pick({ kind: 'crew', name: m.name }); return; }
380404 }
381405 var w = toWorld(sx, sy), best = pickIssue(rows, S.clusters, T, w[0], w[1]);
382406 if (best) pick({ kind: 'issue', number: best[0] });
383 else { picked = null; panel.hidden = true; dirty = true; }
407 else closeCard();
384408 }
409 // Nothing held, nothing hovered: the card, its sentence and the highlight all go.
410 function closeCard() { pinned = false; hovering = false; picked = null; panel.hidden = true; say.textContent = ''; dirty = true; }
385411 function pick(p) { picked = p; refreshPanel(); dirty = true; }
386412 function row(term, text, href) {
387413 var r = document.createElement('div'); r.className = 'status-row';
@@ -393,23 +419,21 @@ ${viewJs}
393419 }
394420 var list = null;
395421 function refreshPanel() {
396 if (!picked) { panel.hidden = true; return; }
422 if (!picked) { panel.hidden = true; say.textContent = ''; return; }
397423 panel.textContent = '';
398 var h = document.createElement('h2');
424 var h = document.createElement('h2'), tail = null;
399425 list = document.createElement('dl'); list.className = 'status-rows';
400426 if (picked.kind === 'issue') {
401427 var r = rows.filter(function (x) { return x[0] === picked.number; })[0];
402 if (!r) { panel.hidden = true; return; }
428 if (!r) { panel.hidden = true; say.textContent = ''; return; }
403429 var pos = at(r);
404 h.textContent = '#' + r[0] + ' ' + r[6];
405 var st = pos ? S.states[S.clusters[pos[2]][1]] : 'not yet opened';
406 row('State', NAMES[st] || st);
407 row('Opened', ago(T - r[4]));
408 if (r[5] && r[5] <= T) row('Landed', ago(T - r[5]));
409 if (r[7]) row('Pull', '#' + r[7] + (r[12] ? ' \\u00b7 checks ' + r[12] : ''), base + '/pulls/' + r[7]);
410 if (r[11]) row('Held', r[11]);
411 crewNow().filter(function (m) { return m.issue === r[0]; }).forEach(function (m) { row('On it', m.name); });
412 row('Issue', 'Open it', base + '/issues/' + r[0]);
430 var st = pos ? NAMES[S.states[S.clusters[pos[2]][1]]] : 'Not yet opened';
431 var who = crewNow().filter(function (m) { return m.issue === r[0]; }).map(function (m) { return m.name; });
432 var c = cardOf(r, T, S.regions[S.clusters[r[1]][0]].name, st, who, base);
outdated

Principle 1/8: row 'Open' with 'Open the issue' says it twice. One link: 'Open issue #N'.

433 h.textContent = c.name;
434 c.facts.forEach(function (f) { row(f[0], f[1]); });
435 tail = document.createElement('p'); var a = document.createElement('a'); a.href = c.href; a.textContent = c.link; tail.appendChild(a);
436 say.textContent = c.text;
413437 } else {
414438 h.textContent = picked.name;
415439 var on = crewNow().filter(function (m) { return m.name === picked.name; })[0];
@@ -420,8 +444,9 @@ ${viewJs}
420444 row('Since', ago(T - on.since));
421445 }
422446 }
423 panel.appendChild(h); panel.appendChild(list);
447 panel.appendChild(h); panel.appendChild(list); if (tail) panel.appendChild(tail);
424448 panel.hidden = false;
449 if (picked.kind !== 'issue') say.textContent = panel.textContent;
425450 }
426451 function crewChips() {
427452 crewBox.textContent = '';
@@ -443,7 +468,7 @@ ${viewJs}
443468 if (!S) return;
444469 var hit = firstFound(rows, finder.value, T);
445470 if (!hit) { finder.setAttribute('aria-invalid', 'true'); findStatus.textContent = 'No issue matches'; return; }
446 pick({ kind: 'issue', number: hit.row[0] });
471 pinned = true; pick({ kind: 'issue', number: hit.row[0] });
447472 fly({ x: hit.pos[0], y: hit.pos[1], k: Math.max(view.k, fitK * 24) });
448473 }
449474 function clearFind() { finder.removeAttribute('aria-invalid'); findStatus.textContent = ''; }
src/web/space_model.ts +18 −3
@@ -115,8 +115,15 @@ export interface Region {
115115
116116 /** [region, state index, x, y, w, h, cell, count] */
117117 export type ClusterRow = [number, number, number, number, number, number, number, number];
118 /** [number, cluster, x, y, created, closed, title, pull, bx, by, bcluster, hold, check] */
119 export type IssueRow = [number, number, number, number, number, number, string, number, number, number, number, string, string];
118 /**
119 * [number, cluster, x, y, created, closed, title, pull, bx, by, bcluster, hold, check, moved].
120 * `moved` is the body card's one extra number (#15590): when it last moved (epoch ms: opened,
121 * landed, or a run on it began or ended). Its pillar is its cluster's region; who is on it
122 * is the crew list's.
123 */
124 export type IssueRow = [
125 number, number, number, number, number, number, string, number, number, number, number, string, string, number,
126 ];
120127
121128 export interface Space {
122129 readonly repo: string;
@@ -247,6 +254,13 @@ export function buildSpace(input: SpaceInput): Space {
247254 runsByActor.set(run.actor, list);
248255 }
249256
257 // Per issue: the latest moment a run on it began or ended.
258 const lastRun = new Map<number, number>();
259 for (const run of input.runs) {
260 const t = run.endedAt === 0 ? run.startedAt : Math.max(run.startedAt, run.endedAt);
261 if (t > (lastRun.get(run.issue) ?? 0)) lastRun.set(run.issue, t);
262 }
263
250264 const regions: Region[] = names.map((name, i) => {
251265 const t = tally[i]!;
252266 const building = per[i]![STATES.indexOf("building")]!.length;
@@ -304,7 +318,8 @@ export function buildSpace(input: SpaceInput): Space {
304318 return;
305319 }
306320 const i = entry.issue;
307 const row: IssueRow = [i.number, ci, x, y, i.createdAt, i.closedAt, i.title, i.pull, 0, 0, -1, i.hold, i.check];
321 const row: IssueRow = [i.number, ci, x, y, i.createdAt, i.closedAt, i.title, i.pull, 0, 0, -1, i.hold, i.check,
322 Math.max(i.createdAt, i.closedAt, lastRun.get(i.number) ?? 0)];
308323 byNumber.set(i.number, row);
309324 issues.push(row);
outdated

Pillar name and kind string repeated on every row inflates space.json at 12k issues. Use the region index (already known) and derive kind from pull on the client.

310325 });
src/web/space_view.ts +26 −1
@@ -165,8 +165,33 @@ export function firstFound(rows: any[][], query: string, T: number): { row: any[
165165 return null;
166166 }
167167
168 /** How long before `T` something was, in the words the card uses. */
169 export function agoText(ms: number): string {
170 const m = Math.round(ms / 60000);
171 if (m < 1) return "just now";
172 if (m < 90) return m + " min ago";
173 const h = Math.round(m / 60);
174 return h < 48 ? h + " h ago" : Math.round(h / 24) + " d ago";
175 }
176
177 /**
178 * A body's card at time `T` (#15590): the facts in order (pillar, state, its pull when it has one,
179 * who is on it, when it last moved), the one link, and the same as one sentence for a screen
180 * reader. `pillar` and `state` are the words at `T`, `who` the crew names on it at `T`, `base` the
181 * repository's address.
182 */
183 export function cardOf(r: any[], T: number, pillar: string, state: string, who: string[], base: string): { name: string; facts: string[][]; text: string; link: string; href: string } {
184 const name = "#" + r[0] + " " + r[6];
185 const facts = [["Pillar", pillar], ["State", state]];
186 if (r[7]) facts.push(["Pull", "#" + r[7] + (r[12] ? ", checks " + r[12] : "")]);
187 facts.push(["On it", who.length ? who.join(", ") : "Nobody"]);
188 facts.push(["Last moved", agoText(Math.max(0, T - Math.min(r[13], T)))]);
189 const text = name + ". " + facts.map(function (f: string[]) { return f[0] + ": " + f[1]; }).join(". ") + ".";
190 return { name: name, facts: facts, text: text, link: "Open issue #" + r[0], href: base + "/issues/" + r[0] };
191 }
192
168193 /** The source the page ships for these functions. */
169 export const viewJs = [clamp, ease, placeAt, crewAt, parseHash, hashOf, pickIssue, findBodies, firstFound].map((f) => f.toString()).join("\n");
194 export const viewJs = [clamp, ease, placeAt, crewAt, parseHash, hashOf, pickIssue, findBodies, firstFound, agoText, cardOf].map((f) => f.toString()).join("\n");
170195
171196 /**
172197 * The view that frames the whole drawing (W×H) in a canvas (cw×ch): the
test/space-card.test.ts added +132
@@ -0,0 +1,132 @@
1 /**
2 * The space's body card (#15590): every body carries its facts, and a tap, hover or key opens the
3 * card with its link.
4 */
5 import { expect, test } from "bun:test";
6 import { Window } from "happy-dom";
7 import { buildSpace, type SpaceInput } from "../src/web/space_model.ts";
8 import { agoText, cardOf } from "../src/web/space_view.ts";
9 import { spaceJs } from "../src/web/space_client.ts";
10
11 const NOW = Date.parse("2026-11-10T12:00:00Z");
12 const H = 3_600_000;
13 const input: SpaceInput = {
14 repo: "keeper/forge",
15 now: NOW,
16 pillars: [{ name: "Trust", merged: 3 }, { name: "Feed", merged: 1 }],
17 issues: [
18 { number: 7, title: "Seal it", pillar: 0, state: "building", createdAt: NOW - 50 * H, closedAt: 0, pull: 0, hold: "", check: "" },
19 { number: 8, title: "Post it", pillar: 1, state: "review", createdAt: NOW - 30 * H, closedAt: 0, pull: 9, hold: "", check: "ok" },
20 { number: 9, title: "Done thing", pillar: 1, state: "landed", createdAt: NOW - 90 * H, closedAt: NOW - 5 * H, pull: 0, hold: "", check: "" },
21 ],
22 runs: [
23 { actor: "scout", issue: 7, startedAt: NOW - 2 * H, endedAt: 0 },
24 { actor: "sentinel", issue: 8, startedAt: NOW - 10 * H, endedAt: NOW - 4 * H },
25 ],
26 };
27
28 test("a body carries one extra number: when it last moved", () => {
29 const rows = Object.fromEntries(buildSpace(input).issues.map((r) => [r[0], r]));
30 expect(rows[7]!.slice(13)).toEqual([NOW - 2 * H]);
31 expect(rows[8]!.slice(13)).toEqual([NOW - 4 * H]);
32 expect(rows[9]!.slice(13)).toEqual([NOW - 5 * H]);
33 expect(rows[7]!.length).toBe(14);
34 });
35
36 test("cardOf: the facts, the sentence for a screen reader, and the one link", () => {
37 const rows = buildSpace(input).issues;
38 const c = cardOf(rows.find((r) => r[0] === 7)!, NOW, "Trust", "Building", ["scout"], "/keeper/forge");
39 expect(c.facts.map((f) => f[0])).toEqual(["Pillar", "State", "On it", "Last moved"]);
40 expect(c.text).toBe("#7 Seal it. Pillar: Trust. State: Building. On it: scout. Last moved: 2 h ago.");
41 expect(c.link).toBe("Open issue #7");
42 expect(c.href).toBe("/keeper/forge/issues/7");
43 // A body with a pull shows the pull as its own fact.
44 const p = cardOf(rows.find((r) => r[0] === 8)!, NOW, "Feed", "In review", [], "/keeper/forge");
45 expect(p.facts).toContainEqual(["Pull", "#9, checks ok"]);
46 expect(p.facts).toContainEqual(["On it", "Nobody"]);
47 expect(agoText(0)).toBe("just now");
48 });
49
50 test("in the page: a tap opens the card with its link; hover and ] do too", async () => {
51 const win = new Window({ url: "https://forge.test/keeper/forge/space" });
52 const doc = win.document;
53 doc.body.innerHTML = `<div id="space" data-base="/keeper/forge" data-repo="keeper/forge" data-src="/s.json">
54 <canvas id="space-cv"></canvas><aside id="space-panel" hidden></aside><p id="space-say" role="status" aria-live="polite"></p><input id="space-t"><output id="space-clock"></output>
55 <span id="space-crew"></span><button id="space-play"></button><button id="space-now"></button><button id="space-fit"></button>
56 <button id="space-in"></button><button id="space-out"></button><input id="space-find"><span id="space-find-status"></span></div>`;
57 const root = doc.getElementById("space")!;
58 Object.defineProperty(root, "clientWidth", { value: 1000 });
59 Object.defineProperty(root, "clientHeight", { value: 600 });
60 const cv = doc.getElementById("space-cv") as any;
61 cv.getContext = () => new Proxy({}, { get: (_t, k) => (k === "measureText" ? () => ({ width: 1 }) : () => {}), set: () => true });
62 cv.setPointerCapture = () => {};
63 const space = buildSpace(input);
64 const g = win as any;
65 g.fetch = async () => ({ ok: true, json: async () => space });
66 g.requestAnimationFrame = () => 0;
67 g.matchMedia = () => ({ matches: false });
68 new g.Function("window", "document", "location", "history", "fetch", "requestAnimationFrame", "getComputedStyle", "localStorage", "performance", "setInterval", "setTimeout", spaceJs)(
69 g, doc, g.location, g.history, g.fetch, g.requestAnimationFrame, g.getComputedStyle.bind(g), g.localStorage, performance, () => 0, () => 0,
70 );
71 await win.happyDOM.waitUntilComplete();
72 // Where body #7 sits on the screen at Fit.
73 const row = space.issues.find((r) => r[0] === 7)!;
74 const k = Math.min(1000 / space.world.w, 600 / space.world.h) * 0.94;
75 const sx = (row[2] - space.world.w / 2) * k + 500;
76 const sy = (row[3] - space.world.h / 2) * k + 300;
77 const fire = (type: string, extra: object = {}) => {
78 const e: any = new g.Event(type, { bubbles: true, cancelable: true });
79 for (const [n, v] of Object.entries({ pointerId: 1, pointerType: "mouse", offsetX: sx, offsetY: sy, timeStamp: 1, ...extra }))
80 Object.defineProperty(e, n, { value: v });
81 cv.dispatchEvent(e);
82 };
83 const panel = doc.getElementById("space-panel") as any;
84 const say = doc.getElementById("space-say") as any;
85 const at = (n: number) => {
86 const r = space.issues.find((x) => x[0] === n)!;
87 return { offsetX: (r[2] - space.world.w / 2) * k + 500, offsetY: (r[3] - space.world.h / 2) * k + 300 };
88 };
89 const key = (name: string) => {
90 const e = new g.Event("keydown", { bubbles: true, cancelable: true }) as any;
91 e.key = name;
outdated

Tautological: ?? 'polite' makes this pass without the attribute. Assert aria-live is 'polite' directly, and add Enter, Escape, [, and hover-not-overriding-pinned cases.

92 cv.dispatchEvent(e);
93 };
94 expect(say.getAttribute("aria-live")).toBe("polite");
95 expect(say.getAttribute("role")).toBe("status");
96 expect(panel.getAttribute("aria-live")).toBeNull();
97 // Hover opens it, and the always-present region says the same facts.
98 fire("pointermove");
99 expect(panel.hidden).toBe(false);
100 expect(panel.textContent).toContain("#7 Seal it");
101 expect(say.textContent).toBe(cardOf(row, NOW, "Trust", "Building", ["scout"], "/keeper/forge").text);
102 fire("pointerleave");
103 expect(panel.hidden).toBe(true);
104 expect(say.textContent).toBe("");
105 // A tap holds it; one link, "Open issue #7".
106 fire("pointerdown");
107 fire("pointerup");
108 const a = panel.querySelector("a")!;
109 expect(a.getAttribute("href")).toBe("/keeper/forge/issues/7");
110 expect(a.textContent).toBe("Open issue #7");
111 expect(panel.querySelectorAll("a").length).toBe(1);
112 // A hover over another body does not take a held card, and leaving does not close it.
113 fire("pointermove", at(8));
114 expect(panel.textContent).toContain("#7 Seal it");
115 fire("pointerleave");
116 expect(panel.hidden).toBe(false);
117 // Enter opens the held body.
118 key("Enter");
119 expect(String(g.location.href)).toContain("/keeper/forge/issues/7");
120 // ] and [ step between bodies; they hold.
121 key("]");
122 const after = panel.textContent;
123 expect(after).not.toContain("#7 Seal it");
124 expect(panel.querySelectorAll("a").length).toBe(1);
125 key("[");
126 expect(panel.textContent).toContain("#7 Seal it");
127 expect(panel.textContent).not.toBe(after);
128 // Escape closes the card and its sentence, and redraws so the highlight goes.
129 key("Escape");
130 expect(panel.hidden).toBe(true);
131 expect(say.textContent).toBe("");
132 }, 20_000);
test/space-screen.test.ts +2
@@ -37,6 +37,8 @@ test("foundLines: the first match's facts and link; no match says so", () => {
3737 expect(out[0]).toBe("#2 Build it");
3838 expect(out.join("\n")).toContain("Pull #7, checks running");
3939 expect(out.at(-1)).toBe(" /a/b/issues/2");
40 expect(out.join("\n")).toMatch(/on it: torque; last moved 17 min ago/);
41 expect(foundLines(space, "cache", (n) => `/x/${n}`).join("\n")).toContain("on it: nobody; last moved 28 h ago");
4042 expect(foundLines(space, "#3", (n) => `/x/${n}`)[0]).toBe("#3 Shipped");
4143 expect(foundLines(space, "zzz", (n) => `/x/${n}`)).toEqual(["No issue matches"]);
4244 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs