Public: anyone can read this; the crew can change it.
The top bar names the areas: Apps, Games, Infrastructure, Explore #17646
Merged 17h 25m ago, live in production
sold/nav-areas → main 0 commits 5 threads · 5 unresolved
50 files
changed +537
−97
- AGENTS.md
- docs/design/areas/shell.md
- docs/design/plan.md
- docs/design/size-budget/changelog.json
- docs/design/size-budget/claim.json
- docs/design/size-budget/explore.json
- docs/design/size-budget/fleet.json
- docs/design/size-budget/forges-new.json
- docs/design/size-budget/home.json
- docs/design/size-budget/maintenance.json
- docs/design/size-budget/pricing.json
- docs/design/size-budget/templates.json
- docs/features/games.md
- docs/features/go-jumps.md
- docs/features/keymap.md
- src/core/empty_words.ts
- src/games/store.ts
- src/tui/app/which.ts
- src/tui/forge_parts.ts
- src/tui/screens/games.ts
- src/web/chrome.ts
- src/web/client.ts
- src/web/go_pages.ts
- src/web/keymap.ts
- src/web/layout.ts
- src/web/near_pages.ts
- src/web/pages/apps.ts
- src/web/pages/games.ts
- src/web/studio/home.ts
- src/web/studio/home_tabs.ts
- src/web/style/base.ts
- src/web/style/components.ts
- src/web/tight.ts
- test/account-menu.test.ts
- test/areas-fit.test.ts
- test/areas.test.ts
- test/docs-link.test.ts
- test/explore-url-filters.test.ts
- test/helpers/shell-page.ts
- test/home-feed.test.ts
- test/keymap.test.ts
- test/keys-goto.test.ts
- test/keys-palette.test.ts
- test/now-links.test.ts
- test/page-text.test.ts
- test/palette-roster.test.ts
- test/talk-page.test.ts
- test/tight.test.ts
- test/tui-apps.test.ts
- test/which-stub.test.ts
AGENTS.md +1
| @@ -109,3 +109,4 @@ A pull that adds a page (`src/web/pages/*.ts`), an MCP tool (`src/http/mcp/tools | ||
| 109 | 109 | `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). |
| 110 | 110 | |
| 111 | 111 | 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 @@ | ||
| 3 | 3 | 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`. |
| 4 | 4 | |
| 5 | 5 | - `.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. | |
| 7 | 7 | - `.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. | |
| 8 | 9 | - `.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. |
| 9 | 10 | - `.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. |
| 10 | 11 | - `.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 | ||
| 23 | 23 | `chain`): one line each on why it is a page; retire or turn into board panels. |
| 24 | 24 | 10. **#2697 Tokenise `style/content.ts`** — 23 colours, 31 sizes; the largest debt. |
| 25 | 25 | 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). | |
| 27 | 27 | 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
docs/design/size-budget/claim.json +1 −1
docs/design/size-budget/explore.json +1 −1
docs/design/size-budget/fleet.json +1 −1
docs/design/size-budget/forges-new.json +1 −1
docs/design/size-budget/home.json +1 −1
docs/design/size-budget/maintenance.json +1 −1
docs/design/size-budget/pricing.json +1 −1
docs/design/size-budget/templates.json +1 −1
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`, | ||
| 8 | 8 | |
| 9 | 9 | ## Where |
| 10 | 10 | |
| 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. | |
| 11 | 12 | - **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.md)) and its mods or plugins (Modrinth, below; Upload jar for `PLUGINS`). Pages: `src/web/pages/games.ts`. |
| 12 | 13 | - **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. |
| 13 | 14 | - **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 | ||
| 9 | 9 | | Keys | Page | Who | |
| 10 | 10 | |---|---|---| |
| 11 | 11 | | `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 | | |
| 12 | 15 | | `g e` | Explore | everyone | |
| 13 | | `g f` | Flow | signed in | | |
| 14 | | `g q` | Asks | signed in | | |
| 15 | 16 | | `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. | |
| 17 | 23 | |
| 18 | 24 | - 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. |
| 19 | 25 | - 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. | |
| 21 | 27 | - 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. |
| 22 | 28 | |
| 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 | ||
| 29 | 29 | |
| 30 | 30 | ## Go and scopes |
| 31 | 31 | |
| 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`). | |
| 33 | 33 | |
| 34 | 34 | ## The terminal gives up g |
| 35 | 35 | |
| @@ -53,7 +53,7 @@ The web and the terminal answer the same tree, `g` table and `v`. The counts (`3 | ||
| 53 | 53 | The terminal reads the same tables (`src/tui/app/which.ts`): |
| 54 | 54 | |
| 55 | 55 | - **`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. | |
| 57 | 57 | - **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. |
| 58 | 58 | - **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. |
| 59 | 59 | - **Space moved elsewhere:** |
src/core/empty_words.ts +4 −1
| @@ -96,13 +96,16 @@ const TABLE = { | ||
| 96 | 96 | appFlags: { sentence: NO_FLAG, reason: `Add a ${FLAGS_FILE} to the repository to declare one.` }, |
| 97 | 97 | appRegistry: { sentence: "Nothing installed from the registry.", reason: "An item is noted here when it is installed." }, |
| 98 | 98 | 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." }, | |
| 100 | 100 | gameServices: { sentence: "Nothing has reported yet.", reason: "The box shows its services once its agent first syncs." }, |
| 101 | 101 | gamePlugins: { sentence: "Nothing is installed.", reason: "Search Modrinth below, or upload a jar." }, |
| 102 | 102 | cloudResources: { sentence: "No cloud account is attached.", reason: "Attach one and the forge reads what it holds and what it costs." }, |
| 103 | 103 | gameSnapshots: { sentence: "No snapshot yet.", reason: "One is taken before every import or restore." }, |
| 104 | 104 | } as const satisfies Readonly<Record<string, EmptyWords>>; |
| 105 | 105 | |
| 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 | ||
| 106 | 109 | export type EmptyKind = keyof typeof TABLE; |
| 107 | 110 | |
| 108 | 111 | 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 | ||
| 281 | 281 | return db.query("SELECT 1 FROM game_grant WHERE box_id = ?1 AND user_id = ?2").get(boxId, user.id) !== null; |
| 282 | 282 | } |
| 283 | 283 | |
| 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 | ||
| 284 | 305 | export function grant(db: Database, boxId: string, userId: string, role: Role | "none", service = ""): void { |
| 306 | players.delete(db); | |
| 285 | 307 | if (role === "none") db.query("DELETE FROM game_grant WHERE box_id = ?1 AND user_id = ?2 AND service = ?3").run(boxId, userId, service); |
| 286 | 308 | else |
| 287 | 309 | db.query( |
src/tui/app/which.ts +6
| @@ -36,6 +36,9 @@ export type WhichStep = { readonly open: Chord } | { readonly act: WhichAct } | | ||
| 36 | 36 | /** The forge's places, as the terminal's palette commands that open them. */ |
| 37 | 37 | const PLACE_COMMAND: Record<keyof typeof GO.global, string> = { |
| 38 | 38 | home: "home", |
| 39 | apps: "apps", | |
| 40 | games: "games", | |
| 41 | infra: "infra", | |
| 39 | 42 | explore: "explore", |
| 40 | 43 | flow: "flow", |
| 41 | 44 | talk: "conversations", |
| @@ -45,6 +48,9 @@ const PLACE_COMMAND: Record<keyof typeof GO.global, string> = { | ||
| 45 | 48 | }; |
| 46 | 49 | const PLACE_WORD: Record<keyof typeof GO.global, string> = { |
| 47 | 50 | home: "Home", |
| 51 | apps: "Apps", | |
| 52 | games: "Games", | |
| 53 | infra: "Infrastructure", | |
| 48 | 54 | explore: "Explore", |
| 49 | 55 | flow: "Flow", |
| 50 | 56 | talk: "Talk", |
src/tui/forge_parts.ts +9
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | import { queueTargetsFor } from "../flow/queue_targets.ts"; |
| 13 | 13 | import { queueTargetLines } from "./screens/flow_targets.ts"; |
| 14 | 14 | import { publicOrigin } from "../core/public_origin.ts"; |
| 15 | import { seesAnyBox } from "../games/store.ts"; | |
| 15 | 16 | import { nearPages } from "../web/near_pages.ts"; |
| 16 | 17 | import { search } from "../actions/search.ts"; |
| 17 | 18 | import { greppable } from "../core/search.ts"; |
| @@ -275,6 +276,13 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 275 | 276 | hint: "on the web", |
| 276 | 277 | run: () => openOnWeb(session, ctx, "/explore", "The explorer"), |
| 277 | 278 | }, |
| 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 | }, | |
| 278 | 286 | { |
| 279 | 287 | // The same list as an Atom feed (#10967): the terminal hands over |
| 280 | 288 | // the feed's address, to copy into a reader. |
| @@ -337,6 +345,7 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 337 | 345 | const pages = nearPages(`/${spec}`, { |
| 338 | 346 | signedIn: session.signedIn, |
| 339 | 347 | admin: session.user?.isAdmin === true, |
| 348 | games: seesAnyBox(session.db, session.user), | |
| 340 | 349 | }).map((p) => p.href); |
| 341 | 350 | return near.length === 0 |
| 342 | 351 | ? pages.length === 0 |
src/tui/screens/games.ts +16 −4
| @@ -13,7 +13,8 @@ | ||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | 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"; | |
| 17 | 18 | import { consoleText, crashOf } from "../../games/console.ts"; |
| 18 | 19 | import { commitPolicy, policyOf, proxyPort, STILL_BILLED } from "../../games/sleep.ts"; |
| 19 | 20 | import { SHELL_SERVICE, queueShell } from "../../games/shell.ts"; |
| @@ -45,6 +46,7 @@ import { | ||
| 45 | 46 | queueCommand, |
| 46 | 47 | recentCommands, |
| 47 | 48 | roleOn, |
| 49 | seesAnyBox, | |
| 48 | 50 | seesBox, |
| 49 | 51 | servicesOf, |
| 50 | 52 | type CommandKind, |
| @@ -101,6 +103,8 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen { | ||
| 101 | 103 | if (join === undefined) return `Each service of each game box you may see. ${NO_ADDRESS}`; |
| 102 | 104 | return "address" in join ? `To join, add this server in Minecraft: ${join.address}` : privateWords(join.private); |
| 103 | 105 | }; |
| 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; | |
| 104 | 108 | const rows = () => |
| 105 | 109 | listBoxes(f.app.db) |
| 106 | 110 | .filter((b) => seesBox(f.app.db, f.user, b.id)) |
| @@ -139,7 +143,7 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen { | ||
| 139 | 143 | binding(["s"], "start"), |
| 140 | 144 | binding(["x"], "stop"), |
| 141 | 145 | binding(["r"], "restart"), |
| 142 | binding(["n"], "new server"), | |
| 146 | binding(["n"], "new server, or a first game box"), | |
| 143 | 147 | binding(["d"], "remove a server"), |
| 144 | 148 | binding(["z"], "sleep when empty, or keep running"), |
| 145 | 149 | binding(["L"], "link your Minecraft name (!forge)"), |
| @@ -161,7 +165,9 @@ export function gamesScreen(f: Session, ctx: Ctx): Screen { | ||
| 161 | 165 | ? `${booting.name}: ${bootWords(booting)}` |
| 162 | 166 | : told !== undefined |
| 163 | 167 | ? `${told.name}: ${lines(told)[0]}` |
| 164 | : all.length === 0 | |
| 168 | : mayStart() | |
| 169 | ? `${emptyText("gameBoxes")} n asks Talk to plan one.` | |
| 170 | : all.length === 0 | |
| 165 | 171 | ? emptyText("gameServices") |
| 166 | 172 | : joinLine(); |
| 167 | 173 | 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 { | ||
| 210 | 216 | } |
| 211 | 217 | // A new server on the selected box (or the first you run): words in, the plan shown, yes |
| 212 | 218 | // 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 | } | |
| 213 | 225 | if (!e.ctrl && !e.alt && e.key === "n") { |
| 214 | 226 | const box = at?.box ?? listBoxes(f.app.db).find((b) => mayDo(roleOn(f.app.db, f.user, b.id), "operator")); |
| 215 | 227 | 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 = { | ||
| 685 | 697 | title: "Games", |
| 686 | 698 | hint: "game servers on your cloud: state, start, stop, restart", |
| 687 | 699 | after: ["pinned"], |
| 688 | offered: (session) => session.user !== undefined, | |
| 700 | offered: (session) => seesAnyBox(session.app.db, session.user), | |
| 689 | 701 | run: (session, ctx) => ctx.push(gamesScreen(session, ctx)), |
| 690 | 702 | }; |
src/web/chrome.ts +2 −1
| @@ -36,6 +36,7 @@ import { autonomyStatus } from "../crew/autonomy_status.ts"; | ||
| 36 | 36 | import { mayRaiseCeiling } from "../actions/crew_ceiling.ts"; |
| 37 | 37 | import { stopWords } from "../crew/stop_words.ts"; |
| 38 | 38 | import { icon } from "./icons.ts"; |
| 39 | import { seesAnyBox } from "../games/store.ts"; | |
| 39 | 40 | import { nearPages } from "./near_pages.ts"; |
| 40 | 41 | import { page, redirect } from "./layout.ts"; |
| 41 | 42 | import { leanPage } from "./lean_page.ts"; |
| @@ -113,7 +114,7 @@ export function notFoundPage(ctx: Ctx, opts: { plain?: boolean; noEcho?: boolean | ||
| 113 | 114 | const get = !opts.plain && (ctx.request.method === "GET" || ctx.request.method === "HEAD"); |
| 114 | 115 | const near = get ? nearTo(ctx.app.db, ctx.auth.user, ctx.params.owner ?? "", ctx.params.name ?? "") : []; |
| 115 | 116 | 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) }) | |
| 117 | 118 | : []; |
| 118 | 119 | const tries = near.map((r) => html`<a href="${repoBase(r)}">${r.ownerName}/${r.name}</a>`); |
| 119 | 120 | // 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 */ ` | ||
| 563 | 563 | // one; a reader already at the top is not moved. |
| 564 | 564 | function surface() { |
| 565 | 565 | 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; | |
| 567 | 568 | if (top < bar) main.scrollIntoView({ block: 'start' }); |
| 568 | 569 | } |
| 569 | 570 | nav.addEventListener('click', function (e) { |
| @@ -1727,7 +1728,10 @@ ${whichStubJs(whichAsset().path)} | ||
| 1727 | 1728 | ['o or Enter', 'Open the focused row', ['o', 'Enter'], openFocused], |
| 1728 | 1729 | ['/', 'Focus search', ['/'], function (e) { |
| 1729 | 1730 | 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(); | |
| 1731 | 1735 | }], |
| 1732 | 1736 | ['t', 'Tell the crew', ['t'], function (e) { |
| 1733 | 1737 | // 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)} | ||
| 1816 | 1820 | pr.appendChild(pk); pr.appendChild(pl); tbody.appendChild(pr); |
| 1817 | 1821 | } |
| 1818 | 1822 | // The \`g\` jumps, read from the same list: one row per page this viewer may open by key. |
| 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 | }); | |
| 1820 | 1827 | table.appendChild(tbody); |
| 1821 | 1828 | if (body) { body.textContent = ''; body.appendChild(table); } |
| 1822 | 1829 | openModal(dlg); |
src/web/go_pages.ts +28 −13
| @@ -11,8 +11,10 @@ export interface GoPage { | ||
| 11 | 11 | /** The name typed to reach it. */ |
| 12 | 12 | readonly name: string; |
| 13 | 13 | 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; | |
| 16 | 18 | /** Present when the Cmd/Ctrl K palette also lists it as a "Go to" row, in its longer wording. */ |
| 17 | 19 | readonly palette?: string; |
| 18 | 20 | /** The letter that follows `g` to jump here from any page (`g e` Explore). One letter, once. */ |
| @@ -21,8 +23,10 @@ export interface GoPage { | ||
| 21 | 23 | |
| 22 | 24 | export const GO_PAGES: readonly GoPage[] = [ |
| 23 | 25 | { 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" }, | |
| 26 | 30 | { name: "Packs", href: "/packs", who: "all", palette: "Forge packs" }, |
| 27 | 31 | { name: "Front page", href: "/front", who: "all", palette: "Front page" }, |
| 28 | 32 | { name: "Search", href: "/search", who: "all", palette: "Search" }, |
| @@ -45,21 +49,32 @@ export const GO_PAGES: readonly GoPage[] = [ | ||
| 45 | 49 | { name: "Audit", href: "/audit", who: "admin" }, |
| 46 | 50 | ]; |
| 47 | 51 | |
| 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; | |
| 53 | 57 | } |
| 54 | 58 | |
| 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; | |
| 58 | 67 | } |
| 59 | 68 | |
| 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 | ||
| 60 | 75 | /** The list as the keys script carries it: [name, href, level needed, the letter after `g` or ""]. */ |
| 61 | 76 | 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 ?? ""]); | |
| 63 | 78 | } |
| 64 | 79 | |
| 65 | 80 | /** 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 @@ | ||
| 19 | 19 | * clash in a scope. |
| 20 | 20 | */ |
| 21 | 21 | 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" }, | |
| 23 | 23 | repo: { code: "c", issues: "i", pulls: "p", runs: "r", map: "m", log: "l", branches: "b", forks: "k", settings: "s" }, |
| 24 | 24 | } as const; |
| 25 | 25 | |
| @@ -124,11 +124,10 @@ export const REPO_TABS = { | ||
| 124 | 124 | /** |
| 125 | 125 | * The g chords that moved with {@link GO} (2026-12-01), each with what it says until |
| 126 | 126 | * {@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. | |
| 129 | 129 | */ |
| 130 | 130 | export const OLD_GO: readonly { readonly was: string; readonly says: string }[] = [ |
| 131 | { was: "g a", says: `g ${GO.repo.map} is the map now` }, | |
| 132 | 131 | { was: "g s", says: `g ${GO.global.system} is System now (g s is a repository's settings)` }, |
| 133 | 132 | ]; |
| 134 | 133 |
src/web/layout.ts +27 −8
| @@ -13,7 +13,8 @@ import { requestHolds } from "../http/conditional.ts"; | ||
| 13 | 13 | import { sshOn } from "../settings/ssh.ts"; |
| 14 | 14 | import { hereAddress, returnTo, withReturn } from "./return_to.ts"; |
| 15 | 15 | 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"; | |
| 17 | 18 | import { NEW_ISSUE_KEY } from "./script_keys.ts"; |
| 18 | 19 | import { newIssueHref } from "./issue_from.ts"; |
| 19 | 20 | import { OPENSEARCH_PATH, OPENSEARCH_TITLE, OPENSEARCH_TYPE } from "./opensearch.ts"; |
| @@ -72,6 +73,7 @@ import { | ||
| 72 | 73 | import { prefersJson } from "./form.ts"; |
| 73 | 74 | import { notePhase } from "../core/route_timing.ts"; |
| 74 | 75 | import { html, raw, when, type Html } from "./html.ts"; |
| 76 | import { tighten } from "./tight.ts"; | |
| 75 | 77 | import { ASK_FORM_ID, askButton, askFormShell } from "./blocked.ts"; |
| 76 | 78 | import { noRoom } from "../spawn/door.ts"; |
| 77 | 79 | import { takeNotice } from "../core/access_link.ts"; |
| @@ -124,8 +126,8 @@ export interface PageOptions { | ||
| 124 | 126 | */ |
| 125 | 127 | description?: string; |
| 126 | 128 | /** |
| 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. | |
| 129 | 131 | */ |
| 130 | 132 | tight?: boolean; |
| 131 | 133 | /** |
| @@ -374,7 +376,6 @@ function userMenu( | ||
| 374 | 376 | const items: (MenuItem | Html)[] = [ |
| 375 | 377 | { label: "Your profile", href: `/${user.username}`, icon: "user", note: user.username }, |
| 376 | 378 | { label: "Repositories", href: "/repos", icon: "repo" }, |
| 377 | { label: "Apps", href: "/apps", icon: "rocket" }, | |
| 378 | 379 | ...featureItems(ctx, user), |
| 379 | 380 | { separator: true, label: "" }, |
| 380 | 381 | { label: "Settings", href: "/settings", icon: "settings" }, |
| @@ -531,6 +532,7 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html { | ||
| 531 | 532 | }); |
| 532 | 533 | const states = open.length > 0 ? appsRuntime(ctx.app)?.statusMany(open) : undefined; |
| 533 | 534 | const foundry = foundryHref(ctx.app, ctx.auth.user); |
| 535 | const viewer = goViewer(ctx); | |
| 534 | 536 | const here = pageRepo(ctx); |
| 535 | 537 | const tell = tellTarget(ctx, here); |
| 536 | 538 | const tellHref = |
| @@ -584,7 +586,7 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html { | ||
| 584 | 586 | ? STATIC_PALETTE.filter((p) => { |
| 585 | 587 | if (p.h === "/settings/keys" && !sshOn(ctx.app.db)) return false; |
| 586 | 588 | 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); | |
| 588 | 590 | }) |
| 589 | 591 | : [ |
| 590 | 592 | ...STATIC_PALETTE.filter((p) => VISITOR_PALETTE.has(p.t)), |
| @@ -711,7 +713,23 @@ function talkButton(ctx: Ctx, user: User, about?: string): Html { | ||
| 711 | 713 | >`; |
| 712 | 714 | } |
| 713 | 715 | |
| 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. */ | |
| 715 | 733 | function topbar( |
| 716 | 734 | ctx: Ctx, |
| 717 | 735 | theme: ThemeName | undefined, |
| @@ -725,6 +743,7 @@ function topbar( | ||
| 725 | 743 | <a href="/" class="wordmark" data-shortcut="${keyOf("home")}" ${hintAttr(keyOf("home"))} |
| 726 | 744 | ><span class="mark"></span>forge</a |
| 727 | 745 | > |
| 746 | ${areas(ctx)} | |
| 728 | 747 | ${when( |
| 729 | 748 | crumbs, |
| 730 | 749 | (items) => |
| @@ -1068,7 +1087,7 @@ export function page(options: PageOptions, status = 200): Response { | ||
| 1068 | 1087 | ? raw(`<style>${options.styleCss}</style>`) |
| 1069 | 1088 | : null} |
| 1070 | 1089 | </head> |
| 1071 | <body data-go="${goLevel({ signedIn: ctx.auth.user !== undefined, admin: ctx.auth.user?.isAdmin === true })}"> | |
| 1090 | <body data-go="${goLevel(goViewer(ctx))}"> | |
| 1072 | 1091 | ${shell} |
| 1073 | 1092 | <script src="${shellAsset().path}" defer></script> |
| 1074 | 1093 | <script src="${beaconAsset().path}" defer></script> |
| @@ -1079,7 +1098,7 @@ export function page(options: PageOptions, status = 200): Response { | ||
| 1079 | 1098 | // Signed-out, flash-free pages are tagged by their own bytes so a revisit |
| 1080 | 1099 | // costs a 304 (`http/etag.ts`). |
| 1081 | 1100 | 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); | |
| 1083 | 1102 | const headers = documentHeaders(options, tagged, links); |
| 1084 | 1103 | // A flash is shown exactly once: rendering it is also what clears it. |
| 1085 | 1104 | if (cookieFlash) headers.append("set-cookie", clearFlashCookie(ctx.url, ctx.app.config.url)); |
src/web/near_pages.ts +2 −2
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | * viewer may be sent to, so a page they cannot open is never named. |
| 6 | 6 | */ |
| 7 | 7 | 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"; | |
| 9 | 9 | |
| 10 | 10 | const NEAR_MAX = 3; |
| 11 | 11 | /** |
| @@ -20,7 +20,7 @@ const MAX_ASKED = 40; | ||
| 20 | 20 | * Up to three pages whose name is within edit distance 3 (at most half its length) of the path's |
| 21 | 21 | * first segment, nearest first. |
| 22 | 22 | */ |
| 23 | export function nearPages(pathname: string, viewer: { signedIn: boolean; admin: boolean }): GoPage[] { | |
| 23 | export function nearPages(pathname: string, viewer: GoViewer): GoPage[] { | |
| 24 | 24 | let first = pathname.split("/").find((s) => s !== "") ?? ""; |
| 25 | 25 | try { |
| 26 | 26 | first = decodeURIComponent(first); |
src/web/pages/apps.ts +3 −4
| @@ -85,7 +85,6 @@ import { noAgentsBlocked } from "../../actions/blocked_words.ts"; | ||
| 85 | 85 | import { flashTo, page, redirect } from "../layout.ts"; |
| 86 | 86 | import { writableAppsOf } from "../studio/asks.ts"; |
| 87 | 87 | import { costLine } from "../studio/cost_line.ts"; |
| 88 | import { homeTabs } from "../studio/home_tabs.ts"; | |
| 89 | 88 | import { shelfRows } from "../studio/shelf.ts"; |
| 90 | 89 | import { |
| 91 | 90 | badge, |
| @@ -227,9 +226,9 @@ export async function appsList(ctx: Ctx): Promise<Response> { | ||
| 227 | 226 | const hasData = |
| 228 | 227 | ctx.auth.user !== undefined && |
| 229 | 228 | (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}`, | |
| 233 | 232 | sub: APPS_PURPOSE, |
| 234 | 233 | })} |
| 235 | 234 | ${cost} |
src/web/pages/games.ts +9 −2
| @@ -67,6 +67,7 @@ import { topologyBlock, TOPOLOGY_CSS } from "./games_topology.ts"; | ||
| 67 | 67 | import { defaultHeadResponse, headResponse } from "../../games/heads.ts"; |
| 68 | 68 | import { eventsOf, eventWords, isBedrock, knowsPlayer, peopleOf, peopleWords, queuePeople, UNDO, type PeopleOp } from "../../games/people.ts"; |
| 69 | 69 | import { queueWorld, undoOf, worldWords } from "../../games/worlds.ts"; |
| 70 | import { START_BOX } from "../../core/empty_words.ts"; | |
| 70 | 71 | import { emptyLine, emptyNote } from "../empty_words.ts"; |
| 71 | 72 | import { findingsOf, type GameFinding } from "../../games/player_events.ts"; |
| 72 | 73 | import { findingsOf as kickFindingsOf } from "../../games/findings.ts"; |
| @@ -149,6 +150,12 @@ function boxOf(ctx: Ctx, need: Role, service = ""): { box: GameBox; role: Role } | ||
| 149 | 150 | return { box, role: role! }; |
| 150 | 151 | } |
| 151 | 152 | |
| 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 | ||
| 152 | 159 | // GET /games |
| 153 | 160 | export function gamesPage(ctx: Ctx): Response { |
| 154 | 161 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| @@ -158,9 +165,9 @@ export function gamesPage(ctx: Ctx): Response { | ||
| 158 | 165 | return timePhase(ctx.request, "render", () => page({ |
| 159 | 166 | ctx, |
| 160 | 167 | 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." })} | |
| 162 | 169 | ${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}` | |
| 164 | 171 | : rowList( |
| 165 | 172 | boxes.map((b) => |
| 166 | 173 | row({ |
src/web/studio/home.ts +1
src/web/studio/home_tabs.ts +6 −6
| @@ -1,19 +1,19 @@ | ||
| 1 | 1 | /** |
| 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`. | |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | import { html, type Html } from "../html.ts"; |
| 9 | 9 | import { tabs } from "../ui.ts"; |
| 10 | 10 | |
| 11 | export type HomeTab = "feed" | "apps" | "design"; | |
| 11 | export type HomeTab = "feed" | "design"; | |
| 12 | 12 | |
| 13 | 13 | /** §5's `tabs()` in a `.mb` block: link tabs, so `aria-current`. */ |
| 14 | 14 | export function homeTabs(current: HomeTab): Html { |
| 15 | 15 | const item = (id: HomeTab, href: string, label: string) => ({ label, href, current: current === id }); |
| 16 | 16 | 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")} | |
| 18 | 18 | </div>`; |
| 19 | 19 | } |
src/web/style/base.ts +28 −1
| @@ -44,7 +44,8 @@ export const base = /* css */ ` | ||
| 44 | 44 | --radius: 8px; /* surfaces: cards, panels, code blocks */ |
| 45 | 45 | --radius-lg: 12px; /* overlays: dialogs, palette, menus */ |
| 46 | 46 | --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)); | |
| 48 | 49 | --page: 1120px; |
| 49 | 50 | --measure: 72ch; |
| 50 | 51 | --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; } | ||
| 148 | 149 | } |
| 149 | 150 | @media (hover: hover) and (pointer: fine) { .wordmark:hover { color: var(--fg); } |
| 150 | 151 | .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) { | |
| 163 | :root:has(.areas) { --areas-h: 44px; } | |
| 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 | } | |
| 151 | 170 | .topbar .spacer { flex: 1; } |
| 152 | 171 | .topbar-tools { display: flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; } |
| 153 | 172 | .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; } | ||
| 234 | 253 | .hide-sm { display: inline-flex; } |
| 235 | 254 | .hide-lg { display: none; } |
| 236 | 255 | } |
| 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 | } | |
| 237 | 264 | |
| 238 | 265 | /* The page does not ask to cover the screen (no viewport-fit): inside another |
| 239 | 266 | 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; } | ||
| 1459 | 1459 | /* Under a finger, 44px each way (docs/design/areas/touch.md). */ |
| 1460 | 1460 | @media (pointer: coarse) { |
| 1461 | 1461 | /* 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)); } | |
| 1463 | 1463 | .btn[data-size], .input, .topbar-search input, .tabs > a, .seg > a, .menu-item, .where-place, summary, label.check, .diff-viewed { min-height: 44px; } |
| 1464 | 1464 | .btn-icon, .btn-icon[data-size], .talk-page .talk :is(.talk-act, .talk-copy) { width: 44px; min-width: 44px; height: 44px; } |
| 1465 | 1465 | .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/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"); | |
| 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/docs-link.test.ts +1 −1
| @@ -138,7 +138,7 @@ test("the /docs index stays small: every document linked from it or from Interna | ||
| 138 | 138 | // public page carries (#14310: image alt, locale, icons, theme colors, JSON-LD) adds about |
| 139 | 139 | // 0.6 KB, so the test app is held to the issue's 15 KB itself. The index's own content is |
| 140 | 140 | // about 4.4 KB; the rest is the head and the shared page chrome. |
| 141 | expect(new TextEncoder().encode(text).length).toBeLessThan(15.7 * 1024); // +~0.6 KB: the theme select and four themes' boot rules (15,977 B measured) | |
| 141 | expect(new TextEncoder().encode(text).length).toBeLessThan(15.9 * 1024); // +~0.6 KB: the theme select and four themes' boot rules; +0.2 KB: the areas in the top bar (16,191 B measured) | |
| 142 | 142 | }); |
| 143 | 143 | |
| 144 | 144 | test("the /docs index costs at most four SQL statements once warm (measured: 2.5 ms server time)", async () => { |
test/explore-url-filters.test.ts +2 −2
| @@ -59,9 +59,9 @@ const listed = (html: string): string[] => { | ||
| 59 | 59 | const list = /<ul class="list">([\s\S]*?)<\/ul>/.exec(html); |
| 60 | 60 | return list === null ? [] : [...list[1]!.matchAll(/<li[^>]*>[\s\S]*?<a href="(\/[^"?]*)">/g)].map((m) => m[1]!); |
| 61 | 61 | }; |
| 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. */ | |
| 63 | 63 | 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"))); | |
| 65 | 65 | if (found === null) throw new Error(`no control named ${label}`); |
| 66 | 66 | return found[1]!.replace(/&/g, "&"); |
| 67 | 67 | }; |
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. */ | |
| 2 | 2 | import { shellJs } from "../../src/web/client.ts"; |
| 3 | 3 | |
| 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> = {}) { | |
| 5 | 5 | const { Window } = await import("happy-dom"); |
| 6 | 6 | const win = new Window({ url: `http://forge.test${path}` }); |
| 7 | 7 | for (const [k, v] of Object.entries(store)) win.sessionStorage.setItem(k, v); |
| 8 | 8 | win.document.body.innerHTML = body; |
| 9 | Object.assign(win.document.body.dataset, data); | |
| 9 | 10 | (win.HTMLElement.prototype as any).scrollIntoView ??= () => {}; |
| 10 | 11 | const assigned: string[] = []; |
| 11 | 12 | const loc = new Proxy(win.location, { |
test/home-feed.test.ts +6 −5
| @@ -160,9 +160,9 @@ describe("home is the feed", () => { | ||
| 160 | 160 | // own" — true of every post here — is not said again and again. |
| 161 | 161 | expect(text).toContain('class="disclosure"'); |
| 162 | 162 | 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. | |
| 164 | 164 | 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>/); | |
| 166 | 166 | expect(text).toContain('class="tabs"'); |
| 167 | 167 | expect(text).not.toContain("home-tabs"); |
| 168 | 168 | // Nothing stands between the composer and the first post: the crew's |
| @@ -176,9 +176,10 @@ describe("home is the feed", () => { | ||
| 176 | 176 | expect(text).not.toContain("spent today across"); |
| 177 | 177 | const apps = await (await get("/apps", aliceCookie)).text(); |
| 178 | 178 | 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 | |
| 180 | 180 | // 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"'); | |
| 182 | 183 | // /asked is the feed narrowed to what the person opened (#16229). |
| 183 | 184 | const moved = await get("/asked", aliceCookie); |
| 184 | 185 | expect(moved.status).toBe(303); |
| @@ -186,7 +187,7 @@ describe("home is the feed", () => { | ||
| 186 | 187 | expect(text).toMatch(/class="tabs"[\s\S]*?href="\/feed"\s+aria-current="page"/); |
| 187 | 188 | for (const page of [apps]) { |
| 188 | 189 | 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); | |
| 190 | 191 | } |
| 191 | 192 | }); |
| 192 | 193 |
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 | ||
| 134 | 134 | // go_pages.ts's letters are the global scope's, every one of them. |
| 135 | 135 | expect(GO_PAGES.flatMap((p) => (p.key === undefined ? [] : [p.key])).sort()).toEqual(Object.values(GO.global).sort()); |
| 136 | 136 | 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). | |
| 138 | 138 | 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"]); | |
| 140 | 140 | // 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"]); | |
| 142 | 142 | expect(oldGo(new Date(OLD_KEYS_UNTIL))).toEqual([]); |
| 143 | 143 | }); |
| 144 | 144 |
test/keys-goto.test.ts +17 −3
| @@ -10,6 +10,20 @@ test("every g-letter is one lowercase letter, bound once", () => { | ||
| 10 | 10 | expect(new Set(letters).size).toBe(letters.length); |
| 11 | 11 | }); |
| 12 | 12 | |
| 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 | ||
| 13 | 27 | test("the main pages are bound: g h, g f, g e, g y (keymap.ts GO)", () => { |
| 14 | 28 | const at = (k: string) => keyed.find((p) => p.key === k)?.href; |
| 15 | 29 | expect(at("h")).toBe("/"); |
| @@ -25,7 +39,7 @@ test("a page has one binding; every target is a page of the list", () => { | ||
| 25 | 39 | |
| 26 | 40 | test("a viewer is offered only the targets they can open", () => { |
| 27 | 41 | 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"]); | |
| 29 | 43 | expect(keys({ signedIn: true, admin: false })).not.toContain("y"); |
| 30 | 44 | expect(keys({ signedIn: true, admin: true })).toContain("y"); |
| 31 | 45 | }); |
| @@ -74,7 +88,7 @@ test("the script: a stranger's or a user's g f does nothing, an admin's goes to | ||
| 74 | 88 | user.press("g"); |
| 75 | 89 | user.press("y"); |
| 76 | 90 | expect(user.assigned).toEqual([]); |
| 77 | const admin = keys(2); | |
| 91 | const admin = keys(3); | |
| 78 | 92 | admin.press("g"); |
| 79 | 93 | admin.press("f"); |
| 80 | 94 | 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 | ||
| 85 | 99 | }); |
| 86 | 100 | |
| 87 | 101 | test("the script: a pause over 1 s forgets the g", () => { |
| 88 | const u = keys(2); | |
| 102 | const u = keys(3); | |
| 89 | 103 | clock(10_000); |
| 90 | 104 | u.press("g"); |
| 91 | 105 | 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", () => { | ||
| 30 | 30 | for (const n of ["System", "Releases", "Flow"]) expect(admin).toContain(n); |
| 31 | 31 | expect(new Set(GO_PAGES.map((p) => p.href)).size).toBe(GO_PAGES.length); |
| 32 | 32 | 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); | |
| 34 | 35 | }); |
| 35 | 36 | |
| 36 | 37 | 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 () => { | ||
| 67 | 68 | |
| 68 | 69 | test("a page wears only the viewer's level; no prompt markup is drawn until : is pressed", async () => { |
| 69 | 70 | 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"/); | |
| 71 | 72 | expect(owner).not.toContain('id="goto"'); |
| 72 | 73 | const anon = await (await fetch(`${f.base}/`)).text(); |
| 73 | 74 | expect(anon).toMatch(/<body[^>]*data-go="0"/); |
| @@ -83,7 +84,7 @@ test("the keys script: : opens the combobox prompt, announces the lead, says whe | ||
| 83 | 84 | for (const a of ["'combobox'", "'aria-controls', 'goto-list'", "aria-activedescendant", "'listbox'", "'option'"]) expect(js).toContain(a); |
| 84 | 85 | expect(js).not.toContain("data-goto"); |
| 85 | 86 | expect(js).toContain("No page called that"); |
| 86 | expect(js).toContain('"Flow","/flow",2'); | |
| 87 | expect(js).toContain('"Flow","/flow",3'); | |
| 87 | 88 | // The field guard returns before the key chain, so a colon typed in a box is a colon. |
| 88 | 89 | const src = readFileSync(new URL("../src/web/client.ts", import.meta.url), "utf8"); |
| 89 | 90 | expect(src.indexOf("t.matches('input, textarea, select, [contenteditable]')")).toBeLessThan(src.indexOf("openGoto();")); |
test/now-links.test.ts +13 −1
| @@ -101,7 +101,6 @@ test("a person who is not a site admin gets no Now pages, and an unknown stage i | ||
| 101 | 101 | const MENU_TITLES: Record<string, string> = { |
| 102 | 102 | "Your profile": "root", |
| 103 | 103 | Repositories: "Your repositories", |
| 104 | Apps: "Apps", | |
| 105 | 104 | Settings: "Settings", |
| 106 | 105 | People: "People", |
| 107 | 106 | Forges: "Forges you sent", |
| @@ -123,6 +122,19 @@ test("every link in the account menu lands on a page that is its label", async ( | ||
| 123 | 122 | } |
| 124 | 123 | }); |
| 125 | 124 | |
| 125 | test("every area in the top bar lands on a page that is its label", async () => { | |
| 126 | const home = await (await get("/", rootCookie)).text(); | |
| 127 | const bar = /<nav class="areas"[\s\S]*?<\/nav>/.exec(home)![0]; | |
| 128 | const items = [...bar.matchAll(/<a href="([^"]+)"[^>]*>([^<]+)<\/a>/g)].map((m) => ({ href: m[1]!, label: m[2]! })); | |
| 129 | expect(items.map((i) => i.label)).toEqual(["Apps", "Games", "Infrastructure", "Explore"]); | |
| 130 | for (const item of items) { | |
| 131 | const res = await get(item.href, rootCookie); | |
| 132 | expect(res.status, item.href).toBe(200); | |
| 133 | // "All clouds · Infrastructure": the area is the title's last name. | |
| 134 | expect((await res.text()).match(/<title>(.*?) · forge<\/title>/s)?.[1]?.split(" · ").at(-1), item.href).toBe(item.label); | |
| 135 | } | |
| 136 | }); | |
| 137 | ||
| 126 | 138 | test("/repos lists the repositories you may write, and asks a visitor to sign in", async () => { |
| 127 | 139 | const page = await (await get("/repos", aliceCookie)).text(); |
| 128 | 140 | expect(page).toContain("alice/notes"); |
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 | ||
| 60 | 60 | expect(raw).toContain("<script"); |
| 61 | 61 | expect(raw).toContain("<style"); |
| 62 | 62 | 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"); | |
| 64 | 66 | // The oldest is said in the largest sensible unit: 50 hours is 2 days. |
| 65 | 67 | expect(text).toMatch(/3 waiting on you, oldest 2 days/); |
| 66 | 68 | 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 | ||
| 96 | 98 | const r = await run([`${servers.url}/feed`], { FORGE_COOKIE: cookie }); |
| 97 | 99 | expect(r.code).toBe(0); |
| 98 | 100 | 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"); | |
| 100 | 103 | const token = cookie.match(/forge_session=([^;]+)/)![1]!; |
| 101 | 104 | expect(r.out).not.toContain(token); |
| 102 | 105 | 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", () => { | ||
| 50 | 50 | expect(roster(admin)).toEqual([ |
| 51 | 51 | ["home", "Home", "your repositories"], |
| 52 | 52 | ["explore", "Explore", "on the web"], |
| 53 | ["apps", "Apps", "on the web"], | |
| 53 | 54 | ["explore-feed", "Explore feed", "Atom address"], |
| 54 | 55 | ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"], |
| 55 | 56 | ["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", | ||
| 270 | 271 | expect(roster({ ...admin, kind: "agent" })).toEqual([ |
| 271 | 272 | ["home", "Home", "your repositories"], |
| 272 | 273 | ["explore", "Explore", "on the web"], |
| 274 | ["apps", "Apps", "on the web"], | |
| 273 | 275 | ["explore-feed", "Explore feed", "Atom address"], |
| 274 | 276 | ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"], |
| 275 | 277 | ["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" | ||
| 391 | 393 | expect(roster(member)).toEqual([ |
| 392 | 394 | ["home", "Home", "your repositories"], |
| 393 | 395 | ["explore", "Explore", "on the web"], |
| 396 | ["apps", "Apps", "on the web"], | |
| 394 | 397 | ["explore-feed", "Explore feed", "Atom address"], |
| 395 | 398 | ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"], |
| 396 | 399 | ["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" | ||
| 486 | 489 | ["claim-link", "A fresh claim link for a forge I sent", "the old link stops; shown once"], |
| 487 | 490 | ["recovery-link", "A recovery link for a forge's owner who lost their passkey", "shown once; works once"], |
| 488 | 491 | ["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"], | |
| 490 | 492 | ["bets", "Bets", "back, stop and finish a repository\'s bets"], |
| 491 | 493 | ["origins", "Connected accounts", "the hosts your mirrors come from"], |
| 492 | 494 | ["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", () => { | ||
| 510 | 512 | expect(roster()).toEqual([ |
| 511 | 513 | ["home", "Home", "your repositories"], |
| 512 | 514 | ["explore", "Explore", "on the web"], |
| 515 | ["apps", "Apps", "on the web"], | |
| 513 | 516 | ["explore-feed", "Explore feed", "Atom address"], |
| 514 | 517 | ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"], |
| 515 | 518 | ["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", () => { | ||
| 100 | 100 | const html = await (await get("/talk", alice)).text(); |
| 101 | 101 | expect(html).toContain('<h1 class="sr-only">Talk</h1>'); |
| 102 | 102 | 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"'))); | |
| 104 | 104 | expect(nav).toContain('<ul class="list talk-list">'); |
| 105 | 105 | const { talkCss } = await import("../src/web/pages/talk_client.ts"); |
| 106 | 106 | 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", () => { | ||
| 2315 | 2315 | describe("narrow viewport controls (#14943)", () => { |
| 2316 | 2316 | const sideNav = async (path: string) => { |
| 2317 | 2317 | 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"'))); | |
| 2319 | 2319 | }; |
| 2320 | 2320 | |
| 2321 | 2321 | 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", () => { | ||
| 502 | 502 | await h.until("On you"); |
| 503 | 503 | // alice is the site admin, so the crew entry would have been there. |
| 504 | 504 | 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"]) | |
| 506 | 506 | expect(ids).not.toContain(gone); |
| 507 | 507 | expect(ids).toContain("repo"); |
| 508 | 508 | 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"); | |
| 509 | 513 | |
| 510 | 514 | const before = h.text(); |
| 511 | 515 | expect(before).not.toContain("new app"); |
test/which-stub.test.ts +1 −1
| @@ -18,7 +18,7 @@ function shell() { | ||
| 18 | 18 | const el: any = new Proxy(function () {}, { get: (_t, k) => (k === "length" ? 0 : el), apply: () => el }); |
| 19 | 19 | const doc: any = { |
| 20 | 20 | 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) }, | |
| 22 | 22 | documentElement: { classList: { add() {} }, setAttribute() {}, removeAttribute() {}, hasAttribute: () => false }, |
| 23 | 23 | activeElement: null, |
| 24 | 24 | currentScript: null, |
new above
offline
The sheet's capital-letter rule reads the DOM with a selector that excludes
.wordmarkand.talk-btn, and no test fails without it. Put the shadowed-letter fact in the data, or add a test.