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

The terminal gives up g: read again is R, each screen's own g a letter of its verb #17200

opened this

Merged 41h 22m ago, live in production

slice4a → main 0 commits 4 threads · 4 unresolved

  • Merged. slice4a was merged into main as 31035f1.

Review

Sign in to review this change.
45 files changed +310 −111
docs/features/ask-to-reach.md +1 −1
@@ -21,7 +21,7 @@ The pasted token waits with the ask, sealed like a connected account's token: fi
2121 - **Home.** The line that says what needs you reads "ben-test asks to reach git.example.com to connect an origin (2 minutes ago)" with **Allow** and **Not now**.
2222 - **Forges** (`/forges`). The ask is the first row under the forge's name, with **Allow**, **Allow for every hosted forge** and **Not now**. A grant reads "May also reach git.example.com" with **Remove this name**.
2323 - **Settings, Hosted forges** (`/settings/hosted-forges#reach`). One sentence with a switch: "Hosted forges may reach the public git hosts (GitHub, GitLab, Codeberg, Bitbucket) and each other." Then "and also:", the names every hosted forge may reach, with a box to add one. Then "and for one forge only:", each forge's own grants and asks. The row that used to hold the switch on Settings, Usage, Capacity now points here.
24 - **In the terminal.** Open the palette (ctrl-k), "What hosted forges may reach": `a` allows for that forge, `e` for every hosted forge, `n` puts the ask aside, `x` takes a grant back, `g` reads again.
24 - **In the terminal.** Open the palette (ctrl-k), "What hosted forges may reach": `a` allows for that forge, `e` for every hosted forge, `n` puts the ask aside, `x` takes a grant back, `R` reads again.
2525
2626 **A grant applies at once and restarts nothing.** The gate asks for the list on every connection (`childGate`, `src/spawn/child_reach.ts`), so Allow opens, and Remove or the switch closes, a forge that is running.
2727
docs/features/boards-live.md +1 −1
@@ -16,4 +16,4 @@ The stream is `src/web/pages/boards-stream.ts`, which sends the frames and carri
1616
1717 ## The view bar (#3695)
1818
19 At the top of a board: the time range (1h, 6h, 24h, 7d, 30d, All) and Live / Paused. Each is a link to the same board with `?range=` or `?live=` in the address, so a view is shared as a link and nothing is saved; "Back to the saved view" drops it. The range and refresh the board's file keeps are saved under "Board" at the bottom. The stream takes the same `?range=`. Compare to previous, custom ranges and variables are not built yet. In the terminal the same view is two keys on the board screen (`src/tui/screens/boards.ts`): `v` steps the range (1h, 6h, 24h, 7d, 30d, All) and `l` flips Live and Paused; the line under the title says "a view, not saved" and nothing is written. `g` still edits the saved range.
19 At the top of a board: the time range (1h, 6h, 24h, 7d, 30d, All) and Live / Paused. Each is a link to the same board with `?range=` or `?live=` in the address, so a view is shared as a link and nothing is saved; "Back to the saved view" drops it. The range and refresh the board's file keeps are saved under "Board" at the bottom. The stream takes the same `?range=`. Compare to previous, custom ranges and variables are not built yet. In the terminal the same view is two keys on the board screen (`src/tui/screens/boards.ts`): `v` steps the range (1h, 6h, 24h, 7d, 30d, All) and `l` flips Live and Paused; the line under the title says "a view, not saved" and nothing is written. `t` still edits the saved range.
docs/features/bottleneck.md +1 −1
@@ -35,7 +35,7 @@ it. Two doors, one reading (`readBottleneck`):
3535 on the page, in the terminal and in the MCP `bottleneck` reading (`host`: `{label, value}` rows, `ops`:
3636 `{day, kind, who, what, why}`); the morning paper says how many came since its last line.
3737 - **In the terminal** (admins, as the page): the palette's *Where the bottleneck is* shows the sentence,
38 a line a row, what the host is tuned to and the changes; `j`/`k` scroll, `g` reads again, `esc` goes back.
38 a line a row, what the host is tuned to and the changes; `j`/`k` scroll, `R` reads again, `esc` goes back.
3939
4040 Code: `src/system/bottleneck.ts`, `src/system/ops_log.ts`, `src/system/host_tuning.ts`, `src/web/pages/bottleneck.ts`,
4141 `src/tui/screens/bottleneck.ts`.
docs/features/bring.md +1 −1
@@ -54,5 +54,5 @@ most recently pushed first; the rest say "Not read yet" and are read on a later
5454 visit. What was read is kept until the repository is pushed.
5555
5656 - Terminal: the palette's "What is left to bring over"; `b` brings the row in,
57 `n` starts a new forge, `g` reads again.
57 `n` starts a new forge, `R` reads again.
5858 - MCP: the `origins` tool, `action: inventory`, `id` an origin: the same rows.
docs/features/check-slots.md +1 −1
@@ -7,7 +7,7 @@ row: How many pull checks each repository is guaranteed at once
77 Every repository is guaranteed some of the forge's check slots (`checks.concurrency`) for its pull checks: 1 by default, more where one repository does most of the work (the forge's own, say 5 of 8). Within its slots a pull's check starts as soon as one is free. Above them a repository borrows a free slot only when more are free than the other waiting repositories are still owed, so an app with one pull waiting gets its slot at the next one that frees, and an idle forge lends every slot. Nothing running is ever stopped to make room; the longest a small app waits is one check. Main's checks, a rebase's check and the verify lane never wait on a grant.
88
99 - **Settings** (`src/web/pages/settings.ts`, `#check-slots`): the repository's slots, how many of its pull checks run now and how many wait; shown while it has pull checks running or waiting, once its slots were set, or from /boards' link (`?check-slots`). Its admin may lower them; raising them is a site admin's. The grants above 1 together leave at least one slot for every app at 1 (on 8 slots: 5 for the forge, or 4 and 3, never 4 and 4).
10 - **The terminal** (`src/tui/screens/autonomy.ts`): the Autonomy screen says the slots and what runs now; `g` sets them.
10 - **The terminal** (`src/tui/screens/autonomy.ts`): the Autonomy screen says the slots and what runs now; `C` sets them.
1111 - **Boards** (`src/web/pages/boards-slots.ts`): "Check slots by repository", shown while any pull check runs or waits, lists each such repository: used of its grant, borrowed, waiting.
1212 - **A held check's log** says why, once: "queued, held: trevato/forge at its grant of 5; tess/app's 1 is reserved".
1313
docs/features/crew-devices.md +1 −1
@@ -27,7 +27,7 @@ refused every change (`forbidden`, as on the pages); the forge's conversation ag
2727 `add`, `grant` and `remove` before any of it runs.
2828
2929 Both doors: Settings › Devices (`src/web/pages/crew_devices.ts`) and the terminal screen (`src/tui/screens/crewdevices.ts`,
30 palette entry *Devices* in a repository you administer: `a` lists, `g` grants, `x` unlists, `s` flips to the sessions)
30 palette entry *Devices* in a repository you administer: `a` lists, `G` grants, `x` unlists, `s` flips to the sessions)
3131 use the same actions. A repository admin lists, unlists and reads; only a site admin grants; anyone else sees nothing.
3232 Each write is an event, so an open page or screen follows.
3333
docs/features/forge-origin.md +1 −1
@@ -28,7 +28,7 @@ Not yet, in order: follow upstream between forges with a pull back, and the one-
2828
2929 ## Follow the forge it came from (#16069)
3030
31 A repository brought across with a connected origin (`migrate`) keeps the address it came from and the origin whose credential reads it. Under its head an admin sees the state ("Brought from <host>/<owner>/<name>; new commits there are not shown here") and one **Follow** button that opens a question and, answered, turns the upstream follow on (`src/origins/follow.ts`, `src/web/pages/origin-follow.ts`, `POST /:owner/:name/follow-origin`, which needs the confirming field); the same place says **Stop following** once it is on. The terminal's About screen (`src/tui/screens/about.ts`) has the same press on `g`, behind a confirm, through the same `setOriginFollow`, so a web viewer sees it live. A new commit on the source's default branch then shows as "N commits behind" at the next check (every 30 minutes, or "Check upstream now"), as a pack's follow does. The credential is the origin's, handed to git through the environment at check time, never argv or config; it is sent only to the origin's own https address (a test may allow a loopback address over http with `credentialOverLoopback`; production never does).
31 A repository brought across with a connected origin (`migrate`) keeps the address it came from and the origin whose credential reads it. Under its head an admin sees the state ("Brought from <host>/<owner>/<name>; new commits there are not shown here") and one **Follow** button that opens a question and, answered, turns the upstream follow on (`src/origins/follow.ts`, `src/web/pages/origin-follow.ts`, `POST /:owner/:name/follow-origin`, which needs the confirming field); the same place says **Stop following** once it is on. The terminal's About screen (`src/tui/screens/about.ts`) has the same press on `F`, behind a confirm, through the same `setOriginFollow`, so a web viewer sees it live. A new commit on the source's default branch then shows as "N commits behind" at the next check (every 30 minutes, or "Check upstream now"), as a pack's follow does. The credential is the origin's, handed to git through the environment at check time, never argv or config; it is sent only to the origin's own https address (a test may allow a loopback address over http with `credentialOverLoopback`; production never does).
3232
3333 Both presses write a `repo.origin_follow` event for the admins' history. An origin that needs signing in again (or was disconnected) stops the follow at its next check and says so on the repository and in the check history; the offer then points to Origins until it is signed in. A mirror (a repository that syncs with its origin) is not offered this: its sweep already takes what is new. Test: `test/forge-origin-follow.test.ts`, two forges.
3434
docs/features/fork-flows.md +1 −1
@@ -17,6 +17,6 @@ A fork you may not read is never named.
1717 - Web: `/forks/flows` (signed in), linked from `/family` (signed in) and from a repository's forks page; `/forges` has no room for it. Source: `src/web/pages/fork-flows.ts`.
1818 - API: `GET /api/v1/forks/flows` returns `{ follows, sent, offered }`.
1919 - MCP: the tool `fork_flows`, with no arguments, returns the same.
20 - Terminal: the palette entry "Fork flows" (`src/tui/screens/forkflows.ts`); `g` reads again.
20 - Terminal: the palette entry "Fork flows" (`src/tui/screens/forkflows.ts`); `R` reads again.
2121
2222 All four read `forkFlows` in `src/core/fork_flows.ts`.
docs/features/go-jumps.md +1 −1
@@ -20,4 +20,4 @@ Press `g`, then a letter within one second, from any page outside a field. Modif
2020 - `g h`, `g q` and `g t` are the chords the top bar already wore (its hover hints show them), so they now work from anywhere and the sheet names them like the rest.
2121 - Test: `test/keys-goto.test.ts` runs the real keys script against a fake document: stranger and user, the 1 s timeout, Ctrl/Meta, and a field.
2222
23 **Terminal:** none added. Terminal screens are reached by their own menus and print their keys in their footer line; `g` there already means "top" in lists or an action on a screen, so a global `g` chord would collide.
23 **Terminal:** no screen binds `g` for an action of its own any more (each moved to a letter of its verb, and the old `g` says where it went until 2026-12-15, `docs/features/keymap.md`). Lists still take `g` as their top until the terminal's own `g` jumps arrive and take `g g` for the top.
docs/features/jobs.md +1 −1
@@ -9,7 +9,7 @@ A job is code that waits (`sleep`, `waitFor`) without a process, survives restar
99 1. In a new app, open a note signed in and press **Remind me tomorrow** (`POST /notes/:id/remind`): a run of the `remind` job starts, loads the note, and waits a day for the note to be removed.
1010 2. Open the app on the forge: while the run holds a timer, its page has **Jobs → See the job runs** (`/:owner/:name/app/jobs`). The row says `waiting for removed:<id>, until <time> at the latest`. **Cancel** stops it; a failed run offers **Retry from the failed step**.
1111 3. The same from a script: `curl -H "authorization: Bearer $TOKEN" $FORGE_URL/api/v1/repos/<owner>/<name>/jobs`, `curl -X POST …/jobs/<run>/cancel`; the `app_deploy` MCP tool does it with `action: "jobs"`, `"cancel_job"` or `"retry_job"` (`name` is the run id).
12 4. The terminal: with the app's repository open, the palette offers **Job runs** (a writer's, while the app holds a job timer); `c` cancels the run under the cursor, `t` retries a failed one, `g` reads again (`src/tui/screens/jobs.ts`).
12 4. The terminal: with the app's repository open, the palette offers **Job runs** (a writer's, while the app holds a job timer); `c` cancels the run under the cursor, `t` retries a failed one, `R` reads again (`src/tui/screens/jobs.ts`).
1313 5. A run that fails for good (a step out of retries, or a changed job) asks the owner once.
1414
1515 Where the code is: the runtime `src/jobs.ts` in the app template (`templates/app-template.json`; its tests, `src/jobs.test.ts`, run by `test/template-jobs.test.ts`), the forge's rows and steering `src/actions/jobs.ts`, `src/http/api/jobs.ts`, `src/web/studio/jobs.ts`, the no-retry answer in `src/apps/timer_fire.ts`, and the ask in `scheduleLines` (`src/actions/schedules.ts`). Tests: `test/jobs-doors.test.ts`.
docs/features/keymap.md +15
@@ -21,4 +21,19 @@ The owner, after the bridge: "tying together all the keybinds is really what im
2121 - **Ranked lists, the space and /system:** /next's rows move with `T` top, `K` up, `J` down and `p` not now, on the page and in the terminal's Next up, where `P` pauses the 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`, which each sort button carries as its hint. 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.
2222 - **/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.
2323
24 ## The terminal gives up g
25
26 No terminal screen takes `g` for a verb of its own, so `g` can start a jump there as it does on the web (`test/keymap-terminal.test.ts` holds it). "Read again" is `R` (the map's `reread`). Each screen's own `g` took a letter of its verb:
27
28 - boards: `t` range;
29 - an issue: `y` go ahead;
30 - about: `F` follow where it came from;
31 - egress: `a` grant, as an app's secrets grant (`x` takes either back);
32 - games, crew devices: `G` grant (their `a` was taken);
33 - autonomy: `C` check slots;
34 - forges: `M` move to a machine;
35 - System: `T` telemetry.
36
37 The old `g` says where each went until 2026-12-15 (`src/tui/screens/moved_key.ts`). A list's own `g`/`G` (top, end) stays until the jump arrives and takes `g g` for the top.
38
2439 Proof: `test/keymap.test.ts`, `test/bridge.test.ts`.
docs/features/large-files.md +1 −1
@@ -9,7 +9,7 @@ A blob over the policy size (10 MB; set `FORGE_LARGE_BLOB_BYTES` to a whole numb
99 ## See them
1010
1111 - Page: `/<owner>/<name>/large` reads the list the offload job saved after the last push (no scan on a request) and lists each blob, largest first: its path on the default branch, its size, its object id, and where it lives (`git`, or `git and store`).
12 - Terminal: open a repository, then the palette's "Large files" (`src/tui/screens/largefiles.ts`); `g` reads again.
12 - Terminal: open a repository, then the palette's "Large files" (`src/tui/screens/largefiles.ts`); `R` reads again.
1313
1414 ## Download one
1515
docs/features/move-machine.md +1 −1
@@ -17,7 +17,7 @@ really was.
1717 It shows the plan (one sentence with the budget), asks, and then shows the
1818 receipt. A forge that is on a machine also offers **Restore**, previewed with
1919 the copy's time and what is lost.
20 - **Terminal, Forges screen**: `g` picks the forge, then the machine, shows
20 - **Terminal, Forges screen**: `M` picks the forge, then the machine, shows
2121 the same plan on a confirm, and toasts the same receipt; `v` is the restore
2222 from the newest copy, the same way (`src/tui/screens/forges.ts`).
2323 - **MCP**: `forges` with `{ action: "move", forge, to }` previews; with
docs/features/security-osv.md +1 −1
@@ -8,7 +8,7 @@ row: "Dependency scan: a repository's lockfile against OSV advisories"
88
99 **More feeds (#17141).** The same refresh also reads GHSA (`api.github.com/advisories`, reviewed npm advisories for the pins the forge holds, written into the mirror as OSV documents; an id OSV already supplied is kept) and rates any mirrored advisory that has a CVE id and no severity from NVD (`services.nvd.nist.gov`), then CVE.org (`cveawg.mitre.org`), by CVSS. NVD and CVE.org rate; they do not find, as they name no npm versions. Each CVE is asked about once, and at most 10 per pass. Both hosts are in `egress`; a gate refusal is reported in the gate's words. Anyone who can read the dependency scan (API or terminal) sees these findings; there is no separate page. Not built: a CISA KEV flag, GitHub token for a higher rate, paging past 100 GHSA hits per 25 pins.
1010
11 **Terminal:** open a repository, then the palette entry "Dependencies" (`src/tui/screens/dependencies.ts`): one row per finding, `g` reads again. It shows what the API shows, to whoever can read the repository, through the same cache and rate limit.
11 **Terminal:** open a repository, then the palette entry "Dependencies" (`src/tui/screens/dependencies.ts`): one row per finding, `R` reads again. It shows what the API shows, to whoever can read the repository, through the same cache and rate limit.
1212
1313 **Load.** The report is held by commit oid and the mirror's stamp, so a repeat read costs a lookup; a client address may read 20 times a minute and the forge 300 (429 with `Retry-After` beyond), and one read takes at most 20 lockfiles and 30 MB.
1414
src/tui/screens/about.ts +4 −2
@@ -15,6 +15,7 @@
1515 * card is an OSC 8 hyperlink besides.
1616 */
1717
18 import { movedKey } from "./moved_key.ts";
1819 import { ARCHIVE_DETAIL, RESTORE_DETAIL, archiveTitle, restoreTitle } from "../../core/archive-words.ts";
1920 import { sourcesScreen } from "./sources.ts";
2021 import type { Database } from "bun:sqlite";
@@ -276,7 +277,7 @@ export function aboutScreen(
276277 ]
277278 : []),
278279 ...(brought() !== undefined
279 ? [binding(["g"], brought()?.following ? "stop following where it came from" : "follow where it came from")]
280 ? [binding(["F"], brought()?.following ? "stop following where it came from" : "follow where it came from")]
280281 : []),
281282 ...(may() && repo?.origin === null ? [binding(["s"], "followed sources")] : []),
282283 // Who can read it is a person's, an admin's call (#8008).
@@ -730,7 +731,8 @@ export function aboutScreen(
730731 return true;
731732 }
732733 const offer = brought();
733 if (e.key === "g" && repo !== undefined && offer !== undefined) {
734 if (repo !== undefined && offer !== undefined && movedKey(ctx, e, "g", "F follows now")) return true;
735 if (e.key === "F" && repo !== undefined && offer !== undefined) {
734736 const at = repo;
735737 const on = !offer.following;
736738 ctx.push(
src/tui/screens/autonomy.ts +4 −2
@@ -14,6 +14,7 @@
1414 * Anyone else gets no palette entry and, if the screen is reached, no values.
1515 */
1616
17 import { movedKey } from "./moved_key.ts";
1718 import { mayRaiseCeiling, raiseCrewCeiling } from "../../actions/crew_ceiling.ts";
1819 import { checkPool, setCheckSlots } from "../../actions/check_slots.ts";
1920 import { pullChecksOf } from "../../checks/check_slots.ts";
@@ -128,7 +129,7 @@ export function autonomyScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
128129 title: "Autonomy",
129130 get keys() {
130131 return mayChange()
131 ? [binding(["m"], "mode"), binding(["p"], "planner"), binding(["s"], "builder"), binding(["r"], "reviewer"), binding(["o"], "polish share"), binding(["g"], "check slots"), ...(mayRaiseCeiling(f.app, f.user) ? [binding(["c"], "raise ceiling")] : [])]
132 ? [binding(["m"], "mode"), binding(["p"], "planner"), binding(["s"], "builder"), binding(["r"], "reviewer"), binding(["o"], "polish share"), binding(["C"], "check slots"), ...(mayRaiseCeiling(f.app, f.user) ? [binding(["c"], "raise ceiling")] : [])]
132133 : [];
133134 },
134135 render(area, s) {
@@ -217,7 +218,8 @@ export function autonomyScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
217218 );
218219 return true;
219220 }
220 if (e.key === "g") {
221 if (movedKey(ctx, e, "g", "C sets the check slots now")) return true;
222 if (e.key === "C") {
221223 ask("Check slots", "pull checks guaranteed at once, 1 or more", "1 or more", String(current().checkSlots), (raw) => {
222224 const n = /^\d{1,2}$/.test(raw) ? Number(raw) : Number.NaN;
223225 const set = setCheckSlots(f.app, f.user, current(), n);
src/tui/screens/boards.ts +6 −4
@@ -3,7 +3,7 @@
33 * keeps, then one board's panels as text. It reads through the same
44 * `listAllBoards` and `showBoard` the page and the API do, so the gate is the
55 * action's (an agent or anyone else is told nothing); the palette offers the
6 * door only to that person. `n` makes a board, `c` copies the marked one, `e` renames it and `g`
6 * door only to that person. `n` makes a board, `c` copies the marked one, `e` renames it and `t`
77 * sets its range (`changeBoard`; `home` still jumps to the top), and `D` deletes it after `y/n`
88 * (`actions/boards.ts`, as the page does). Otherwise reading, but for pins: a chart is not drawn, a
99 * panel is said as its title, chart, size and the query that feeds it, then what `panelData` reads
@@ -14,6 +14,7 @@
1414 * so a panel that moved says how many points and its latest value (`liveWords`).
1515 */
1616
17 import { movedKey } from "./moved_key.ts";
1718 import { formatValue } from "../../boards/chart.ts";
1819 import { keyOf } from "../../web/keymap.ts";
1920 import { watchBoard, type Frame } from "../../boards/live_hub.ts";
@@ -345,7 +346,7 @@ export function boardsScreen(f: Session, ctx: Ctx): Screen {
345346 get keys() {
346347 return [
347348 binding(["j", "k"], "move"), binding(["enter"], "open"), binding(["n"], "new"), binding(["c"], "copy"),
348 ...(mayEdit ? [binding(["e"], "rename"), binding(["g"], "range")] : []),
349 ...(mayEdit ? [binding(["e"], "rename"), binding(["t"], "range")] : []),
349350 binding(["D"], "delete"), binding([keyOf("reread")], "refresh"),
350351 ];
351352 },
@@ -375,8 +376,9 @@ export function boardsScreen(f: Session, ctx: Ctx): Screen {
375376 }
376377 return true;
377378 }
378 // Before the list's own keys: `g` would jump to the top.
379 if (mayEdit && (e.key === "e" || e.key === "g")) {
379 // Before the list's own keys: `t` sets the range (`g` until 12-15 says so).

The file's header comment (line 6) still says g sets the range; make it t. Same for the other screen headers listed in the review body.

380 if (mayEdit && movedKey(ctx, e, "g", "t sets the range now")) return true;
381 if (mayEdit && (e.key === "e" || e.key === "t")) {
380382 const row = rows[state.index];
381383 if (row !== undefined) edit(row, e.key === "e" ? "title" : "range");
382384 return true;
src/tui/screens/bottleneck.ts +3 −2
@@ -4,6 +4,7 @@
44 * (`readBottleneck`). Gated as the page is: a forge admin who is a person. Read-only.
55 */
66
7 import { keyOf } from "../../web/keymap.ts";
78 import { telemetryReader } from "../../actions/telemetry.ts";
89 import { readBottleneck, type Bottleneck } from "../../system/bottleneck.ts";
910 import { live } from "../../system/live.ts";
@@ -42,7 +43,7 @@ export function bottleneckScreen(session: Session, ctx: Ctx): Screen {
4243 let lines = bottleneckLines(session);
4344 return {
4445 title: "Where the bottleneck is",
45 keys: [binding(["j", "k"], "scroll"), binding(["g"], "read again"), binding(["esc", "q"], "back")],
46 keys: [binding(["j", "k"], "scroll"), binding([keyOf("reread")], "read again"), binding(["esc", "q"], "back")],
4647 render(area, s) {
4748 const c = ctx.theme.c;
4849 drawLines(s, area, c, scroll, lines.map((text) => [{ text, style: style(text.startsWith(" ") ? c.mutedFg : c.fg, c.bg) }]));
@@ -50,7 +51,7 @@ export function bottleneckScreen(session: Session, ctx: Ctx): Screen {
5051 },
5152 key(e) {
5253 if (scroll.key(e, lines.length)) return true;
53 if (e.key === "g") {
54 if (e.key === keyOf("reread")) {
5455 lines = bottleneckLines(session);
5556 return true;
5657 }
src/tui/screens/crewdevices.ts +7 −5
@@ -3,12 +3,13 @@
33 * block (`web/pages/crew_devices.ts`) from the same actions
44 * (`actions/crew_devices.ts`), gated the same way. A repository's admin sees
55 * the devices and the sessions and may list (`a`) and unlist (`x`) one; only a
6 * site admin may grant (`g`), pinning the host key the device shows; anyone
6 * site admin may grant (`G`), pinning the host key the device shows; anyone
77 * else sees nothing. `s` flips between the devices and the sessions the crew
88 * made. Each write is an event on the bus, so the open settings page redraws
99 * and this screen follows a write made there.
1010 */
1111
12 import { movedKey } from "./moved_key.ts";
1213 import {
1314 addCrewDevice,
1415 devicesView,
@@ -73,7 +74,7 @@ export function crewDevicesScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
7374 binding(["j", "k"], "move cursor"),
7475 binding(["s"], showSessions ? "devices" : "sessions"),
7576 ...(may ? [binding(["a"], "list a device"), binding(["x"], "unlist")] : []),
76 ...(may && view().canGrant ? [binding(["g"], "grant")] : []),
77 ...(may && view().canGrant ? [binding(["G"], "grant")] : []),
7778 ];
7879 },
7980 async load(signal) {
@@ -89,7 +90,7 @@ export function crewDevicesScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
8990 : showSessions
9091 ? "ssh sessions the crew reported: their own note, not an audit. s shows the devices."
9192 : v.canGrant
92 ? "Devices a run may ssh to. a lists one, g grants it, x unlists."
93 ? "Devices a run may ssh to. a lists one, G grants it, x unlists."
9394 : "Devices a run may reach. a lists one, x unlists. Only a site admin grants.";
9495 s.text(head!.x, head!.y, truncate(note, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w);
9596 drawList(s, list!, c, state, rows());
@@ -98,7 +99,8 @@ export function crewDevicesScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
9899 const all = view();
99100 const count = showSessions ? all.sessions.length : all.devices.length;
100101 if (e.ctrl || e.alt) return false;
101 if (e.key !== "s" && e.key !== "a" && e.key !== "x" && e.key !== "g") return state.key(e, count);
102 if (movedKey(ctx, e, "g", "G grants now")) return true;
103 if (e.key !== "s" && e.key !== "a" && e.key !== "x" && e.key !== "G") return state.key(e, count);
102104 if (e.key === "s") {
103105 showSessions = !showSessions;
104106 state.clamp(showSessions ? all.sessions.length : all.devices.length);
@@ -133,7 +135,7 @@ export function crewDevicesScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
133135 }
134136 const at = showSessions ? undefined : all.devices[state.index];
135137 if (at === undefined) return true;
136 if (e.key === "g") {
138 if (e.key === "G") {
137139 if (!all.canGrant) {
138140 ctx.toast(ERRORS["forbidden"]!, "danger");
139141 return true;
src/tui/screens/dataset.ts +3 −2
@@ -4,6 +4,7 @@
44 * them. Gated as the page is: a forge admin who is a person. Read-only.
55 */
66
7 import { keyOf } from "../../web/keymap.ts";
78 import { datasetAnswers, lastExport } from "../../actions/dataset.ts";
89 import { datasetStats } from "../../core/dataset.ts";
910 import type { Ctx, Screen } from "../app/app.ts";
@@ -39,7 +40,7 @@ export function datasetScreen(session: Session, ctx: Ctx): Screen {
3940 let lines = datasetLines(session);
4041 return {
4142 title: "Dataset",
42 keys: [binding(["j", "k"], "scroll"), binding(["g"], "read again"), binding(["esc", "q"], "back")],
43 keys: [binding(["j", "k"], "scroll"), binding([keyOf("reread")], "read again"), binding(["esc", "q"], "back")],
4344 render(area, s) {
4445 const c = ctx.theme.c;
4546 drawLines(s, area, c, scroll, lines.map((text) => [{ text, style: style(text.startsWith(" ") ? c.mutedFg : c.fg, c.bg) }]));
@@ -47,7 +48,7 @@ export function datasetScreen(session: Session, ctx: Ctx): Screen {
4748 },
4849 key(e) {
4950 if (scroll.key(e, lines.length)) return true;
50 if (e.key === "g") {
51 if (e.key === keyOf("reread")) {
5152 lines = datasetLines(session);
5253 return true;
5354 }
src/tui/screens/dependencies.ts +4 −3
@@ -2,9 +2,10 @@
22 * A repository's dependency findings, in the terminal (#6004): the report behind
33 * `GET /api/v1/repos/:owner/:name/dependencies` (`security/report_cache.ts`, so the API and this
44 * screen share one cached read and one rate limit), gated the same way — anyone who can read the
5 * repository sees it. `g` reads again.
5 * repository sees it. `R` reads again (the keymap's reread).
outdated

Header still says g reads again; it is R now (keyOf("reread")). Update the comment.

66 */
77
8 import { keyOf } from "../../web/keymap.ts";
89 import { requireReader } from "../../actions/access.ts";
910 import type { Repo } from "../../core/repos.ts";
1011 import { repoDir } from "../../git/repos.ts";
@@ -48,7 +49,7 @@ export function dependenciesScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
4849 const again = (): void => void read().catch(() => (note = "The lockfiles could not be read.")).finally(() => ctx.invalidate());
4950 return {
5051 title: `${repo.ownerName}/${repo.name} — Dependencies`,
51 keys: [binding(["j", "k"], "move cursor"), binding(["g"], "read again")],
52 keys: [binding(["j", "k"], "move cursor"), binding([keyOf("reread")], "read again")],
5253 async load() {
5354 again();
5455 },
@@ -60,7 +61,7 @@ export function dependenciesScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
6061 },
6162 key(e) {
6263 if (state.key(e, report?.findings.length ?? 0)) return true;
63 if (e.ctrl || e.alt || e.key !== "g") return false;
64 if (e.ctrl || e.alt || e.key !== keyOf("reread")) return false;
6465 again();
6566 return true;
6667 },
src/tui/screens/egress.ts +6 −4
@@ -1,10 +1,11 @@
11 /**
22 * An app's private destinations in the terminal, a site admin's: the list the
3 * settings page shows, with `g` to grant the one under the cursor once `y`
3 * settings page shows, with `a` to grant the one under the cursor once `y`
44 * confirms it (a grant widens the boundary) and `x` to revoke it once `y`
55 * confirms that too. The actions decide who may; anyone else is offered nothing.
66 */
77
8 import { movedKey } from "./moved_key.ts";
89 import {
910 egressView,
1011 grantAppEgress,
@@ -58,7 +59,7 @@ export function egressScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
5859 title: "Private egress",
5960 get keys() {
6061 return [
61 ...(canChange ? [binding(["g"], "grant"), binding(["x"], "revoke")] : []),
62 ...(canChange ? [binding(["a"], "grant"), binding(["x"], "revoke")] : []),
6263 binding(["j", "k"], "move cursor"),
6364 ];
6465 },
@@ -74,7 +75,8 @@ export function egressScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
7475 },
7576 key(e) {
7677 const row = canChange ? rows[state.index] : undefined;
77 if (e.key === "g" && row !== undefined) {
78 if (row !== undefined && movedKey(ctx, e, "g", "a grants now")) return true;
79 if (e.key === "a" && row !== undefined) {
7880 if (row.granted) return true;
7981 const { destination } = row;
8082 ctx.push(
@@ -97,7 +99,7 @@ export function egressScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
9799 ctx.push(
98100 confirmScreen(ctx, screen, {
99101 title: `Stop ${repo.ownerName}/${repo.name} reaching ${destination}?`,
100 body: ["The app's outbound traffic to it is refused until g grants it again."],
102 body: ["The app's outbound traffic to it is refused until a grants it again."],
101103 actions: [{ label: "Revoke", variant: "danger" }, { label: "Cancel", variant: "ghost" }],
102104 yesNo: true,
103105 width: 78,
src/tui/screens/forges.ts +4 −2
@@ -4,6 +4,7 @@
44 * claim link; that stays on the page.
55 */
66
7 import { movedKey } from "./moved_key.ts";
78 import type { Ctx, Screen } from "../app/app.ts";
89 import { binding } from "../app/keys.ts";
910 import { rowActivityWords, sentWords } from "../../spawn/client_words.ts";
@@ -390,7 +391,7 @@ export function forgesScreen(ctx: Ctx, rows: readonly ClientRow[], session?: Ses
390391 };
391392 const screen: Screen = {
392393 title: "Forges you sent",
393 keys: [binding(["s"], "stop"), binding(["a"], "archive"), binding(["r"], "restore"), binding(["x"], "remove"), binding(["n"], "new link"), binding(["l"], "end a link"), binding(["u"], "undo an ended link"), binding(["o"], "own code or this forge's"), binding(["m"], "move"), binding(["g"], "move to a machine"), binding(["v"], "restore from the newest copy"), binding(["e"], "upgrade a shared forge"), binding(["h"], "machines' heartbeats"), binding(["w"], "raise to xlarge"), binding(["f"], "state"), binding(["/"], "search"), binding(["c"], "csv"), binding(["esc"], "close")],
394 keys: [binding(["s"], "stop"), binding(["a"], "archive"), binding(["r"], "restore"), binding(["x"], "remove"), binding(["n"], "new link"), binding(["l"], "end a link"), binding(["u"], "undo an ended link"), binding(["o"], "own code or this forge's"), binding(["m"], "move"), binding(["M"], "move to a machine"), binding(["v"], "restore from the newest copy"), binding(["e"], "upgrade a shared forge"), binding(["h"], "machines' heartbeats"), binding(["w"], "raise to xlarge"), binding(["f"], "state"), binding(["/"], "search"), binding(["c"], "csv"), binding(["esc"], "close")],
394395 render(area, s) {
395396 const c = ctx.theme.c;
396397 const w = Math.min(100, Math.max(30, area.w - 6));
@@ -454,7 +455,8 @@ export function forgesScreen(ctx: Ctx, rows: readonly ClientRow[], session?: Ses
454455 }),
455456 );
456457 } else if (e.key === "m") sandboxOne();
457 else if (e.key === "g") machineOne(false);
458 else if (e.key === "M") machineOne(false);
459 else if (e.key === "g") movedKey(ctx, e, "g", "M moves it to a machine now");
458460 else if (e.key === "v") machineOne(true);
459461 else if (e.key === "e") upgradeOne();
460462 else if (e.key === "h") machinesSeen();
src/tui/screens/forkflows.ts +3 −2
@@ -4,6 +4,7 @@
44 * behind /forks/flows, GET /api/v1/forks/flows and MCP `fork_flows` (#17056); stored state only.
55 */
66
7 import { keyOf } from "../../web/keymap.ts";
78 import { agoWords } from "../../actions/follow_words.ts";
89 import { EMPTY_WORDS } from "../../core/empty_words.ts";
910 import { forkFlows, type ForkFlows } from "../../core/fork_flows.ts";
@@ -29,7 +30,7 @@ export function forkFlowsScreen(f: Session, ctx: Ctx): Screen {
2930 let shown = rows();
3031 const screen: Screen = {
3132 title: "Fork flows",
32 keys: [binding(["j", "k"], "move cursor"), binding(["g"], "read again")],
33 keys: [binding(["j", "k"], "move cursor"), binding([keyOf("reread")], "read again")],
3334 render(area, s) {
3435 const c = ctx.theme.c;
3536 const [, body] = split(area, "v", [len(1), fill(1)]);
@@ -41,7 +42,7 @@ export function forkFlowsScreen(f: Session, ctx: Ctx): Screen {
4142 },
4243 key(e) {
4344 if (state.key(e, shown.length)) return true;
44 if (e.ctrl || e.alt || e.key !== "g") return false;
45 if (e.ctrl || e.alt || e.key !== keyOf("reread")) return false;
4546 shown = rows();
4647 state.clamp(shown.length);
4748 ctx.invalidate();
src/tui/screens/games.ts +10 −6
@@ -5,9 +5,10 @@
55 * opens a service as /games/<box>/<service> does: its console (the log tail, and `:` queues an
66 * rcon command), its env (`e` sets or clears a key, committed through `commitServiceEnv`) and its
77 * plugins (`a` adds a Modrinth slug or a URL through `addPlugin`; uploading a jar is the page's
8 * alone). `g` opens the box's grants, which an owner sets with `a`, through `grant`.
8 * alone). `G` opens the box's grants, which an owner sets with `a` there, through `grant`.
outdated

Header still says g opens the box's grants and the owner sets them with a; it is G now. Update the comment.

99 */
1010
11 import { movedKey } from "./moved_key.ts";
1112 import { emptyText } from "../../core/empty_words.ts";
1213 import { boxStatus, boxStatusShared } from "../../games/diag.ts";
1314 import { getUserByName } from "../../core/users.ts";
@@ -51,7 +52,7 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen {
5152 keys: [
5253 binding(["j", "k"], "move cursor"),
5354 binding(["enter"], "console, env, plugins"),
54 binding(["g"], "grants"),
55 binding(["G"], "grants"),
5556 binding(["s"], "start"),
5657 binding(["x"], "stop"),
5758 binding(["r"], "restart"),
@@ -87,16 +88,19 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen {
8788 },
8889 key(e) {
8990 const all = rows();
91 // Before the list's own keys, which would take g and G as top and end.
92 const here = all[state.index];
93 if (here !== undefined && movedKey(ctx, e, "g", "G opens the grants now")) return true;
94 if (here !== undefined && !e.ctrl && !e.alt && e.key === "G") {
95 ctx.push(gameGrantsScreen(f, ctx, here.box));
96 return true;
97 }
9098 if (state.key(e, all.length)) return true;
9199 const at = all[state.index];
92100 if (at !== undefined && !e.ctrl && !e.alt && e.key === "enter") {
93101 ctx.push(gameServiceScreen(f, ctx, at.box, at.service.name));
94102 return true;
95103 }
96 if (at !== undefined && !e.ctrl && !e.alt && e.key === "g") {
97 ctx.push(gameGrantsScreen(f, ctx, at.box));
98 return true;
99 }
100104 const kind: CommandKind | undefined = e.key === "s" ? "start" : e.key === "x" ? "stop" : e.key === "r" ? "restart" : undefined;
101105 if (kind === undefined || at === undefined || e.ctrl || e.alt) return false;
102106 if (!mayDo(roleOn(f.app.db, f.user, at.box.id, at.service.name), "operator")) note = `You are not an operator of ${at.service.name}.`;
src/tui/screens/hostreach.ts +4 −3
@@ -5,9 +5,10 @@
55 * ask: `a` allows it for that forge, `e` for every hosted forge, `n` puts it
66 * aside. On a grant: `x` takes it back. Each write is an event and applies to
77 * a running forge at once; the screen reads again after its own writes and
8 * with `g`.
8 * with `R` (the keymap's reread).
outdated

Header still says read again is g; it is R now. Update the comment.

99 */
1010
11 import { keyOf } from "../../web/keymap.ts";
1112 import {
1213 allowReach,
1314 putAsideReach,
@@ -103,7 +104,7 @@ export function hostReachScreen(f: Session, ctx: Ctx): Screen {
103104 binding(["e"], "allow for every forge"),
104105 binding(["n"], "not now"),
105106 binding(["x"], "take a grant back"),
106 binding(["g"], "read again"),
107 binding([keyOf("reread")], "read again"),
107108 ],
108109 async load() {
109110 await read();
@@ -135,7 +136,7 @@ export function hostReachScreen(f: Session, ctx: Ctx): Screen {
135136 const lines = view === undefined ? [] : reachLines(view);
136137 if (state.key(e, lines.length)) return true;
137138 if (e.ctrl || e.alt) return false;
138 if (e.key === "g") {
139 if (e.key === keyOf("reread")) {
139140 void read();
140141 return true;
141142 }
src/tui/screens/inventory.ts +3 −2
@@ -6,6 +6,7 @@
66 * `o` opens it here once it is. Offered to whoever is signed in, as the page.
77 */
88
9 import { keyOf } from "../../web/keymap.ts";
910 import { holds, inventoryOfOrigins, type InventoryItem } from "../../actions/inventory.ts";
1011 import { listUserOrigins } from "../../actions/origins.ts";
1112 import { STATE_WORDS } from "../../origins/inventory.ts";
@@ -45,7 +46,7 @@ export function inventoryScreen(f: Session, ctx: Ctx): Screen {
4546
4647 return {
4748 title: "What is left to bring over",
48 keys: [binding(["j", "k"], "move cursor"), binding(["b"], "bring in"), binding(["n"], "new forge"), binding(["g"], "read again")],
49 keys: [binding(["j", "k"], "move cursor"), binding(["b"], "bring in"), binding(["n"], "new forge"), binding([keyOf("reread")], "read again")],
4950 render(area, s) {
5051 const c = ctx.theme.c;
5152 const [head, body] = split(area, "v", [len(1), fill(1)]);
@@ -66,7 +67,7 @@ export function inventoryScreen(f: Session, ctx: Ctx): Screen {
6667 key(e) {
6768 if (state.key(e, items.length)) return true;
6869 if (e.ctrl || e.alt) return false;
69 if (e.key === "g") {
70 if (e.key === keyOf("reread")) {
7071 load();
7172 return true;
7273 }
src/tui/screens/issue.ts +6 −4
@@ -14,6 +14,7 @@
1414 * hook needed.
1515 */
1616
17 import { movedKey } from "./moved_key.ts";
1718 import { outsideClause } from "../../web/outside.ts";
1819 import { keyOf } from "../../web/keymap.ts";
1920 import { putFlowFirst } from "../../actions/flow_first.ts";
@@ -212,7 +213,7 @@ export function issueScreen(
212213 /** The text `e` opened the editor with; set while the composer edits, not comments. */
213214 let editing: string | undefined;
214215 const mayWrite = (): boolean => src.capabilities.write && repo !== undefined;
215 /** `g` is a person's: the crew parked the issue and may not unpark itself. */
216 /** `y` (go ahead) is a person's: the crew parked the issue and may not unpark itself. */
216217 const mayGoAhead = (): boolean =>
217218 mayWrite() &&
218219 held.length > 0 &&
@@ -431,7 +432,7 @@ export function issueScreen(
431432 });
432433 };
433434
434 /** `g` — say the issue may go ahead without its dropped or split blockers. */
435 /** `y` — say the issue may go ahead without its dropped or split blockers. */
435436 const goAhead = (): void => {
436437 const at = row();
437438 if (at?.issue === undefined || held.length === 0) return;
@@ -638,7 +639,7 @@ export function issueScreen(
638639 }),
639640 binding(["l"], "labels"),
640641 binding(["t"], "teams"),
641 ...(mayGoAhead() ? [binding(["g"], "go ahead")] : []),
642 ...(mayGoAhead() ? [binding(["y"], "go ahead")] : []),
642643 binding(["w"], "waits for"),
643644 binding(["S"], issueRow?.sealed === true ? "unseal" : "seal"),
644645 ...(issueRow?.sealed === true
@@ -944,7 +945,8 @@ export function issueScreen(
944945 );
945946 return true;
946947 }
947 if (e.key === "g" && mayGoAhead()) {
948 if (mayGoAhead() && movedKey(ctx, e, "g", "y goes ahead now")) return true;
949 if (e.key === "y" && mayGoAhead()) {
948950 goAhead();
949951 return true;
950952 }
src/tui/screens/jobs.ts +5 −4
@@ -4,10 +4,11 @@
44 * same way: a writer reads and steers. The runs live in the app itself, so
55 * the screen asks it (waking it) on open and after each write, and keeps the
66 * answer; `c` cancels the run under the cursor, `t` retries a failed one from
7 * its failed step, `g` reads again. A write is an event on the bus, so an
7 * its failed step, `R` reads again. A write is an event on the bus, so an
88 * open web page redraws.
99 */
1010
11 import { keyOf } from "../../web/keymap.ts";
1112 import { requireWriter } from "../../actions/access.ts";
1213 import { JOB_WORDS, jobRows, jobTimers, steerJob, type JobError, type JobRunRow } from "../../actions/jobs.ts";
1314 import type { Repo } from "../../core/repos.ts";
@@ -34,7 +35,7 @@ export function jobsScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
3435 const read = async (): Promise<void> => {
3536 const got = await jobRows(f.app, f.user, repo);
3637 rows = got.ok ? got.value : [];
37 note = got.ok ? (rows.length === 0 ? "This app has no job runs." : "c cancels an unfinished run, t retries a failed one, g reads again.") : JOB_TUI_WORDS[got.error];
38 note = got.ok ? (rows.length === 0 ? "This app has no job runs." : "c cancels an unfinished run, t retries a failed one, R reads again.") : JOB_TUI_WORDS[got.error];
3839 ctx.invalidate();
3940 };
4041 const steer = async (action: "cancel" | "retry"): Promise<void> => {
@@ -46,7 +47,7 @@ export function jobsScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
4647 };
4748 return {
4849 title: `${repo.ownerName}/${repo.name} — Job runs`,
49 keys: [binding(["j", "k"], "move cursor"), binding(["c"], "cancel"), binding(["t"], "retry from the failed step"), binding(["g"], "read again")],
50 keys: [binding(["j", "k"], "move cursor"), binding(["c"], "cancel"), binding(["t"], "retry from the failed step"), binding([keyOf("reread")], "read again")],
5051 async load() {
5152 await read();
5253 },
@@ -64,7 +65,7 @@ export function jobsScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
6465 key(e) {
6566 if (state.key(e, rows.length)) return true;
6667 if (e.ctrl || e.alt) return false;
67 if (e.key === "g") void read();
68 if (e.key === keyOf("reread")) void read();
6869 else if (e.key === "c") void steer("cancel");
6970 else if (e.key === "t") void steer("retry");
7071 else return false;
src/tui/screens/largefiles.ts +3 −2
@@ -2,6 +2,7 @@
22 * A repository's large files in the terminal (#4490): the /:owner/:name/large page's rows, from
33 * the same read (`blob/large.ts`, `largeFiles`). Whoever may read the repository sees it.
44 */
5 import { keyOf } from "../../web/keymap.ts";
56 import { largeFiles, type LargeFile } from "../../blob/large.ts";
67 import { canRead, type Repo } from "../../core/repos.ts";
78 import { fileSize } from "../../web/ui.ts";
@@ -33,12 +34,12 @@ export function largeFilesScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
3334 load();
3435 return {
3536 title: `${repo.ownerName}/${repo.name} — Large files`,
36 keys: [binding(["j", "k"], "move cursor"), binding(["g"], "read again")],
37 keys: [binding(["j", "k"], "move cursor"), binding([keyOf("reread")], "read again")],
3738 render(area, s) {
3839 drawList(s, area, ctx.theme.c, state, loaded ? rows : []);
3940 },
4041 key(e) {
41 if (e.key === "g") {
42 if (e.key === keyOf("reread")) {
4243 load();
4344 return true;
4445 }
src/tui/screens/moved_key.ts added +19
@@ -0,0 +1,19 @@
1 /**
2 * A key a terminal screen gave up says where it went, for two weeks (`web/keymap.ts`
3 * OLD_KEYS_UNTIL), as the keymap's own moved keys do: pressing the old one shows the new one and
4 * does nothing else.
5 *
6 * Screens give up `g` alone so that `g` can start a jump, as it does on the web: "read again"
7 * went to `R` (the map's `reread`, hinted by the app for every screen that refreshes on it), and
8 * each screen's own `g` went to a letter of its verb.
9 */
10 import { oldKeysHinted } from "../../web/keymap.ts";
11 import type { Ctx } from "../app/app.ts";
12 import type { KeyEvent } from "../term/input.ts";
13
14 /** True, after saying `says`, when `e` is the key `was` and the hint's date has not passed. */
15 export function movedKey(ctx: Ctx, e: KeyEvent, was: string, says: string): boolean {
16 if (e.ctrl || e.alt || e.key !== was || !oldKeysHinted()) return false;
17 ctx.toast(says);
18 return true;
19 }
src/tui/screens/system.ts +4 −2
@@ -33,6 +33,7 @@
3333 * what is off, from the last reading, gated as the rest.
3434 */
3535
36 import { movedKey } from "./moved_key.ts";
3637 import type { Ctx, Screen } from "../app/app.ts";
3738 import type { SystemView } from "../../system/view.ts";
3839 import { rolloutLine, type ForgeHealth } from "../../kernel/guard.ts";
@@ -442,7 +443,7 @@ export function systemScreen(ctx: Ctx, lines: readonly string[], session: Sessio
442443 };
443444 const screen: Screen = {
444445 title: "System",
445 keys: [binding(["h"], "window"), ...(reads ? [binding(["d"], "database size")] : []), ...(mayReadAtlas(session?.user) ? [binding(["a"], "tables")] : []), ...(offered ? [binding(["g"], "grant or take back telemetry")] : []), ...(canSeeMemory(session.user) ? [binding(["x"], "explore series")] : []), binding(["enter", "esc", "q"], "close")],
446 keys: [binding(["h"], "window"), ...(reads ? [binding(["d"], "database size")] : []), ...(mayReadAtlas(session?.user) ? [binding(["a"], "tables")] : []), ...(offered ? [binding(["T"], "grant or take back telemetry")] : []), ...(canSeeMemory(session.user) ? [binding(["x"], "explore series")] : []), binding(["enter", "esc", "q"], "close")],
446447 render(area, s) {
447448 const features = featuresLines(session);
448449 // Never waits on the walk: the last measurement, a new one started behind it when stale.
@@ -481,7 +482,8 @@ export function systemScreen(ctx: Ctx, lines: readonly string[], session: Sessio
481482 if (e.key === "h") {
482483 span = (span + 1) % WINDOWS.length;
483484 history = historyLines(session, WINDOWS[span]!);
484 } else if (e.key === "g") askGrant();
485 } else if (e.key === "T") askGrant();
486 else if (e.key === "g") movedKey(ctx, e, "g", "T grants or takes back telemetry now");
485487 else if (e.key === "x" && canSeeMemory(session.user)) later(ctx, () => seriesScreen(session, ctx));
486488 else if (e.key === "d" && reads) later(ctx, () => dbSizeScreen(session, ctx));
487489 else if (e.key === "a" && mayReadAtlas(session.user)) later(ctx, () => abstractionsScreen(session, ctx));
src/web/keymap.ts +9
@@ -139,6 +139,7 @@ export const OLD_KEYS: readonly OldKey[] = [
139139 { page: "runs", was: "S", now: "wheel" },
140140 { page: "runs", was: "a", now: "requeue" },
141141 { page: "terminal", was: "r", now: "reread" },
142 { page: "terminal", was: "g", now: "reread" },
142143 { page: "next", was: "t", now: "top" },
143144 { page: "next", was: "u", now: "raise" },
144145 { page: "next", was: "d", now: "lower" },
@@ -158,6 +159,14 @@ export function oldKeys(page: OldKey["page"], now: Date = oldKeysClock ?? new Da
158159 }
159160
160161 let oldKeysClock: Date | undefined;
162 /**
163 * Whether a moved key is still hinted: before {@link OLD_KEYS_UNTIL}, on the same clock as {@link
164 * oldKeys}.
165 */
166 export function oldKeysHinted(now: Date = oldKeysClock ?? new Date()): boolean {
167 return now.getTime() < Date.parse(OLD_KEYS_UNTIL);
168 }
169
161170 /**
162171 * A test's clock for {@link oldKeys} on served pages, so a hint test means the same on any date;
163172 * undefined reads the clock again.
test/egress-admin.test.ts +1 −1
@@ -97,7 +97,7 @@ describe("egress grants in the terminal", () => {
9797 await h.openAbout();
9898 await h.press("e");
9999 await settleUntil(h.tui, "asked for, not granted");
100 await h.press("g");
100 await h.press("a");
101101 await settleUntil(h.tui, "reach");
102102 expect(grants()).toEqual([]);
103103 await h.press("y");
test/keymap-terminal.test.ts +42 −1
@@ -7,7 +7,8 @@
77 import { expect, test } from "bun:test";
88 import { readFileSync } from "node:fs";
99 import { join } from "node:path";
10 import { keyOf } from "../src/web/keymap.ts";
10 import { keyOf, OLD_KEYS_UNTIL, provideOldKeysClockForTest } from "../src/web/keymap.ts";
11 import { movedKey } from "../src/tui/screens/moved_key.ts";
1112
1213 const ROOT = join(import.meta.dir, "..");
1314
@@ -87,3 +88,43 @@ test("the scan catches the shapes a refresh on r takes", () => {
8788 expect(hits(`binding(["r"], "rename")`)).toEqual([]);
8889 expect(hits(`binding([keyOf("reread")], "refresh")`)).toEqual([]);
8990 });
91
92 /** A terminal binding that takes g by itself, with what it is called. */
93 const G_BINDING = /binding\(\[(?:"[^"]*",\s*)*"g"(?:,\s*"[^"]*")*\],\s*(["`])([^"`]*)\1/g;
94
95 /**
96 * A handler that reads the key g itself (`e.key === "g"`). Not a moved key's hint (`movedKey`), a
97 * chord with Ctrl (`e.ctrl &&`), or the lists' own top, which reads g with Home until the
98 * terminal's jumps take `g g` for it.
99 */
100 const G_HANDLER = /^.*e\.key\s*===\s*"g".*$/gm;
101 const G_ALLOWED = /movedKey|e\.ctrl\s*&&|"home"/;
102
103 test("no terminal screen takes g for a verb of its own: g is to start a jump, as on the web", () => {
104 const sources = terminalSources();
105 const taken: string[] = [];
106 for (const [path, text] of Object.entries(sources))
107 for (const m of text.matchAll(G_HANDLER)) {
108 if (G_ALLOWED.test(m[0])) continue;
109 const line = text.slice(0, m.index).split("\n").length;
110 taken.push(`${path}:${line}: reads the key g: read again is ${keyOf("reread")}; any other verb takes a letter of its own`);
111 }
112 for (const [path, text] of Object.entries(sources))
113 for (const m of text.matchAll(G_BINDING))
114 // The lists' own top and end (g, G) stay until the jump arrives and takes g g for the top.
115 if (m[2] !== "top, end") taken.push(`${path}: g "${m[2]}": read again is ${keyOf("reread")}; any other verb takes a letter of its own`);
116 expect(taken).toEqual([]);
117 });
118
119 test("a screen's moved g says where it went until the date, and nothing after", () => {
120 const said: string[] = [];
121 const ctx = { toast: (t: string) => void said.push(t) } as unknown as Parameters<typeof movedKey>[0];
122 const key = (k: string) => ({ key: k, ctrl: false, alt: false, shift: false }) as Parameters<typeof movedKey>[1];
123 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 1));
124 expect(movedKey(ctx, key("g"), "g", "G grants now")).toBe(true);
125 expect(movedKey(ctx, key("G"), "g", "G grants now")).toBe(false);
126 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL)));
127 expect(movedKey(ctx, key("g"), "g", "G grants now")).toBe(false);
128 provideOldKeysClockForTest(undefined);
129 expect(said).toEqual(["G grants now"]);
130 });
test/keymap.test.ts +5 −1
@@ -143,7 +143,11 @@ test("both doors share one meaning per key: R refreshes a terminal screen, / fil
143143 // No terminal key differs from the web's: Next up's not now is p too, and its planner pause is P.
144144 expect((Object.entries(KEYMAP) as [string, KeyDef][]).filter(([, d]) => d.terminal !== undefined).map(([id]) => id)).toEqual([]);
145145 expect([keyOf("park"), keyOf("pausePlanner")]).toEqual(["p", "P"]);
146 expect(oldKeys("terminal", new Date(Date.parse(OLD_KEYS_UNTIL) - 1))).toEqual([{ was: "r", key: "R", says: "R is refresh now" }]);
146 // g read again too, on the screens that took g for it (slice 4a): g is to start a jump.
147 expect(oldKeys("terminal", new Date(Date.parse(OLD_KEYS_UNTIL) - 1))).toEqual([
148 { was: "r", key: "R", says: "R is refresh now" },
149 { was: "g", key: "R", says: "R is refresh now" },
150 ]);
147151 });
148152
149153 test("the g jumps the map names are go_pages.ts's", () => {
test/move-machine-doors.test.ts +2 −2
@@ -104,7 +104,7 @@ test("a cross-origin post does not move anything", async () => {
104104 expect(routeOf(app, "gamma")).toBeUndefined();
105105 });
106106
107 test("the terminal's Forges screen drives the same plan and move on g", async () => {
107 test("the terminal's Forges screen drives the same plan and move on M", async () => {
108108 forge("epsilon");
109109 const alice = app.db.query<{ id: string }, []>("SELECT id FROM user WHERE username = 'alice'").get()!;
110110 const user = getUserById(app.db, alice.id)!;
@@ -115,7 +115,7 @@ test("the terminal's Forges screen drives the same plan and move on g", async ()
115115 tui.push(forgesScreen(tui.ctx, await clientRows(app), session));
116116 await settleApp(tui);
117117 const press = async (key: string): Promise<string> => (terminal.feed(key), await settleApp(tui), tui.screen.toText());
118 expect(await press("g")).toContain("Move which forge to another machine?");
118 expect(await press("M")).toContain("Move which forge to another machine?");
119119 // The picker's rows are alpha, beta, epsilon, gamma: epsilon is the third.
120120 await press("\x1b[B");
121121 await press("\x1b[B");
test/tui-autonomy.test.ts +2 −2
@@ -314,14 +314,14 @@ describe("autonomy in the terminal", () => {
314314 const h = boot(ada);
315315 await h.open();
316316 expect(h.text()).toContain("Checks 1 at once guaranteed, of the forge's 8");
317 await h.press("g");
317 await h.press("C");
318318 for (let i = 0; i < 4; i++) await h.press("backspace");
319319 await h.type("2");
320320 await h.press("enter");
321321 expect(saved().checkSlots).toBe(2);
322322 expect(h.text()).toContain("Checks 2 at once guaranteed");
323323 // More than the pool leaves for the others is refused with the page's sentence.
324 await h.press("g");
324 await h.press("C");
325325 for (let i = 0; i < 4; i++) await h.press("backspace");
326326 await h.type("99");
327327 await h.press("enter");
test/tui-boards-rename.test.ts +6 −6
@@ -1,5 +1,5 @@
11 /**
2 * `e` renames and `g` sets the range of the marked board on the Boards list
2 * `e` renames and `t` sets the range of the marked board on the Boards list
33 * (#8033), through the action the board page uses; nobody but an admin person
44 * is offered either key.
55 */
@@ -106,16 +106,16 @@ describe("tui boards: rename and range", () => {
106106 expect((await board()).title).toBe("Weekly runs");
107107 });
108108
109 test("g is prefilled with the range and changes it, keeping the refresh", async () => {
109 test("t is prefilled with the range and changes it, keeping the refresh", async () => {
110110 await writeBoard(app, carol, "runs", { title: "Weekly runs", range: "7d", refresh: "1m", panels: (await board()).panels });
111 const opened = await screenText(carol, "g");
111 const opened = await screenText(carol, "t");
112112 expect(opened).toContain("Board range");
113113 expect(opened).toContain("7d");
114 expect(await screenText(carol, "g" + BACK + BACK + "24h\r")).toContain("range changed");
114 expect(await screenText(carol, "t" + BACK + BACK + "24h\r")).toContain("range changed");
115115 const now = await board();
116116 expect(now.range).toBe("24h");
117117 expect(now.refresh).toBe("1m");
118 expect(await screenText(carol, "g" + BACK.repeat(3) + "2w\r")).toContain("That was refused");
118 expect(await screenText(carol, "t" + BACK.repeat(3) + "2w\r")).toContain("That was refused");
119119 expect((await board()).range).toBe("24h");
120120 });
121121
@@ -125,7 +125,7 @@ describe("tui boards: rename and range", () => {
125125 for (const who of [bob, bot, undefined]) {
126126 const text = await screenText(who);
127127 expect(text).not.toContain("e rename");
128 expect(text).not.toContain("g range");
128 expect(text).not.toContain("t range");
129129 await screenText(who, "eZ\r");
130130 await screenText(who, "gx\r");
131131 }
test/tui-crew-devices.test.ts +4 −4
@@ -78,7 +78,7 @@ test("a repository admin lists, reads and unlists, with no grant key; the web pa
7878 const { tui, session } = open(cy);
7979 await settleApp(tui);
8080 expect(tui.screen.toText()).toContain("a site admin grants");
81 expect(tui.screen.toText()).not.toContain("g grants");
81 expect(tui.screen.toText()).not.toContain("G grants");
8282 tui.dispatch(key("a"));
8383 await settleApp(tui);
8484 type(tui, PI);
@@ -95,7 +95,7 @@ test("a repository admin lists, reads and unlists, with no grant key; the web pa
9595 expect(await (await fetch(`${servers.url}/cy/arm/settings/devices`, { headers: { cookie: adaCookie } })).text()).toContain("100.89.95.68:22");
9696
9797 // g does nothing for a repository admin who is no site admin.
98 tui.dispatch(key("g"));
98 tui.dispatch(key("G"));
9999 await settleApp(tui);
100100 expect(devicesView(app, cy, repo).ok && (devicesView(app, cy, repo) as { value: { devices: { granted: boolean }[] } }).value.devices[0]!.granted).toBe(false);
101101 expect(events).not.toContain("crew.device.granted");
@@ -118,8 +118,8 @@ test("a site admin grants from the terminal with a pasted host key, and it is an
118118 const off = app.bus.subscribe((e) => events.push(e.kind));
119119 const { tui } = open(ada);
120120 await settleApp(tui);
121 expect(tui.screen.toText()).toContain("g grants");
122 tui.dispatch(key("g"));
121 expect(tui.screen.toText()).toContain("G grants");
122 tui.dispatch(key("G"));
123123 await settleApp(tui);
124124 tui.dispatch({ type: "paste", text: HOST_KEY });
125125 tui.dispatch(key("enter"));
test/tui-egress.test.ts +26 −8
@@ -138,14 +138,14 @@ describe("private destinations in the terminal", () => {
138138 expect(h.text()).toContain(ARM);
139139 expect(h.text()).toContain(CAMERA);
140140 expect(h.text()).toContain("asked for, not granted");
141 await h.press("g");
141 await h.press("a");
142142 expect(h.text()).toContain(`Let acme/arm reach ${ARM}?`);
143143 expect(grants()).toEqual([]);
144144 await h.press("y");
145145 expect(grants()).toEqual([ARM]);
146146 expect(h.text()).toContain(`${ARM} is granted.`);
147 // Already granted: `g` asks nothing and grants nothing again.
148 await h.press("g");
147 // Already granted: `a` asks nothing and grants nothing again.
148 await h.press("a");
149149 expect(h.text()).not.toContain(`Let acme/arm reach ${ARM}?`);
150150 expect(h.text()).toContain("granted by ada");
151151 expect(changes().map((e) => e.kind)).toEqual(["app.egress.granted"]);
@@ -162,13 +162,13 @@ describe("private destinations in the terminal", () => {
162162 const h = boot(ada);
163163 await h.toAbout();
164164 await h.press("e");
165 await h.press("g");
165 await h.press("a");
166166 await h.press("y");
167167 expect(grants()).toEqual([ARM]);
168168 const before = changes().length;
169169 await h.press("x");
170170 expect(h.text()).toContain(`Stop acme/arm reaching ${ARM}?`);
171 expect(h.text()).toContain("refused until g grants it again.");
171 expect(h.text()).toContain("refused until a grants it again.");
172172 await h.press("n");
173173 expect(h.text()).not.toContain(`Stop acme/arm reaching ${ARM}?`);
174174 await h.press("x");
@@ -182,12 +182,30 @@ describe("private destinations in the terminal", () => {
182182 h.stop();
183183 });
184184
185 test("a site admin who presses g then n grants nothing", async () => {
185 test("the old g, before its date, says a grants now and does nothing else: no prompt, no grant", async () => {
186 const { OLD_KEYS_UNTIL, provideOldKeysClockForTest } = await import("../src/web/keymap.ts");
187 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
188 const before = changes().length;
189 const h = boot(ada);
190 try {
191 await h.toAbout();
192 await h.press("e");
193 await h.press("g");
194 expect(h.text()).toContain("a grants now");
195 expect(h.text()).not.toContain(`Let acme/arm reach ${ARM}?`);
196 expect(changes().length).toBe(before);
197 } finally {
198 provideOldKeysClockForTest(undefined);
199 h.stop();
200 }
201 });
202
203 test("a site admin who presses a then n grants nothing", async () => {
186204 const before = changes().length;
187205 const h = boot(ada);
188206 await h.toAbout();
189207 await h.press("e");
190 await h.press("g");
208 await h.press("a");
191209 expect(h.text()).toContain(`Let acme/arm reach ${ARM}?`);
192210 expect(h.text()).toContain("The app's outbound traffic to it is allowed until you revoke it with x.");
193211 await h.press("n");
@@ -196,7 +214,7 @@ describe("private destinations in the terminal", () => {
196214 expect(changes().length).toBe(before);
197215 const view = await egressView(forge, ada, repo);
198216 expect(view.ok && view.value.rows.find((r) => r.destination === ARM)?.granted).toBe(false);
199 await h.press("g");
217 await h.press("a");
200218 expect(h.text()).toContain(`Let acme/arm reach ${ARM}?`);
201219 await h.press("esc");
202220 expect(h.text()).not.toContain(`Let acme/arm reach ${ARM}?`);
test/tui-games.test.ts +18 −2
@@ -2,7 +2,7 @@
22 * Games in the terminal, both doors (review of #16913): from the Games screen, `enter` opens a
33 * service's console (its log tail, and `:` queues an rcon command), env (`e` commits a key through
44 * the page's own `commitServiceEnv`, refusals in its words) and plugins (`a` adds a Modrinth slug
5 * through `addPlugin`; a jar upload is the page's alone, and the screen says so), and `g` opens the
5 * through `addPlugin`; a jar upload is the page's alone, and the screen says so), and `G` opens the
66 * box's grants, which only an owner sets.
77 */
88 import { afterAll, beforeAll, expect, test } from "bun:test";
@@ -15,7 +15,7 @@ import { createUser, getUserByName, type User } from "../src/core/users.ts";
1515 import { readCompose, serviceEnv } from "../src/games/compose.ts";
1616 import { boxNamed, createGameBox, grantsOf, recentCommands, recordSync } from "../src/games/store.ts";
1717 import { createForgeApp } from "../src/tui/forge.ts";
18 import { gameGrantsScreen, gameServiceScreen } from "../src/tui/screens/games.ts";
18 import { gameGrantsScreen, gameServiceScreen, gamesScreen } from "../src/tui/screens/games.ts";
1919 import { headlessTerminal } from "../src/tui/term/terminal.ts";
2020 import { quietLogs } from "./helpers/globals.ts";
2121 import { settleApp, settleUntil } from "./helpers/tui.ts";
@@ -149,3 +149,19 @@ test("grants: listed to the box's owner, set by them; a member who is not an own
149149 expect(tui.screen.toText()).toContain("bob is operator of hub.");
150150 tui.stop?.();
151151 });
152
153 test("on the games list, the old g, before its date, says G opens the grants and opens nothing, ahead of the list's own top", async () => {
154 const { OLD_KEYS_UNTIL, provideOldKeysClockForTest } = await import("../src/web/keymap.ts");
155 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
156 const { tui, session, type } = drive(alice);
157 try {
158 tui.ctx.push(gamesScreen(session, tui.ctx));
159 await settleApp(tui);
160 await type("g");
161 expect(tui.screen.toText()).toContain("G opens the grants now");
162 expect(tui.screen.toText()).not.toContain("Only an owner of this box sets grants.");
163 } finally {
164 provideOldKeysClockForTest(undefined);
165 tui.stop?.();
166 }
167 });
test/tui-issue-goahead.test.ts +23 −7
@@ -123,7 +123,7 @@ describe("go ahead in the terminal", () => {
123123 try {
124124 await openWaiting(h);
125125 expect(h.text()).not.toContain("go ahead");
126 await h.press("g");
126 await h.press("y");
127127 expect(heldBlockers(forge.db, waiting.id)).toHaveLength(1);
128128 } finally {
129129 h.app.stop();
@@ -136,7 +136,7 @@ describe("go ahead in the terminal", () => {
136136 await openWaiting(h);
137137 expect(h.text()).toContain(`#${blocker.number} (dropped)`);
138138 expect(h.text()).not.toContain("go ahead");
139 await h.press("g");
139 await h.press("y");
140140 expect(h.text()).not.toContain("Let it go ahead?");
141141 expect(heldBlockers(forge.db, waiting.id)).toHaveLength(1);
142142 } finally {
@@ -150,7 +150,7 @@ describe("go ahead in the terminal", () => {
150150 await openWaiting(h);
151151 expect(h.text()).toContain(`#${blocker.number} (dropped)`);
152152 expect(h.text()).not.toContain("go ahead");
153 await h.press("g");
153 await h.press("y");
154154 expect(h.text()).not.toContain("Let it go ahead?");
155155 expect(heldBlockers(forge.db, waiting.id)).toHaveLength(1);
156156 } finally {
@@ -158,11 +158,27 @@ describe("go ahead in the terminal", () => {
158158 }
159159 });
160160
161 test("the old g, before its date, says y goes ahead now and asks nothing", async () => {
162 const { OLD_KEYS_UNTIL, provideOldKeysClockForTest } = await import("../src/web/keymap.ts");
163 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
164 const h = boot(alice);
165 try {
166 await openWaiting(h);
167 await h.press("g");
168 expect(h.text()).toContain("y goes ahead now");
169 expect(h.text()).not.toContain("Let it go ahead?");
170 expect(heldBlockers(forge.db, waiting.id)).toHaveLength(1);
171 } finally {
172 provideOldKeysClockForTest(undefined);
173 h.app.stop();
174 }
175 });
176
161177 test("enter on the default choice cancels and leaves the wait", async () => {
162178 const h = boot(alice);
163179 try {
164180 await openWaiting(h);
165 await h.press("g");
181 await h.press("y");
166182 await settleUntil(h.app, "Let it go ahead?");
167183 await h.press("enter");
168184 expect(heldBlockers(forge.db, waiting.id)).toHaveLength(1);
@@ -178,7 +194,7 @@ describe("go ahead in the terminal", () => {
178194 await openWaiting(h);
179195 expect(h.text()).toContain(`#${blocker.number} (dropped)`);
180196 expect(h.text()).toContain("go ahead");
181 await h.press("g");
197 await h.press("y");
182198 await settleUntil(h.app, "Let it go ahead?");
183199 await h.press("left", "enter");
184200 await settleUntil(h.app, "may go ahead");
@@ -194,7 +210,7 @@ describe("go ahead in the terminal", () => {
194210 try {
195211 await openWaiting(h);
196212 expect(h.text()).not.toContain("closed without being done");
197 await h.press("g");
213 await h.press("y");
198214 expect(h.text()).not.toContain("Let it go ahead?");
199215 } finally {
200216 h.app.stop();
@@ -205,7 +221,7 @@ describe("go ahead in the terminal", () => {
205221 const h = boot(alice);
206222 try {
207223 await openWaiting(h, "pending", many.number);
208 await h.press("g");
224 await h.press("y");
209225 await settleUntil(h.app, "Go ahead without");
210226 await h.press("enter");
211227 await settleUntil(h.app, "Let it go ahead?");
test/tui-origin-follow.test.ts +24 −7
@@ -37,10 +37,11 @@ const ok = <T>(r: { ok: true; value: T } | { ok: false; error: unknown }): T =>
3737
3838 function card(user: User) {
3939 const pushed: Screen[] = [];
40 const said: string[] = [];
4041 const ctx = {
4142 theme: theme("dark"),
4243 invalidate() {},
43 toast() {},
44 toast: (text: string) => void said.push(text),
4445 push: (s: Screen) => pushed.push(s),
4546 pop() {},
4647 copy() {},
@@ -50,6 +51,7 @@ function card(user: User) {
5051 const screen = aboutScreen(f, ctx, { render() {} } as unknown as Screen, src, undefined, "main");
5152 return {
5253 pushed,
54 said,
5355 offered: (key: string) => screen.keys.some((b) => b.keys.includes(key)),
5456 press: (key: string) => screen.key!(pressed(key)),
5557 };
@@ -81,10 +83,10 @@ afterAll(async () => {
8183 await rm(dir, { recursive: true, force: true, maxRetries: 5 });
8284 });
8385
84 test("the admin who brought it is offered `g`, and only the confirm follows", () => {
86 test("the admin who brought it is offered `F`, and only the confirm follows", () => {
8587 const c = card(alice);
86 expect(c.offered("g")).toBe(true);
87 expect(c.press("g")).toBe(true);
88 expect(c.offered("F")).toBe(true);
89 expect(c.press("F")).toBe(true);
8890 expect(getFollow(app.db, repo.id)?.enabled).toBe(false);
8991 const confirm = c.pushed[0]!;
9092 expect(confirm.title).toBe("Follow where it came from");
@@ -94,12 +96,27 @@ test("the admin who brought it is offered `g`, and only the confirm follows", ()
9496 confirm.key!(pressed("right"));
9597 confirm.key!(pressed("enter"));
9698 expect(getFollow(app.db, repo.id)?.enabled).toBe(true);
97 expect(card(alice).offered("g")).toBe(true);
99 expect(card(alice).offered("F")).toBe(true);
98100 });
99101
100102 test("someone who did not bring it is offered nothing", () => {
101103 const c = card(carol);
102 expect(c.offered("g")).toBe(false);
103 c.press("g");
104 expect(c.offered("F")).toBe(false);
105 c.press("F");
104106 expect(c.pushed).toEqual([]);
105107 });
108
109 test("the old g, before its date, says F follows now and asks nothing", async () => {
110 const { OLD_KEYS_UNTIL, provideOldKeysClockForTest } = await import("../src/web/keymap.ts");
111 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
112 try {
113 const c = card(alice);
114 const before = getFollow(app.db, repo.id)?.enabled;
115 expect(c.press("g")).toBe(true);
116 expect(c.said).toEqual(["F follows now"]);
117 expect(c.pushed).toEqual([]);
118 expect(getFollow(app.db, repo.id)?.enabled).toBe(before);
119 } finally {
120 provideOldKeysClockForTest(undefined);
121 }
122 });
test/tui-system.test.ts +22 −6
@@ -330,22 +330,38 @@ describe("tui system telemetry grant", () => {
330330 return { tui, press };
331331 };
332332
333 test("the old g, before its date, says T and asks nothing", async () => {
334 const { OLD_KEYS_UNTIL, provideOldKeysClockForTest } = await import("../src/web/keymap.ts");
335 provideOldKeysClockForTest(new Date(Date.parse(OLD_KEYS_UNTIL) - 86_400_000));
336 const h = boot(carol);
337 try {
338 await settleApp(h.tui);
339 await h.press("g");
340 expect(h.tui.screen.toText()).toContain("T grants or takes back telemetry now");
341 expect(h.tui.screen.toText()).not.toContain("telemetry:read? y/n");
342 expect(hasGrant(app.db, bot.id)).toBe(false);
343 } finally {
344 provideOldKeysClockForTest(undefined);
345 h.tui.stop?.();
346 }
347 });
348
333349 test("an admin grants and takes back after a confirm", async () => {
334350 const h = boot(carol);
335351 await settleApp(h.tui);
336352 expect(h.tui.screen.toText()).toContain("telemetry:read held by: no agent");
337 await h.press("g");
353 await h.press("T");
338354 await h.press("enter");
339355 expect(h.tui.screen.toText()).toContain("grant sysbot telemetry:read? y/n");
340356 await h.press("left", "enter");
341357 expect(hasGrant(app.db, bot.id)).toBe(true);
342358 expect(h.tui.screen.toText()).toContain("telemetry:read held by: sysbot");
343 await h.press("g");
359 await h.press("T");
344360 await h.press("enter");
345361 expect(h.tui.screen.toText()).toContain("take back sysbot telemetry:read? y/n");
346362 await h.press("enter");
347363 expect(hasGrant(app.db, bot.id)).toBe(true);
348 await h.press("g");
364 await h.press("T");
349365 await h.press("enter");
350366 await h.press("left", "enter");
351367 expect(hasGrant(app.db, bot.id)).toBe(false);
@@ -356,7 +372,7 @@ describe("tui system telemetry grant", () => {
356372 const h = boot(bob);
357373 await settleApp(h.tui);
358374 expect(h.tui.screen.toText()).not.toContain("telemetry:read");
359 await h.press("g");
375 await h.press("T");
360376 expect(h.tui.screen.toText()).toContain("telemetry:read is a forge admin's to grant");
361377 expect(h.tui.screen.toText()).not.toContain("Grant telemetry:read to");
362378 expect(h.tui.screen.toText()).toContain("CPU");
@@ -365,14 +381,14 @@ describe("tui system telemetry grant", () => {
365381 h.tui.stop?.();
366382 });
367383
368 test("the System command passes the session, so the admin has the line and g", async () => {
384 test("the System command passes the session, so the admin has the line and T", async () => {
369385 const { app: tui, session } = createForgeApp(app, identity(carol), { terminal: headlessTerminal(120, 70), exitHooks: false });
370386 tui.start();
371387 const system = forgeCommands(session)(tui.ctx).find((c) => c.id === "system");
372388 system!.run();
373389 await settleApp(tui);
374390 expect(tui.screen.toText()).toContain("telemetry:read held by:");
375 tui.dispatch({ type: "key", key: "g", ctrl: false, alt: false, shift: false });
391 tui.dispatch({ type: "key", key: "T", ctrl: false, alt: false, shift: false });
376392 await settleApp(tui);
377393 expect(tui.screen.toText()).toContain("Grant telemetry:read to");
378394 tui.stop?.();

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

Keyboard shortcuts

Docs