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

The top bar names the areas: Apps, Games, Infrastructure, Explore #17646

opened this

Merged 17h 25m ago, live in production

sold/nav-areas → main 0 commits 5 threads · 5 unresolved

  • Merged. sold/nav-areas was merged into main as 4c6a89c.

Review

Sign in to review this change.
50 files changed +537 −97
AGENTS.md +1
@@ -109,3 +109,4 @@ A pull that adds a page (`src/web/pages/*.ts`), an MCP tool (`src/http/mcp/tools
109109 `src/spawn/routes.ts`: `tables`, per data directory, the router's table of forges moved to another machine (#16859), read once from `routes.json` and kept by `setRoute`, the only writer (a rename of the whole file); at most one entry per moved forge, gone on restart (the file is the state). `src/spawn/machines.ts`: `registered`, the machines declared by `FORGE_MACHINES` (or put by a test), made on first read, and each process machine's `running` process groups by forge name; at most one per forge, gone on restart. `src/spawn/move_machine.ts`: `busy`, the forges being moved now, so a second ask is refused; gone when the move ends. The terminal door is `g` on the Forges screen (`src/tui/screens/forges.ts`; `planMove`/`moveToMachine` give the page, the MCP `forges` tool and the terminal the same words).
110110
111111 A new route of the studio's own router (`buildRouter`, `src/http/server.ts`) is added in the module of its concept under `src/http/routes/`, named for that one concept (`talk`, `accounts`, `repo_issues`, `git_http`…), never in `server.ts`, which only mounts them; `buildRouter` is the one list, so a new module is mounted there and `bun scripts/lazy-lists.ts` writes its route list (a test fails for a route module nothing mounts, #17036). The router matches in insertion order, so a literal route goes above the `/:owner…` ones: literal-path modules are called first, `repo_*` the `/:owner/:name` ones, and the few modules whose place is not obvious say why in their header (`repo_display`, `repo_api`, `migrate`). Smart-HTTP access (`withGitAccess`, `asStranger`) is `src/http/git_access.ts`.
112 `src/games/store.ts`: `players`, per database, the ids of everyone with a grant on a game box, read once per 30 s (`PLAYERS_MS`) so the top bar's Games costs no query a page; `grant`, the one writer, drops it; at most one id per person granted, gone on restart (the rows are `game_grant`).
docs/design/areas/shell.md +2 −1
@@ -3,8 +3,9 @@
33 The chrome every page sits in: a skip link, the sticky top bar with the wordmark, the main column and the footer, drawn by `page()` in `src/web/layout.ts` (the top bar by `topbar()`, its search by `searchBar()`, the footer by `footer()`); a page hands over its body and never draws the frame itself. Rules live in `src/web/style/base.ts`, the search field's and the crumbs' narrow-screen rule in `src/web/style/components.ts`.
44
55 - `.skip` — the "Skip to content" link, first in the document and hidden above the top until it has keyboard focus.
6 - `.topbar` — the `<header role="banner">` across the top of every page: wordmark, crumbs, then the tools.
6 - `.topbar` — the `<header role="banner">` across the top of every page: wordmark, areas, crumbs, then the tools.
77 - `.wordmark` — the forge's name and mark, linking home (`g h`); the mark turns on hover. Also written by the board's own header in `src/web/pages/board.ts`.
8 - `.areas` — the top bar's `<nav aria-label="Areas">`, after the wordmark: Apps, Games, Infrastructure and Explore, the `GO_PAGES` rows marked `area` (`src/web/go_pages.ts`), each viewer only those they may use, the current one by weight (`aria-current`). Games needs a grant on a box (`seesAnyBox`, one read per 30 s a process). From 720px the links are in the bar, and up to 1199px the search field gives way to its icon. Under 720px they are the bar's first line, 44px and pinned with it, on every page with a bar: a repository's, a visitor's and one that passes `tools` too. `--areas-h` adds those 44px to `--topbar-h`, so what sticks or scrolls under the bar follows. A page with tabs of its own shows them under the bar as before.
89 - `.topbar-tools` — the top bar's right-hand group (search, Asks, the new and user menus): one row that may shrink but never wraps, its bare `a.small` links 44px tall.
910 - `.topbar-search` — the top bar's search form: an icon, a borderless input and its `/` key hint in one bordered pill, the border taking the accent on focus. Shown from 720px; below that the icon button carries search.
1011 - `.hide-lg` — shown under 720px, hidden from 720px: the narrow-screen stand-in for something `.hide-sm` shows on wide screens (the search icon button beside `.topbar-search`).
docs/design/plan.md +1 −1
@@ -23,5 +23,5 @@ Each item is one filed issue, small enough for one run; items 4–9 wait for the
2323 `chain`): one line each on why it is a page; retire or turn into board panels.
2424 10. **#2697 Tokenise `style/content.ts`** — 23 colours, 31 sizes; the largest debt.
2525 11. **#2698 Tokenise `style/components.ts`, `studio/home.ts`, `pages/looks.ts`, `pages/site.ts`.**
26 12. **#2699 Top bar diet** — at most search, New, and the user menu on the left of the fold.
26 12. **#2699 Top bar diet** — replaced: the top bar names the areas (docs/design/areas/shell.md).
2727 13. **#2700 Class rule against DESIGN.md §5** — done: 13 classes no page drew are gone, the other 505 page-local ones are registered in DESIGN.md §5d, and the check reads §5 rather than the baseline. Items 4–12 retire §5d entries as they redo each page.
docs/design/size-budget/changelog.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/changelog",
3 "js": 30720,
3 "js": 30976,
44 "css": 52992
55 }
docs/design/size-budget/claim.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/claim",
3 "js": 28160,
3 "js": 28416,
44 "css": 52992
55 }
docs/design/size-budget/explore.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/explore",
3 "js": 25344,
3 "js": 25600,
44 "css": 52992
55 }
docs/design/size-budget/fleet.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/fleet",
3 "js": 25344,
3 "js": 25600,
44 "css": 52992
55 }
docs/design/size-budget/forges-new.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/forges/new",
3 "js": 25344,
3 "js": 25600,
44 "css": 52992
55 }
docs/design/size-budget/home.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/",
3 "js": 25600,
3 "js": 25856,
44 "css": 52992
55 }
docs/design/size-budget/maintenance.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/maintenance",
3 "js": 25344,
3 "js": 25600,
44 "css": 52992
55 }
docs/design/size-budget/pricing.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/pricing",
3 "js": 25344,
3 "js": 25600,
44 "css": 52992
55 }
docs/design/size-budget/templates.json +1 −1
@@ -1,5 +1,5 @@
11 {
22 "page": "/templates",
3 "js": 25344,
3 "js": 25600,
44 "css": 52992
55 }
docs/features/games.md +1
@@ -8,6 +8,7 @@ A **game box** is a VM on your own cloud running Docker and `forge-game-agent`,
88
99 ## Where
1010
11 - **In the navigation:** Games is in the top bar, at `g p` (`g P` inside a repository), in Cmd/Ctrl K and in the terminal's palette, for a forge admin and anyone with a grant on a box. With no box, an admin's `/games` has Start a game box: it asks Talk for a plan, which builds nothing until approved. In the terminal `n` on an empty Games screen sends the same words.
1112 - **Web:** `/games` lists the boxes you may see; `/games/<box>` is the network, one row a service with Start, Stop and Restart; `/games/<box>/<service>` is the console (a live log over SSE in the game's own colours: the agent and the sync route turn each colour escape into its § code before they drop every other escape, and the page draws § codes through the one renderer, with Raw for the lines as kept; an RCON input whose answer shows inline, with the service's earlier commands on up and down; a crash found in the log leads in one line, "Crashed: Fabric could not load the mods: Install fabric-api", with the crash folded under it and a Share on mclo.gs button that says it publishes the log where anyone with the link can read it, and posts only on that click), the environment editor (commits `games: <service> env: <keys>`), the settings ([Game settings](game-settings.md)) and its mods or plugins (Modrinth, below; Upload jar for `PLUGINS`). Pages: `src/web/pages/games.ts`.
1213 - **Terminal:** the Games screen (`src/tui/screens/games.ts`): each service, `s`, `x`, `r`; `enter` opens its console and env, `c` there its settings, and `m` its mods (`/` search, `a` install, `u` update all, `d` remove, then `y` commits the preview shown); a service's console reads its log with the colour codes gone, a crash first in one line, and `:`'s prompt walks earlier commands with up and down.
1314 - **MCP:** `games` (admin-listed): `list`, `console`, `power`, `env`, `config`, `config_set`, and `mods`, `mods_search`, `mods_install`, `mods_update`, `mods_remove` (each change planned first; `dryRun: false` commits), with the same grants.
docs/features/go-jumps.md +11 −5
@@ -9,15 +9,21 @@ Press `g`, then a letter within one second, from any page outside a field. Modif
99 | Keys | Page | Who |
1010 |---|---|---|
1111 | `g h` | Home | everyone |
12 | `g a` | Apps | everyone |
13 | `g p` | Games | admins, and anyone with a grant on a game box |
14 | `g i` | Infrastructure | admins |
1215 | `g e` | Explore | everyone |
13 | `g f` | Flow | signed in |
14 | `g q` | Asks | signed in |
1516 | `g t` | Talk | signed in |
16 | `g s` | System | admins |
17 | `g n` | Next up | signed in |
18 | `g f` | Flow | admins |
19 | `g b` | Boards | admins |
20 | `g y` | System | admins |
21
22 Inside a repository `g p`, `g i` and `g b` are its pull requests, issues and branches, so Games, Infrastructure and Boards are `g P`, `g I` and `g B` there. `?` lists them that way.
1723
1824 - A page the viewer cannot open does nothing (no error, no redirect to sign-in): the script only knows the pages for the viewer's level.
1925 - The table is `GO_PAGES` in `src/web/go_pages.ts`, the same list as the `:` prompt and Cmd/Ctrl K. A page gets a jump by giving it a `key` there; a test refuses a letter used twice. `?` lists the jumps the viewer has, read from that table.
20 - `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.
26 - `g h` 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.
2127 - 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.
2228
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.
29 **Terminal:** `g` opens the same places, areas first (`src/tui/app/which.ts`): Games and Infrastructure are screens (`src/tui/screens/games.ts`, `src/tui/screens/infra.ts`), Apps and Explore give their web address. `g g` is the top of a list.
docs/features/keymap.md +2 −2
@@ -29,7 +29,7 @@ The owner, after the bridge: "tying together all the keybinds is really what im
2929
3030 ## Go and scopes
3131
32 `g` and a letter is a destination in the scope the page is in (`keymap.ts` `GO`, one table): inside a repository `g c` code, `g i` issues, `g p` pulls, `g r` runs, `g m` map, `g l` log (commits), `g b` branches, `g k` forks, `g s` settings; elsewhere `g h` home, `g e` explore, `g f` flow, `g t` Talk, `g n` next up, `g y` system, `g b` boards. A forge place a repository shadows is `g` and the capital there (`g B` boards), or `Space g`, or Cmd/Ctrl K. The chords that moved say where they went until 2026-12-15 when they would now do nothing (`g a`: the map is `g m`; `g s` outside a repository: System is `g y`).
32 `g` and a letter is a destination in the scope the page is in (`keymap.ts` `GO`, one table): inside a repository `g c` code, `g i` issues, `g p` pulls, `g r` runs, `g m` map, `g l` log (commits), `g b` branches, `g k` forks, `g s` settings; elsewhere `g h` home, `g a` Apps, `g p` Games, `g i` Infrastructure, `g e` explore, `g f` flow, `g t` Talk, `g n` next up, `g y` system, `g b` boards. A forge place a repository shadows is `g` and the capital there (`g B` boards, `g P` Games, `g I` Infrastructure), or `Space g`, or Cmd/Ctrl K. The chords that moved say where they went until 2026-12-15 when they would now do nothing (`g s` outside a repository: System is `g y`).
3333
3434 ## The terminal gives up g
3535
@@ -53,7 +53,7 @@ The web and the terminal answer the same tree, `g` table and `v`. The counts (`3
5353 The terminal reads the same tables (`src/tui/app/which.ts`):
5454
5555 - **`Space`, a group, a leaf.** A verb presses its key on the screen, so `Space p m` and `m` are one act. A place opens its palette command. What only a web page does (a settings page with no screen, copying a link) says so.
56 - **`g` and a letter** opens a forge place by its palette command (`g h` home, `g f` flow, `g t` Talk, `g y` System, `g b` boards, `g n` next up). **`g g`** is the top of a list, as `Home` is; `G` is still the end.
56 - **`g` and a letter** opens a forge place by its palette command (`g h` home, `g a` Apps, `g p` Games, `g i` Infrastructure, `g f` flow, `g t` Talk, `g y` System, `g b` boards, `g n` next up). **`g g`** is the top of a list, as `Home` is; `G` is still the end.
5757 - **The panel** of next keys sits at the foot while a chord is open. Escape or Backspace goes up a level, and a key that is nothing says so.
5858 - **Space is the leader only off a control.** A form's checkbox, a picker's tick and the git stage (lazygit-style) keep their Space; `test/keymap-terminal.test.ts` lists them.
5959 - **Space moved elsewhere:**
src/core/empty_words.ts +4 −1
@@ -96,13 +96,16 @@ const TABLE = {
9696 appFlags: { sentence: NO_FLAG, reason: `Add a ${FLAGS_FILE} to the repository to declare one.` },
9797 appRegistry: { sentence: "Nothing installed from the registry.", reason: "An item is noted here when it is installed." },
9898 regValues: { sentence: "No values." },
99 gameBoxes: { sentence: "Nothing runs here yet.", reason: "A game box is a machine on your cloud running a compose project; an admin makes one from Infra." },
99 gameBoxes: { sentence: "Nothing runs here yet.", reason: "A game box is a machine on your cloud running a compose project; an admin starts one." },
100100 gameServices: { sentence: "Nothing has reported yet.", reason: "The box shows its services once its agent first syncs." },
101101 gamePlugins: { sentence: "Nothing is installed.", reason: "Search Modrinth below, or upload a jar." },
102102 cloudResources: { sentence: "No cloud account is attached.", reason: "Attach one and the forge reads what it holds and what it costs." },
103103 gameSnapshots: { sentence: "No snapshot yet.", reason: "One is taken before every import or restore." },
104104 } as const satisfies Readonly<Record<string, EmptyWords>>;
105105
106 /** What Start a game box asks Talk, from the page and the terminal: `infra` plans one free, and the forge asks before it builds. */
107 export const START_BOX = "Start a game box on my cloud: plan it, show me the places and what each costs a month, and build nothing until I say so.";
108
106109 export type EmptyKind = keyof typeof TABLE;
107110
108111 export const EMPTY_WORDS: Readonly<Record<EmptyKind, EmptyWords>> = TABLE;
src/games/store.ts +22
@@ -281,7 +281,29 @@ export function seesBox(db: Database, user: User | undefined, boxId: string): bo
281281 return db.query("SELECT 1 FROM game_grant WHERE box_id = ?1 AND user_id = ?2").get(boxId, user.id) !== null;
282282 }
283283
284 /** How long who holds a grant is believed: another process's grant shows within this. */
285 export const PLAYERS_MS = 30_000;
286 /** Everyone with a grant on any box, per database; `grant`, the one writer, drops it. */
287 const players = new WeakMap<Database, { readonly at: number; readonly ids: ReadonlySet<string> }>();
288
289 /**
290 * Whether `user` may see any game box: a forge admin, or anyone with a grant. The top bar asks on
291 * every page, so it is one read per {@link PLAYERS_MS}, never one a page.
292 */
293 export function seesAnyBox(db: Database, user: User | undefined, now = Date.now()): boolean {
294 if (user === undefined) return false;
295 if (user.isAdmin) return true;
296 let held = players.get(db);
297 if (held === undefined || now - held.at >= PLAYERS_MS) {
298 const rows = db.query<{ user_id: string }, []>("SELECT DISTINCT user_id FROM game_grant").all();
299 held = { at: now, ids: new Set(rows.map((r) => r.user_id)) };
300 players.set(db, held);
301 }
302 return held.ids.has(user.id);
303 }
304
284305 export function grant(db: Database, boxId: string, userId: string, role: Role | "none", service = ""): void {
306 players.delete(db);
285307 if (role === "none") db.query("DELETE FROM game_grant WHERE box_id = ?1 AND user_id = ?2 AND service = ?3").run(boxId, userId, service);
286308 else
287309 db.query(
src/tui/app/which.ts +6
@@ -36,6 +36,9 @@ export type WhichStep = { readonly open: Chord } | { readonly act: WhichAct } |
3636 /** The forge's places, as the terminal's palette commands that open them. */
3737 const PLACE_COMMAND: Record<keyof typeof GO.global, string> = {
3838 home: "home",
39 apps: "apps",
40 games: "games",
41 infra: "infra",
3942 explore: "explore",
4043 flow: "flow",
4144 talk: "conversations",
@@ -45,6 +48,9 @@ const PLACE_COMMAND: Record<keyof typeof GO.global, string> = {
4548 };
4649 const PLACE_WORD: Record<keyof typeof GO.global, string> = {
4750 home: "Home",
51 apps: "Apps",
52 games: "Games",
53 infra: "Infrastructure",
4854 explore: "Explore",
4955 flow: "Flow",
5056 talk: "Talk",
src/tui/forge_parts.ts +9
@@ -12,6 +12,7 @@
1212 import { queueTargetsFor } from "../flow/queue_targets.ts";
1313 import { queueTargetLines } from "./screens/flow_targets.ts";
1414 import { publicOrigin } from "../core/public_origin.ts";
15 import { seesAnyBox } from "../games/store.ts";
1516 import { nearPages } from "../web/near_pages.ts";
1617 import { search } from "../actions/search.ts";
1718 import { greppable } from "../core/search.ts";
@@ -275,6 +276,13 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
275276 hint: "on the web",
276277 run: () => openOnWeb(session, ctx, "/explore", "The explorer"),
277278 },
279 {
280 // Every app the person can reach is the web's /apps; the terminal hands over its address.
281 id: "apps",
282 title: "Apps",
283 hint: "on the web",
284 run: () => openOnWeb(session, ctx, "/apps", "Apps"),
285 },
278286 {
279287 // The same list as an Atom feed (#10967): the terminal hands over
280288 // the feed's address, to copy into a reader.
@@ -337,6 +345,7 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
337345 const pages = nearPages(`/${spec}`, {
338346 signedIn: session.signedIn,
339347 admin: session.user?.isAdmin === true,
348 games: seesAnyBox(session.db, session.user),
340349 }).map((p) => p.href);
341350 return near.length === 0
342351 ? pages.length === 0
src/tui/screens/games.ts +16 −4
@@ -13,7 +13,8 @@
1313 */
1414
1515 import { movedKey } from "./moved_key.ts";
16 import { emptyText } from "../../core/empty_words.ts";
16 import { TALK_WORDS, talk } from "../../actions/talk.ts";
17 import { emptyText, START_BOX } from "../../core/empty_words.ts";
1718 import { consoleText, crashOf } from "../../games/console.ts";
1819 import { commitPolicy, policyOf, proxyPort, STILL_BILLED } from "../../games/sleep.ts";
1920 import { SHELL_SERVICE, queueShell } from "../../games/shell.ts";
@@ -45,6 +46,7 @@ import {
4546 queueCommand,
4647 recentCommands,
4748 roleOn,
49 seesAnyBox,
4850 seesBox,
4951 servicesOf,
5052 type CommandKind,
@@ -101,6 +103,8 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen {
101103 if (join === undefined) return `Each service of each game box you may see. ${NO_ADDRESS}`;
102104 return "address" in join ? `To join, add this server in Minecraft: ${join.address}` : privateWords(join.private);
103105 };
106 /** An admin of a forge with no box may start the first, as /games offers. */
107 const mayStart = (): boolean => f.user?.isAdmin === true && listBoxes(f.app.db).length === 0;
104108 const rows = () =>
105109 listBoxes(f.app.db)
106110 .filter((b) => seesBox(f.app.db, f.user, b.id))
@@ -139,7 +143,7 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen {
139143 binding(["s"], "start"),
140144 binding(["x"], "stop"),
141145 binding(["r"], "restart"),
142 binding(["n"], "new server"),
146 binding(["n"], "new server, or a first game box"),
143147 binding(["d"], "remove a server"),
144148 binding(["z"], "sleep when empty, or keep running"),
145149 binding(["L"], "link your Minecraft name (!forge)"),
@@ -161,7 +165,9 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen {
161165 ? `${booting.name}: ${bootWords(booting)}`
162166 : told !== undefined
163167 ? `${told.name}: ${lines(told)[0]}`
164 : all.length === 0
168 : mayStart()
169 ? `${emptyText("gameBoxes")} n asks Talk to plan one.`
170 : all.length === 0
165171 ? emptyText("gameServices")
166172 : joinLine();
167173 s.text(head!.x, head!.y, truncate(said, head!.w), style(booting !== undefined && note === "" && bootTroubled(booting) ? c.danger : c.mutedFg, c.bg), head!.x + head!.w);
@@ -210,6 +216,12 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen {
210216 }
211217 // A new server on the selected box (or the first you run): words in, the plan shown, yes
212218 // commits.
219 if (!e.ctrl && !e.alt && e.key === "n" && mayStart()) {
220 const said = talk(f.app, f.user, START_BOX);
221 note = said.ok ? (said.value.kept?.line ?? "Asked Talk for the plan: read it in Talk. Nothing is built until you say so.") : TALK_WORDS[said.error][1];
222 ctx.invalidate();
223 return true;
224 }
213225 if (!e.ctrl && !e.alt && e.key === "n") {
214226 const box = at?.box ?? listBoxes(f.app.db).find((b) => mayDo(roleOn(f.app.db, f.user, b.id), "operator"));
215227 if (box === undefined || !mayDo(roleOn(f.app.db, f.user, box.id), "operator")) note = "You run no game box to add a server to.";
@@ -685,6 +697,6 @@ export const entry: PaletteEntry = {
685697 title: "Games",
686698 hint: "game servers on your cloud: state, start, stop, restart",
687699 after: ["pinned"],
688 offered: (session) => session.user !== undefined,
700 offered: (session) => seesAnyBox(session.app.db, session.user),
689701 run: (session, ctx) => ctx.push(gamesScreen(session, ctx)),
690702 };
src/web/chrome.ts +2 −1
@@ -36,6 +36,7 @@ import { autonomyStatus } from "../crew/autonomy_status.ts";
3636 import { mayRaiseCeiling } from "../actions/crew_ceiling.ts";
3737 import { stopWords } from "../crew/stop_words.ts";
3838 import { icon } from "./icons.ts";
39 import { seesAnyBox } from "../games/store.ts";
3940 import { nearPages } from "./near_pages.ts";
4041 import { page, redirect } from "./layout.ts";
4142 import { leanPage } from "./lean_page.ts";
@@ -113,7 +114,7 @@ export function notFoundPage(ctx: Ctx, opts: { plain?: boolean; noEcho?: boolean
113114 const get = !opts.plain && (ctx.request.method === "GET" || ctx.request.method === "HEAD");
114115 const near = get ? nearTo(ctx.app.db, ctx.auth.user, ctx.params.owner ?? "", ctx.params.name ?? "") : [];
115116 const pages = get
116 ? nearPages(ctx.url.pathname, { signedIn: ctx.auth.user !== undefined, admin: ctx.auth.user?.isAdmin === true })
117 ? nearPages(ctx.url.pathname, { signedIn: ctx.auth.user !== undefined, admin: ctx.auth.user?.isAdmin === true, games: seesAnyBox(ctx.app.db, ctx.auth.user) })
117118 : [];
118119 const tries = near.map((r) => html`<a href="${repoBase(r)}">${r.ownerName}/${r.name}</a>`);
119120 // The nearest real page by name, in plain words; a path with no near page still gets Explore.
src/web/client.ts +10 −3
@@ -563,7 +563,8 @@ export const codeJs = /* js */ `
563563 // one; a reader already at the top is not moved.
564564 function surface() {
565565 var top = main.getBoundingClientRect().top;
566 var bar = parseInt(getComputedStyle(doc.documentElement).getPropertyValue('--topbar-h'), 10) || 56;
566 var head = doc.querySelector('.topbar');
567 var bar = head ? head.offsetHeight : 0;
567568 if (top < bar) main.scrollIntoView({ block: 'start' });
568569 }
569570 nav.addEventListener('click', function (e) {
@@ -1727,7 +1728,10 @@ ${whichStubJs(whichAsset().path)}
17271728 ['o or Enter', 'Open the focused row', ['o', 'Enter'], openFocused],
17281729 ['/', 'Focus search', ['/'], function (e) {
17291730 var box = doc.querySelector('[data-search-input]');
1730 if (box) { e.preventDefault(); box.focus(); box.select(); }
1731 if (!box) return;
1732 e.preventDefault();
1733 // A bar too narrow for its field shows the icon instead: the palette searches there.
1734 if (box.getClientRects().length > 0) { box.focus(); box.select(); } else openPalette();
17311735 }],
17321736 ['t', 'Tell the crew', ['t'], function (e) {
17331737 // The tell box this page already has (the feed's, the home's, /tell's own form), else the page
@@ -1816,7 +1820,10 @@ ${whichStubJs(whichAsset().path)}
18161820 pr.appendChild(pk); pr.appendChild(pl); tbody.appendChild(pr);
18171821 }
18181822 // The \`g\` jumps, read from the same list: one row per page this viewer may open by key.
outdated

The sheet's capital-letter rule reads the DOM with a selector that excludes .wordmark and .talk-btn, and no test fails without it. Put the shadowed-letter fact in the data, or add a test.

1819 gotoPages().forEach(function (p) { if (p[3] !== '') tbody.appendChild(keyRow('g ' + p[3], 'Go to ' + p[0])); });
1823 // One the page's own g tab shadows (a repository's) is the capital there.
1824 gotoPages().forEach(function (p) {
1825 if (p[3] !== '') tbody.appendChild(keyRow('g ' + (doc.querySelector('[data-shortcut="g ' + p[3] + '"]:not(.wordmark):not(.talk-btn)') ? p[3].toUpperCase() : p[3]), 'Go to ' + p[0]));
1826 });
18201827 table.appendChild(tbody);
18211828 if (body) { body.textContent = ''; body.appendChild(table); }
18221829 openModal(dlg);
src/web/go_pages.ts +28 −13
@@ -11,8 +11,10 @@ export interface GoPage {
1111 /** The name typed to reach it. */
1212 readonly name: string;
1313 readonly href: string;
14 /** Who is shown it: anyone, a signed-in person, or a site admin. */
15 readonly who: "all" | "user" | "admin";
14 /** Who is shown it: anyone, a signed-in person, whoever may see a game box, or a site admin. */
15 readonly who: "all" | "user" | "games" | "admin";
16 /** One of the forge's areas: the top bar names it on every page. */
17 readonly area?: true;
1618 /** Present when the Cmd/Ctrl K palette also lists it as a "Go to" row, in its longer wording. */
1719 readonly palette?: string;
1820 /** The letter that follows `g` to jump here from any page (`g e` Explore). One letter, once. */
@@ -21,8 +23,10 @@ export interface GoPage {
2123
2224 export const GO_PAGES: readonly GoPage[] = [
2325 { name: "Home", href: "/", who: "all", key: GO.global.home, palette: "Home" },
24 { name: "Apps", href: "/apps", who: "all", palette: "Apps" },
25 { name: "Explore", href: "/explore", who: "all", key: GO.global.explore, palette: "Explore" },
26 { name: "Apps", href: "/apps", who: "all", area: true, key: GO.global.apps, palette: "Apps" },
27 { name: "Games", href: "/games", who: "games", area: true, key: GO.global.games, palette: "Games" },
28 { name: "Infrastructure", href: "/infra", who: "admin", area: true, key: GO.global.infra, palette: "Infrastructure" },
29 { name: "Explore", href: "/explore", who: "all", area: true, key: GO.global.explore, palette: "Explore" },
2630 { name: "Packs", href: "/packs", who: "all", palette: "Forge packs" },
2731 { name: "Front page", href: "/front", who: "all", palette: "Front page" },
2832 { name: "Search", href: "/search", who: "all", palette: "Search" },
@@ -45,21 +49,32 @@ export const GO_PAGES: readonly GoPage[] = [
4549 { name: "Audit", href: "/audit", who: "admin" },
4650 ];
4751
48 /** The pages this viewer may be sent to, in list order. */
49 export function goPagesFor(viewer: { signedIn: boolean; admin: boolean }): GoPage[] {
50 return GO_PAGES.filter(
51 (p) => p.who === "all" || (viewer.signedIn && (p.who === "user" || viewer.admin)),
52 );
52 /** Who is looking. `games` is `seesAnyBox` (`games/store.ts`), which a site admin always is. */
53 export interface GoViewer {
54 readonly signedIn: boolean;
55 readonly admin: boolean;
56 readonly games?: boolean;
5357 }
5458
55 /** The one digit the page wears so the keys script can pick its pages: 0 a stranger, 1 signed in, 2 admin. */
56 export function goLevel(viewer: { signedIn: boolean; admin: boolean }): 0 | 1 | 2 {
57 return !viewer.signedIn ? 0 : viewer.admin ? 2 : 1;
59 /** What each kind of page needs, as a level: each level may open all that a lower one may. */
60 const NEEDS = { all: 0, user: 1, games: 2, admin: 3 } as const satisfies Record<GoPage["who"], number>;
61
62 /** The one digit the page wears so the keys script can pick its pages (`NEEDS`). */
63 export function goLevel(viewer: GoViewer): 0 | 1 | 2 | 3 {
64 if (!viewer.signedIn) return NEEDS.all;
65 if (viewer.admin) return NEEDS.admin;
66 return viewer.games === true ? NEEDS.games : NEEDS.user;
5867 }
5968
69 /** Whether this viewer may be sent to a page. */
70 export const mayGo = (page: Pick<GoPage, "who">, viewer: GoViewer): boolean => NEEDS[page.who] <= goLevel(viewer);
71
72 /** The pages this viewer may be sent to, in list order. */
73 export const goPagesFor = (viewer: GoViewer): GoPage[] => GO_PAGES.filter((p) => mayGo(p, viewer));
74
6075 /** The list as the keys script carries it: [name, href, level needed, the letter after `g` or ""]. */
6176 export function goPagesData(): [string, string, number, string][] {
62 return GO_PAGES.map((p) => [p.name, p.href, p.who === "all" ? 0 : p.who === "user" ? 1 : 2, p.key ?? ""]);
77 return GO_PAGES.map((p) => [p.name, p.href, NEEDS[p.who], p.key ?? ""]);
6378 }
6479
6580 /** The Cmd/Ctrl K palette's "Go to" rows, in list order, and which of them a stranger may see. */
src/web/keymap.ts +3 −4
@@ -19,7 +19,7 @@
1919 * clash in a scope.
2020 */
2121 export const GO = {
22 global: { home: "h", explore: "e", flow: "f", talk: "t", next: "n", system: "y", boards: "b" },
22 global: { home: "h", apps: "a", games: "p", infra: "i", explore: "e", flow: "f", talk: "t", next: "n", system: "y", boards: "b" },
2323 repo: { code: "c", issues: "i", pulls: "p", runs: "r", map: "m", log: "l", branches: "b", forks: "k", settings: "s" },
2424 } as const;
2525
@@ -124,11 +124,10 @@ export const REPO_TABS = {
124124 /**
125125 * The g chords that moved with {@link GO} (2026-12-01), each with what it says until
126126 * {@link OLD_KEYS_UNTIL} when pressed where it now does nothing: the shell says it only when no tab
127 * and no place took the chord. g f in a repository now goes to Flow, and g m to its map, so those
128 * are not hinted: they go somewhere.
127 * and no place took the chord. g f in a repository now goes to Flow, g m to its map and g a
128 * to Apps, so those are not hinted: they go somewhere.
129129 */
130130 export const OLD_GO: readonly { readonly was: string; readonly says: string }[] = [
131 { was: "g a", says: `g ${GO.repo.map} is the map now` },
132131 { was: "g s", says: `g ${GO.global.system} is System now (g s is a repository's settings)` },
133132 ];
134133
src/web/layout.ts +27 −8
@@ -13,7 +13,8 @@ import { requestHolds } from "../http/conditional.ts";
1313 import { sshOn } from "../settings/ssh.ts";
1414 import { hereAddress, returnTo, withReturn } from "./return_to.ts";
1515 import { countWaiting } from "../core/fence.ts";
16 import { goLevel, goPaletteRows } from "./go_pages.ts";
16 import { GO_PAGES, goLevel, goPaletteRows, mayGo, type GoViewer } from "./go_pages.ts";
17 import { seesAnyBox } from "../games/store.ts";
1718 import { NEW_ISSUE_KEY } from "./script_keys.ts";
1819 import { newIssueHref } from "./issue_from.ts";
1920 import { OPENSEARCH_PATH, OPENSEARCH_TITLE, OPENSEARCH_TYPE } from "./opensearch.ts";
@@ -72,6 +73,7 @@ import {
7273 import { prefersJson } from "./form.ts";
7374 import { notePhase } from "../core/route_timing.ts";
7475 import { html, raw, when, type Html } from "./html.ts";
76 import { tighten } from "./tight.ts";
7577 import { ASK_FORM_ID, askButton, askFormShell } from "./blocked.ts";
7678 import { noRoom } from "../spawn/door.ts";
7779 import { takeNotice } from "../core/access_link.ts";
@@ -124,8 +126,8 @@ export interface PageOptions {
124126 */
125127 description?: string;
126128 /**
127 * Drop the source indentation from the markup of a page that must stay small (/pricing).
128 * A document with a `<pre>` or `<textarea>` keeps its indentation, which is content there.
129 * Drop the source indentation from the markup of a page that must stay small (/pricing,
130 * the signed-out home). A `<pre>` and a `<textarea>` keep theirs, which is content there.
129131 */
130132 tight?: boolean;
131133 /**
@@ -374,7 +376,6 @@ function userMenu(
374376 const items: (MenuItem | Html)[] = [
375377 { label: "Your profile", href: `/${user.username}`, icon: "user", note: user.username },
376378 { label: "Repositories", href: "/repos", icon: "repo" },
377 { label: "Apps", href: "/apps", icon: "rocket" },
378379 ...featureItems(ctx, user),
379380 { separator: true, label: "" },
380381 { label: "Settings", href: "/settings", icon: "settings" },
@@ -531,6 +532,7 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html {
531532 });
532533 const states = open.length > 0 ? appsRuntime(ctx.app)?.statusMany(open) : undefined;
533534 const foundry = foundryHref(ctx.app, ctx.auth.user);
535 const viewer = goViewer(ctx);
534536 const here = pageRepo(ctx);
535537 const tell = tellTarget(ctx, here);
536538 const tellHref =
@@ -584,7 +586,7 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html {
584586 ? STATIC_PALETTE.filter((p) => {
585587 if (p.h === "/settings/keys" && !sshOn(ctx.app.db)) return false;
586588 const row = GO_ROWS.find((r) => r.t === p.t && r.h === p.h);
587 return row === undefined || row.who !== "admin" || ctx.auth.user?.isAdmin === true;
589 return row === undefined || mayGo(row, viewer);
588590 })
589591 : [
590592 ...STATIC_PALETTE.filter((p) => VISITOR_PALETTE.has(p.t)),
@@ -711,7 +713,23 @@ function talkButton(ctx: Ctx, user: User, about?: string): Html {
711713 >`;
712714 }
713715
714 /** The skip link and the topbar: the wordmark, the crumbs, the tools. */
716 /** Who is looking, for the pages they may be sent to. No read of its own: `seesAnyBox` keeps it. */
717 const goViewer = (ctx: Ctx): GoViewer => ({
718 signedIn: ctx.auth.user !== undefined,
719 admin: ctx.auth.user?.isAdmin === true,
720 games: seesAnyBox(ctx.app.db, ctx.auth.user),
721 });
722
723 /** The areas this viewer may use (`GO_PAGES`), the one they are in marked. */
724 function areas(ctx: Ctx): Html {
725 const viewer = goViewer(ctx);
726 const at = ctx.url.pathname;
727 return html`<nav class="areas" aria-label="Areas">${GO_PAGES.filter((p) => p.area === true && mayGo(p, viewer)).map(
728 (p) => html`<a href="${p.href}"${at === p.href || at.startsWith(`${p.href}/`) ? raw(' aria-current="page"') : null}>${p.name}</a>`,
729 )}</nav>`;
730 }
731
732 /** The skip link and the topbar: the wordmark, the areas, the crumbs, the tools. */
715733 function topbar(
716734 ctx: Ctx,
717735 theme: ThemeName | undefined,
@@ -725,6 +743,7 @@ function topbar(
725743 <a href="/" class="wordmark" data-shortcut="${keyOf("home")}" ${hintAttr(keyOf("home"))}
726744 ><span class="mark"></span>forge</a
727745 >
746 ${areas(ctx)}
728747 ${when(
729748 crumbs,
730749 (items) =>
@@ -1068,7 +1087,7 @@ export function page(options: PageOptions, status = 200): Response {
10681087 ? raw(`<style>${options.styleCss}</style>`)
10691088 : null}
10701089 </head>
1071 <body data-go="${goLevel({ signedIn: ctx.auth.user !== undefined, admin: ctx.auth.user?.isAdmin === true })}">
1090 <body data-go="${goLevel(goViewer(ctx))}">
10721091 ${shell}
10731092 <script src="${shellAsset().path}" defer></script>
10741093 <script src="${beaconAsset().path}" defer></script>
@@ -1079,7 +1098,7 @@ export function page(options: PageOptions, status = 200): Response {
10791098 // Signed-out, flash-free pages are tagged by their own bytes so a revisit
10801099 // costs a 304 (`http/etag.ts`).
10811100 const tagged = taggable(ctx.request, ctx.auth.user !== undefined, flash !== undefined) && status === 200;
1082 const text = pointAtSprite(options.tight === true && !/<(pre|textarea)\b/i.test(doc.text) ? doc.text.replace(/[ \t]*\n\s*/g, "\n") : doc.text, spriteAsset().path);
1101 const text = pointAtSprite(options.tight === true ? tighten(doc.text) : doc.text, spriteAsset().path);
10831102 const headers = documentHeaders(options, tagged, links);
10841103 // A flash is shown exactly once: rendering it is also what clears it.
10851104 if (cookieFlash) headers.append("set-cookie", clearFlashCookie(ctx.url, ctx.app.config.url));
src/web/near_pages.ts +2 −2
@@ -5,7 +5,7 @@
55 * viewer may be sent to, so a page they cannot open is never named.
66 */
77 import { editDistance } from "../text/edit_distance.ts";
8 import { goPagesFor, type GoPage } from "./go_pages.ts";
8 import { goPagesFor, type GoPage, type GoViewer } from "./go_pages.ts";
99
1010 const NEAR_MAX = 3;
1111 /**
@@ -20,7 +20,7 @@ const MAX_ASKED = 40;
2020 * Up to three pages whose name is within edit distance 3 (at most half its length) of the path's
2121 * first segment, nearest first.
2222 */
23 export function nearPages(pathname: string, viewer: { signedIn: boolean; admin: boolean }): GoPage[] {
23 export function nearPages(pathname: string, viewer: GoViewer): GoPage[] {
2424 let first = pathname.split("/").find((s) => s !== "") ?? "";
2525 try {
2626 first = decodeURIComponent(first);
src/web/pages/apps.ts +3 −4
@@ -85,7 +85,6 @@ import { noAgentsBlocked } from "../../actions/blocked_words.ts";
8585 import { flashTo, page, redirect } from "../layout.ts";
8686 import { writableAppsOf } from "../studio/asks.ts";
8787 import { costLine } from "../studio/cost_line.ts";
88 import { homeTabs } from "../studio/home_tabs.ts";
8988 import { shelfRows } from "../studio/shelf.ts";
9089 import {
9190 badge,
@@ -227,9 +226,9 @@ export async function appsList(ctx: Ctx): Promise<Response> {
227226 const hasData =
228227 ctx.auth.user !== undefined &&
229228 (ctx.auth.user.isAdmin || writableAppsOf(ctx, ctx.auth.user).repos.length > 0);
230 const body = html`<div data-apps-page>${when(ctx.auth.user, () => homeTabs("apps"))}
231 ${pageHead("Apps", {
232 actions: hasData ? html`${btn("Data", { href: "/data", size: "sm" })}${create}` : create,
229 const body = html`<div data-apps-page>${pageHead("Apps", {
230 // The feed's own tabs name Feed and Design only: this is the way back to it.
231 actions: html`${ctx.auth.user === undefined ? null : btn("Feed", { href: "/feed", size: "sm" })}${hasData ? btn("Data", { href: "/data", size: "sm" }) : null}${create}`,
233232 sub: APPS_PURPOSE,
234233 })}
235234 ${cost}
src/web/pages/games.ts +9 −2
@@ -67,6 +67,7 @@ import { topologyBlock, TOPOLOGY_CSS } from "./games_topology.ts";
6767 import { defaultHeadResponse, headResponse } from "../../games/heads.ts";
6868 import { eventsOf, eventWords, isBedrock, knowsPlayer, peopleOf, peopleWords, queuePeople, UNDO, type PeopleOp } from "../../games/people.ts";
6969 import { queueWorld, undoOf, worldWords } from "../../games/worlds.ts";
70 import { START_BOX } from "../../core/empty_words.ts";
7071 import { emptyLine, emptyNote } from "../empty_words.ts";
7172 import { findingsOf, type GameFinding } from "../../games/player_events.ts";
7273 import { findingsOf as kickFindingsOf } from "../../games/findings.ts";
@@ -149,6 +150,12 @@ function boxOf(ctx: Ctx, need: Role, service = ""): { box: GameBox; role: Role }
149150 return { box, role: role! };
150151 }
outdated

The request names Minecraft, but the button says "a game box". Make the two agree (principle 8), and drop the second sentence under the button (principle 1).

151152
153 /** An admin's first box: one press asks Talk for the plan, since only `infra` makes a game box. */
154 const startBox = (): Html => html`<form method="post" action="/talk" class="mt">
155 <input type="hidden" name="text" value="${START_BOX}" />
156 ${btn("Start a game box", { variant: "primary" })}
157 </form>`;
158
152159 // GET /games
153160 export function gamesPage(ctx: Ctx): Response {
154161 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
@@ -158,9 +165,9 @@ export function gamesPage(ctx: Ctx): Response {
158165 return timePhase(ctx.request, "render", () => page({
159166 ctx,
160167 title: "Games",
161 body: html`${pageHead("Games", { sub: "Game servers on your own cloud, run from a compose file in a repository." })}
168 body: html`${pageHead("Games", { sub: "Game servers on your own cloud: start, stop and play." })}
162169 ${boxes.length === 0
163 ? html`${emptyLine("gameBoxes")}${user.isAdmin ? html`<p><a href="/infra/build">Make one</a></p>` : null}`
170 ? html`${emptyLine("gameBoxes")}${user.isAdmin ? startBox() : null}`
164171 : rowList(
165172 boxes.map((b) =>
166173 row({
src/web/studio/home.ts +1
@@ -897,6 +897,7 @@ export function studioDoor(ctx: Ctx): Response {
897897 body,
898898 scriptJs: script,
899899 ...(tag === undefined ? {} : { etag: tag }),
900 tight: true,
900901 jsonLd: siteStructuredData(origin, running().version),
901902 ...(visitor
902903 ? {
src/web/studio/home_tabs.ts +6 −6
@@ -1,19 +1,19 @@
11 /**
2 * The home's tabs — Feed, Your apps, Design — drawn on each of the pages, so each is a tap from
3 * the others and never only the logo away (#599, #851). Drawn with §5's tabs. What was once an
4 * "Asked" tab is gone (#16229): what a person made is an issue or a pull request, found in the
5 * feed's `?show=mine`.
2 * The home's tabs, Feed and Design, drawn on both pages with §5's tabs, so each is a tap from the
3 * other and never only the logo away (#599, #851). Apps is an area, in the top bar. What was once an
4 * "Asked" tab is gone (#16229): what a person made is an issue or a pull request, found in the feed's
5 * `?show=mine`.
66 */
77
88 import { html, type Html } from "../html.ts";
99 import { tabs } from "../ui.ts";
1010
11 export type HomeTab = "feed" | "apps" | "design";
11 export type HomeTab = "feed" | "design";
1212
1313 /** §5's `tabs()` in a `.mb` block: link tabs, so `aria-current`. */
1414 export function homeTabs(current: HomeTab): Html {
1515 const item = (id: HomeTab, href: string, label: string) => ({ label, href, current: current === id });
1616 return html`<div class="mb">
17 ${tabs([item("feed", "/feed", "Feed"), item("apps", "/apps", "Your apps"), item("design", "/design", "Design")], "Home")}
17 ${tabs([item("feed", "/feed", "Feed"), item("design", "/design", "Design")], "Home")}
1818 </div>`;
1919 }
src/web/style/base.ts +28 −1
@@ -44,7 +44,8 @@ export const base = /* css */ `
4444 --radius: 8px; /* surfaces: cards, panels, code blocks */
4545 --radius-lg: 12px; /* overlays: dialogs, palette, menus */
4646 --fs-min: 12px; /* type floor: no meaningful text is smaller */
47 --topbar-h: 56px;
47 --areas-h: 0px;
48 --topbar-h: calc(56px + var(--areas-h));
4849 --page: 1120px;
4950 --measure: 72ch;
5051 --ring: 2px solid var(--accent); /* the one focus ring: buttons, links, inputs, summaries */
@@ -148,6 +149,24 @@ h3 { font-size: 14px; font-weight: 600; line-height: 1.4; }
148149 }
149150 @media (hover: hover) and (pointer: fine) { .wordmark:hover { color: var(--fg); }
150151 .wordmark:hover .mark { transform: rotate(135deg); } }
152 /* The areas, in the bar from 720px. On a phone they are its first line, on every page and pinned with
153 it: 44px, which --areas-h adds to --topbar-h so all that sticks or scrolls under the bar follows. */
154 .areas { display: flex; flex: none; }
155 .areas > a {
156 display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px;
157 color: var(--muted-fg); font-size: 14px; white-space: nowrap;
158 }
159 .areas > a[aria-current="page"] { color: var(--fg); font-weight: 550; }
160 @media (hover: hover) and (pointer: fine) { .areas > a:hover { color: var(--fg); } }
161 @media (min-width: 720px) { .areas + .crumbs { margin-left: 12px; } }
162 @media (max-width: 719px) {
outdated

Phone: a page with [data-own-tabs] or .repo-head gets no areas strip, so home and every repository page have no Apps, Games, Infrastructure or Explore under 720px. Draw the strip everywhere, or merge the areas into the page's own tabs.

163 :root:has(.areas) { --areas-h: 44px; }
outdated

:not([data-visitor]) hides the strip from signed-out phones, who then have no top-bar way to Apps or Explore. Show it to them as well.

164 .topbar:has(.areas) { flex-wrap: wrap; row-gap: 8px; }
165 .areas {
166 order: -1; flex: 1 0 100%; min-width: 0; margin: -8px 0 0 -8px;
167 overflow-x: auto; scrollbar-width: none;
168 }
169 }
151170 .topbar .spacer { flex: 1; }
152171 .topbar-tools { display: flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; }
153172 .topbar-tools > a.small { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; flex: none; }
@@ -234,6 +253,14 @@ time[datetime].age { min-width: ${AGE_SLOT_CH}ch; }
234253 .hide-sm { display: inline-flex; }
235254 .hide-lg { display: none; }
236255 }
256 /* Beside the areas the search is its icon until there is room for the field, and the crumbs are what
257 gives way to a long name, never the tools. */
258 @media (min-width: 720px) { .topbar:has(.areas) .topbar-tools { flex: none; } }
259 @media (min-width: 720px) and (max-width: 899px) { .topbar:has(.areas) .menu > summary .truncate { max-width: 10ch; } }
260 @media (min-width: 720px) and (max-width: 1199px) {
261 .topbar:has(.areas) .topbar-search { display: none; }
262 .topbar:has(.areas) .topbar-tools > .hide-lg { display: inline-flex; }
263 }
237264
238265 /* The page does not ask to cover the screen (no viewport-fit): inside another
239266 app's embedded browser that put its top under the app's own bar (2026-11-13).
src/web/style/components.ts +1 −1
@@ -1459,7 +1459,7 @@ ul.list { overflow-anchor: none; }
14591459 /* Under a finger, 44px each way (docs/design/areas/touch.md). */
14601460 @media (pointer: coarse) {
14611461 /* The bar's height follows its tallest control: the search's 44px box and its 1px border each side, in 8px of padding. */
1462 :root { --topbar-h: calc(44px + 2 * 1px + 2 * 8px); }
1462 :root { --topbar-h: calc(44px + 2 * 1px + 2 * 8px + var(--areas-h)); }
14631463 .btn[data-size], .input, .topbar-search input, .tabs > a, .seg > a, .menu-item, .where-place, summary, label.check, .diff-viewed { min-height: 44px; }
14641464 .btn-icon, .btn-icon[data-size], .talk-page .talk :is(.talk-act, .talk-copy) { width: 44px; min-width: 44px; height: 44px; }
14651465 .seg > a, label.check, .diff-viewed, .crumbs a, .repo-title a, .byline a, .foot a { display: inline-flex; align-items: center; }
src/web/tight.ts added +3
@@ -0,0 +1,3 @@
1 /** `page()`'s `tight`: each run of line breaks and indentation is one line break; a `<pre>` and a `<textarea>` keep theirs. */
2 export const tighten = (text: string): string =>
3 text.replace(/<(pre|textarea)\b[\s\S]*?<\/\1>|[ \t]*\n\s*/gi, (m) => (m.startsWith("<") ? m : "\n"));
test/account-menu.test.ts +2 −2
@@ -57,7 +57,7 @@ const SESSION = ["---", "[Theme]", "Keyboard shortcuts", "Sign out"];
5757
5858 test("a member's menu: their own pages, Settings, then this browser", async () => {
5959 const { rows, html } = await menuRows("/", member);
60 expect(rows).toEqual(["Your profile", "Repositories", "Apps", "---", "Settings", ...SESSION]);
60 expect(rows).toEqual(["Your profile", "Repositories", "---", "Settings", ...SESSION]);
6161 // The first row says whose profile; the button names the account for a screen reader.
6262 expect(html).toContain('<span class="menu-note">ada</span>');
6363 expect(html).toContain('aria-label="Account: ada"');
@@ -65,7 +65,7 @@ test("a member's menu: their own pages, Settings, then this browser", async () =
6565
6666 test("an admin's menu adds People and Forges beside Settings, and nothing else", async () => {
6767 const { rows } = await menuRows("/", admin);
68 expect(rows).toEqual(["Your profile", "Repositories", "Apps", "---", "Settings", "People", "Forges", ...SESSION]);
68 expect(rows).toEqual(["Your profile", "Repositories", "---", "Settings", "People", "Forges", ...SESSION]);
6969 });
7070
7171 test("a visitor's menu: no account rows, the same one row for appearance, and the way to every theme", async () => {
test/areas-fit.test.ts added +75
@@ -0,0 +1,75 @@
1 /**
2 * The areas on a 390 px touch phone, drawn (where a Chromium starts): on every page they are the bar's
3 * first line, in words, still there after a scroll, and cost the bar no more than their own 44 px.
4 */
5 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App } from "../src/app.ts";
10 import { createRepo } from "../src/core/repos.ts";
11 import { createSession } from "../src/core/sessions.ts";
12 import { createUser } from "../src/core/users.ts";
13 import { createGameBox, grant } from "../src/games/store.ts";
14 import { serve, type Servers } from "../src/http/server.ts";
15 import { findChromium } from "../src/looks/capture.ts";
16 import { chromiumRuns, sharedBrowser, type SharedBrowser } from "./helpers/chrome.ts";
17
18 const found = findChromium();
19 const chromium = found !== undefined && chromiumRuns(found) ? found : undefined;
20 if (chromium === undefined) console.log("SKIPPING: no chromium that starts on this machine, so the phone's areas are not measured");
21
22 describe.skipIf(chromium === undefined)("the areas at 390x844", () => {
23 let dir = "";
24 let app: App, servers: Servers, browser: SharedBrowser;
25 const token: Record<string, string> = {};
26
27 beforeAll(async () => {
28 dir = await mkdtemp(join(tmpdir(), "forge-areas-fit-"));
29 app = createApp({ dataDir: dir, port: 0 });
30 servers = await serve(app);
31 for (const [username, isAdmin] of [["alice", true], ["player", false]] as const) {
32 const r = await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@f.test`, password: "a-good-passphrase", isAdmin });
33 if (!r.ok) throw new Error(r.error);
34 token[username] = createSession(app.db, r.value.id).token;
35 if (isAdmin) await createRepo(app.db, app.reposRoot, { ownerId: r.value.id, name: "site", visibility: "public", description: "A long description that wraps. ".repeat(6) });
36 else grant(app.db, createGameBox(app.db, { name: "net", repo: "alice/net" }).id, r.value.id, "operator");
37 }
38 browser = await sharedBrowser(chromium!);
39 }, 60_000);
40 afterAll(async () => {
41 await browser.close();
42 servers.stop();
43 app.close();
44 await rm(dir, { recursive: true, force: true });
45 });
46
47 const MEASURE = `(() => {
48 const strip = document.querySelector(".areas"), bar = document.querySelector(".topbar");
49 document.body.style.minHeight = "3000px";
50 scrollTo({ top: 900, behavior: "instant" });
51 const links = [...strip.children].map((a) => ({ name: a.textContent, r: a.getBoundingClientRect() }));
52 const out = {
53 scrolled: scrollY > 800,
54 seen: links.filter(({ r }) => r.width > 0 && r.top >= 0 && r.bottom <= 60 && r.left >= 0 && r.right <= 390 && r.height >= 44).map((l) => l.name),
55 wide: document.documentElement.scrollWidth,
56 };
57 const tall = bar.offsetHeight;
58 strip.remove();
59 out.cost = tall - bar.offsetHeight;
60 return JSON.stringify(out);
61 })()`;
62
63 const PAGES: [string, string, string[]][] = [
64 ...["/", "/feed", "/design", "/alice/site", "/apps", "/talk"].map((p): [string, string, string[]] => ["alice", p, ["Apps", "Games", "Infrastructure", "Explore"]]),
65 ...["/", "/games"].map((p): [string, string, string[]] => ["player", p, ["Apps", "Games", "Explore"]]),
66 ...["/", "/explore", "/alice/site"].map((p): [string, string, string[]] => ["", p, ["Apps", "Explore"]]),
67 ];
68 test("every page shows them in words, pinned, for 44 px", async () => {
69 for (const [who, path, want] of PAGES) {
70 const cookies = who === "" ? [] : [{ name: "forge_session", value: token[who]! }];
71 const m = JSON.parse(await browser.evaluate(`${servers.url}${path}`, { width: 390, height: 844 }, cookies, MEASURE, "light", true)) as { scrolled: boolean; seen: string[]; wide: number; cost: number };
72 expect({ path, who, ...m }).toEqual({ path, who, scrolled: true, seen: want, wide: 390, cost: 44 });
73 }
74 }, 60_000);
75 });
test/areas.test.ts added +179
@@ -0,0 +1,179 @@
1 /**
2 * The areas (go_pages.ts `area`): the top bar, the palette, the `:` list and the terminal's g panel
3 * name the same ones, each person only what they may use. Who may see a game box is kept 30 s a
4 * process, and a grant or a revoke made here shows on the next page.
5 */
6 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { createApp, type App } from "../src/app.ts";
11 import { createRepo } from "../src/core/repos.ts";
12 import { START_BOX } from "../src/core/empty_words.ts";
13 import { listConversations, listTurns } from "../src/core/conversations.ts";
14 import { createSession } from "../src/core/sessions.ts";
15 import { createUser, type User } from "../src/core/users.ts";
16 import { createGameBox, grant, PLAYERS_MS, seesAnyBox } from "../src/games/store.ts";
17 import { forgeHttp, type ForgeHttp } from "../src/http/server.ts";
18 import { entry as gamesEntry, gamesScreen } from "../src/tui/screens/games.ts";
19 import { entry as infraEntry } from "../src/tui/screens/infra.ts";
20 import { whichRows } from "../src/tui/app/which.ts";
21 import type { Session } from "../src/tui/session.ts";
22 import type { KeyEvent } from "../src/tui/term/input.ts";
23 import { goPagesFor } from "../src/web/go_pages.ts";
24 import { quietLogs } from "./helpers/globals.ts";
25 import { shellPage } from "./helpers/shell-page.ts";
26 import { quietCtx, screenText, sessionFor } from "./helpers/tui-text.ts";
27
28 quietLogs();
29
30 const ORIGIN = "http://forge.test";
31 let dir = "";
32 let app: App, http: ForgeHttp;
33 let admin: User, member: User, player: User;
34 let box = "";
35
36 beforeAll(async () => {
37 dir = await mkdtemp(join(tmpdir(), "forge-areas-"));
38 app = createApp({ dataDir: dir, port: 0 });
39 http = forgeHttp(app);
40 const made = async (username: string, isAdmin: boolean): Promise<User> => {
41 const r = await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@f.test`, password: "a-good-passphrase", isAdmin });
42 if (!r.ok) throw new Error(r.error);
43 return r.value;
44 };
45 admin = await made("alice", true);
46 member = await made("bob", false);
47 player = await made("carol", false);
48 }, 30_000);
49 afterAll(async () => {
50 http.close();
51 app.close();
52 await rm(dir, { recursive: true, force: true });
53 });
54
55 const cookies = new Map<string, string>();
56 async function pageFor(user: User | undefined, path = "/explore"): Promise<string> {
57 if (user !== undefined && !cookies.has(user.id)) cookies.set(user.id, `forge_session=${createSession(app.db, user.id).token}`);
58 const res = await http.handle(new Request(ORIGIN + path, user === undefined ? {} : { headers: { cookie: cookies.get(user.id)! } }));
59 return await res.text();
60 }
61 const navOf = (page: string): string => /<nav class="areas"[\s\S]*?<\/nav>/.exec(page)?.[0] ?? "";
62 const named = (page: string): string[] => [...navOf(page).matchAll(/<a [^>]*>([^<]+)<\/a>/g)].map((m) => m[1]!);
63 const AREAS = ["Apps", "Games", "Infrastructure", "Explore"];
64 /** The areas among the palette's "Go to" rows. */
65 const inPalette = (page: string): string[] => {
66 const json = /id="palette-index">([\s\S]*?)<\/script>/.exec(page)![1]!;
67 return (JSON.parse(json) as { items: { t: string }[] }).items.map((i) => i.t).filter((t) => AREAS.includes(t));
68 };
69
70 test("an admin with no box may start one, and the empty state says what a game box is", async () => {
71 const page = await pageFor(admin, "/games");
72 expect(page).toContain("A game box is a machine on your cloud");
73 expect(page).toContain('action="/talk"');
74 expect(page).toContain("Start a game box");
75 expect(page).toContain(`value="${START_BOX}"`);
76 expect(await pageFor(member, "/games")).not.toContain("Start a game box");
77 });
78
79 test("the terminal's empty Games screen sends the same words with n, for an admin only", () => {
80 const asked = (user: User) => listConversations(app.db, user.id).flatMap((c) => {
81 const turns = listTurns(app.db, user.id, c.id);
82 return turns.ok ? turns.value.map((t) => t.text) : [];
83 });
84 const n: KeyEvent = { type: "key", key: "n", ctrl: false, alt: false, shift: false };
85 for (const [user, may] of [[member, false], [admin, true]] as const) {
86 const screen = gamesScreen(sessionFor(app, user), quietCtx());
87 expect(screenText(screen, 200, 20).includes("n asks Talk to plan one"), user.username).toBe(may);
88 screen.key!(n);
89 expect(asked(user).includes(START_BOX), user.username).toBe(may);
90 }
91 });
92
93 test("every door names the areas a person may use, and no other", async () => {
94 box = createGameBox(app.db, { name: "net", repo: "alice/mc-network" }).id;
95 grant(app.db, box, player.id, "viewer", "hub");
96 const who: [User | undefined, string[]][] = [
97 [undefined, ["Apps", "Explore"]],
98 [member, ["Apps", "Explore"]],
99 [player, ["Apps", "Games", "Explore"]],
100 [admin, AREAS],
101 ];
102 for (const [user, want] of who) {
103 const page = await pageFor(user);
104 const name = user?.username ?? "a stranger";
105 expect(named(page), `${name}: the bar`).toEqual(want);
106 expect(inPalette(page), `${name}: the palette`).toEqual(want);
107 const viewer = { signedIn: user !== undefined, admin: user?.isAdmin === true, games: seesAnyBox(app.db, user) };
108 expect(goPagesFor(viewer).filter((p) => p.area).map((p) => p.name), `${name}: the : list`).toEqual(want);
109 if (user === undefined) continue;
110 const session = { app, db: app.db, user } as unknown as Session;
111 const commands = new Set(["apps", "explore", ...(gamesEntry.offered(session) ? ["games"] : []), ...(infraEntry.offered(session) ? ["infra"] : [])]);
112 expect(whichRows({ kind: "go", path: [] }, commands).rows.map((r) => r.label).filter((l) => AREAS.includes(l)), `${name}: the terminal`).toEqual(want);
113 }
114 });
115
116 test("the area a page is in is marked, its inner pages too", async () => {
117 expect(navOf(await pageFor(admin, "/games"))).toContain('href="/games" aria-current="page"');
118 expect(navOf(await pageFor(admin, "/games/net"))).toContain('href="/games" aria-current="page"');
119 expect(navOf(await pageFor(admin, "/explore"))).not.toContain('href="/games" aria-current');
120 });
121
122 test("a grant and a revoke made here show on the next page", async () => {
123 expect(named(await pageFor(member))).not.toContain("Games");
124 grant(app.db, box, member.id, "operator");
125 expect(named(await pageFor(member))).toContain("Games");
126 grant(app.db, box, member.id, "none");
outdated

This asserts the text of a CSS selector, so it would pass with the strip hidden on every page that matters. Replace it with a check of what the phone draws on the home page and a repository page.

127 expect(named(await pageFor(member))).not.toContain("Games");
128 });
129
130 test("another process's grant shows within the 30 s, and no page between reads the table", () => {
131 const t = Date.now() + 1_000_000;
132 expect(seesAnyBox(app.db, member, t)).toBe(false);
133 // Written as another process would: past `grant`, so this one's copy stands.
134 app.db.query("INSERT INTO game_grant (box_id, user_id, role, service) VALUES (?1, ?2, 'viewer', '')").run(box, member.id);
135 expect(seesAnyBox(app.db, member, t + PLAYERS_MS - 1)).toBe(false);
136 expect(seesAnyBox(app.db, member, t + PLAYERS_MS)).toBe(true);
137 grant(app.db, box, member.id, "none");
138 });
139
140 test("who holds a grant is read from an index", () => {
141 const plan = app.db.query<{ detail: string }, []>("EXPLAIN QUERY PLAN SELECT DISTINCT user_id FROM game_grant").all().map((r) => r.detail);
142 expect(plan.join("\n")).toContain("USING COVERING INDEX");
143 });
144
145 test("every page with a bar carries the one strip: a repository's, the home's, Design's, a visitor's and the front door's", async () => {
146 const made = await createRepo(app.db, app.reposRoot, { ownerId: admin.id, name: "site", visibility: "public" });
147 expect(made.ok).toBe(true);
148 for (const path of ["/", "/feed", "/design", "/alice/site", "/settings/payments"]) {
149 const page = await pageFor(admin, path);
150 expect(named(page), path).toEqual(AREAS);
151 expect(page.match(/<nav class="areas"/g)!.length, path).toBe(1);
152 }
153 for (const path of ["/", "/explore", "/alice/site"]) expect(named(await pageFor(undefined, path)), `a visitor's ${path}`).toEqual(["Apps", "Explore"]);
154 });
155
156 test("/ opens the palette where the bar draws no search field, and focuses the field where it does", async () => {
157 const index = '<script type="application/json" id="palette-index">{"items":[]}</script>';
158 const body = `${index}<dialog id="palette"><input class="palette-input"><div class="palette-list"></div></dialog><input data-search-input>`;
159 for (const drawn of [false, true]) {
160 const p = await shellPage("/explore", body);
161 const field = p.doc.querySelector("[data-search-input]");
162 field.getClientRects = () => (drawn ? [{}] : []);
163 p.key("/");
164 expect(p.doc.getElementById("palette").hasAttribute("open"), `field drawn: ${drawn}`).toBe(!drawn);
165 expect(p.doc.activeElement === field, `field drawn: ${drawn}`).toBe(drawn);
166 }
167 });
168
169 test("? names a place a repository's tab shadows by its capital, and the others by their letter", async () => {
170 const help = '<dialog id="help-dialog"><div data-help-body></div></dialog>';
171 const listed = async (tabs: string) => {
172 const p = await shellPage("/alice/site", `${tabs}${help}`, {}, { go: "3" });
173 for (let n = 0; n < 2 && !p.doc.getElementById("help-dialog").hasAttribute("open"); n++) p.key("?");
174 const rows = [...p.doc.querySelectorAll("[data-help-body] tr")].map((r: any) => r.textContent.replace(/\s+/g, ""));
175 return rows.filter((r: string) => /Goto(Apps|Games|Infrastructure)$/.test(r));
176 };
177 expect(await listed("")).toEqual(["gaGotoApps", "gpGotoGames", "giGotoInfrastructure"]);
178 expect(await listed('<a href="/p" data-shortcut="g p">Pulls</a><a href="/i" data-shortcut="g i">Issues</a>')).toEqual(["gaGotoApps", "gPGotoGames", "gIGotoInfrastructure"]);
179 });
test/explore-url-filters.test.ts +2 −2
@@ -59,9 +59,9 @@ const listed = (html: string): string[] => {
5959 const list = /<ul class="list">([\s\S]*?)<\/ul>/.exec(html);
6060 return list === null ? [] : [...list[1]!.matchAll(/<li[^>]*>[\s\S]*?<a href="(\/[^"?]*)">/g)].map((m) => m[1]!);
6161 };
62 /** The href of the control whose visible text is `label`, as the page wrote it. */
62 /** The href of the page's own control whose visible text is `label`: the top bar has an Apps too. */
6363 const linkTo = (html: string, label: string): string => {
64 const found = new RegExp(`<a[^>]*href="([^"]+)"[^>]*>\\s*${label}\\s*</a>`).exec(html);
64 const found = new RegExp(`<a[^>]*href="([^"]+)"[^>]*>\\s*${label}\\s*</a>`).exec(html.slice(html.indexOf("<main")));
6565 if (found === null) throw new Error(`no control named ${label}`);
6666 return found[1]!.replace(/&amp;/g, "&");
6767 };
test/helpers/shell-page.ts +3 −2
@@ -1,11 +1,12 @@
1 /** A page with the shell script (`shellJs`) running over given markup in happy-dom; `store` seeds the tab's sessionStorage. */
1 /** A page with the shell script (`shellJs`) running over given markup in happy-dom; `store` seeds the tab's sessionStorage, `data` the body's data attributes. */
22 import { shellJs } from "../../src/web/client.ts";
33
4 export async function shellPage(path: string, body: string, store: Record<string, string> = {}) {
4 export async function shellPage(path: string, body: string, store: Record<string, string> = {}, data: Record<string, string> = {}) {
55 const { Window } = await import("happy-dom");
66 const win = new Window({ url: `http://forge.test${path}` });
77 for (const [k, v] of Object.entries(store)) win.sessionStorage.setItem(k, v);
88 win.document.body.innerHTML = body;
9 Object.assign(win.document.body.dataset, data);
910 (win.HTMLElement.prototype as any).scrollIntoView ??= () => {};
1011 const assigned: string[] = [];
1112 const loc = new Proxy(win.location, {
test/home-feed.test.ts +6 −5
@@ -160,9 +160,9 @@ describe("home is the feed", () => {
160160 // own" — true of every post here — is not said again and again.
161161 expect(text).toContain('class="disclosure"');
162162 expect(text).not.toContain("because you own alice/garden");
163 // Your apps: a narrow column, and a tab on a phone.
163 // Your apps: a narrow column, and an area in the bar, one tap away on a phone too.
164164 expect(text).toContain('id="live-apps"');
165 expect(text).toContain('href="/apps"');
165 expect(text).toMatch(/<nav class="areas"[^>]*>\s*<a href="\/apps">Apps<\/a>/);
166166 expect(text).toContain('class="tabs"');
167167 expect(text).not.toContain("home-tabs");
168168 // Nothing stands between the composer and the first post: the crew's
@@ -176,9 +176,10 @@ describe("home is the feed", () => {
176176 expect(text).not.toContain("spent today across");
177177 const apps = await (await get("/apps", aliceCookie)).text();
178178 expect(apps).toContain("spent today across");
179 // Each of the three pages carries the three tabs, so a phone has a way
179 // The bar marks Apps, and the page links the feed, so a phone has a way
180180 // back that is not only the logo.
181 expect(apps).toMatch(/class="tabs"[\s\S]*?href="\/apps"\s+aria-current="page"/);
181 expect(apps).toMatch(/<nav class="areas"[^>]*>\s*<a href="\/apps" aria-current="page">Apps<\/a>/);
182 expect(apps.slice(apps.indexOf("<main"))).toContain('href="/feed"');
182183 // /asked is the feed narrowed to what the person opened (#16229).
183184 const moved = await get("/asked", aliceCookie);
184185 expect(moved.status).toBe(303);
@@ -186,7 +187,7 @@ describe("home is the feed", () => {
186187 expect(text).toMatch(/class="tabs"[\s\S]*?href="\/feed"\s+aria-current="page"/);
187188 for (const page of [apps]) {
188189 expect(page).not.toContain("home-tabs");
189 for (const w of ["Feed", "Your apps"]) expect(page).toContain(w);
190 for (const w of ["Feed", "Apps"]) expect(page).toContain(w);
190191 }
191192 });
192193
test/keymap.test.ts +3 −3
@@ -134,11 +134,11 @@ test("the g jumps are one table by scope: no letter twice in a scope, go_pages a
134134 // go_pages.ts's letters are the global scope's, every one of them.
135135 expect(GO_PAGES.flatMap((p) => (p.key === undefined ? [] : [p.key])).sort()).toEqual(Object.values(GO.global).sort());
136136 expect((Object.values(REPO_TABS) as string[]).sort()).toEqual(Object.values(GO.repo).map((l) => `g ${l}`).sort());
137 // Inside a repository a forge place with the same letter is g and the capital (boards: g B).
137 // Inside a repository a forge place with the same letter is g and the capital (boards g B, Games g P, Infrastructure g I).
138138 const shadowed = Object.values(GO.global).filter((l) => (Object.values(GO.repo) as string[]).includes(l));
139 expect(shadowed).toEqual(["b"]);
139 expect(shadowed).toEqual(["p", "i", "b"]);
140140 // The moved chords say where they went, until the date.
141 expect(oldGo(new Date(Date.parse(OLD_KEYS_UNTIL) - 1)).map((o) => o.was)).toEqual(["g a", "g s"]);
141 expect(oldGo(new Date(Date.parse(OLD_KEYS_UNTIL) - 1)).map((o) => o.was)).toEqual(["g s"]);
142142 expect(oldGo(new Date(OLD_KEYS_UNTIL))).toEqual([]);
143143 });
144144
test/keys-goto.test.ts +17 −3
@@ -10,6 +10,20 @@ test("every g-letter is one lowercase letter, bound once", () => {
1010 expect(new Set(letters).size).toBe(letters.length);
1111 });
1212
13 test("the areas are bound: g a Apps, g p Games for a player or an admin, g i Infrastructure for an admin", () => {
14 clock(10_000);
15 const pressed = (level: number): string[] => {
16 const k = keys(level);
17 for (const letter of ["a", "p", "i"]) {
18 k.press("g");
19 k.press(letter);
20 }
21 return k.assigned;
22 };
23 expect([0, 1, 2, 3].map(pressed)).toEqual([["/apps"], ["/apps"], ["/apps", "/games"], ["/apps", "/games", "/infra"]]);
24 Date.now = realNow;
25 });
26
1327 test("the main pages are bound: g h, g f, g e, g y (keymap.ts GO)", () => {
1428 const at = (k: string) => keyed.find((p) => p.key === k)?.href;
1529 expect(at("h")).toBe("/");
@@ -25,7 +39,7 @@ test("a page has one binding; every target is a page of the list", () => {
2539
2640 test("a viewer is offered only the targets they can open", () => {
2741 const keys = (v: { signedIn: boolean; admin: boolean }) => goPagesFor(v).filter((p) => p.key).map((p) => p.key);
28 expect(keys({ signedIn: false, admin: false })).toEqual(["h", "e"]);
42 expect(keys({ signedIn: false, admin: false })).toEqual(["h", "a", "e"]);
2943 expect(keys({ signedIn: true, admin: false })).not.toContain("y");
3044 expect(keys({ signedIn: true, admin: true })).toContain("y");
3145 });
@@ -74,7 +88,7 @@ test("the script: a stranger's or a user's g f does nothing, an admin's goes to
7488 user.press("g");
7589 user.press("y");
7690 expect(user.assigned).toEqual([]);
77 const admin = keys(2);
91 const admin = keys(3);
7892 admin.press("g");
7993 admin.press("f");
8094 expect(admin.assigned).toEqual(["/flow"]);
@@ -85,7 +99,7 @@ test("the script: a stranger's or a user's g f does nothing, an admin's goes to
8599 });
86100
87101 test("the script: a pause over 1 s forgets the g", () => {
88 const u = keys(2);
102 const u = keys(3);
89103 clock(10_000);
90104 u.press("g");
91105 clock(11_500);
test/keys-palette.test.ts +4 −3
@@ -30,7 +30,8 @@ test("the page list is plain data, scoped by who is looking", () => {
3030 for (const n of ["System", "Releases", "Flow"]) expect(admin).toContain(n);
3131 expect(new Set(GO_PAGES.map((p) => p.href)).size).toBe(GO_PAGES.length);
3232 expect(goLevel({ signedIn: false, admin: false })).toBe(0);
33 expect(goLevel({ signedIn: true, admin: true })).toBe(2);
33 expect(goLevel({ signedIn: true, admin: true })).toBe(3);
34 expect(goLevel({ signedIn: true, admin: false, games: true })).toBe(2);
3435 });
3536
3637 test("the filter: substring match, case and space ignored, a prefix beats a substring", () => {
@@ -67,7 +68,7 @@ test("every listed page answers: no href is a dead route", async () => {
6768
6869 test("a page wears only the viewer's level; no prompt markup is drawn until : is pressed", async () => {
6970 const owner = await (await fetch(`${f.base}/`, { headers: { cookie: f.ownerCookie } })).text();
70 expect(owner).toMatch(/<body[^>]*data-go="[12]"/);
71 expect(owner).toMatch(/<body[^>]*data-go="3"/);
7172 expect(owner).not.toContain('id="goto"');
7273 const anon = await (await fetch(`${f.base}/`)).text();
7374 expect(anon).toMatch(/<body[^>]*data-go="0"/);
@@ -83,7 +84,7 @@ test("the keys script: : opens the combobox prompt, announces the lead, says whe
8384 for (const a of ["'combobox'", "'aria-controls', 'goto-list'", "aria-activedescendant", "'listbox'", "'option'"]) expect(js).toContain(a);
8485 expect(js).not.toContain("data-goto");
8586 expect(js).toContain("No page called that");
86 expect(js).toContain('"Flow","/flow",2');
87 expect(js).toContain('"Flow","/flow",3');
8788 // The field guard returns before the key chain, so a colon typed in a box is a colon.
8889 const src = readFileSync(new URL("../src/web/client.ts", import.meta.url), "utf8");
8990 expect(src.indexOf("t.matches('input, textarea, select, [contenteditable]')")).toBeLessThan(src.indexOf("openGoto();"));
test/page-text.test.ts +5 −2
@@ -60,7 +60,9 @@ test("the real home reads as text: heading and waiting count, no CSS, script or
6060 expect(raw).toContain("<script");
6161 expect(raw).toContain("<style");
6262 const text = pageText(raw);
63 expect(text).toContain("Feed Your apps Design");
63 // Your apps are one step away in the bar, and the page's own tabs are Feed and Design.
64 expect(text).toContain("Apps Games Infrastructure Explore");
65 expect(text).toContain("Feed Design");
6466 // The oldest is said in the largest sensible unit: 50 hours is 2 days.
6567 expect(text).toMatch(/3 waiting on you, oldest 2 days/);
6668 expect(text).not.toMatch(/<\/?[a-z]/i);
@@ -96,7 +98,8 @@ test("scripts/home-read.ts prints the text and the stats line, sends FORGE_COOKI
9698 const r = await run([`${servers.url}/feed`], { FORGE_COOKIE: cookie });
9799 expect(r.code).toBe(0);
98100 expect(r.out.trimEnd().split("\n").pop()).toMatch(/^chars \d+ · words \d+ · fetched in \d+ ms$/);
99 expect(r.out).toContain("Feed Your apps Design");
101 expect(r.out).toContain("Apps Games Infrastructure Explore");
102 expect(r.out).toContain("Feed Design");
100103 const token = cookie.match(/forge_session=([^;]+)/)![1]!;
101104 expect(r.out).not.toContain(token);
102105 expect(r.err).not.toContain(token);
test/palette-roster.test.ts +4 −1
@@ -50,6 +50,7 @@ test("a site-admin person is offered the whole roster", () => {
5050 expect(roster(admin)).toEqual([
5151 ["home", "Home", "your repositories"],
5252 ["explore", "Explore", "on the web"],
53 ["apps", "Apps", "on the web"],
5354 ["explore-feed", "Explore feed", "Atom address"],
5455 ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"],
5556 ["asks-admin", "What stands in the way", "what waits on you and what stands in your way; a asks whoever can, o opens the control"],
@@ -270,6 +271,7 @@ test("a site-admin agent is offered the roster without the person-only entries",
270271 expect(roster({ ...admin, kind: "agent" })).toEqual([
271272 ["home", "Home", "your repositories"],
272273 ["explore", "Explore", "on the web"],
274 ["apps", "Apps", "on the web"],
273275 ["explore-feed", "Explore feed", "Atom address"],
274276 ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"],
275277 ["asks-admin", "What stands in the way", "what waits on you and what stands in your way; a asks whoever can, o opens the control"],
@@ -391,6 +393,7 @@ test("a member person is offered the signed-in roster without the admin entries"
391393 expect(roster(member)).toEqual([
392394 ["home", "Home", "your repositories"],
393395 ["explore", "Explore", "on the web"],
396 ["apps", "Apps", "on the web"],
394397 ["explore-feed", "Explore feed", "Atom address"],
395398 ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"],
396399 ["asks-admin", "What stands in the way", "what waits on you and what stands in your way; a asks whoever can, o opens the control"],
@@ -486,7 +489,6 @@ test("a member person is offered the signed-in roster without the admin entries"
486489 ["claim-link", "A fresh claim link for a forge I sent", "the old link stops; shown once"],
487490 ["recovery-link", "A recovery link for a forge's owner who lost their passkey", "shown once; works once"],
488491 ["bulk", "Bulk actions", "your last bulk actions; u undoes one inside its day"],
489 ["games", "Games", "game servers on your cloud: state, start, stop, restart"],
490492 ["bets", "Bets", "back, stop and finish a repository\'s bets"],
491493 ["origins", "Connected accounts", "the hosts your mirrors come from"],
492494 ["design-gallery", "Component gallery", "every component the design names"],
@@ -510,6 +512,7 @@ test("signed out, the palette offers sign-in and the public entries", () => {
510512 expect(roster()).toEqual([
511513 ["home", "Home", "your repositories"],
512514 ["explore", "Explore", "on the web"],
515 ["apps", "Apps", "on the web"],
513516 ["explore-feed", "Explore feed", "Atom address"],
514517 ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"],
515518 ["registry-gallery", "Registry gallery", "registry items and the apps that use them"],
test/talk-page.test.ts +2 −2
@@ -100,7 +100,7 @@ describe("the page", () => {
100100 const html = await (await get("/talk", alice)).text();
101101 expect(html).toContain('<h1 class="sr-only">Talk</h1>');
102102 expect(html).not.toContain('class="page-head"');
103 const nav = html.slice(html.indexOf('<nav class="talk-chats"'), html.indexOf("</nav>"));
103 const nav = html.slice(html.indexOf('<nav class="talk-chats"'), html.indexOf("</nav>", html.indexOf('<nav class="talk-chats"')));
104104 expect(nav).toContain('<ul class="list talk-list">');
105105 const { talkCss } = await import("../src/web/pages/talk_client.ts");
106106 const rule = (sel: string) => talkCss.match(new RegExp(`(?:^|\\n)${sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*\\{([^}]*)\\}`))?.[1];
@@ -2315,7 +2315,7 @@ describe("the header's Talk button counts confirms waiting", () => {
23152315 describe("narrow viewport controls (#14943)", () => {
23162316 const sideNav = async (path: string) => {
23172317 const html = await (await get(path, alice)).text();
2318 return html.slice(html.indexOf('<nav class="talk-chats"'), html.indexOf("</nav>"));
2318 return html.slice(html.indexOf('<nav class="talk-chats"'), html.indexOf("</nav>", html.indexOf('<nav class="talk-chats"')));
23192319 };
23202320
23212321 test("New comes first, then the search, then the rows; a phone gets the list as its own view, not a fold", async () => {
test/tight.test.ts added +8
@@ -0,0 +1,8 @@
1 import { expect, test } from "bun:test";
2 import { tighten } from "../src/web/tight.ts";
3
4 test("indentation and blank lines go, and a pre and a textarea keep every space of theirs", () => {
5 const pre = "<pre class=\"x\"><code>a\n\n b \n</code></pre>";
6 const area = "<textarea name=\"t\">one\n\n two\n</textarea>";
7 expect(tighten(`<p>\n\n a b\n </p>\n ${pre}\n\n <i>\n c</i>${area}\n \n<preview-x>\n d</preview-x>`)).toBe(`<p>\na b\n</p>\n${pre}\n<i>\nc</i>${area}\n<preview-x>\nd</preview-x>`);
8 });
test/tui-apps.test.ts +5 −1
@@ -502,10 +502,14 @@ describe("terminal: apps, runs and the crew", () => {
502502 await h.until("On you");
503503 // alice is the site admin, so the crew entry would have been there.
504504 const ids = forgeCommands(h.session)(h.app.ctx).map((c) => c.id);
505 for (const gone of ["apps", "app", "runs", "crew"])
505 for (const gone of ["app", "runs", "crew"])
506506 expect(ids).not.toContain(gone);
507507 expect(ids).toContain("repo");
508508 expect(ids).toContain("pulls");
509 // "apps" is the g a jump: it says where the web page is, and opens no screen.
510 await forgeCommands(h.session)(h.app.ctx).find((c) => c.id === "apps")!.run();
511 await h.until("Apps is on the web at /apps");
512 expect(h.text()).toContain("On you");
509513
510514 const before = h.text();
511515 expect(before).not.toContain("new app");
test/which-stub.test.ts +1 −1
@@ -18,7 +18,7 @@ function shell() {
1818 const el: any = new Proxy(function () {}, { get: (_t, k) => (k === "length" ? 0 : el), apply: () => el });
1919 const doc: any = {
2020 head: { appendChild: (s: Script) => void scripts.push(s) },
21 body: { getAttribute: (n: string) => (n === "data-go" ? "2" : null) },
21 body: { getAttribute: (n: string) => (n === "data-go" ? "3" : null) },
2222 documentElement: { classList: { add() {} }, setAttribute() {}, removeAttribute() {}, hasAttribute: () => false },
2323 activeElement: null,
2424 currentScript: null,

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

Keyboard shortcuts

Docs