Show the Activities picker as a two-column Score ledger ordered by recently played or A to Z

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-12 10:35:28 -08:00
1 parent ba19f79f1c
commit fde92ef4d2
11 files changed
+453 -99

No files matched your search

@@ -5,7 +5,7 @@ One row per file of every game but Ghoul Rush (which has its own files: [core](.
| File | Role |
|---|---|
| `public/activities.js` | the list of activities (`ACTIVITIES`: each game's id, title, picker card line `blurb` and module path) an optional `courses` list (Mini golf's six course ids, which open a course dashboard), `bestKey(id, course?)`, the flat looks.json key for its best score (`activityBestSnake`, one per golf course `activityBestGolfPirate` to `activityBestGolfFrost`, `activityBestTrails`, `activityBestBugs`, `activityBestDrive`, `activityBestStack`, `activityBestBumper`, `activityBestRapids`, `activityBestFuse`, `activityBestHop`, `activityBestBounce`, `activityBestGhoul`, `activityBestFlock`); lists Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road, Ghoul Rush and Flock Dash, `bestKeys(entry)`, every best key a game keeps, and documents the game contract including the course parts (`courses` and `preview()` on the export, `setCourse()` and `course` on the game), the optional `pointer(type, x, y)`, `release(name)` (a game key let go) and `lowerIsBetter`; data only, imported by the page and by Node |
| `public/activities.js` | the list of activities (`ACTIVITIES`: each game's id, title, picker row line `blurb` and module path) an optional `courses` list (Mini golf's six course ids, which open a course dashboard), `bestKey(id, course?)`, the flat looks.json key for its best score (`activityBestSnake`, one per golf course `activityBestGolfPirate` to `activityBestGolfFrost`, `activityBestTrails`, `activityBestBugs`, `activityBestDrive`, `activityBestStack`, `activityBestBumper`, `activityBestRapids`, `activityBestFuse`, `activityBestHop`, `activityBestBounce`, `activityBestGhoul`, `activityBestFlock`); lists Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road, Ghoul Rush and Flock Dash, `bestKeys(entry)`, every best key a game keeps, `playedKey(id)` (`activityPlayedSnake`, the epoch ms a game was last picked, 0 for never) and `orderGames(list, looks, order)` (the picker's `{ played, unplayed }`), and documents the game contract including the course parts (`courses` and `preview()` on the export, `setCourse()` and `course` on the game), the optional `pointer(type, x, y)`, `release(name)` (a game key let go) and `lowerIsBetter`; data only, imported by the page and by Node |
| `public/activities/snake.js` | Snake: its rules as plain exported functions and the game contract (`create({ canvas, tone, onScore })` returning `start`, `pause`, `resume`, `key`, `tick`, `resize`, `score`, `state`); it never runs a timer or listens for keys, so the Activities window drives it; it also holds the music's rules: `MUSIC_TRACKS`, `dealMusic(random, last)` (a round's shuffle of the ten tracks, never opening on the last round's opener), `trackFor(deck, level)` and `heat(round)` (the snake's speed as 0.3 to 1, so the lead and drums are in from the first step) |
| `public/activities/trails.js` | Light Trails: its rules as plain exported functions (`newRound`, `newHeat`, `turn`, `boost`, `advance` in 8 ms slices (where your crash is held for `GRACE_MS`, a turn in that time riding out of it; rivals get no grace), `choose` and `room` for the rivals' flood-fill steering, `applyPower` (a Mystery becoming another pad), `pickPower` (by each pad's `from` arena, a Heart only under `MAX_LIVES`), `fireLaser`, `hyperjump`, `awardLives` (a life every `LIFE_SCORE` points, the mark moving on at the cap), `spawnItem`, `closeRing`), the `ARENAS` (rivals, sharpness and what each adds), the `POWERS` pads (Boost, Phase, Eraser, Slow-mo, Coin, Heart, Shield held across heats until a crash in your grace pops it, Laser with `LASER_SHOTS`, Score x2 through one `gain()` every score goes through, Wide Trail with its side cells in `rider.wide`, Coin Rain whose `rain` coins never hold back a pad, Hyperjump, Mystery) and the game contract; `START_LIVES` is 5; memo is the furthest arena reached; a read-only `round` getter for the tests only; it also holds the music's rules: `MUSIC_TRACKS` (its five songs) and `dealMusic(random, last)` (a shuffle of them, never opening on `last`); a run plays the deal one song after another, each in full from the top (asking with `{ restart: true }` until the music takes it), moves on when `music()` answers `"ended"`, deals again after the last, and a new run deals afresh, never opening on the song the last run was playing; its tones and hums play `SFX_LOUDER` times as loud through tones.js's `louder`, all but the engine drones (`DRONES`), kept low under the songs |
| `public/activities/bugs.js` | Bug Hunt: its rules as plain exported functions (`newRound`, `spawnWave`, `slotPos`, `advance` in 8 ms slices over `round.input`, which `key()` and `release()` set, `hurtBug`, `hurtBoss`, `hitShip`, `applyPower`, `ghostly`, `tentacleTip`, `bossRadius`), the `BUGS` by first wave, the `BOSSES` every `BOSS_EVERY` waves, the `POWERS`, the `SECTORS` scenery and the game contract with `release()`; memo is the tally of `DISCOVERIES` as bits; a read-only `round` getter for the tests only |
@@ -52,12 +52,13 @@ One row per file of every game but Ghoul Rush (which has its own files: [core](.
| `public/activities/snake-music.js` | Snake's ten music tracks as data (no imports): `SNAKE_MUSIC`, `{ bpm, rush, voices, patterns, order }` each, named `snake<Place>` and listed in `MUSIC_TRACKS` in `snake.js`. A round deals them in a fresh order, one to each level, so a run hears a different track at every level and none twice. They were picked on the pages in `prototypes/music/snake` (rhythm-first folk and world tunes led by something plucked or reedy, mostly dark or modal), and their bars are not all sixteen steps: 6/8 is 12, 7/8 is 14, ten beats is 20, twelve beats is 24, each pattern a whole number of its bars; merged by `snake-sfx.js` |
| `public/activities/light-trails/1.mp3` to `5.mp3` | Light Trails' five background songs, named `trailsSong1` to `trailsSong5` under `songs` in `trails-sfx.js` and listed in `SERVABLE`; re-encoded for size with ffmpeg (80 kbps stereo MP3 at 44.1 kHz, loudness-normalized to -16 LUFS with `loudnorm`, metadata stripped), about 7.6 MB together, and copied into every skill with the rest of the console. The server leaves them out of its start-up cache warm |
| `public/activities/flock-dash/1.mp3` to `5.mp3` | Flock Dash's five background songs, named `flockSong1` to `flockSong5` under `songs` in `flock-sfx.js` and listed in `SERVABLE`; re-encoded for size with ffmpeg the way Light Trails' were (80 kbps stereo MP3 at 44.1 kHz, loudness-normalized to -16 LUFS with `loudnorm`, metadata stripped), about 6.4 MB together, and copied into every skill with the rest of the console. The server leaves them out of its start-up cache warm; `flock.js` deals all five in a fresh order each round with `dealMusic()`, plays each in full one after another and deals again after the last, never opening on the song that just ended |
| `public/screens/activities.js` | Activities: `#btn-activities` (the die right of the megaphone), `#activities-modal`, the one frame timer (`requestAnimationFrame`, swappable with `setTickSource()` for the page tests), the keys (arrows, W/A/S/D, space, P, Esc; stopped at the dialog so none reach the page behind; `CHEAT_CODE`, typed on a game's board, turns on endless lives through the game's `cheat(on)` until the round starts over, and `dropCheats()` turns it off on leaving for the picker or closing; `STAGE_CODE`, the same arrows then S, calls the game's `stageSelect()` where it has one, Ghoul Rush's practice stage select) and `pauseAll()`, which a new question, a finish, a hidden page, a window blur and a close all go through and which never resumes a game (it also sends a pointer game a cancel, dropping a drag). Canvas pointer events (down, move, up, cancel, with pointer capture) go to a game with `pointer()`, and key releases to a game with `release()`; a press on a paused board resumes without starting a drag. While paused, any game key or a board click resumes, except while a round is `held`: a question or finish that pauses a round on an open window holds it, the banner adds `#activities-unpause` (**Unpause game**) beside **Go to it**, and only that button plays on (`play()` refuses a held round), since a key or click already on its way used to dismiss the banner unread. Go to it, or closing the window any other way, lets the hold go, and a banner with nothing left to say drops it. Every start and play-on first counts down 3, 2, 1 (`COUNT_FROM`, 700 ms a number, `setCountdownMs()` for the page tests, which set 0 unless they test it): the game is already `running`, the frame timer just does not tick it, and game keys, overlay clicks and board presses wait, while P and Esc still pause. With two or more games listed the window opens on the picker (`view`: `"picker"` or `"game"`, `applyView()`): a card button per game (`drawPicker()`, covers in `COVERS` drawn as SVG with `cv-*` token classes, since the page's policy refuses a style attribute) with its blurb, best and a **Last played** or **Round paused** tag, arrows walking the cards (`moveFocus()`), and `#activities-back` (**All games**) back to it. One game at a time: `pick()` drops the last game from `games` when another is picked, and `openActivities()` goes straight back into a paused round. The last pick is kept as `lastActivity` and gets the focus; `lowerIsBetter` games keep the lowest round as the best; the header shows the current game's best (`paintTitle()`). `renderActivities()` in the render pass compares `myTurn()` and `finish()` with the last render and shows the banner with **Go to it**. Loads a game with `import()` when it is picked and keeps it until another is picked; `setActivityList()` lets a test list a stub second game, which brings up the picker |
| `public/screens/activities.js` | Activities: `#btn-activities` (the die right of the megaphone), `#activities-modal`, the one frame timer (`requestAnimationFrame`, swappable with `setTickSource()` for the page tests), the keys (arrows, W/A/S/D, space, P, Esc; stopped at the dialog so none reach the page behind; `CHEAT_CODE`, typed on a game's board, turns on endless lives through the game's `cheat(on)` until the round starts over, and `dropCheats()` turns it off on leaving for the picker or closing; `STAGE_CODE`, the same arrows then S, calls the game's `stageSelect()` where it has one, Ghoul Rush's practice stage select) and `pauseAll()`, which a new question, a finish, a hidden page, a window blur and a close all go through and which never resumes a game (it also sends a pointer game a cancel, dropping a drag). Canvas pointer events (down, move, up, cancel, with pointer capture) go to a game with `pointer()`, and key releases to a game with `release()`; a press on a paused board resumes without starting a drag. While paused, any game key or a board click resumes, except while a round is `held`: a question or finish that pauses a round on an open window holds it, the banner adds `#activities-unpause` (**Unpause game**) beside **Go to it**, and only that button plays on (`play()` refuses a held round), since a key or click already on its way used to dismiss the banner unread. Go to it, or closing the window any other way, lets the hold go, and a banner with nothing left to say drops it. Every start and play-on first counts down 3, 2, 1 (`COUNT_FROM`, 700 ms a number, `setCountdownMs()` for the page tests, which set 0 unless they test it): the game is already `running`, the frame timer just does not tick it, and game keys, overlay clicks and board presses wait, while P and Esc still pause. With two or more games listed the window opens on the picker (`view`: `"picker"` or `"game"`, `applyView()`): a picker of game rows in two columns (`drawPicker()`: an Order bar with **Recently played** and **A to Z**, saved in `activityOrder`, and the game count; one grid of `.activities-row` buttons from `orderGames()`, with never-picked games under a **Not played yet** heading that spans both columns; covers in `COVERS` drawn as SVG with `cv-*` token classes, since the page's policy refuses a style attribute) with each game's blurb, a best chip (thousands separators) and a **Last played** or **Paused at N** tag, arrows walking the rows and the course cards by position (`moveFocus()`: left and right through the list, up and down to the nearest button in the next line; an Order button keeps its arrows), and `#activities-back` (**All games**) back to it. One game at a time: `pick()` drops the last game from `games` when another is picked, and `openActivities()` goes straight back into a paused round. The last pick is kept as `lastActivity` and gets the focus; `lowerIsBetter` games keep the lowest round as the best; the header shows the current game's best (`paintTitle()`). `renderActivities()` in the render pass compares `myTurn()` and `finish()` with the last render and shows the banner with **Go to it**. Loads a game with `import()` when it is picked and keeps it until another is picked; `setActivityList()` lets a test list a stub second game, which brings up the picker |
| `public/styles/activities.css` | the Activities rules: the die in the top bar, the Notebook-sized dialog, the board and its state overlay, the your-turn banner in the highlight color, the picker and the notes |
**Building an Activities game:** the rules every game follows, so a new one plays like the rest.
- **Lives are prominent.** A game with lives draws them as the lives pill: `livesText(round.lives)` in the `LIVES` color from `pills.js`, placed right after the level/stage pill, which `drawPill()` draws solid pink with a heart per life. Never a plain `♥ N` on the dark backing: that was hard to read at a glance. The unit suite checks every game with lives for it.
- **Every game adds looks.json keys, and `cleanLooks()` keeps at most 120.** A new game adds a best (one per course for a game with courses), a memo, a played time (`activityPlayed<Id>`) and, with music, a music volume; the picker adds `activityOrder`. About 76 keys are in use, so raise the cap (or fold keys) before the games that would pass 120.
- **Every game with lives takes the endless-lives code.** Typing up, down, up, down, left, right, left, right, B, A, space on the board gives endless lives until the round starts over or the person leaves the game (`CHEAT_CODE` in `screens/activities.js`, which calls the game's `cheat(true)` and `cheat(false)` on leaving for the picker or closing). A game with lives answers `cheat(on)` by setting `round.infinite`, never takes a life while it is set (`if (!round.infinite) round.lives -= 1`), lets `start()` make a new round without it, and shows `livesText(Infinity)` ("♥ x∞") in its lives pill. `scripts/test-web-console-activities.mjs` checks every listed game whose round has `lives`.
- **Banners never get in the way.** A banner over the board (`"Hit!"`, a new level, a power-up) is placed on the frame it first shows, on the part of the board away from the player, and fades to `BANNER_SEE_THROUGH` (0.12) over `BANNER_FADE_MS` while the player, or anything the player must react to (a diving bug, a bomb, a rival, a hazard, the road over a hill), is in its strip; Snake's `bannerRow()` and `underBanner()` are the model. Give the banner object a `see` field, multiply the draw's alpha by it, and export the strip check (`underBanner`) for the unit suite.
- **The window owns pausing.** A game never resumes itself; `screens/activities.js` decides when a key or click plays on, including the hold on a question or finish (see the row above), so a game needs nothing of its own for it. Full screen is the window's too (`setFull()`: the button, `F`, and a turn or finish putting it back; `fitFull()` sizes the game to the whole screen (black bars where its shape leaves room) and docks the overlaid panel in a bar that holds it, `data-dock="side"` or `"below"`, or floats it, `"float"`, shrunk to the score while a round plays and the pointer is still; and tells the desktop app `activities-full`); a game only sees a bigger `resize()`, so a new game needs nothing for it, as long as its `resize()` sets the canvas's CSS size.
+16 -11
View File
@@ -240,7 +240,7 @@ and hides it while *Hide unavailable workflows* is on. Its chip has a visible
removes the folder (any other spec also asks you to type its name). Click a card and Planny
flies while it gets ready;
a few seconds later the same page is that skill's console, already running. No
command names to remember. Pathfinder, Plan, Quick Task, Diagnose and Revise plan can also
command names to remember. Pathfinder, Plan, Quick Task, Diagnose, UI Prototype and Revise plan can also
start from one of your [Notebook](#your-notebook) tabs: see *Sent from the
dashboard* there.
@@ -509,8 +509,9 @@ working in.
bullet). It stays on this machine. A box filled from a tab is an ordinary
draft from then on: like anything you type, its text is kept with the
session's draft and its pictures with its uploads, unread until you send it.
- **Sent from the dashboard.** On a lit Pathfinder, Plan or Quick Task card
with *Start fresh*, and on a lit Revise plan card with a spec picked that has
- **Sent from the dashboard.** On a lit Pathfinder, Plan, Quick Task or UI
Prototype card with *Start fresh*, on a lit Diagnose card whatever is
picked, and on a lit Revise plan card with a spec picked that has
no plan change waiting, the confirm pane offers **Start with a note from your
Notebook**. Turn it on and pick a tab: empty tabs are grayed, a tab you have
sent shows a small **sent** badge, and a preview shows the whole tab, its text
@@ -518,7 +519,8 @@ working in.
untick one to tick another. A tab over 50 KB gets a *Long tab* note so you can
trim it first, and the pane's command line reads `+ note: <tab>`. Pressing
**Start** is the consent, and nothing is put on the launch itself. The skill's
first open text box marked `"fill": "note"` (the idea box, or Revise plan's
first open text box marked `"fill": "note"` (the idea box, Diagnose's
*What is wrong*, UI Prototype's *What to prototype*, or Revise plan's
*What should change* box) then arrives filled, once, with the tab's text and
the ticked pictures attached, and you can edit it before you press **Send**. A
tab or picture deleted in between leaves the box empty (with a note) or skips
@@ -538,12 +540,15 @@ working in.
The **die** in the top bar, right of the megaphone, opens **Activities**: small
games to play while you wait, say through a long build. Thirteen ship today,
**Snake**, **Mini golf**, **Light Trails**, **Bug Hunt**, **Sunset Drive**, **Stack Deploy**, **Bumper Ring**, **Rapids Run**, **Hot Potato**, **Crossing Rush**, **Bounce Road**, **Ghoul Rush** and **Flock Dash**. The window opens on a
**picker**: a card per game with a small cover scene, a line about it, its best
score, and a **Last played** tag on the one you played last, which also has the
focus. Click a card (or walk the cards with the arrows and press space or
Enter) to open its game, and **All games** at the bottom left goes back to the
picker. One game plays at a time: going back keeps a round paused on its card
(**Round paused, score 14**), reopening the window goes straight back into a
**picker**: a row per game, in two columns on a wide window, with a small cover
scene, a line about it, its best score, and a **Last played** tag on the one you
played last, which also has the focus. The **Order** bar above sorts the games
you have played by **Recently played** or **A to Z** (your choice is kept), and
games you have never picked sit at the end under **Not played yet**. Click a row
(or walk the rows with the arrows and press space or Enter) to open its game,
and **All games** at the bottom left goes back to the picker. One game plays at
a time: going back keeps a round paused on its row (**Paused at 14**),
reopening the window goes straight back into a
paused round, and picking a different game ends it. While a game is on screen,
the header shows its best, such as **Activities · Snake best: 12**, or
**Snake: no best yet**.
@@ -1990,7 +1995,7 @@ origin.
| `POST /notepad/tab/delete` | `{ id }`. Removes the tab from the index, then its folder (text and pictures); 404 `no-such-tab`. |
| `POST /notepad/tab/order` | `{ order: [id] }`, every current id exactly once; 400 `bad` otherwise. |
| `POST /notepad/tab/last` | `{ id }`. Remembers the open tab; 404 `no-such-tab`. |
| `POST /notepad/tab/sent` | `{ id, workflow, spec? }`. Records that the tab was sent (`workflow` one of `pathfinder`, `plan`, `quick-task`, `revise-plan`, `diagnose`; `spec` like `specs/<name>`) as `sent: { workflow, spec?, at }` on its `tabs.json` entry, shown back in `GET /notepad`'s `tabs`. The page posts it only after the Send that carried the filled box; 400 `bad-sent`, 404 `no-such-tab`. |
| `POST /notepad/tab/sent` | `{ id, workflow, spec? }`. Records that the tab was sent (`workflow` one of `pathfinder`, `plan`, `quick-task`, `revise-plan`, `diagnose`, `ui-prototype`; `spec` like `specs/<name>`) as `sent: { workflow, spec?, at }` on its `tabs.json` entry, shown back in `GET /notepad`'s `tabs`. The page posts it only after the Send that carried the filled box; 400 `bad-sent`, 404 `no-such-tab`. |
| `GET /notepad/images/<tab>/<uuid>.jpg`, `<uuid>.thumb.jpg` | Serves a picture or its thumbnail as `image/jpeg`, only by a tab id and a UUID name, a regular file (never a link) whose real path stays inside `~/.plan2code/notepads/`; anything else is 404. |
| `POST /subagents` | `{ on, instruction, max }` (`instruction: null` for the shipped default). Saves the switch for this project and skill and answers `{ ok, setting }`; 400 `not-offered` on a skill without the switch, `bad`, `too-long` (over 2,000 characters) or `max` (outside 1 to 20). |
| `GET /agents` | The agents view's data: your custom agents and the shipped built-ins and templates, each entry merged with its lookup result `{ state, path, where, folder }`: `state` is `found` (on PATH), `outside` (saved Windows PATH, npm's global folder or an install folder) or `missing`, and `where` says which search found it. Built-ins carry their `install` lines for the server's OS only. |
+1 -1
View File
@@ -36,7 +36,7 @@ Details: [Status line](./.agents-docs/AGENTS-architecture-statusline.md)
## Web Console
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) installed once under `~/.plan2code/console/<version>/` (`installSharedConsole` in `install.js`) and reached from every skill through a forwarding stub, `src/web-console-stub/console.mjs`. The bare `plan2code` skill opens its dashboard, a card menu that launches any skill in the same session. Pages cover questions, sign-off gates (with an in-page code review), build progress, the living document, a spec's saved prototypes (a **Prototypes** tab: an `.md` read in place, an `.html` opened in the default browser), an **Ask** chat, a read-only **Workspace** of extra folders (remembered per folder and spec in `~/.plan2code/console/workspaces.json`), a session meter, a **git board** for the `git` workflow (three tabs, Changes, Branches and Sync, opening on the likely next step; branches, pull, push, commits and pull-request links, drawn from `state.git`; contract in `notes/git.md`), **Stop with a handoff** (handoffs live in `~/.plan2code/handoffs/`, owned by `handoffs.mjs`, swept after 30 days, and offered as dashboard chips to pick up in the same session), a private **Notebook** in the top bar (named tabs of Markdown and pictures, a live-preview CodeMirror editor, one notepad per folder in `~/.plan2code/notepads/`, owned by `notepads.mjs`, private: the agent reads a tab only when you start Pathfinder, Plan, Quick Task or Revise plan from the dashboard with it and send the box it fills (an idea box marked `fill: "note"`, up to five ticked pictures attached), which then marks the tab sent via `POST /notepad/tab/sent`; the agent CLI never imports the store; removed only through Cleanup once a month untouched), **Activities** behind the top bar's die (thirteen small games, Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road, Ghoul Rush and Flock Dash, listed in `public/activities.js` with one module per game under `public/activities/` (Ghoul Rush is its own folder of modules, `public/activities/ghoul-rush/`) and a card line (`blurb`) each, a picker page of game cards once two are listed that plays one game at a time (another pick drops the last game's round), driven by `screens/activities.js` (keys, key releases for a game with `release()`, canvas pointer events for a game with `pointer()`, one frame timer), paused whenever the person's turn comes and resumed only by the person (while that pause's banner is up, only by its **Unpause game** button), best scores in flat `activityBest<Id>` keys in `looks.json` (lowest wins for a game that sets `lowerIsBetter`; Mini golf opens on a dashboard of its six 18-hole courses, one file each under `public/activities/golf-course-<id>.js`, and keeps a best per course, `activityBestGolf<Course>`), and one number a game may keep between sessions in `activityMemo<Id>` (Snake's tally of surprises found, Light Trails' furthest arena, Bug Hunt's tally of finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's most stages cleared in a run, Flock Dash's furthest stage), never shown to the agent), a built-in 21-topic Help, the app-only **Implementation Loop** (a dashboard card and a setup screen drawn by the page, `public/screens/loop-setup.js`; the last setup remembered per project in `~/.plan2code/console/loop-setup.json`, owned by `loop-setup.mjs`; a page that locks while `state.loop.driving` is set, until the app posts `loopEnd`; a skill run with `--loop` reports a `loopOutcome` instead of asking for sign-off, per `notes/loop.md`), a first-run Welcome, User Preferences (gear: four tabs, Appearance, Agents & models, System and Sounds & activities, on the `public/tabs.js` helper Help also uses, with `public/prefs.js`, `screens/prefs-dialog.js` and `screens/agents-view.js`), an agent-less **setup** page (the `setup` workflow `plan2code` or the desktop app opens when no agent can run: each built-in's found / outside-PATH / missing state from `agent-lookup.mjs`, install lines, Check again, Use it from here, starter templates and Start, which hands the tab to the new agent through a token-guarded `POST /handover` and a `move` event; the app shows it in its window from a Set up an agent button instead) and a bug/idea link to GitHub issues. On opted-in skills (every workflow but the dashboard, setup, Changelog, Git, Handoff and UI Prototype) a **Subagents** button in the top bar turns helpers on or off per project and skill (on by default for those skills until switched off, saved in `~/.plan2code/console/subagents.json`), and a Helper strength choice (Balanced, Thrifty, Best, Match my session; rules in `src/shared-references/helper-strength.md`, shipped in the sixteen helper skills); the agent hears of it as a standing instruction only when it Line truncated
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) installed once under `~/.plan2code/console/<version>/` (`installSharedConsole` in `install.js`) and reached from every skill through a forwarding stub, `src/web-console-stub/console.mjs`. The bare `plan2code` skill opens its dashboard, a card menu that launches any skill in the same session. Pages cover questions, sign-off gates (with an in-page code review), build progress, the living document, a spec's saved prototypes (a **Prototypes** tab: an `.md` read in place, an `.html` opened in the default browser), an **Ask** chat, a read-only **Workspace** of extra folders (remembered per folder and spec in `~/.plan2code/console/workspaces.json`), a session meter, a **git board** for the `git` workflow (three tabs, Changes, Branches and Sync, opening on the likely next step; branches, pull, push, commits and pull-request links, drawn from `state.git`; contract in `notes/git.md`), **Stop with a handoff** (handoffs live in `~/.plan2code/handoffs/`, owned by `handoffs.mjs`, swept after 30 days, and offered as dashboard chips to pick up in the same session), a private **Notebook** in the top bar (named tabs of Markdown and pictures, a live-preview CodeMirror editor, one notepad per folder in `~/.plan2code/notepads/`, owned by `notepads.mjs`, private: the agent reads a tab only when you start Pathfinder, Plan, Quick Task, Diagnose, UI Prototype or Revise plan from the dashboard with it and send the box it fills (an idea box marked `fill: "note"`, up to five ticked pictures attached), which then marks the tab sent via `POST /notepad/tab/sent`; the agent CLI never imports the store; removed only through Cleanup once a month untouched), **Activities** behind the top bar's die (thirteen small games, Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road, Ghoul Rush and Flock Dash, listed in `public/activities.js` with one module per game under `public/activities/` (Ghoul Rush is its own folder of modules, `public/activities/ghoul-rush/`) and a card line (`blurb`) each, a picker of game rows in two columns, ordered Recently played or A to Z (saved in `activityOrder`), with never-picked games under Not played yet, once two are listed, that plays one game at a time (another pick drops the last game's round), driven by `screens/activities.js` (keys, key releases for a game with `release()`, canvas pointer events for a game with `pointer()`, one frame timer), paused whenever the person's turn comes and resumed only by the person (while that pause's banner is up, only by its **Unpause game** button), best scores in flat `activityBest<Id>` keys in `looks.json` (and the time each game was last picked in `activityPlayed<Id>`) (lowest wins for a game that sets `lowerIsBetter`; Mini golf opens on a dashboard of its six 18-hole courses, one file each under `public/activities/golf-course-<id>.js`, and keeps a best per course, `activityBestGolf<Course>`), and one number a game may keep between sessions in `activityMemo<Id>` (Snake's tally of surprises found, Light Trails' furthest arena, Bug Hunt's tally of finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's most stages cleared in a run, Flock Dash's furthest stage), never shown to the agent), a built-in 21-topic Help, the app-only **Implementation Loop** (a dashboard card and a setup screen drawn by the page, `public/screens/loop-setup.js`; the last setup remembered per project in `~/.plan2code/console/loop-setup.json`, owned by `loop-setup.mjs`; a page that locks while `state.loop.driving` is set, until the app posts `loopEnd`; a skill run with `--loop` reports a `loopOutcome` instead of asking for sign-off, per `notes/loop.md`), a first-run Welcome, User Preferences (gear: four tabs, Appearance, Agents & models, System and Sounds & activities, on the `public/tabs.js` helper Help also uses, with `public/prefs.js`, `screens/prefs-dialog.js` and `screens/agents-view.js`), an agent-less **setup** page (the `setup` workflow `plan2code` or the desktop app opens when no agent can run: each built-in's found / outside-PATH / missing state from `agent-lookup.mjs`, install lines, Check again, Use it from here, starter templates and Start, which hands the tab to the new agent through a token-guarded `POST /handover` and a `move` event; the app shows it in its window from a Set up an agent button instead) and a bug/idea link to GitHub issues. On opted-in skills (every workflow but the dashboard, setup, Changelog, Git, Handoff and UI Prototype) a **Subagents** button in the top bar turns helpers on or off per project and skill (on by default for those skills until switched off, saved in `~/.plan2code/console/subagents.json`), and a Helper strenLine truncated
One agent list and one lookup rule serve the launcher, the console and the app: `src/launcher/agents.json` (the built-ins and starter templates with per-OS install data) and `src/web-console/agent-lookup.mjs` (`loadAgentList()` and `findAgent()`, both copied by `install.js` into `~/.plan2code/bin/`); the app carries a Rust twin held to the same cases by `scripts/fixtures/agent-lookup-cases.json`.
Building or changing an Activities game: follow the game rules in [Activities](./.agents-docs/AGENTS-architecture-activities.md) ("Building an Activities game": lives in the solid lives pill, the endless-lives code (`cheat(on)`) in every game with lives, banners placed away from the player and see-through over what matters, pausing left to the window).
+57 -1
View File
@@ -11,7 +11,7 @@ import test from "node:test";
import assert from "node:assert/strict";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { ACTIVITIES, bestKey, bestKeys, memoKey, musicKey, musicLevel } from "../src/web-console/public/activities.js";
import { ACTIVITIES, bestKey, bestKeys, memoKey, musicKey, musicLevel, orderGames, playedKey } from "../src/web-console/public/activities.js";
import { BOSS_BITES, COMBO_MS, MAX_LEVEL, MUSIC_TRACKS, dealMusic, heat, trackFor, DISCOVERIES, FOOD_PER_LEVEL, FRUITS, GRID, ICE_STEPS, LEVELS, MAX_COMBO, MIN_CELL, MIN_STEP_MS, POWERS, STEP_MS, SURPRISES, age, applyPower, applySurprise, fruitFor, tallyBit, newRound, onFood, SPECIALS, pace, placeFood, step, stepMs, turn } from "../src/web-console/public/activities/snake.js";
import golf, * as golfRules from "../src/web-console/public/activities/golf.js";
import { COURSE_W, COURSE_H, COURSES, FRONT_NINE, HOLE_COUNT, courseById } from "../src/web-console/public/activities/golf-holes.js";
@@ -307,6 +307,62 @@ test("memoKey builds a flat looks.json key from a list id", () => {
assert.equal(memoKey("golf"), "activityMemoGolf");
});
test("playedKey builds a flat looks.json key from a list id, distinct for every game", () => {
assert.equal(playedKey("snake"), "activityPlayedSnake");
assert.equal(playedKey("golf"), "activityPlayedGolf");
const keys = ACTIVITIES.map((a) => playedKey(a.id));
assert.equal(new Set(keys).size, ACTIVITIES.length, "every listed game has its own key");
});
test("orderGames splits played from not played yet and orders each group", () => {
const ids = (entries) => entries.map((e) => e.id);
const byId = (id) => ACTIVITIES.find((a) => a.id === id);
const az = [...ACTIVITIES].sort((a, b) => a.title.localeCompare(b.title));
// Nothing saved: every game is unplayed, A to Z, and `list`'s own entries come back.
let out = orderGames(ACTIVITIES, {}, "recent");
assert.deepEqual(out.played, []);
assert.deepEqual(ids(out.unplayed), ids(az));
assert.ok(out.unplayed.every((e) => ACTIVITIES.includes(e)), "entries, never copies");
// The last pick alone makes that game played.
out = orderGames(ACTIVITIES, { lastActivity: "bugs" }, "recent");
assert.deepEqual(ids(out.played), ["bugs"]);
assert.equal(out.unplayed.length, ACTIVITIES.length - 1);
assert.ok(!ids(out.unplayed).includes("bugs"));
// A best counts as played, Mini golf's on any one course too.
out = orderGames(ACTIVITIES, { activityBestSnake: 40, activityBestGolfFrost: 61 }, "recent");
assert.deepEqual(ids(out.played).sort(), ["golf", "snake"]);
// Mixed times: newest first, then the last pick (no time), then A to Z.
const looks = { activityPlayedStack: 300, activityPlayedSnake: 100, activityPlayedBugs: 200, lastActivity: "golf", activityBestFlock: 5, activityBestBounce: 9 };
out = orderGames(ACTIVITIES, looks, "recent");
assert.deepEqual(ids(out.played), ["stack", "bugs", "snake", "golf", "bounce", "flock"]);
assert.ok(!ids(out.unplayed).some((id) => ids(out.played).includes(id)), "no game in both groups");
assert.equal(out.played.length + out.unplayed.length, ACTIVITIES.length);
// Equal times sort A to Z.
out = orderGames(ACTIVITIES, { activityPlayedSnake: 50, activityPlayedBugs: 50, activityPlayedStack: 50 }, "recent");
assert.deepEqual(ids(out.played), ["bugs", "snake", "stack"]);
// "az" sorts the played group A to Z; unplayed stays A to Z.
out = orderGames(ACTIVITIES, looks, "az");
assert.deepEqual(ids(out.played), ids(out.played.slice().sort((a, b) => a.title.localeCompare(b.title))));
assert.deepEqual(ids(out.played).sort(), ["bounce", "bugs", "flock", "golf", "snake", "stack"]);
assert.deepEqual(ids(out.unplayed), ids(az.filter((e) => !out.played.includes(e))));
// An unknown or missing order reads as "recent".
assert.deepEqual(ids(orderGames(ACTIVITIES, looks, "nope").played), ids(orderGames(ACTIVITIES, looks, "recent").played));
assert.deepEqual(ids(orderGames(ACTIVITIES, looks).played), ids(orderGames(ACTIVITIES, looks, "recent").played));
// A time for an id not in the list is ignored, and nothing outside `list` is returned.
const some = [byId("snake"), byId("golf"), byId("stack")];
out = orderGames(some, { activityPlayedBugs: 999, activityPlayedStack: 10, lastActivity: "bugs" }, "recent");
assert.deepEqual(ids(out.played), ["stack"]);
assert.deepEqual(ids(out.unplayed), ["golf", "snake"]);
});
/* ----------------------------------------------------------- contract */
test("musicKey builds a flat looks.json key, and a game with music has a default volume a saved one replaces", () => {
+1 -1
View File
@@ -361,7 +361,7 @@ test("framed, an Activities game in full screen asks the app for the whole scree
t.after(() => fs.rmSync(looksFile, { force: true }));
const s = await openSession(await pages.browser(), { t, workflow: "plan", payload: { agent: { status: "working", activity: "Reading" } }, env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
await s.page.click("#btn-activities");
await s.page.locator('.activities-card[data-activity="snake"]').click();
await s.page.locator('.activities-row[data-activity="snake"]').click();
await s.page.locator("#activities-board").waitFor();
const told = async () => (await toApp(s, "activities-full")).map((m) => m.on);
// Each key asks the browser for its own full screen too, and the browser answers a moment
+119 -28
View File
@@ -108,7 +108,7 @@ async function openActivities(s, id = "snake", course = "pirate") {
const board = s.page.locator("#activities-board");
await until(async () => (await picker.isVisible()) || (await board.isVisible()), 5000);
if (await picker.isVisible()) {
await picker.locator(`.activities-card[data-activity="${id}"]`).click();
await picker.locator(`.activities-row[data-activity="${id}"]`).click();
if (id === "golf") await courseCard(s, course).click();
}
await until(async () => (await board.isVisible()) && (await overlay(s)) !== "", 5000);
@@ -158,13 +158,13 @@ async function iconUsable(s, where) {
assert.ok(await btn.isEnabled(), `the die is usable on ${where}`);
}
const cardTitles = (s) => s.page.locator("#activities-picker .activities-card-title").allInnerTexts();
const card = (s, id) => s.page.locator(`#activities-picker .activities-card[data-activity="${id}"]`);
const cardTitles = (s) => s.page.locator("#activities-picker .activities-row-title").allInnerTexts();
const card = (s, id) => s.page.locator(`#activities-picker .activities-row[data-activity="${id}"]`);
const focusedCard = (s) => s.page.evaluate(() => document.activeElement?.dataset?.activity || null);
const courseCard = (s, id) => s.page.locator(`#activities-picker .activities-course[data-course="${id}"]`);
const focusedCourse = (s) => s.page.evaluate(() => document.activeElement?.dataset?.course || null);
test("the die sits right of the megaphone and opens on the picker, a card per game with its best, and a card opens its game", async (t) => {
test("the die sits right of the megaphone and opens on the picker, a ledger row per game with its best, and a row opens its game", async (t) => {
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12 });
const s = await openSession(await suite.browser(), { t, workflow: "dashboard" });
await pastTheIntro(s);
@@ -172,11 +172,20 @@ test("the die sits right of the megaphone and opens on the picker, a card per ga
const next = await s.page.evaluate(() => document.getElementById("btn-feedback").nextElementSibling?.id);
assert.equal(next, "btn-activities");
await openPicker(s);
assert.deepEqual(await cardTitles(s), ["Snake", "Mini golf", "Light Trails", "Bug Hunt", "Sunset Drive", "Stack Deploy", "Bumper Ring", "Rapids Run", "Hot Potato", "Crossing Rush", "Bounce Road", "Ghoul Rush", "Flock Dash"]);
// Snake's seeded best makes it the one played row; the rest sit under Not played yet, A to Z.
assert.deepEqual(await cardTitles(s), ["Snake", "Bounce Road", "Bug Hunt", "Bumper Ring", "Crossing Rush", "Flock Dash", "Ghoul Rush", "Hot Potato", "Light Trails", "Mini golf", "Rapids Run", "Stack Deploy", "Sunset Drive"]);
assert.equal(await s.page.locator("#activities-picker .activities-count").innerText(), "13 games");
assert.equal((await s.page.locator("#activities-picker .activities-group").innerText()).replace(/\s+/g, " "), "Not played yet 12");
assert.equal(await s.page.locator("#activities-picker .activities-order-pill[aria-pressed=true]").innerText(), "Recently played");
const rowTop = (id) => card(s, id).evaluate((n) => n.offsetTop);
assert.equal(await rowTop("bounce"), await rowTop("bugs"), "two rows to a line on a wide dialog");
await s.page.setViewportSize({ width: 560, height: 800 });
assert.ok(await until(async () => (await rowTop("bounce")) !== (await rowTop("bugs")), 5000), "one column when the dialog is narrow");
await s.page.setViewportSize({ width: 1280, height: 800 });
assert.ok(await s.page.locator("#activities-board").isHidden(), "no board behind the picker");
assert.ok(await s.page.locator("#activities-back").isHidden(), "nothing to go back to");
assert.equal(await s.page.locator("#activities-title").innerText(), "Activities", "the header names no game");
assert.match(await card(s, "snake").innerText(), /Best: 12/);
assert.match(await card(s, "snake").innerText(), /Best 12/);
assert.match(await card(s, "golf").innerText(), /6 courses to play/);
assert.equal(await s.page.locator("#activities-picker svg").count(), (await cardTitles(s)).length, "each card has its cover");
assert.equal(await focusedCard(s), "snake", "with no last pick, focus is on the first card");
@@ -187,23 +196,42 @@ test("the die sits right of the megaphone and opens on the picker, a card per ga
assert.equal(await s.page.evaluate(() => document.activeElement?.id), "activities-board", "keys reach the game with no extra click");
});
test("the arrows walk the picker's cards, and space or Enter opens the one in focus", async (t) => {
savedLooks(t, { welcomeSeen: true });
test("the arrows walk the picker's rows by position across the Not played yet heading, and space or Enter opens the one in focus", async (t) => {
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12 });
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await openPicker(s);
const press = async (key, n = 1) => {
for (let i = 0; i < n; i++) await s.page.keyboard.press(key);
};
// Rows: snake (played), then A to Z under the heading, two to a line:
// bounce bugs / bumper hop / flock ghoul / fuse trails / golf rapids / stack drive.
assert.equal(await focusedCard(s), "snake", "the last played, here the one played row, has focus");
await press("ArrowDown");
assert.equal(await focusedCard(s), "bounce", "down from the last played row lands on the nearest unplayed row");
await press("ArrowUp");
assert.equal(await focusedCard(s), "snake");
await s.page.keyboard.press("ArrowRight");
await press("ArrowUp");
assert.equal(await focusedCard(s), "snake", "the first line stays put");
await press("ArrowRight", 2);
assert.equal(await focusedCard(s), "bugs", "right steps through the list, across the heading");
await press("ArrowDown");
assert.equal(await focusedCard(s), "hop", "down keeps the column");
await press("ArrowLeft");
assert.equal(await focusedCard(s), "bumper");
await press("ArrowRight", 12);
assert.equal(await focusedCard(s), "drive", "the last row stays put");
await press("ArrowDown");
assert.equal(await focusedCard(s), "drive", "the last line stays put");
await press("ArrowUp");
assert.equal(await focusedCard(s), "rapids");
await press("ArrowLeft");
assert.equal(await focusedCard(s), "golf");
for (let i = 0; i < 12; i++) await s.page.keyboard.press("ArrowRight");
assert.equal(await focusedCard(s), "flock", "the last card stays put");
for (let i = 0; i < 11; i++) await s.page.keyboard.press("ArrowLeft");
assert.equal(await focusedCard(s), "golf");
await s.page.keyboard.press("Enter");
await press("Enter");
// Mini golf opens on its course dashboard, walked the same way.
await until(async () => (await focusedCourse(s)) === "pirate", 5000);
await s.page.keyboard.press("ArrowRight");
await press("ArrowRight");
assert.equal(await focusedCourse(s), "cave");
await s.page.keyboard.press("Enter");
await press("Enter");
await until(async () => (await overlay(s)) === "Press space or click to start", 5000);
assert.equal(await s.page.locator("#activities-title").innerText(), "Activities · Mini golf, Caves of Doom: no best yet");
assert.equal(await s.page.locator("#activities-back").innerText(), "All courses");
@@ -211,11 +239,30 @@ test("the arrows walk the picker's cards, and space or Enter opens the one in fo
await until(async () => (await focusedCourse(s)) === "cave", 5000);
assert.equal(await s.page.locator("#activities-back").innerText(), "All games");
await s.page.click("#activities-back");
await s.page.locator("#activities-picker .activities-card[data-activity]").first().waitFor();
await s.page.locator("#activities-picker .activities-row[data-activity]").first().waitFor();
assert.equal(await focusedCard(s), "golf", "back on the picker, the game just left is in focus");
// Mini golf was just picked, so it leads Recently played; right steps to Snake.
await press("ArrowRight");
assert.equal(await focusedCard(s), "snake");
await press(" ");
assert.ok(await until(async () => (await s.page.locator("#activities-title").innerText()) .startsWith("Activities · Snake"), 5000), "space opens the row in focus");
});
test("the Order buttons keep their arrows, and a press redraws the picker and keeps focus on the button", async (t) => {
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12 });
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await openPicker(s);
const az = s.page.locator('#activities-picker .activities-order-pill[data-order="az"]');
const focusedOrder = () => s.page.evaluate(() => document.activeElement?.dataset?.order || null);
await az.focus();
await s.page.keyboard.press("ArrowRight");
await s.page.keyboard.press(" ");
await until(async () => (await s.page.locator("#activities-title").innerText()) === "Activities · Light Trails: no best yet", 5000);
await s.page.keyboard.press("ArrowDown");
assert.equal(await focusedOrder(), "az", "the arrows leave an Order button where it is");
await az.press("Enter");
assert.equal(await focusedOrder(), "az", "focus is back on the pressed button after the redraw");
assert.equal(await az.getAttribute("aria-pressed"), "true");
await az.press("Enter");
assert.equal(await az.getAttribute("aria-pressed"), "true", "a press on the pressed button does nothing");
});
test("picking Mini golf shows it, saves it as the last played, and keys reach it with no extra click", async (t) => {
@@ -254,7 +301,7 @@ test("one game at a time: All games keeps the round paused for its own card, and
await s.page.locator("#activities-picker").waitFor();
await step(s, 1);
assert.equal(await framesWaiting(s), 0, "the picker does not tick the game");
assert.match(await card(s, "snake").innerText(), /Round paused, score 0/);
assert.match(await card(s, "snake").innerText(), /Paused at 0/);
assert.match(await s.page.locator("#activities-picker").innerText(), /Picking a different game ends the paused round/);
// Closed and reopened with a round waiting: straight back into it.
await s.page.keyboard.press("Escape");
@@ -270,12 +317,12 @@ test("one game at a time: All games keeps the round paused for its own card, and
await card(s, "trails").click();
await until(async () => (await overlay(s)) === "Press space to start", 5000);
await s.page.click("#activities-back");
assert.doesNotMatch(await s.page.locator("#activities-picker").innerText(), /Round paused/);
assert.doesNotMatch(await s.page.locator("#activities-picker").innerText(), /Paused at/);
await card(s, "snake").click();
await until(async () => (await overlay(s)) === "Press space to start", 5000);
});
test("a new session's picker marks the last played and puts focus on it, and a last pick no longer listed falls back to the first card", async (t) => {
test("a new session's picker marks the last played and puts focus on it, and a last pick no longer listed falls back to the first row", async (t) => {
savedLooks(t, { welcomeSeen: true, lastActivity: "golf" });
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await openPicker(s);
@@ -286,8 +333,45 @@ test("a new session's picker marks the last played and puts focus on it, and a l
fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { welcomeSeen: true, hideActivities: false, lastActivity: "chess" } }));
const again = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await openPicker(again);
assert.equal(await focusedCard(again), "snake", "an unknown pick puts focus on the first card");
assert.equal(await again.page.locator("#activities-picker .activities-card-tag").count(), 0);
assert.equal(await focusedCard(again), "bounce", "an unknown pick puts focus on the first row drawn, the first of A to Z");
assert.equal(await again.page.locator("#activities-picker .activities-row-tag").count(), 0);
});
test("picking a game moves it to the top of Recently played and stamps its played time, and A to Z reorders the played rows and is still chosen after closing and reopening, and after a reload", async (t) => {
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12 });
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await openPicker(s);
const playedTitles = async (page = s) => (await cardTitles(page)).slice(0, 2);
assert.deepEqual(await playedTitles(), ["Snake", "Bounce Road"]);
await card(s, "stack").click();
await until(async () => (await overlay(s)) === "Press space to start", 5000);
await until(async () => (await serverLooks(s)).activityPlayedStack > 0, 5000);
await s.page.click("#activities-back");
assert.deepEqual(await playedTitles(), ["Stack Deploy", "Snake"], "the new pick leads Recently played");
assert.match(await card(s, "stack").innerText(), /Last played/);
const az = s.page.locator('#activities-picker .activities-order-pill[data-order="az"]');
const recent = s.page.locator('#activities-picker .activities-order-pill[data-order="recent"]');
await az.click();
assert.equal(await az.getAttribute("aria-pressed"), "true");
assert.equal(await recent.getAttribute("aria-pressed"), "false");
assert.deepEqual(await playedTitles(), ["Snake", "Stack Deploy"], "A to Z reorders the played rows");
await until(async () => (await serverLooks(s)).activityOrder === "az", 5000);
await s.page.keyboard.press("Escape");
await s.page.waitForFunction(() => !document.getElementById("activities-modal").open);
await openPicker(s);
assert.equal(await az.getAttribute("aria-pressed"), "true", "still chosen after closing and reopening");
assert.deepEqual(await playedTitles(), ["Snake", "Stack Deploy"]);
const again = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await openPicker(again);
assert.equal(await again.page.locator('#activities-picker .activities-order-pill[data-order="az"]').getAttribute("aria-pressed"), "true", "read from looks in a new page");
assert.deepEqual(await playedTitles(again), ["Snake", "Stack Deploy"]);
});
test("a best score reads with thousands separators on its row", async (t) => {
savedLooks(t, { welcomeSeen: true, activityBestSnake: 51900 });
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await openPicker(s);
assert.match(await card(s, "snake").innerText(), /Best 51,900/);
});
test("Light Trails plays in the real window: a wide board, the rivals ride, and an arrow steers you", async (t) => {
@@ -1100,7 +1184,7 @@ test("Full screen gives the board the whole screen with a panel holding the scor
await openPicker(s);
const btn = s.page.locator("#activities-full");
assert.ok(await btn.isHidden(), "no Full screen on the picker");
await s.page.locator('.activities-card[data-activity="snake"]').click();
await s.page.locator('.activities-row[data-activity="snake"]').click();
await until(async () => (await overlay(s)) !== "", 5000);
const before = await fullParts(s);
assert.ok(!before.full && !before.rail && !before.scoreInRail, "the window opens at its own size, with no panel");
@@ -2055,7 +2139,7 @@ test("Mini golf: a full round saves its total as its course's best, a lower one
await s.page.click("#activities-back");
await courseCard(s, "pirate").waitFor();
await s.page.click("#activities-back");
assert.match(await card(s, "golf").innerText(), /Best on 2 of 6 courses/);
assert.match(await card(s, "golf").innerText(), /2 of 6 courses/);
const reset = s.page.locator("#activities-reset");
await reset.click();
@@ -2088,10 +2172,14 @@ test("Mini golf running breaks no content-security rule and logs no error", asyn
});
test("saved Activities values that do not hold up fall back to their defaults", async (t) => {
savedLooks(t, { welcomeSeen: true, activityBestSnake: -5, hideActivities: "yes", lastActivity: 5 });
savedLooks(t, { welcomeSeen: true, activityBestSnake: -5, hideActivities: "yes", lastActivity: 5, activityPlayedSnake: -5, activityPlayedGolf: 1.9, activityPlayedBugs: "soon", activityOrder: "bogus" });
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
const looks = await pageLooks(s);
assert.equal(looks.activityBestSnake, 0, "a negative best is none");
assert.equal(looks.activityPlayedSnake, 0, "a negative played time is never");
assert.equal(looks.activityPlayedGolf, 1, "a played time is a whole number");
assert.equal(looks.activityPlayedBugs, 0, "a played time that is not a number is never");
assert.equal(looks.activityOrder, "recent", "an order that is not recent or az is recent, the default");
assert.equal(looks.hideActivities, true, "a switch that is not a boolean is off, the default");
assert.equal(looks.lastActivity, "", "a last pick that is not a string is none");
assert.ok(await s.page.locator("#btn-activities").isHidden(), "and the die stays hidden");
@@ -2118,7 +2206,7 @@ test("Back to default turns Show Activities back off and keeps the best scores",
});
test("Reset best scores asks once inside the window, then writes 0", async (t) => {
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12 });
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12, activityPlayedBugs: 1700000000000, activityOrder: "az" });
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
await handTicks(s);
await listScoringSnake(s, 3);
@@ -2132,6 +2220,9 @@ test("Reset best scores asks once inside the window, then writes 0", async (t) =
await reset.click();
assert.equal(await reset.innerText(), "Reset best scores");
await until(async () => (await serverLooks(s)).activityBestSnake === 0, 5000);
const kept = await serverLooks(s);
assert.equal(kept.activityPlayedBugs, 1700000000000, "played times stay");
assert.equal(kept.activityOrder, "az", "the picker's order stays");
await s.page.locator("#activities-board").focus();
await s.page.keyboard.press(" ");
assert.equal(await s.page.locator("#activities-score").innerText(), "Score: 3 · Best: 0", "the window shows the cleared best");
+3 -1
View File
@@ -878,7 +878,7 @@ test("prefs: Back to default resets Appearance or Sounds & activities only, and
test("looks: resetLooks(keys) changes only those keys, and the role is marked as asked", () => {
const before = { ...looks };
try {
Object.assign(looks, { theme: "dark", width: "wide", accent: "violet", role: "pm", sound: false, soundQuestion: false, hideActivities: false, activityBestSnake: 7, lastActivity: "snake", skipIntro: true });
Object.assign(looks, { theme: "dark", width: "wide", accent: "violet", role: "pm", sound: false, soundQuestion: false, hideActivities: false, activityBestSnake: 7, lastActivity: "snake", activityPlayedSnake: 1700000000000, activityOrder: "az", skipIntro: true });
resetLooks(prefsResetScope("appearance"));
assert.equal(looks.theme, DEFAULT_LOOKS.theme);
assert.equal(looks.width, DEFAULT_LOOKS.width);
@@ -893,6 +893,8 @@ test("looks: resetLooks(keys) changes only those keys, and the role is marked as
assert.equal(looks.hideActivities, DEFAULT_LOOKS.hideActivities);
assert.equal(looks.activityBestSnake, 7, "best scores stay");
assert.equal(looks.lastActivity, "snake", "the last pick stays");
assert.equal(looks.activityPlayedSnake, 1700000000000, "played times stay");
assert.equal(looks.activityOrder, "az", "the picker's order stays");
} finally {
for (const key of Object.keys(looks)) delete looks[key];
Object.assign(looks, before);
+36
View File
@@ -64,6 +64,42 @@ export const bestKeys = (entry) => (entry.courses ? entry.courses.map((c) => bes
// leaves it at 0.
export const memoKey = (id) => "activityMemo" + cap(id);
// The looks.json key that holds when a game was last picked, in epoch
// milliseconds: activityPlayedSnake. Set on pick (screens/activities.js
// pick()), never by a score; 0 means never picked.
export const playedKey = (id) => "activityPlayed" + cap(id);
// Splits the game list into the games the person has played and the ones not
// played yet, for the picker's rows. Returns { played, unplayed }, arrays of
// the `list` entries themselves. A game is played when it has a played time,
// is the last pick, or has a best score on any course. `unplayed` is always
// A to Z. `order` "az" sorts `played` A to Z; anything else (the default
// "recent") sorts it newest pick first, the last pick ahead of games with no
// time, ties A to Z. Keys for games not in `list` are ignored.
export function orderGames(list, looks, order) {
const byTitle = (a, b) => a.title.localeCompare(b.title);
const timeOf = (e) => {
const n = Number(looks[playedKey(e.id)]);
return Number.isFinite(n) && n > 0 ? n : 0;
};
const isPlayed = (e) => timeOf(e) > 0 || e.id === looks.lastActivity || bestKeys(e).some((key) => looks[key] > 0);
const played = list.filter(isPlayed);
const unplayed = list.filter((e) => !isPlayed(e)).sort(byTitle);
if (order === "az") return { played: played.sort(byTitle), unplayed };
played.sort((a, b) => {
const ta = timeOf(a);
const tb = timeOf(b);
if (ta !== tb) return tb - ta;
if (ta === 0) {
const la = a.id === looks.lastActivity;
const lb = b.id === looks.lastActivity;
if (la !== lb) return la ? -1 : 1;
}
return byTitle(a, b);
});
return { played, unplayed };
}
// The looks.json key that holds a game's music volume, 0 to 100:
// activityMusicDrive. Only a game whose entry sets `music` has one.
export const musicKey = (id) => "activityMusic" + cap(id);
+13 -3
View File
@@ -9,7 +9,7 @@ import { normalizeRole, ROLE_NOT_SET } from "./starters.js";
import { bootData, hooks } from "./state.js";
import { el } from "./render.js";
import { tellApp } from "./app-bridge.js";
import { ACTIVITIES, bestKeys, memoKey, musicKey, musicLevel } from "./activities.js";
import { ACTIVITIES, bestKeys, memoKey, musicKey, musicLevel, playedKey } from "./activities.js";
const $ = (id) => document.getElementById(id);
@@ -49,6 +49,11 @@ export const DEFAULT_LOOKS = {
...Object.fromEntries(ACTIVITIES.map((a) => [memoKey(a.id), 0])),
// And, for a game with music, its music volume (activityMusicDrive), 0 to 100.
...Object.fromEntries(ACTIVITIES.filter((a) => a.music !== undefined).map((a) => [musicKey(a.id), a.music])),
// And when each game was last picked (activityPlayedSnake, epoch ms, 0 for
// never) and the picker's order, "recent" or "az". Neither is cleared by
// Reset best scores or Back to default.
...Object.fromEntries(ACTIVITIES.map((a) => [playedKey(a.id), 0])),
activityOrder: "recent",
};
export let looks = { ...DEFAULT_LOOKS };
@@ -79,8 +84,11 @@ export function adoptLooks(saved) {
}
const memo = Number(looks[memoKey(a.id)]);
looks[memoKey(a.id)] = Number.isFinite(memo) && memo > 0 ? Math.floor(memo) : 0;
const played = Number(looks[playedKey(a.id)]);
looks[playedKey(a.id)] = Number.isFinite(played) && played > 0 ? Math.floor(played) : 0;
if (a.music !== undefined) looks[musicKey(a.id)] = Math.round(musicLevel(a, looks[musicKey(a.id)]) * 100);
}
if (!["recent", "az"].includes(looks.activityOrder)) looks.activityOrder = DEFAULT_LOOKS.activityOrder;
if (saved && typeof saved === "object" && Object.hasOwn(saved, "role")) looks.role = normalizeRole(saved.role);
else delete looks.role;
}
@@ -286,7 +294,8 @@ export function renderSwatches() {
// "Back to default": every look returns to its default, but the role is
// marked as asked, the welcome stays seen, and the Activities' best scores
// and last pick stay (only Reset best scores clears those). Given `keys` (one
// and last pick stay (only Reset best scores clears those), and so do the
// played times and the picker's order (nothing clears those). Given `keys` (one
// Preferences tab's, prefsResetScope() in prefs.js), only those change: the
// role is cleared but marked as asked, the rest take their defaults, and
// every other key stays as it is.
@@ -295,10 +304,11 @@ export function resetLooks(keys) {
for (const key of keys) looks[key] = key === "role" ? ROLE_NOT_SET : DEFAULT_LOOKS[key];
return;
}
const kept = { lastActivity: looks.lastActivity };
const kept = { lastActivity: looks.lastActivity, activityOrder: looks.activityOrder };
for (const a of ACTIVITIES) {
for (const key of bestKeys(a)) kept[key] = looks[key];
kept[memoKey(a.id)] = looks[memoKey(a.id)];
kept[playedKey(a.id)] = looks[playedKey(a.id)];
}
looks = { ...DEFAULT_LOOKS, ...kept, role: ROLE_NOT_SET, welcomeSeen: looks.welcomeSeen };
}
+119 -48
View File
@@ -3,7 +3,7 @@
// Small games for a long wait. The list of games is activities.js; each game
// is its own module under activities/, loaded with import() the first time it
// is picked, and answers the calls the list's header names. The window opens
// on a picker of game cards and plays one game at a time. This file owns
// on a picker of game rows and plays one game at a time. This file owns
// everything around a game: the dialog, the picker, the one frame timer, the
// keys and the pauses. A game never runs a timer of its own, so a paused game cannot move:
// pausing is this file not ticking plus the game's own paused state. Nothing
@@ -15,7 +15,7 @@ import { finish, myTurn } from "../selectors.js";
import { looks, saveLooks } from "../looks.js";
import { el, lightDismiss, SVG_NS } from "../render.js";
import { tellApp } from "../app-bridge.js";
import { ACTIVITIES, bestKey, bestKeys, memoKey, musicKey, musicLevel } from "../activities.js";
import { ACTIVITIES, bestKey, bestKeys, memoKey, musicKey, musicLevel, orderGames, playedKey } from "../activities.js";
import { hum as playHum, hushTones as hushSounds, tone as playTone, unlockTones } from "../tones.js";
import { hushMusic, music as playMusic } from "../music.js";
@@ -97,7 +97,7 @@ const games = new Map();
// A load in flight per game id, so two quick opens share one import().
const loading = new Map();
let currentId = null;
// What the window shows: "picker", the page of game cards, "courses", the
// What the window shows: "picker", the page of game rows, "courses", the
// dashboard of a game with courses (Mini golf's six), or "game", the board of
// the game on screen. With one game listed there is no picker.
let view = "game";
@@ -399,6 +399,7 @@ function resetBest() {
return;
}
disarmReset();
// Best keys only: the played times and the picker's order stay.
for (const entry of list) for (const key of bestKeys(entry)) looks[key] = 0;
saveLooks();
paintOverlay();
@@ -758,7 +759,7 @@ async function showGame(id) {
/* ------------------------------------------------------------- picker */
// Each card's cover, drawn as a little SVG scene: [tag, attributes] pairs on
// Each row's cover, drawn as a little SVG scene: [tag, attributes] pairs on
// a 120 by 72 box. A `cv-` class carries one of the page's tokens
// (styles/activities.css), since the page's policy refuses a style attribute.
// A game with no cover of its own gets the plain one.
@@ -1084,53 +1085,114 @@ function cover(id) {
return svg;
}
// The round a card's game has waiting, if any: only the game last played can
// The round a row's game has waiting, if any: only the game last played can
// have one, since picking another lets it go.
const pausedRound = (id) => {
const g = games.get(id);
return g && g.state === "paused" ? g : null;
};
// The picker: a card per game with its cover, its line, its best and, for the
// game last played, whether a round of it is waiting.
// The "N games" count the Order bar shows.
const countText = (n) => `${n} game${n === 1 ? "" : "s"}`;
// A row's best chip: a muted label and a value. Mini golf counts the courses
// it has a best on; a game with no best yet reads "No best yet" with no value.
function bestChip(entry) {
const chip = el("span", "activities-row-best");
const label = (text) => chip.append(el("span", "activities-row-best-label", text));
const value = (text) => chip.append(el("span", "activities-row-best-value", text));
if (entry.courses) {
const n = entry.courses.filter((c) => best(entry.id, c)).length;
if (n) value(`${n} of ${entry.courses.length} courses`);
else label(`${entry.courses.length} courses to play`);
return chip;
}
const n = best(entry.id);
if (!n) {
chip.classList.add("none");
label("No best yet");
return chip;
}
label(lowerIsBetter.has(entry.id) ? "Best round" : "Best");
chip.append(" ");
value(n.toLocaleString("en-US"));
return chip;
}
// One row of the picker: the cover, the title with its tag, the line about the
// game and its best chip. The tag says whether a round is waiting, else
// whether this was the last game played.
function gameRow(entry) {
const b = el("button", "activities-row");
b.type = "button";
b.dataset.activity = entry.id;
const art = el("span", "activities-cover");
art.append(cover(entry.id));
const head = el("span", "activities-row-head", "");
head.append(el("span", "activities-row-title", entry.title));
const waiting = pausedRound(entry.id);
const tag = waiting ? `Paused at ${Number(waiting.score).toLocaleString("en-US")}` : entry.id === looks.lastActivity ? "Last played" : "";
if (tag) head.append(el("span", `activities-row-tag${waiting ? " waiting" : ""}`, tag));
const text = el("span", "activities-row-text");
text.append(head, el("span", "activities-row-blurb", entry.blurb || ""));
b.append(art, text, bestChip(entry));
b.addEventListener("click", () => pick(entry.id));
return b;
}
// The picker: an Order bar (Recently played or A to Z, and the game count),
// then one grid of game rows, with the games never picked under a Not played
// yet heading that spans both columns.
function drawPicker() {
const picker = $("activities-picker");
if (!hasPicker()) return picker.replaceChildren();
const cards = el("div", "activities-cards");
cards.setAttribute("role", "group");
cards.setAttribute("aria-label", "Pick a game");
for (const entry of list) {
const b = el("button", "activities-card");
b.type = "button";
b.dataset.activity = entry.id;
const art = el("span", "activities-cover");
art.append(cover(entry.id));
const body = el("span", "activities-card-body");
const n = best(entry.id);
// A game with courses counts the courses it has a best on.
const played = entry.courses ? entry.courses.filter((c) => best(entry.id, c)).length : 0;
const bestText = entry.courses
? played ? `Best on ${played} of ${entry.courses.length} courses` : `${entry.courses.length} courses to play`
: n ? `${lowerIsBetter.has(entry.id) ? "Best round" : "Best"}: ${n}` : "No best yet";
body.append(el("span", "activities-card-title", entry.title), el("span", "activities-card-blurb", entry.blurb || ""), el("span", "activities-card-best", bestText));
b.append(art, body);
const waiting = pausedRound(entry.id);
const tag = waiting ? `Round paused, score ${waiting.score}` : entry.id === looks.lastActivity ? "Last played" : "";
if (tag) b.append(el("span", `activities-card-tag${waiting ? " waiting" : ""}`, tag));
b.addEventListener("click", () => pick(entry.id));
cards.append(b);
const order = looks.activityOrder === "az" ? "az" : "recent";
const { played, unplayed } = orderGames(list, looks, order);
const bar = el("div", "activities-order");
bar.append(el("span", "activities-order-label", "Order"));
for (const [key, text] of [["recent", "Recently played"], ["az", "A to Z"]]) {
const pill = el("button", "activities-order-pill", text);
pill.type = "button";
pill.dataset.order = key;
pill.setAttribute("aria-pressed", String(order === key));
pill.addEventListener("click", () => setOrder(key));
bar.append(pill);
}
const parts = [cards];
bar.append(el("span", "activities-count", countText(list.length)));
const rows = el("div", "activities-rows");
rows.setAttribute("role", "group");
rows.setAttribute("aria-label", "Pick a game");
rows.append(...played.map(gameRow));
if (unplayed.length) {
const group = el("div", "activities-group", "Not played yet");
group.setAttribute("role", "heading");
group.setAttribute("aria-level", "3");
group.append(" ", el("span", "activities-group-count", String(unplayed.length)));
rows.append(group, ...unplayed.map(gameRow));
}
const parts = [bar, rows];
if (list.some((e) => pausedRound(e.id))) parts.push(el("p", "help activities-picker-note", "Picking a different game ends the paused round."));
picker.replaceChildren(...parts);
}
// An Order button pressed: keep the order, draw the picker again and put
// focus back on the button, which the redraw replaced. The pressed one does nothing.
function setOrder(order) {
if ((looks.activityOrder === "az" ? "az" : "recent") === order) return;
looks.activityOrder = order;
saveLooks();
drawPicker();
const pill = $("activities-picker").querySelector(`[data-order="${order}"]`);
if (pill) pill.focus({ preventScroll: true });
}
// The game to put focus on when the picker shows: the one with a round
// waiting, else the last one played, else the first.
// waiting, else the last one played; none means the first row drawn.
function focusId() {
if (currentId && list.some((e) => e.id === currentId)) return currentId;
const waiting = list.find((e) => pausedRound(e.id));
if (waiting) return waiting.id;
if (list.some((e) => e.id === looks.lastActivity)) return looks.lastActivity;
return list.length ? list[0].id : null;
return null;
}
function showPicker() {
@@ -1142,7 +1204,8 @@ function showPicker() {
paintTitle();
drawPicker();
layout();
const card = $("activities-picker").querySelector(`[data-activity="${focusId()}"]`);
const id = focusId();
const card = (id && $("activities-picker").querySelector(`[data-activity="${id}"]`)) || $("activities-picker").querySelector(".activities-row");
if (card) card.focus({ preventScroll: true });
}
@@ -1150,10 +1213,9 @@ function showPicker() {
// one picked, so only one game is ever loaded with a round in it. A game
// with courses opens on its dashboard.
function pick(id) {
if (looks.lastActivity !== id) {
looks.lastActivity = id;
saveLooks();
}
looks.lastActivity = id;
looks[playedKey(id)] = Date.now();
saveLooks();
if (currentId && currentId !== id) {
pauseAll("closed");
games.delete(currentId);
@@ -1248,16 +1310,25 @@ function playCourse(id, course) {
showGame(id);
}
// The arrows walk the cards: left and right one at a time, up and down a row.
// The arrows walk the rows and the course cards by position: left and right
// one at a time through the list, up and down to the nearest button in the
// next line above or below (closest left edge), staying put at the first or
// last line. The group heading is no button, so it is never focused. An Order
// button keeps its arrows, as a normal tab stop.
function moveFocus(dir) {
const cards = [...$("activities-picker").querySelectorAll(".activities-card")];
const active = document.activeElement;
if (active instanceof Element && active.classList.contains("activities-order-pill")) return;
const cards = [...$("activities-picker").querySelectorAll(".activities-row, .activities-card")];
if (!cards.length) return;
const at = cards.indexOf(document.activeElement);
const at = cards.indexOf(active);
if (at < 0) return cards[0].focus();
const perRow = Math.max(1, cards.filter((c) => c.offsetTop === cards[0].offsetTop).length);
const step = { left: -1, right: 1, up: -perRow, down: perRow }[dir];
const next = cards[Math.min(cards.length - 1, Math.max(0, at + step))];
next.focus();
if (dir === "left" || dir === "right") return cards[Math.min(cards.length - 1, Math.max(0, at + (dir === "left" ? -1 : 1)))].focus();
const tops = [...new Set(cards.map((c) => c.offsetTop))].sort((a, b) => a - b);
const line = tops.indexOf(cards[at].offsetTop) + (dir === "up" ? -1 : 1);
if (line < 0 || line >= tops.length) return;
const left = cards[at].offsetLeft;
const near = cards.filter((c) => c.offsetTop === tops[line]).sort((a, b) => Math.abs(a.offsetLeft - left) - Math.abs(b.offsetLeft - left))[0];
near.focus();
}
/* ------------------------------------------------------------ opening */
@@ -1344,8 +1415,8 @@ function onGameKey(e, key) {
e.stopPropagation();
return full ? toggleFull() : closeActivities();
}
// On the picker and a course dashboard the arrows walk the cards, and
// space and Enter press one.
// On the picker and a course dashboard the arrows walk the rows and
// cards, and space and Enter press one.
if (view === "picker" || view === "courses") {
if (Object.hasOwn(KEYS, key) && KEYS[key] !== "action") {
e.preventDefault();
+85 -3
View File
@@ -175,14 +175,16 @@
.activities-banner .btn { flex: none; }
.activities-banner .btn[hidden] { display: none; }
/* The picker: a page of game cards in place of the board, shown once two or
more games are listed. Each card is one button: a cover scene, the title,
/* The picker: a page of game rows in place of the board, shown once two or
more games are listed. Each row is one button: a cover scene, the title,
a line about the game, its best, and a tag for the last one played. */
.activities-picker {
flex: 1 1 auto;
min-height: 0;
overflow: auto;
padding: 4px 2px 8px;
/* The rows' columns follow the picker's own width, not the window's. */
container-type: inline-size;
}
.activities-picker[hidden] { display: none; }
/* Cards keep one width and wrap, and each row (a short last one too) sits in
@@ -255,6 +257,85 @@
}
.activities-card-tag.waiting { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); }
.activities-picker-note { margin: 12px 0 0; }
/* The game picker's ledger: an Order bar, then one grid of compact rows (one
column, two from about 640px of picker width). The Not played yet heading
spans both columns, so the arrows walk one grid. */
.activities-order { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.activities-order-label { color: var(--ink-3); font-size: 0.85em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.activities-order-pill {
padding: 3px 12px;
border: 1px solid var(--rule-2);
border-radius: 999px;
background: var(--panel);
color: var(--ink-2);
font: inherit;
font-size: 0.9em;
font-weight: 600;
cursor: pointer;
}
.activities-order-pill:hover { border-color: var(--accent-line); color: var(--ink); }
.activities-order-pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.activities-order-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.activities-count { margin-left: auto; color: var(--ink-3); font-size: 0.9em; font-weight: 600; font-variant-numeric: tabular-nums; }
.activities-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@container (min-width: 640px) {
.activities-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.activities-row {
display: grid;
grid-template-columns: 96px minmax(0, 1fr) auto;
align-items: center;
gap: 12px;
padding: 8px 12px 8px 8px;
border: 1px solid transparent;
border-radius: 10px;
background: var(--panel);
color: var(--ink);
font: inherit;
text-align: left;
cursor: pointer;
transition: border-color 120ms ease-out, box-shadow 120ms ease-out, transform 120ms ease-out;
}
.activities-row:hover,
.activities-row:focus-visible { border-color: var(--accent-line); background: var(--panel-2); }
.activities-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.activities-row .activities-cover { border: 1px solid var(--rule-2); border-radius: 6px; overflow: hidden; }
.activities-row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.activities-row-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.activities-row-title { font-size: 1.05em; font-weight: 800; }
.activities-row-blurb { color: var(--ink-2); font-size: 0.92em; line-height: 1.35; }
.activities-row-tag {
padding: 1px 8px;
border: 1px solid var(--rule-2);
border-radius: 999px;
color: var(--ink-2);
font-size: 0.78em;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.activities-row-tag.waiting { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); }
.activities-row-best {
padding: 3px 10px;
border: 1px solid var(--rule-2);
border-radius: 999px;
background: var(--panel-2);
color: var(--ink-3);
font-size: 0.85em;
font-weight: 600;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.activities-row-best-value { color: var(--ink); font-weight: 800; }
.activities-row-best.none { border-color: transparent; background: transparent; }
.activities-group {
grid-column: 1 / -1;
margin-top: 6px;
padding-top: 10px;
border-top: 1px solid var(--rule);
font-weight: 800;
}
.activities-group-count { color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
/* All games sits at the far left of the actions, away from Close. */
.modal.activities .activities-back { margin-right: auto; }
.modal.activities .activities-back[hidden] { display: none; }
@@ -264,7 +345,8 @@
.modal.activities .activities-music input { width: 110px; accent-color: var(--accent); }
.modal.activities .activities-music:has(input:disabled) { opacity: 0.55; }
@media (prefers-reduced-motion: no-preference) {
.activities-card:hover { transform: translateY(-2px); }
.activities-card:hover,
.activities-row:hover { transform: translateY(-2px); }
}
/* The board: fills the free space and centers the canvas, with the state