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

One keymap (d): /next, the space and /system take their keys from the map; no page chooses a key of its own #17138

opened this

Merged 40h 34m ago, live in production

keymap-d → main 0 commits 1 thread · 1 unresolved

  • Merged. keymap-d was merged into main as f70698f.

Review

Sign in to review this change.
19 files changed +230 −101
docs/features/keymap.md +2 −1
@@ -18,6 +18,7 @@ The owner, after the bridge: "tying together all the keybinds is really what im
1818 - **A repository's tabs** are its own `g` jumps (`REPO_TABS`): `g c` code, `g i` issues, `g p` pulls, `g a` map, `g m` commits, `g b` branches, `g f` forks, `g r` runs, `g s` settings. Inside a repository `g f` and `g s` are its own, by design; the forge-wide Front page and Settings are a step away through `:` and Cmd/Ctrl K. A file's Propose a change is `e`.
1919 - **A quick second key** finds its button: `j` then `m` within a second merges, as `m` alone does (never after `g`, whose letter is a jump).
2020
21 Coming: /boards, /flow and Talk, and the pages that still bind their own keys (/next's `t` `u` `d` `l`, the space's `n`, /system's `c` and `m`), listed in the test with that pull.
21 - **Ranked lists, the space and /system:** /next's rows move with `T` top, `K` up, `J` down and `p` not now (the terminal's Next up keeps `l` for not now, since `p` pauses its planner); the space's canvas zooms with `+` and `-`, fits with `0`, jumps to now with `n` and steps bodies with `]` and `[`; /system's process table toggles CPU and memory with `S`. The terminal's cockpit puts a card off with `p` (later, the keymap's park), not `l`. Their old keys (`t` `u` `d` `l`, `c` `m`, the cockpit's `l`) say the new one until 2026-12-15.
22 - **/boards, /flow and Talk** bind no keys of their own: they answer the shell's moves and nothing fires while typing in Talk's box. The test now has no page left that chooses a key.
2223

Stray extra blank line before Proof:; remove one.

2324 Proof: `test/keymap.test.ts`, `test/bridge.test.ts`.
docs/features/next-up.md +3 −3
@@ -7,7 +7,7 @@ row: Next up
77 `/:owner/:name/next` is the one ranked list the crew builds from (#8694). It reads as one numbered queue in the dispatcher's order (#11619): each row has its position, title, who is on it (or "next"), and one word of state: building, checking, in review, landing, waiting on #N, held or ready. A pull that is open on the issue sets building, checking or in review. Three native folds hold the rows, each with a count: "Up next" (the first ten, open), "After" (the rest) and "Later" (behind the Later gate). There is no script for the folds and no `?all=1`; the folds are keyboard and screen-reader reachable at any width. The terminal's Next up screen shows the same numbers and state words.
88
99 - **Role:** each row is tagged *Blocker* (it holds other open work up: "finishing it frees N") or *Enabler* (it holds nothing up; its line says what it serves, else that the owner ranked it). The tag is a label only: it never changes the order the picker takes work in.
10 - **Move:** `Top` (`t`), `Up` (`u`), `Down` (`d`) and `Not now` (`l`) are forms on each row, with the key shown beside each (Shift+J/K or Alt+↓/↑ also move down and up; Alt+Shift combos do nothing); `j`/`k` choose the row, and a row can be dragged. Each is one `POST /:owner/:name/next` (`number`, `to` = `top`, `not-now` or `after:<number>`) and saves at once. Writers only; the same-origin check applies.
10 - **Move:** `Top` (`T`), `Up` (`K`), `Down` (`J`) and `Not now` (`p`, park) are forms on each row, with the key shown beside each, from the forge's one keymap (`docs/features/keymap.md`); Alt+↓/↑ also move down and up, and Alt+Shift combos do nothing; until 2026-12-15 the old `t`, `u`, `d` and `l` say the new key; `j`/`k` choose the row, and a row can be dragged. Each is one `POST /:owner/:name/next` (`number`, `to` = `top`, `not-now` or `after:<number>`) and saves at once. Writers only; the same-origin check applies.
1111 - **Top lifts the gate:** `Top` on a deferred issue removes its `wait_for` edge to the Later gate (and the Later umbrella's edge to it) in the same action. Work that only deferred work needs stays deferred, and the refusal says so.
1212 - **Owner's pick:** a row a person placed (page, terminal or MCP) is marked "Owner's pick" on the page and in the terminal. Automatic ranking leaves it at its place and orders only the other rows around it; only a person's move changes it, and `Not now` clears it along with the rank. A move of another row does not mark the rows the planner placed. Nothing calls the automatic mode yet (`writeOrder` with `owner: false`): the guarantee is in place and tested, ahead of its first caller.
1313 - **Not now** links the issue to wait for the open Later gate and drops its rank.
@@ -15,9 +15,9 @@ row: Next up
1515 - **MCP:** `next_up { app, issue?, to?, all? }` reads the list, or moves one issue with the same words.
1616 - A rank is cleared when the issue closes. Dependencies order within the list and are shown, never edited here.
1717
18 **Terminal:** the palette's "Next up in a repository" opens the same list; `t`, `u`, `d` and `l` are Top, Up, Down and Not now on the row under the cursor, through the same action as the page and MCP. A reader sees the order and the keys do nothing; a move made anywhere reorders an open screen live. At most 200 issues are ranked; a move past that is refused and says so.
18 **Terminal:** the palette's "Next up in a repository" opens the same list; `T`, `K`, `J` and `l` are Top, Up, Down and Not now on the row under the cursor (`l`, not `p`, since `p` pauses the planner there; the keymap says so), through the same action as the page and MCP. A reader sees the order and the keys do nothing; a move made anywhere reorders an open screen live. At most 200 issues are ranked; a move past that is refused and says so.
1919
20 **Filter (#11867):** a plain GET form above the list narrows `/next` to one pillar (`?pillar=P7` or `Later`, typed in a box) and/or a word (`?q=cache`, matched without regard to case, shown as typed, at most 80 characters). A filter only hides rows: each keeps its real place in the whole ranking, the cut line stays where the whole list puts it (drawn only between shown rows), and a move made under a filter moves in the whole order and returns to the same filter. A line says "N of M shown", and that the week's capacity bar is left out while filtered. An unknown or malformed pillar shows an empty list that says so. **Terminal:** `/` asks for a pillar and/or a word (`P7 cache`); an empty answer clears it; ranks, `t` `u` `d` `l` and the header count behave as on the page.
20 **Filter (#11867):** a plain GET form above the list narrows `/next` to one pillar (`?pillar=P7` or `Later`, typed in a box) and/or a word (`?q=cache`, matched without regard to case, shown as typed, at most 80 characters). A filter only hides rows: each keeps its real place in the whole ranking, the cut line stays where the whole list puts it (drawn only between shown rows), and a move made under a filter moves in the whole order and returns to the same filter. A line says "N of M shown", and that the week's capacity bar is left out while filtered. An unknown or malformed pillar shows an empty list that says so. **Terminal:** `/` asks for a pillar and/or a word (`P7 cache`); an empty answer clears it; ranks, `T` `K` `J` (top, up, down) and `l` (not now; `p` pauses the planner on this screen) and the header count behave as on the page.
2121
2222 **The chapter line (#12681):** under the title, once the repository has chapters, `Ranked for <open chapter>: <progress sentence>` (linked), or "No chapter is open" with a link to draft one; a repository that never drafted a chapter shows no line. **Terminal:** the screen prints the same line under the title, from the same function (`chapterLineParts` in `core/chapters.ts`), wrapped to the width and never cut (#13254, #12991).
2323
src/tui/screens/cockpit.ts +9 −3
@@ -8,7 +8,7 @@
88 */
99
1010 import { actOnProposal } from "../../actions/proposals.ts";
11 import { keyOf } from "../../web/keymap.ts";
11 import { keyOf, oldKeys } from "../../web/keymap.ts";
1212 import { decideAsk } from "../../actions/asks_decide.ts";
1313 import { cockpitFor, type Cockpit, type CockpitAction } from "../../web/studio/cockpit.ts";
1414 import type { Ctx, Screen } from "../app/app.ts";
@@ -71,7 +71,7 @@ export function cockpitScreen(f: Session, ctx: Ctx): Screen {
7171 };
7272 return {
7373 title: "Cockpit",
74 keys: [binding(["j", "k"], "move"), binding(["enter"], "do"), binding(["l"], "later"), binding(["o"], "web"), binding([keyOf("reread")], "refresh")],
74 keys: [binding(["j", "k"], "move"), binding(["enter"], "do"), binding([keyOf("park")], "later"), binding(["o"], "web"), binding([keyOf("reread")], "refresh")],
7575 load: async () => read(),
7676 render(area, s) {
7777 const c = ctx.theme.c;
@@ -86,7 +86,13 @@ export function cockpitScreen(f: Session, ctx: Ctx): Screen {
8686 open(state.index);
8787 return true;
8888 }
89 if (e.key === "l" || e.key === "o") {
89 // Later is the forge's one keymap's park (web/keymap.ts), p; the old l says so for two weeks.
90 const moved = oldKeys("cockpit").find((o) => o.was === e.key);
91 if (moved !== undefined) {
92 ctx.toast(moved.says);
93 return true;
94 }
95 if (e.key === keyOf("park") || e.key === "o") {
9096 const line = lines[state.index];
9197 if (line !== undefined) {
9298 if (e.key === "o") openOnWeb(f, ctx, line.path, "That");
src/tui/screens/next.ts +17 −9
@@ -13,6 +13,7 @@
1313 */
1414
1515 import { rankedWords, rankIssue, stepTo, type Place, placeOf } from "../../actions/next.ts";
16 import { keyOf, oldKeys, VERBS } from "../../web/keymap.ts";
1617 import { listChapters, itemsOf, chapterLineWords, chapterNames } from "../../core/chapters.ts";
1718 import { takeOrder } from "../../crew/take_order.ts";
1819 import { nextAll, type NextGroup } from "../../core/next_all.ts";
@@ -214,6 +215,7 @@ export function nextScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
214215 };
215216 });
216217
218 const NOT_NOW = VERBS.park.terminal.key;
217219 const screen: Screen = {
218220 title: "Next up",
219221 get keys() {
@@ -221,10 +223,12 @@ export function nextScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
221223 return [
222224 binding(["j", "k"], "move cursor"),
223225 binding(["enter"], "open"),
224 binding(["t"], "top", { disabled: !on || rows.indexOf(current()!) === 0 }),
225 binding(["u"], "up", { disabled: !on || rows.indexOf(current()!) === 0 }),
226 binding(["d"], "down", { disabled: !on || rows.indexOf(current()!) >= rows.length - 1 }),
227 binding(["l"], "not now", { disabled: !on }),
226 // The forge's one keymap (web/keymap.ts): T, K and J as on the page; not now is l here,
227 // since p pauses the planner on this screen (the map says so).
228 binding([keyOf("top")], "top", { disabled: !on || rows.indexOf(current()!) === 0 }),
229 binding([keyOf("raise")], "up", { disabled: !on || rows.indexOf(current()!) === 0 }),
230 binding([keyOf("lower")], "down", { disabled: !on || rows.indexOf(current()!) >= rows.length - 1 }),
231 binding([NOT_NOW], "not now", { disabled: !on }),
228232 binding(["x"], "tick", { disabled: !on }),
229233 binding(["s"], "snooze", { disabled: !may() || ticked.size === 0 }),
230234 binding(["z"], "undo", { disabled: !may() || lastBatch.length === 0 }),
@@ -258,16 +262,20 @@ export function nextScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
258262 key(e) {
259263 if (state.key(e, shown.length)) return true;
260264 if (e.ctrl || e.alt) return false;
261 if (e.key === "enter") open();
262 else if (e.key === "t") rank({ to: "top" });
263 else if (e.key === "u") step(-1);
264 else if (e.key === "d") step(1);
265 // The old t, u and d say where they went, for two weeks (keymap.ts OLD_KEYS); l is still not
266 // now.
267 const moved = oldKeys("next").find((o) => o.was === e.key && o.was !== NOT_NOW);
268 if (moved !== undefined) ctx.toast(moved.says);
269 else if (e.key === "enter") open();
270 else if (e.key === keyOf("top")) rank({ to: "top" });
271 else if (e.key === keyOf("raise")) step(-1);
272 else if (e.key === keyOf("lower")) step(1);
265273 else if (e.key === "x") tickRow();
266274 else if (e.key === "s") batch(false);
267275 else if (e.key === "z") batch(true);
268276 else if (e.key === "/") ask();
269277 else if (e.key === "p") pause();
270 else if (e.key === "l") rank({ to: "not_now" });
278 else if (e.key === NOT_NOW) rank({ to: "not_now" });
271279 else return false;
272280 return true;
273281 },
src/web/keymap.ts +29 −6
@@ -16,7 +16,7 @@ import { GO_PAGES } from "./go_pages.ts";
1616 const go = (href: string): string => `g ${GO_PAGES.find((p) => p.href === href)?.key ?? ""}`;
1717
1818 /** What a key acts on: a verb means one thing per kind, and a move works anywhere. */
19 export type KeyKind = "any" | "pull" | "issue" | "run" | "figure" | "card" | "file";
19 export type KeyKind = "any" | "pull" | "issue" | "run" | "figure" | "card" | "file" | "rank" | "space" | "table";
2020
2121 export interface KeyDef {
2222 /** The `KeyboardEvent.key` it answers; a sequence is written with a space ("g h"). */
@@ -65,7 +65,16 @@ export const VERBS = {
6565 approve: { key: "a", label: "Approve", what: "Approve it", kinds: ["pull"] },
6666 assign: { key: "a", label: "Assign", what: "Give it to someone", kinds: ["issue"] },
6767 sharpen: { key: "e", label: "Sharpen", what: "Have the planner plan it again", kinds: ["issue"] },
68 park: { key: "p", label: "Park", what: "Park it behind the Later gate", kinds: ["issue"] },
68 park: {
69 key: "p",
70 label: "Park",
71 what: "Park it behind the Later gate",
72 kinds: ["issue", "rank"],
73 terminal: { key: "l", reason: "the terminal's Next up screen pauses the planner on p for the repository's owner, a key that screen has had since before the map" },
74 },
75 top: { key: "T", label: "Top", what: "Move it to the top of the list", kinds: ["rank"] },
76 raise: { key: "K", label: "Up", what: "Move it one place up (Alt+↑ too)", kinds: ["rank"] },
77 lower: { key: "J", label: "Down", what: "Move it one place down (Alt+↓ too)", kinds: ["rank"] },
6978 stop: { key: "s", label: "Stop", what: "Stop the run", kinds: ["run"] },
7079 requeue: {
7180 key: "r",
@@ -75,8 +84,13 @@ export const VERBS = {
7584 },
7685 watch: { key: "w", label: "Watch live", what: "Watch the run live", kinds: ["run"] },
7786 wheel: { key: "i", label: "Take the wheel", what: "Take the wheel: steer the running agent", kinds: ["run"] },
78 fewer: { key: "-", label: "Fewer", what: "Turn the figure down", kinds: ["figure"] },
79 more: { key: "+", label: "More", what: "Turn the figure up", kinds: ["figure"] },
87 fewer: { key: "-", label: "Fewer", what: "Turn the figure down, or zoom out", kinds: ["figure", "space"] },
88 more: { key: "+", label: "More", what: "Turn the figure up, or zoom in", kinds: ["figure", "space"] },
89 fit: { key: "0", label: "Fit", what: "Fit the whole space in view", kinds: ["space"] },
90 now: { key: "n", label: "Now", what: "Jump to now", kinds: ["space"] },
91 nextBody: { key: "]", label: "Next", what: "Go to the next body", kinds: ["space"] },
92 prevBody: { key: "[", label: "Previous", what: "Go to the previous body", kinds: ["space"] },
93 sort: { key: "S", label: "Sort", what: "Sort the table by the other measure (CPU, memory)", kinds: ["table"] },
8094 set: { key: "Enter", label: "Set", what: "Set the figure to what it shows", kinds: ["figure"] },
8195 undo: { key: "z", label: "Undo", what: "Put back what was just done", kinds: ["any"] },
8296 edit: { key: "e", label: "Propose a change", what: "Propose a change to the file", kinds: ["file"] },
@@ -109,9 +123,11 @@ export const OLD_KEYS_UNTIL = "2026-12-15T00:00:00Z";
109123 export interface OldKey {
110124 /**
111125 * Where it was: "pull" for the Files page's verdicts, "review" for /review's rows, "files" for a
112 * repository's files, "runs" for the terminal's run list, "terminal" for every terminal screen.
126 * repository's files, "runs" for the terminal's run list, "terminal" for every terminal screen,
127 * "next" for /next's rows, "system" for /system's process table, "cockpit" for the terminal's
128 * cockpit.
113129 */
114 readonly page: "pull" | "review" | "files" | "runs" | "terminal";
130 readonly page: "pull" | "review" | "files" | "runs" | "terminal" | "next" | "system" | "cockpit";
115131 readonly was: string;
116132 readonly now: KeyId;
117133 /** The word a person reads for what the key does there, when the map's label is not it. */
@@ -128,6 +144,13 @@ export const OLD_KEYS: readonly OldKey[] = [
128144 { page: "runs", was: "S", now: "wheel" },
129145 { page: "runs", was: "a", now: "requeue" },
130146 { page: "terminal", was: "r", now: "reread" },
147 { page: "next", was: "t", now: "top" },
148 { page: "next", was: "u", now: "raise" },
149 { page: "next", was: "d", now: "lower" },
150 { page: "next", was: "l", now: "park" },
151 { page: "system", was: "c", now: "sort" },
152 { page: "system", was: "m", now: "sort" },
153 { page: "cockpit", was: "l", now: "park", word: "later" },
131154 ];
132155
133156 /**
src/web/pages/next.ts +19 −10
@@ -7,6 +7,7 @@
77 * beside each action (`j`/`k` choose the row), which post the same form.
88 */
99 import { keyStep } from "./next_keys.ts";
10 import { keyOf, oldKeys } from "../keymap.ts";
1011 import { DEFAULT_DECLINE, decideOffer, decideOutsider, decisionOf, outsiderShelf } from "../../actions/outsider_decision.ts";
1112 import { REASON_MAX } from "../../core/reports.ts";
1213 import { placeOf, rankIssue, rankedWords, stepTo, type Place } from "../../actions/next.ts";
@@ -55,9 +56,15 @@ export const NEXT_CSS = `[data-next] { overflow-wrap: anywhere; }
5556 [data-next] .form-actions > .input { flex: 1 1 10rem; min-width: 0; min-height: 44px; }
5657 [data-next] .form-actions > .btn, [data-next] .form-actions > a { min-height: 44px; display: inline-flex; align-items: center; }`;
5758
58 export const KEYS_JS = `
59 /**
60 * The page's key script, read at each render: the old keys' hints end on their date (keymap.ts).
61 */
62 export const keysJs = (): string => `
5963 (() => {
6064 ${keyStep.toString()}
65 // The keymap's (keymap.ts): Top, Up, Down and Not now; the old t, u, d and l say so for two weeks.
66 const KEYS = ${JSON.stringify({ up: keyOf("raise"), down: keyOf("lower") })};
67 const OLD = ${JSON.stringify(Object.fromEntries(oldKeys("next").map((o) => [o.was, o.says])))};
6168 const list = document.getElementById("next-list");
6269 const remembered = sessionStorage.getItem("next-focus");
6370 if (remembered) {
@@ -79,17 +86,19 @@ export const KEYS_JS = `
7986 location.reload();
8087 return true;
8188 };
82 // One key, one action, on the row that has focus: the key is shown on the button.
89 // One key, one action, on the row that has focus: the key is shown on the button. Read in capture,
90 // so an old key's hint is said before the shell's own t (Tell the crew) or l can act.
8391 document.addEventListener("keydown", (e) => {
8492 if (e.metaKey || e.ctrlKey || e.target.closest("input, textarea, select, [contenteditable]")) return;
85 const step = keyStep(e);
86 if (!step) return;
8793 const row = document.activeElement && document.activeElement.closest("li[data-number]");
94 if (row && !e.altKey && OLD[e.key]) { e.preventDefault(); e.stopImmediatePropagation(); if (window.forgeSay) window.forgeSay(OLD[e.key]); return; }
95 const step = keyStep(e, KEYS);
96 if (!step) return;
8897 const form = row && row.querySelector('form[data-key="' + step + '"]');
8998 if (!form) return;
9099 e.preventDefault();
91100 send(new FormData(form), row.dataset.number);
92 });
101 }, true);
93102 if (!list) return;
94103 ${FIT_COUNT_JS}
95104 const usd = list.dataset.capacity === undefined ? NaN : Number(list.dataset.capacity);
@@ -180,11 +189,11 @@ function line(
180189 const up = stepTo(numbers, at, -1);
181190 const down = stepTo(numbers, at, 1);
182191 const controls = writer
183 ? html`${away ? null : tick(n)}${at > 0 || away ? move(base, n, "top", "Top", "t", back) : null}${away
192 ? html`${away ? null : tick(n)}${at > 0 || away ? move(base, n, "top", "Top", keyOf("top"), back) : null}${away
184193 ? null
185 : html`${up === undefined ? null : move(base, n, up, "Up", "u", back)}${down === undefined
194 : html`${up === undefined ? null : move(base, n, up, "Up", keyOf("raise"), back)}${down === undefined
186195 ? null
187 : move(base, n, down, "Down", "d", back)}${move(base, n, "not-now", "Not now", "l", back)}`}`
196 : move(base, n, down, "Down", keyOf("lower"), back)}${move(base, n, "not-now", "Not now", keyOf("park"), back)}`}`
188197 : null;
189198 return row({
190199 href: `${base}/issues/${n}`,
@@ -335,7 +344,7 @@ export function nextPage(ctx: Ctx): Response {
335344 ${first.length > 0 ? section(isFiltered ? "Matching" : "Up next", first, true, "next-list") : null}${rest.length > 0 ? section("After", rest, false) : null}`}
336345 ${chaptersSection(ctx, repo, back, chapters, itemsFor)}
337346 <p class="muted small mt" id="next-week">${sentence} <a href="${base}/week">The week</a>${writer
338 ? " · Drag a row. Keys: t top · l Later · Shift+J/K or Alt+↓/↑ down/up · j/k choose a row."
347 ? ` · Drag a row. Keys: ${keyOf("top")} top · ${keyOf("park")} Later · ${keyOf("lower")}/${keyOf("raise")} or Alt+↓/↑ down/up · j/k choose a row.`
339348 : null}</p>
340349 ${walletRow(ctx, repo, base)}
341350 ${parked.length > 0
@@ -354,7 +363,7 @@ export function nextPage(ctx: Ctx): Response {
354363 palette: repoPalette(ctx, repo),
355364 body,
356365 styleCss: NEXT_CSS,
357 ...(writer ? { scriptJs: KEYS_JS } : {}),
366 ...(writer ? { scriptJs: keysJs() } : {}),
358367 });
359368 notePhase(ctx.request, "render", performance.now() - rendering);
360369 return response;
src/web/pages/next_keys.ts +5 −6
@@ -1,12 +1,11 @@
11 /** The /next key mapping as one pure function: a key event in, the form key (data-key) it
22 * presses out. */
33
4 /** Plain keys press their own form; Shift+J/K and Alt+arrows are Down and Up; Alt+Shift combos do
5 * nothing. Self-contained and untyped: it is shipped to the browser as its own source. */
6 export function keyStep(e: { key: string; shiftKey: boolean; altKey: boolean }): string | undefined {
7 const table: Record<string, Record<string, string>> = { shift: { J: "d", K: "u" }, alt: { ArrowUp: "u", ArrowDown: "d" } };
4 /** A key presses the form of the same key (the keymap's T, K, J and p: keys.ts passes them); Alt+↑
5 * and Alt+↓ are Up and Down too; Alt+Shift combos do nothing. Self-contained and untyped: it is
6 * shipped to the browser as its own source. */
7 export function keyStep(e: { key: string; shiftKey: boolean; altKey: boolean }, keys: { up: string; down: string }): string | undefined {
88 if (e.altKey && e.shiftKey) return undefined;
9 if (e.altKey) return table.alt![e.key];
10 if (e.shiftKey) return table.shift![e.key];
9 if (e.altKey) return e.key === "ArrowUp" ? keys.up : e.key === "ArrowDown" ? keys.down : undefined;
1110 return e.key;
1211 }
src/web/pages/system.ts +4 −3
@@ -22,6 +22,7 @@
2222 * against its size (#10853, `spawn/usage.ts`).
2323 */
2424 import { askingOf, type Asker } from "../../perf/asking.ts";
25 import { keyOf } from "../keymap.ts";
2526 import { emptyNote } from "../empty_words.ts";
2627 import { sentinelRepoPath, withheldFindings, type WithheldFinding } from "../../crew/sentinel.ts";
2728 import { ownRepoRate, rateLine, RATE_MIN, type Rate } from "../../checks/deepsec_rate.ts";
@@ -829,8 +830,8 @@ export async function systemPage(ctx: Ctx, patterns: () => readonly string[]): P
829830 ${largestDirsSection(largestUnder)}
830831 ${dbSizeSection(dbNow)}
831832 <section class="settings-block"><h2>Processes</h2>
832 <div class="js-only small muted">Sort by <button class="btn" data-size="sm" type="button" data-sort="cpu" aria-pressed="true"><kbd>c</kbd> CPU</button>
833 <button class="btn" data-size="sm" type="button" data-sort="mem" aria-pressed="false"><kbd>m</kbd> memory</button></div>
833 <div class="js-only small muted">Sort by <button class="btn" data-size="sm" type="button" data-sort="cpu" aria-pressed="true">CPU</button>
834 <button class="btn" data-size="sm" type="button" data-sort="mem" aria-pressed="false">memory</button> <kbd>${keyOf("sort")}</kbd> toggles</div>
834835 <div id="sys-procs" data-live-hold>${at("sys-procs")}</div></section>
835836 ${routeUseSection(timePhase(ctx.request, "routes", () => {
836837 return leastUsed(routeUsage(ctx.app.db, patterns(), new Date()));
@@ -851,7 +852,7 @@ export async function systemPage(ctx: Ctx, patterns: () => readonly string[]): P
851852 ${memory}
852853 ${owner ? timePhase(ctx.request, "census", () => { const r = censusReport(ctx.app.db); return heapCensusSection(r.censuses, r.grew); }) : html``}
853854 ${stalePullsSection(ctx, false)}`;
854 const response = page({ ctx, title: "System", body, wide: true, scriptJs: systemLiveJs });
855 const response = page({ ctx, title: "System", body, wide: true, scriptJs: systemLiveJs() });
855856 notePhase(ctx.request, "render", performance.now() - rendering);
856857 return response;
857858 }
src/web/space_client.ts +9 −6
@@ -12,6 +12,7 @@
1212 */
1313
1414 import { STATES, STATE_INK } from "./space_model.ts";
15 import { keyOf } from "./keymap.ts";
1516 import { viewJs } from "./space_view.ts";
1617
1718 /**
@@ -70,6 +71,8 @@ export const spaceJs = /* js */ `
7071 ${legendJs}
7172 (function () {
7273 ${viewJs}
74 // The canvas's keys are the forge's one keymap's (keymap.ts), for the space.
75 var SK = ${JSON.stringify({ more: keyOf("more"), fewer: keyOf("fewer"), fit: keyOf("fit"), now: keyOf("now"), next: keyOf("nextBody"), prev: keyOf("prevBody") })};
7376 var root = document.getElementById('space');
7477 var cv = document.getElementById('space-cv');
7578 if (!root || !cv || !cv.getContext) return;
@@ -360,12 +363,12 @@ ${viewJs}
360363 }, { passive: false });
361364 cv.addEventListener('keydown', function (e) {
362365 var step = 80 / view.k, mod = e.metaKey || e.ctrlKey, key = e.key;
363 if (key === '+' || key === '=') zoomAt(W / 2, H / 2, 1.4);
364 else if (key === '-' || key === '_') zoomAt(W / 2, H / 2, 1 / 1.4);
365 else if (!mod && key === '0') fit();
366 else if (!mod && key === 'n') goNow();
367 else if (key === ']') stepBody(1);
368 else if (key === '[') stepBody(-1);
366 if (key === SK.more || key === '=') zoomAt(W / 2, H / 2, 1.4);
367 else if (key === SK.fewer || key === '_') zoomAt(W / 2, H / 2, 1 / 1.4);
368 else if (!mod && key === SK.fit) fit();
369 else if (!mod && key === SK.now) goNow();
370 else if (key === SK.next) stepBody(1);
371 else if (key === SK.prev) stepBody(-1);
369372 else if (key === 'Enter' && picked && picked.kind === 'issue') location.href = base + '/issues/' + picked.number;
370373 else if (key === 'Escape' && picked) closeCard();
371374 else if (key === 'ArrowLeft') view.x -= step;
src/web/system-live.ts +13 −8
@@ -1,10 +1,11 @@
11 /**
2 * /system's client: sorting the process table by CPU or memory (`c`, `m`, or the buttons) and one EventSource, each pushed sample patched into the
3 * element of the id it names. No reload, no timer, no polling; EventSource
4 * itself reconnects after a roll (the stream's `retry:` hint) and the first
5 * frame of the new stream is the latest sample. `?pause` opens nothing.
6 * The markup comes from our own server, escaped there, so it is set as HTML.
2 * /system's client: sorting the process table by CPU or memory (the keymap's `S` toggles them, or
3 * the buttons) and one EventSource, each pushed sample patched into the element of the id it names.
4 * No reload, no timer, no polling; EventSource itself reconnects after a roll (the stream's
5 * `retry:` hint) and the first frame of the new stream is the latest sample. `?pause` opens
6 * nothing. The markup comes from our own server, escaped there, so it is set as HTML.
77 */
8 import { keyOf, oldKeys } from "./keymap.ts";
89 /**
910 * The ordering of the process table, apart from the page so a test can run it:
1011 * `rank(items, key, kinds)` is a new array in kind order (as `kinds` lists
@@ -21,8 +22,11 @@ function rank(items, key, kinds) {
2122 }
2223 `;
2324
24 export const systemLiveJs = /* js */ `
25 /** The page's script, read at each render: the old c and m hints end on their date (keymap.ts). */
26 export const systemLiveJs = (): string => /* js */ `
2527 (function () {
28 var SORT_KEY = ${JSON.stringify(keyOf("sort"))};
29 var OLD_SORT = ${JSON.stringify(Object.fromEntries(oldKeys("system").map((o) => [o.was, o.says])))};
2630 ${procSortJs}
2731 var KINDS = ['forge', 'crew', 'check', 'app', 'host'], key = 'cpu';
2832 function read(el) {
@@ -50,8 +54,9 @@ export const systemLiveJs = /* js */ `
5054 var t = e.target, tag = t && t.tagName;
5155 if (e.ctrlKey || e.metaKey || e.altKey || tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || (t && t.isContentEditable)) return;
5256 if ((tag === 'BUTTON' || tag === 'A') && !(t.hasAttribute && t.hasAttribute('data-sort'))) return;
53 if (e.key === 'c') pick('cpu'); else if (e.key === 'm') pick('mem');
54 });
57 if (e.key === SORT_KEY) pick(key === 'cpu' ? 'mem' : 'cpu');
58 else if (OLD_SORT[e.key] && window.forgeSay) { e.preventDefault(); e.stopImmediatePropagation(); window.forgeSay(OLD_SORT[e.key]); }
59 }, true);
5560 // A region marked data-live-hold keeps the reader's place across a swap: the scroll of
5661 // its table box and of itself, and the focused element, found again by a stable key
5762 // (the kind and the row's first cell, the tag, its place among that tag in the row).
test/cockpit.test.ts +15 −3
@@ -5,6 +5,7 @@
55 * own cards in the page's own order.
66 */
77 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
8 import { OLD_KEYS_UNTIL, provideOldKeysClockForTest } from "../src/web/keymap.ts";
89 import { mkdtemp, rm } from "node:fs/promises";
910 import { tmpdir } from "node:os";
1011 import { join } from "node:path";
@@ -196,7 +197,7 @@ describe("the cockpit", () => {
196197 if (!made.ok) throw new Error(JSON.stringify(made.error));
197198 return made.value.id;
198199 };
199 const drive = async (id: string, key: string): Promise<void> => {
200 const drive = async (id: string, key: string, until = "Done."): Promise<void> => {
200201 const terminal = headlessTerminal(120, 30);
201202 const { app: tui } = createForgeApp(app, { sshUsername: alice.username, remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: alice }, { terminal, exitHooks: false });
202203 tui.start();
@@ -214,15 +215,26 @@ describe("the cockpit", () => {
214215 await settleApp(tui);
215216 }
216217 terminal.feed(key);
217 await settleUntil(tui, "Done.");
218 await settleUntil(tui, until);
218219 tui.stop();
219220 };
220221 const yes = mk("Yes one");
221222 await drive(yes, "\r");
222223 expect(getProposal(app.db, yes)?.state).toBe("approved");
223224 const later = mk("Later one");
224 await drive(later, "l");
225 // Later is the keymap's park, p (keymap.ts).
226 await drive(later, "p");
225227 expect(getProposal(app.db, later)?.state).toBe("later");
228 // The old l, for two weeks, says p is later now and moves nothing (the clock pinned before the
229 // date).
230 const kept = mk("Kept one");
231 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
232 try {
233 await drive(kept, "l", "p is later now");
234 } finally {
235 provideOldKeysClockForTest(undefined);
236 }
237 expect(getProposal(app.db, kept)?.state).not.toBe("later");
226238 });
227239
228240 test("the kiosk leaves out a card that wants typed words, and keeps every other kind", () => {
test/keymap-terminal.test.ts +1
@@ -38,6 +38,7 @@ const OWN_R: Record<string, string> = {
3838 "src/tui/screens/forges.ts": "restore",
3939 "src/tui/screens/games.ts": "restart",
4040 "src/tui/screens/hooks.ts": "redeliver",
41 "src/tui/screens/infra.ts": "restore a snapshot",
4142 "src/tui/screens/interrupted_out.ts": "try again",
4243 "src/tui/screens/limbs.ts": "raise",
4344 "src/tui/screens/mirror.ts": "retry",
test/keymap.test.ts +20 −6
@@ -5,6 +5,8 @@
55 * map's moves, no key fires while typing, and the bridge is handed its verbs from the map.
66 */
77 import { expect, test } from "bun:test";
8 import { spaceJs } from "../src/web/space_client.ts";
9 import { systemLiveJs } from "../src/web/system-live.ts";
810 import { finderButton } from "../src/web/pages/explorer.ts";
911 import { readdirSync, readFileSync, statSync } from "node:fs";
1012 import { join, relative } from "node:path";
@@ -21,9 +23,6 @@ const ROOT = join(import.meta.dir, "..");
2123 * the map. This list only shrinks; a file here that no longer has a literal must leave it.
2224 */
2325 const PENDING: Record<string, string> = {
24 "src/web/pages/next.ts": "(d): Top, Up, Down and Not now are t, u, d and l, which Tell, Update and Right own",
25 "src/web/space_client.ts": "(d): n jumps the space to now",
26 "src/web/system-live.ts": "(d): c and m pick CPU and memory, which Write and Merge own",
2726 };
2827
2928 /**
@@ -89,6 +88,7 @@ test("a moved key says where it went for two weeks, then nothing: the date is in
8988 expect(oldKeys("review", before).map((o) => [o.was, o.key])).toEqual([["c", "x"], ["r", "b"]]);
9089 expect(oldKeys("pull", new Date(OLD_KEYS_UNTIL))).toEqual([]);
9190 expect(oldKeys("files", before)).toEqual([{ was: "t", key: "f", says: "f is go to file now" }]);
91 expect(oldKeys("cockpit", before)).toEqual([{ was: "l", key: "p", says: "p is later now" }]);
9292 expect(oldKeys("runs", before).map((o) => [o.was, o.key])).toEqual([["x", "s"], ["S", "i"], ["a", "r"]]);
9393 expect(oldKeys("review", new Date(Date.parse(OLD_KEYS_UNTIL) + 86_400_000))).toEqual([]);
9494 // Two weeks from the change, not a standing alias.
@@ -110,6 +110,21 @@ test("Go to file is the keymap's f on a repository's files, and t, for two weeks
110110 expect(after).not.toContain("data-was=");
111111 });
112112
113 test("the space's canvas and /system's sort take their keys from the map; /system's c and m say S for two weeks", () => {
114 expect(spaceJs).toContain('var SK = {"more":"+","fewer":"-","fit":"0","now":"n","next":"]","prev":"["};');
115 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
116 const sys = systemLiveJs();
117 provideOldKeysClockForTest(new Date(OLD_KEYS_UNTIL));
118 const sysAfter = systemLiveJs();
119 provideOldKeysClockForTest(undefined);
120 expect(sys).toContain('var SORT_KEY = "S";');
121 expect(sys).toContain('"c":"S is sort now","m":"S is sort now"');
122 expect(sysAfter).toContain("var OLD_SORT = {};");
123 // Read in capture, so the hint is said before the shell's own c can act.
124 expect(sys).toContain("e.stopImmediatePropagation(); window.forgeSay(OLD_SORT[e.key]); }\n }, true);");
125 expect(oldKeys("next", new Date(Date.parse(OLD_KEYS_UNTIL) - 1)).map((o) => [o.was, o.key])).toEqual([["t", "T"], ["u", "K"], ["d", "J"], ["l", "p"]]);
126 });
127
113128 test("a repository's tabs are g jumps of their own, and shadow a forge-wide one only where the map says", () => {
114129 const tabs = Object.values(REPO_TABS);
115130 expect(new Set(tabs).size).toBe(tabs.length);
@@ -125,9 +140,8 @@ test("the shell says where a moved key went, and a quick second key still finds
125140
126141 test("both doors share one meaning per key: R refreshes a terminal screen, / filters or searches, r queues a run again", () => {
127142 expect([keyOf("reread"), keyOf("search"), keyOf("requeue"), keyOf("stop"), keyOf("wheel")]).toEqual(["R", "/", "r", "s", "i"]);
128 // No terminal key differs from the web's here: the run cards on the issue and pull screens steer
129 // on i, as the run list does.
130 expect((Object.entries(KEYMAP) as [string, KeyDef][]).filter(([, d]) => d.terminal !== undefined).map(([id]) => id)).toEqual([]);
143 // The only terminal key that differs is listed with why: not now on the Next up screen.
144 expect((Object.entries(KEYMAP) as [string, KeyDef][]).filter(([, d]) => d.terminal !== undefined).map(([id]) => id)).toEqual(["park"]);
131145 expect(oldKeys("terminal", new Date(Date.parse(OLD_KEYS_UNTIL) - 1))).toEqual([{ was: "r", key: "R", says: "R is refresh now" }]);
132146 });
133147
test/next-keys.test.ts +60 −22
@@ -12,7 +12,10 @@ import { createSession } from "../src/core/sessions.ts";
1212 import { createUser } from "../src/core/users.ts";
1313 import { serve, type Servers } from "../src/http/server.ts";
1414 import { keyStep } from "../src/web/pages/next_keys.ts";
15 import { KEYS_JS } from "../src/web/pages/next.ts";
15 import { keysJs } from "../src/web/pages/next.ts";
16 import { OLD_KEYS_UNTIL, provideOldKeysClockForTest } from "../src/web/keymap.ts";
17 import { findChromium } from "../src/looks/capture.ts";
18 import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts";
1619
1720 let dir: string;
1821 let app: App;
@@ -68,40 +71,75 @@ const press = async (number: number, key: string) => {
6871 test("the page carries the key hooks and lists them in its help", async () => {
6972 const html = await page();
7073 const row = new RegExp(`<li[^>]*data-number="${numbers[1]}"[\\s\\S]*?</li>`).exec(html)![0];
71 for (const k of ["t", "u", "d", "l"]) expect(row).toContain(`data-key="${k}"`);
72 expect(html).toContain("t top · l Later");
73 expect(html).toContain("Shift+J");
74 expect(html).toContain("Alt+");
75 expect(KEYS_JS).toContain("next-focus");
74 // The keymap's Top, Up, Down and Not now (keymap.ts): T, K, J and p.
75 for (const k of ["T", "K", "J", "p"]) expect(row).toContain(`data-key="${k}"`);
76 expect(html).toContain("T top · p Later · J/K or Alt+↓/↑ down/up");
77 expect(keysJs()).toContain("next-focus");
78 // The old t, u, d and l say the new key for two weeks, then the script carries none.
79 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
80 const hinted = keysJs();
81 provideOldKeysClockForTest(new Date(OLD_KEYS_UNTIL));
82 const after = keysJs();
83 provideOldKeysClockForTest(undefined);
84 expect(hinted).toContain('"t":"T is top now"');
85 expect(after).toContain("const OLD = {};");
7686 });
7787
7888 test("each key submits the existing form and the order follows", async () => {
7989 const [a, b, c, d] = numbers as [number, number, number, number];
80 await press(c, "t"); // t: to the top
90 await press(c, "T"); // T: to the top
8191 expect(order()).toEqual([c, a, b, d]);
82 await press(c, "d"); // Shift+J / Alt+Down: one place down
92 await press(c, "J"); // J / Alt+Down: one place down
8393 expect(order()).toEqual([a, c, b, d]);
84 await press(d, "u"); // Shift+K / Alt+Up: one place up
94 await press(d, "K"); // K / Alt+Up: one place up
8595 expect(order()).toEqual([a, c, d, b]);
86 await press(a, "l"); // l: behind the Later gate
96 await press(a, "p"); // p: behind the Later gate (park)
8797 expect(order()).toEqual([c, d, b]);
8898 });
8999
90100 const ev = (key: string, mods: { shiftKey?: boolean; altKey?: boolean } = {}) => ({ key, shiftKey: false, altKey: false, ...mods });
91101
92 test("keyStep maps modifiers to the form keys", () => {
93 expect(keyStep(ev("t"))).toBe("t");
94 expect(keyStep(ev("l"))).toBe("l");
95 expect(keyStep(ev("J", { shiftKey: true }))).toBe("d");
96 expect(keyStep(ev("K", { shiftKey: true }))).toBe("u");
97 expect(keyStep(ev("ArrowDown", { altKey: true }))).toBe("d");
98 expect(keyStep(ev("ArrowUp", { altKey: true }))).toBe("u");
99 expect(keyStep(ev("ArrowUp"))).toBe("ArrowUp"); // plain arrows have no form: no row lookup matches
100 expect(keyStep(ev("J", { altKey: true }))).toBeUndefined();
101 expect(keyStep(ev("T", { shiftKey: true }))).toBeUndefined();
102 expect(keyStep(ev("ArrowDown", { altKey: true, shiftKey: true }))).toBeUndefined();
102 test("keyStep: a key presses its own form, and Alt+arrows are Up and Down", () => {
103 const keys = { up: "K", down: "J" };
104 expect(keyStep(ev("T", { shiftKey: true }), keys)).toBe("T");
105 expect(keyStep(ev("p"), keys)).toBe("p");
106 expect(keyStep(ev("J", { shiftKey: true }), keys)).toBe("J");
107 expect(keyStep(ev("K", { shiftKey: true }), keys)).toBe("K");
108 expect(keyStep(ev("ArrowDown", { altKey: true }), keys)).toBe("J");
109 expect(keyStep(ev("ArrowUp", { altKey: true }), keys)).toBe("K");
110 expect(keyStep(ev("ArrowUp"), keys)).toBe("ArrowUp"); // plain arrows have no form: no row lookup matches
111 expect(keyStep(ev("J", { altKey: true }), keys)).toBeUndefined();
112 expect(keyStep(ev("ArrowDown", { altKey: true, shiftKey: true }), keys)).toBeUndefined();
103113 });
104114
105115 test("the shipped script carries the same function", () => {
106 expect(KEYS_JS).toContain(keyStep.toString());
116 expect(keysJs()).toContain(keyStep.toString());
107117 });
118
119 const found = findChromium();
120 const chromium = found !== undefined && chromiumRuns(found) ? found : undefined;
121 const noBrowser = chromium === undefined && (process.env["FORGE_CHECK"] ?? "") === "";
122 if (noBrowser) console.log("SKIPPING: no chromium that starts on this machine, so /next's keys are not pressed");
123
124 test.skipIf(noBrowser)("in a browser, the old t on a focused row says T is top now, moves nothing, and the shell's t (Tell the crew) never takes the focus", async () => {
125 if (chromium === undefined) throw new Error("no Chromium starts in this check, so /next's keys are not pressed: the check's image must carry one (FORGE_CHROMIUM)");
126 const before = order();
127 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
128 try {
129 const [name, value] = cookie.split("=") as [string, string];
130 const out = JSON.parse(await evaluateLoaded(chromium, `${servers.url}/alice/keys/next`, { width: 1280, height: 900 }, [{ name, value }], `(async () => {
131 const row = document.querySelectorAll('li[data-number]')[1];
132 const link = row.querySelector('a');
133 link.focus();
134 link.dispatchEvent(new KeyboardEvent('keydown', { key: 't', bubbles: true, cancelable: true }));
135 await new Promise((r) => requestAnimationFrame(r));
136 return JSON.stringify({ said: document.querySelector('.toast[data-key-says]')?.textContent.trim() ?? null, focusInRow: row.contains(document.activeElement), path: location.pathname });
137 })()`)) as { said: string | null; focusInRow: boolean; path: string };
138 expect(out.said).toBe("T is top now");
139 expect(out.focusInRow).toBe(true);
140 expect(out.path).toBe("/alice/keys/next");
141 expect(order()).toEqual(before);
142 } finally {
143 provideOldKeysClockForTest(undefined);
144 }
145 }, 30_000);
test/next-up.test.ts +2 −2
@@ -180,8 +180,8 @@ describe("Next up", () => {
180180 expect(writer).toContain(`value="${n.b}"`);
181181 expect(writer).toContain("Not now");
182182 // The key is shown beside each action, and the rows take j/k.
183 for (const key of ["t", "u", "d", "l"]) expect(writer).toContain(`data-key="${key}"`);
184 expect(writer).toContain("<kbd>t</kbd>");
183 for (const key of ["T", "K", "J", "p"]) expect(writer).toContain(`data-key="${key}"`);
184 expect(writer).toContain("<kbd>T</kbd>");
185185 expect(writer).toContain("data-nav");
186186 expect(writer).toContain("Blocker");
187187 expect(writer).toContain("Enabler");
test/system-btop.test.ts +1 −1
@@ -158,7 +158,7 @@ describe("/system as btop", () => {
158158 });
159159
160160 test("hotkeys are ignored on a focused button or link, except the sort buttons", () => {
161 expect(systemLiveJs).toContain("(tag === 'BUTTON' || tag === 'A') && !(t.hasAttribute && t.hasAttribute('data-sort'))");
161 expect(systemLiveJs()).toContain("(tag === 'BUTTON' || tag === 'A') && !(t.hasAttribute && t.hasAttribute('data-sort'))");
162162 });
163163
164164 test("the terminal's System view has the cores with history, swap, rates and the top processes", () => {
test/system-stream.test.ts +1 −1
@@ -188,7 +188,7 @@ describe("/system's process table holds the reader's place", () => {
188188 class FakeSource {
189189 addEventListener(_: string, fn: typeof listener) { listener = fn; }
190190 }
191 new Function("document", "EventSource", "location", systemLiveJs)(doc, FakeSource, { search: "" });
191 new Function("document", "EventSource", "location", systemLiveJs())(doc, FakeSource, { search: "" });
192192 const push = (regions: Record<string, string>) => listener({ data: JSON.stringify({ regions }) });
193193 return { doc, push };
194194 }
test/tui-next-up.test.ts +16 −7
@@ -6,6 +6,7 @@
66 * hears it.
77 */
88 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
9 import { OLD_KEYS_UNTIL, provideOldKeysClockForTest } from "../src/web/keymap.ts";
910 import { mkdtemp, rm } from "node:fs/promises";
1011 import { tmpdir } from "node:os";
1112 import { join } from "node:path";
@@ -108,11 +109,19 @@ describe("next up in the terminal", () => {
108109 const before = order();
109110 expect(before).toEqual([n.a!, n.b!]);
110111
111 // Down, then Top on the row the cursor followed.
112 // The old d, for two weeks, says the new key and moves nothing (keymap.ts OLD_KEYS).
113 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
112114 await h.press("d");
115 provideOldKeysClockForTest(undefined);
116 expect(order()).toEqual(before);
117 expect(heard).toHaveLength(0);
118 expect(h.text()).toContain("J is down now");
119
120 // Down, then Top on the row the cursor followed.
121 await h.press("J");
113122 expect(order()[1]).toBe(before[0]!);
114123 expect(heard).toHaveLength(1);
115 await h.press("t");
124 await h.press("T");
116125 expect(order()[0]).toBe(before[0]!);
117126 expect(heard).toHaveLength(2);
118127
@@ -161,13 +170,13 @@ describe("next up in the terminal", () => {
161170 // Down from the top, then Top again: the order of the rows that can start stays in step with the screen.
162171 const startable = (): number[] => nextUp(forge.db, repo).rows.filter((r) => r.state === "ready").map((r) => r.issue.number);
163172 const before = startable();
164 await h.press("d");
173 await h.press("J");
165174 expect(startable()).toEqual([before[1]!, before[0]!]);
166 await h.press("t");
175 await h.press("T");
167176 expect(startable()).toEqual(before);
168177 expect(order().at(-1)).toBe(waiting);
169178 // The blocked row itself can be lifted to the top: it is ranked, and still waits.
170 await h.press("j", "j", "t");
179 await h.press("j", "j", "T");
171180 const row = nextUp(forge.db, repo).rows[0]!;
172181 expect(row.issue.number).toBe(waiting);
173182 expect(row.state).toBe("blocked");
@@ -180,7 +189,7 @@ describe("next up in the terminal", () => {
180189 await h.toNext("alice/plan");
181190 expect(h.text()).toContain("you can read this order, not change it");
182191 const before = order();
183 await h.press("j", "t", "l", "d");
192 await h.press("j", "T", "l", "J");
184193 expect(order()).toEqual(before);
185194 h.stop();
186195 });
@@ -206,7 +215,7 @@ describe("next up in the terminal", () => {
206215 expect(text).not.toContain("Work a");
207216 expect(text).toContain(`${before.indexOf(n.b!) + 1}. #` + n.b); // its place in the whole ranking
208217 // Top moves the row under the cursor in the whole order, not in the shown one.
209 await h.press("t");
218 await h.press("T");
210219 expect(order()[0]).toBe(n.b!);
211220 expect(order()).toHaveLength(before.length);
212221 // Clear: empty submit.
test/week-doors.test.ts +4 −4
@@ -28,7 +28,7 @@ import { createUser, getUserByName, type User } from "../src/core/users.ts";
2828 import { latestRetro, takenOf, tickWeeks, failureClass } from "../src/flow/retro.ts";
2929 import { CUT_TOP_WORDS, cutLine, cutWords, FIT_COUNT_JS, rowCosts, weekView } from "../src/flow/week.ts";
3030 import { serve, type Servers } from "../src/http/server.ts";
31 import { KEYS_JS } from "../src/web/pages/next.ts";
31 import { keysJs } from "../src/web/pages/next.ts";
3232 import { Window } from "happy-dom";
3333 import { createForgeApp } from "../src/tui/forge.ts";
3434 import { headlessTerminal } from "../src/tui/term/terminal.ts";
@@ -180,8 +180,8 @@ describe("the week's doors", () => {
180180 const without = page.replace(/ data-capacity="[^"]*"/, "");
181181 expect(without).not.toContain("data-capacity");
182182 // The server and the script say the same sentences.
183 expect(KEYS_JS).toContain(JSON.stringify(CUT_TOP_WORDS));
184 expect(KEYS_JS).toContain(JSON.stringify(cutWords("{n}")));
183 expect(keysJs()).toContain(JSON.stringify(CUT_TOP_WORDS));
184 expect(keysJs()).toContain(JSON.stringify(cutWords("{n}")));
185185 });
186186
187187 test("dragging a row moves the line before any save, and a refusal puts it back", async () => {
@@ -201,7 +201,7 @@ describe("the week's doors", () => {
201201 };
202202 const location = { pathname: "/alice/plan/next", reload: () => { reloaded = true; } };
203203 const store = { getItem: () => null, setItem: () => {}, removeItem: () => {} };
204 new Function("document", "sessionStorage", "fetch", "location", "FormData", KEYS_JS)(doc, store, fetcher, location, window.FormData);
204 new Function("document", "sessionStorage", "fetch", "location", "FormData", keysJs())(doc, store, fetcher, location, window.FormData);
205205 const lis = [...list.querySelectorAll("li[data-number]")];
206206 const fire = (el: { dispatchEvent(e: unknown): boolean }, type: string) => el.dispatchEvent(new window.Event(type, { bubbles: true, cancelable: true }));
207207 fire(lis[0]!, "dragstart");

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs