[ui] PlanetGarden: Analysis, review, lessons and the tablet smoke that always stops Chrome

This commit is contained in:
2026-11-17 19:56:24 +01:00
parent 1ff00b0e3f
commit f0cb6750c4
13 changed files with 467 additions and 8 deletions
+1
View File
@@ -19,4 +19,5 @@ One row per feature, with its analysis document (CLAUDE.md §5.1). Gaps live in
| The rose: care by feel, growth from days of care, drift, moods, her numbers; the care log and the identity | 1 | Merged to `main`; built, not deployed. Tuning is the author's | [rose.md](features/rose.md) | [feature-rose-care.md](reviews/feature-rose-care.md) |
| Where the sunset is: choose a town (or skip to a guess from the device's zone), kept on the device; tonight's sunset in the garden | 1 | Merged to `main`; built, not deployed | [sunset-place.md](features/sunset-place.md) | [feature-sunset-place.md](reviews/feature-sunset-place.md) |
| The sun: real sunrise, sunset and solar noon on the device; polar day and night | 1 | Merged to `main`; engine only, the app does not show it yet | [sun.md](features/sun.md) | [feature-sun.md](reviews/feature-sun.md) |
| Her planet and the gardener: a round tiny planet, a boy or girl chosen at the first open, the ring of care by a tap on her, care by gesture (tilt the can, swipe weeds up, sweep petals, drag the windbreak, stroke her); every gesture also a button | 1 | Merged to `main`; built, not deployed. Code stand-ins; the painted art waits on the board | [planet-garden.md](features/planet-garden.md) | [feature-planet-garden.md](reviews/feature-planet-garden.md) |
| The art pipeline and the art board: STYLE.md (S1–S5 and the fox's F1–F4 approved), the manifest (Phase 1–3, 53 pictures), stand-ins, `tools/art-prep`, the published board | 0 | Merged to `main`; board published (private). The app is unchanged. Gate waits on the first real picture | [art-pipeline.md](features/art-pipeline.md) | [feature-art-board.md](reviews/feature-art-board.md), [art-phase2-3-pictures.md](reviews/art-phase2-3-pictures.md) |
+8 -1
View File
@@ -49,7 +49,7 @@ board exist, and the first real picture is the author's to make.
## Phase 1 — The rose alone
**Started 2026-11-01** with the sun, while the Phase 0 gate waits on the author (pictures,
sentences). Nothing in Phase 1 is visible to the player yet.
sentences). Phase 1 is built in code, not deployed (no host yet, G0.13).
| Id | Gap | Status / evidence |
|:--|:--|:--|
@@ -61,8 +61,15 @@ sentences). Nothing in Phase 1 is visible to the player yet.
| ~~G1.7~~ | ~~Thorns were on the roadmap but undesigned~~ | Closed 2026-11-02 on `feature/thorns`, as the author chose: thorns teach gentleness. `engine/touch` (2 properties: spaced taps are never a rush; one blush a visit); a tremor is one touch; nothing recorded. 6 of 6 put-back bugs caught. |
| ~~G1.8~~ | ~~Two tabs (CLAUDE.md §8, predicted)~~ | Closed 2026-11-07 on `fix/two-tabs`. Measured first: two e2e tests failed (an open tab saw neither care nor a town from the other). Storage announces committed writes on a `BroadcastChannel`; the rose and the garden read again, adding to what they show. No lock needed: nothing stored drifts. 7 of 7 put-back bugs caught. |
| ~~G1.10~~ | ~~The garden named only the sunset, never the sunrise (ROADMAP Phase 1: *sunset and sunrise*)~~ | Closed 2026-11-17 on `feature/sunrise`: from sunset until it comes, the line names the real sunrise; the in-game sunset still names the sunset. engine `nextSunEvent` with a 300-run property; e2e at 05:00 in Brno; seen on a real Android tablet. 5 of 5 put-back bugs caught. |
| ~~G1.9~~ | ~~The garden was a page of buttons, not a game (the author, 2026-11-17)~~ | Closed 2026-11-17 on `feature/planet-garden`: her round planet, a gardener the player chooses at the first open (fixed lists, kept in `profile`, never in the rose file), the ring of care by a tap on her, care by gesture with a button for each. 84 ui tests incl. 7 on the planet and 7 on gestures; e2e `planet.spec.ts` 3; 9 of 9 put-back bugs caught (2 only after tests were added); 7 of 7 by real touch on the Android tablet. **Open in it:** painted art for the planet and the gardener, and how customised looks are drawn (STYLE.md §3b, the author's). |
| G1.3 | Towns have no Czech names (*Vídeň*) | Open. Natural Earth has none; arrives with Czech copy. |
## Phase 6 — Release
| Id | Gap | Status / evidence |
|:--|:--|:--|
| G6.1 | A legal check of the look: a child on a small round planet with a rose is the book's best-known image, and its estate holds trademarks | Open, **before any public release**. The author accepted the risk on 2026-11-17 (CLAUDE.md §8); the guards are STYLE.md S2, S6, §3b and review points 10–11. |
## Design questions — answered
Raised by GAMEPLAY.md and ROADMAP.md, answered by the author 2026-11-01. Details in
+121
View File
@@ -0,0 +1,121 @@
# The planet garden — a gardener, gestures, and her own small world
Status: built on `feature/planet-garden`, merged to `main` 2026-11-17; built, not deployed. Decided by the author, Mark, on 2026-11-17, after
seeing the garden as a page of buttons: *"It is a game: create a proper planet, a character who does
the care, animations of how the character does it; tap the rose for actions; swipe in patterns;
pull weeds by tapping them and swiping."* His answers the same day:
- **Her world:** a **round tiny planet** (reverses STYLE.md S2).
- **The character:** a **human gardener, a boy or a girl, customised at the beginning** (reverses
STYLE.md's *no people*).
- **Gestures:** tap her to choose care; swipe weeds out; pour by tilting; patterns for the rest
(sweep petals, drag the windbreak, stroke her petals). **Buttons stay** for keyboard and screen
readers (CLAUDE.md §7: accessibility is not a phase).
Review: `feature-planet-garden.md`.
## 0. The risk the author accepted, and the guards
A child tending a rose on a small round planet is the most recognisable image of the book whose
text, names and drawings CLAUDE.md §5.6 rule 3 forbids, and whose estate holds trademarks
(GAMEPLAY.md §7). The author was told this in the choice itself and chose it. Recorded here, in
STYLE.md and CLAUDE.md, with these guards, which become review points and avoid lines:
| Guard | Why |
|:--|:--|
| **The gardener is the player's own**: chosen and customised (boy or girl, skin tone, hair style and colour, clothes colour, a hat or not) | No two players' gardeners need look alike, and none is a fixed character from anywhere. |
| **Never**: a scarf, a long coat or cape, a green suit with epaulettes, a crown, a sword; no outfit option recreates one | The book's boy is drawn with these. |
| **The planet is a cultivated garden world**: meadow, the dry-stone wall, the garden bed, the chair, the wild berry bush; **no volcanoes, no baobab-like trees, no single lamp post** | The book's planet is bare with volcanoes and baobabs. |
| **The look is our gouache** (STYLE.md §1), never pen-and-wash | The book's drawings are pen and watercolour. |
| **No glass dome over her, ever; the windbreak is woven willow** | Unchanged (§4). |
| **A legal check of the look before any public release** (store listings, Pages made public) | New gap; the author's risk, made visible. |
## 1. Why and what, in the player's terms
**The first open.** Before the garden, one quiet question: *Who tends her?* The player chooses a
boy or a girl, then skin tone, hair, clothes colour, a hat. A small preview of their gardener turns
as they choose. *This is me* finishes it. It can be changed later, from the garden.
**The garden is a small round world.** Her planet fills the lower half of the screen, the real sky
above it (code, as now). On its top: the garden bed with the rose, the wall behind, the chair, the
watering can by the bed; the gardener stands beside her.
**Tap the rose** and the care she needs right now opens around her as a small ring of choices (only
what she needs; *Touch her* is always there). Choose one and the gardener walks over and does it,
with the player's own hand in the gesture:
| Care | The gesture | The gardener |
|:--|:--|:--|
| **Water** | **Press the can and tilt**: drag sideways from it; the further the tilt, the faster the pour. Let go when her leaves lift (the same *by feel* as now). | Holds the can, tilting it as the player tilts; water falls. |
| **Weeds** | Weeds show in the bed. **Tap a weed, then swipe up** from it: it stretches, then pops out with its roots. | Bends, tugs, the weed comes free, the gardener bumps down on the grass and gets up. |
| **Fallen petals** | **Sweep**: one swipe sideways across the petals gathers them. | Sweeps them into a little pile and pockets them. |
| **Wind** | **Drag the windbreak** from the side of the bed into the wind, on her windward side. | Carries it and sets it in the ground. |
| **Touch her** | **Stroke** slowly across her petals: a fond answer. Quick, rushed taps: *Gently. I have thorns.* (thorns.md) | Reaches out and touches a petal. |
Every act is the same event as today (rose.md, thorns.md): nothing about growth, drift, the petal or
her numbers changes. The gestures are how the player's hand meets the same rules.
**Keyboard and screen readers.** The ring's choices are buttons; each one also works without its
gesture: *Water* still pours while Space or Enter is held; *Pull the weeds* pulls them all, one by
one, while the gardener does it; *Gather the petals*, *Shade her*, *Touch her* likewise. The scene
says what happens in one polite line.
**Reduced motion.** The gardener does not walk or bend: the scene shows the result at once.
## 2. Technical architecture
```mermaid
flowchart LR
app["apps/rosea<br/>App.svelte"] --> shell["packages/ui<br/>Shell: first-open choice, then the scene"]
shell --> scene["packages/ui/scene<br/>Planet.svelte (SVG): planet, bed, rose, can,<br/>weeds, petals, windbreak, gardener"]
scene --> gestures["packages/ui/scene/gestures.ts<br/>pure: tilt, swipe up, sweep, drag, stroke"]
scene --> engine["packages/engine<br/>rose (care, pour), touch (thorns),<br/>scene/ weedsToday, petalsToday (seeded counts)"]
shell --> storage["packages/storage<br/>profile: gardener (shape-checked)"]
```
| # | Decision | Why |
|:--|:--|:--|
| G1 | **One SVG scene** (`Planet.svelte`), every part its own group with a stand-in drawn in code until art is accepted; the sky stays code (S5). | One coordinate system for gestures, animation and layout; no canvas, so every part can carry an accessible name. |
| G2 | **Gesture recognisers are pure functions** of pointer samples (`gestures.ts`): `tiltOf`, `isSwipeUp`, `isSweep`, `dropTarget`, `strokeOf`. Unit- and property-tested. | Input interpretation is not game logic, but it must be testable without a browser. The rules stay in the engine. |
| G3 | **How many weeds and petals** a day shows is the engine's: `weedsToday(seed, day)` (2–4 when `weedsOn`), `petalsToday(seed, day)` (3–5 when `petalsOn`). One `weed` / `petals` care event when the **last** one is pulled or gathered. | A count on screen is the engine's (CLAUDE.md §6.2). Half-pulled weeds are not care yet: nothing is written until the job is done, and leaving half-way loses nothing earned. |
| G4 | **Pour by tilt** maps tilt to the same pour rate the hold uses (`ROSE.fullPour` over `FULL_CAN_MS`), scaled 0–1.5× by tilt; the event's `amount` is unchanged in meaning. | Watering by feel (rose.md R1) stays one rule. |
| G5 | **The gardener** is a separate component with poses (`stand`, `walk`, `pour`, `bend`, `pull`, `sweep`, `carry`, `reach`, `sit`) and a look from the player's choice. Poses are SVG stand-ins now; real art replaces them sheet by sheet. | Art and animation can arrive later without touching gestures or rules. |
| G6 | **The gardener's look is stored in `profile`** as `{ presentation: 'boy' \| 'girl', skin, hair, hairColour, clothes, hat }`, each from a fixed list; shape-checked like every stored value. Never sent anywhere. | No free text; nothing identifying; local only (CLAUDE.md §4). |
| G7 | **The ring** opens on a tap of the rose; it holds only her current needs plus *Touch her*; Escape or a tap outside closes it; focus moves into it and back. | Silence and calm: no permanent row of buttons over her. |
## 3. Risk analysis
| Risk | Answer |
|:--|:--|
| **Likeness to the book** (the author's accepted risk) | §0's guards, as avoid lines in every prompt, review points, and a legal check before release. |
| **Soul: a child avatar for adult players** | The author chose boy or girl. Recorded as a question for his two-week play: does an adult player see themselves in a child gardener? A grown-up option is one list entry away. |
| **Soul: fiddly gestures that make care feel like failing** | Generous thresholds; every gesture has a button; a missed gesture does nothing and says nothing; nothing is lost. |
| **Motion** | `prefers-reduced-motion`: no walking or bending; results at once. |
| **Accessibility** | Buttons for every act (G7); one polite line says what the gardener did; keyboard focus never trapped. |
| Privacy | The gardener's look stays in `profile`, on the device; it is not in the rose file (keep-her-safe.md K4 is unchanged). |
| Offline | Everything is code and bundled stand-ins. |
## 4. Gap analysis
- New: **G1.9** the planet garden (this); **G6.x** a legal check of the look before any public release.
- STYLE.md: S2 (where she lives) and *no people* are reversed by the author; §3b *the gardener* is
new; §4 and §7 gain the guards; the manifest gains the planet, the gardener's sheet and pose
sheets, and the customisation parts.
- Not in this feature: the gardener on the journey's other planets (Phase 2), the fox on her planet.
## 5. Verification matrix
| Case | Kind | Where |
|:--|:--|:--|
| `tiltOf`: sideways drag → 0–1 tilt; `isSwipeUp` needs upward distance and direction; `isSweep` needs sideways distance across the petals; `strokeOf` tells a slow stroke from a tap | unit + property | `ui/test/gestures.test.ts` |
| `weedsToday` / `petalsToday`: 0 on a day without, 2–4 / 3–5 with, the same on every replay | unit + property | `engine/test/scene.test.ts` |
| Gardener look: every option list is fixed; storage refuses anything else; it never enters the rose file | unit | `storage/test` |
| First open asks *Who tends her?*; the choice is kept; *Change gardener* reopens it | unit | `ui/test/gardener.test.ts` |
| Tap the rose: the ring shows only her needs plus *Touch her*; Escape closes it and focus returns | unit | `ui/test/planet.test.ts` |
| Pulling every weed writes one `weed` event; leaving half-way writes none | unit | same |
| A sweep across the petals writes one `petals` event; dragging the windbreak onto the windward side writes `shade` | unit | same |
| Pour by tilt writes one `water` event whose amount follows the tilt and time | unit | same |
| Buttons do every act without a gesture | unit | same |
| Reduced motion: no animation classes | unit | same |
| Built app: first-open choice, tap the rose, pull weeds by swiping, axe | e2e | `e2e/planet.spec.ts` |
| The real tablet: the same by real touch | device | `scripts/android-smoke.ts` (made permanent here) |
+2 -2
View File
@@ -10,9 +10,9 @@ and **how to apply it**.
| `architecture.md` | none yet | Layering, ownership, seams. |
| `design.md` | none yet | Wording, silence, empty states. |
| [`art.md`](art.md) | 3 | The image pipeline. |
| [`code.md`](code.md) | 3 | TypeScript, Svelte, async ordering, Rust. |
| [`code.md`](code.md) | 4 | TypeScript, Svelte, async ordering, Rust. |
| [`technical.md`](technical.md) | 7 | The browser and the build as platforms. |
| [`testing.md`](testing.md) | 10 | What makes a test worth having, and how a passing test lies. |
| [`testing.md`](testing.md) | 12 | What makes a test worth having, and how a passing test lies. |
| `privacy.md` | none yet | What could leave the device or make a person findable. (The geocell finding is in the review, not here: it was caught before it cost anything.) |
| [`process.md`](process.md) | 4 | Workflow, commits, credentials, honesty about what shipped. |
+13
View File
@@ -50,3 +50,16 @@ hands out Proxies wherever state is deep.
**How to apply it.** At every storage or messaging boundary, write a plain copy built
field by field (in `@rosea/storage`, the same shape check used on reading). Keep lists
that are only passed along as `$state.raw`. Test the boundary with `new Proxy(value, {})`.
## `svelte/motion` reads `matchMedia` when it is imported
**What happened.** On 2026-11-17 the gardener's walk used `Tween` from `svelte/motion`. Every UI
test file failed at import: jsdom has no `window.matchMedia`, and the module reads it at load (for
its reduced-motion store), not when a tween runs.
**Why it bit.** An import with side effects breaks every file that imports it, even transitively,
and the error points at the module, not at the component that needed it.
**How to apply it.** In `packages/ui`, animate with a small `setInterval` easing inside an
`$effect` (`packages/ui/src/scene/Planet.svelte`), reading reduced motion once through a guarded
`matchMedia` call. If `svelte/motion` is wanted later, stub `matchMedia` in the test setup first.
+28
View File
@@ -146,3 +146,31 @@ asserts something the edge makes false.
**How to apply it.** Bound every search to the region the test means (here: daytime on the
pour's own local day), and when a test built on a search fails, print what the search
returned before debugging the code under test.
## jsdom has no `PointerEvent`, so a test pointer carries no coordinates
**What happened.** On 2026-11-17 the planet garden's gesture tests fired `pointerDown` and
`pointerMove` with `clientX`/`clientY`, and every gesture read as a tap at (0, 0). jsdom has no
`PointerEvent`; testing-library falls back to a plain `Event`, which drops the coordinates.
**Why it bit.** The test looked like a finger and measured nothing. A missing browser API in the
test environment does not fail loudly; it quietly hands the code a poorer event.
**How to apply it.** Before testing pointer gestures in jsdom, polyfill `PointerEvent` on
`MouseEvent` (`packages/ui/test/planet.test.ts`) and assert one coordinate-dependent outcome first
(a sideways swipe does *not* pull a weed). Check real fingers on the device (`pnpm test:android`).
## A device test's clean-up must cover its very first step
**What happened.** On 2026-11-17 `scripts/android-smoke.ts` connected to Chrome on the tablet
*before* its `try`. Chrome was still cold-starting, the connect failed with *socket hang up*, and
the `finally` that stops Chrome and removes the adb mappings never ran: Chrome stayed open on a
device the author asked to leave as it was found. It was stopped by hand.
**Why it bit.** Clean-up written for the failures you expect (a step fails) misses the one that
happens first (the setup fails). On a shared device, a leftover is somebody else's problem.
**How to apply it.** Open the `try` before the first command that changes the device; make the
clean-up tolerate half-done setup (`page?.close()`, `browser?.close()`); retry connections that
race a cold start (the script tries for 30 s). After every device run, check: `pidof` the app is
empty, `reverse --list` and `forward --list` are empty.
+68
View File
@@ -0,0 +1,68 @@
# Review — `feature/planet-garden`
Adversarial self-review (CLAUDE.md §5.3). Analysis: [`features/planet-garden.md`](../features/planet-garden.md).
Reviewed 2026-11-17 on Node 22.23.4, Windows 10. There is no PR: the only remote is Gitea.
## What the author decided, and what was built
Mark, on 2026-11-17: *a game, with a proper planet, a character who does the care with animations,
taps on the rose and swiped patterns; weeds tapped and swiped out.* He chose a **round tiny planet**,
a **human gardener, a boy or a girl, customised at the beginning**, and **all four gesture sets**.
- The first open asks **Who tends her?**: boy or girl, skin tone, hair style and colour, clothes
colour, a hat, with a live preview; kept on the device (`profile.gardener`, a JSON Schema of
fixed lists). *Change gardener* reopens it.
- The garden is **her planet** (SVG): the real sky's light (engine `lightAt`), the meadow world, her
bed, the wall, the chair, the watering can, the day's weeds and fallen petals (engine
`weedsToday`, `petalsToday`), the windbreak on a windy hour, and **the gardener**, who walks round
the world to the work and takes a pose for it (stand-ins until art).
- **Tap her** (or Enter on her) opens **the ring** of what she needs, plus *Touch her* and *Close*;
Escape closes it, focus returns to her. **Press the can and tilt** to pour (the tilt sets the
rate); **swipe each weed up**; **sweep across the petals**; **drag the windbreak** to her
windward side; **stroke her petals** slowly. Every gesture has its button in the ring.
- The art board gains the gardener's sheet and eight poses, and her home planet in three lights;
STYLE.md records S2 (reversed) and S6 with their guards and review points 10–11.
Also on this branch: the tap-highlight fix (seen on the real tablet) and `pnpm test:android`.
## Bug drills
| Put back | Result |
|:--|:--|
| A sideways swipe pulls a weed | **MISSED at first**, then CAUGHT: the "sideways" tests were also too short, so the distance rule hid the direction rule; a long diagonal test added |
| Every pulled weed is written as care, not only the last | CAUGHT |
| The sweep need not cover every petal | CAUGHT |
| The windbreak counts wherever it is dropped | CAUGHT |
| Tilt is ignored (pours at the steady rate) | CAUGHT |
| A stroke opens the ring instead of touching her | CAUGHT |
| The gardener question is not shown at the first open | CAUGHT: 2 |
| The gardener's look accepts any value | CAUGHT: 2 |
| Reduced motion still walks | **MISSED at first**, then CAUGHT: the test checked a CSS class, not where the gardener stands; it now reads his angle straight after an act |
The first rerun of the reduced-motion drill reported CAUGHT against a test that was failing on its own (it looked before the garden loaded); fixed, then every drill was run again against a green suite.
## Findings
| # | Area | Finding | Resolution |
|:--|:--|:--|:--|
| 1 | Likeness / legal | A child tending a rose on a small round planet is the book's most recognisable image. | The author's decision, made knowingly. Guards: the gardener is the player's own, in work clothes; nothing to choose recreates the book's boy (tested on the option lists); the planet is a cultivated garden; review points 10–11; **G6.1: a legal check of the look before any public release.** |
| 2 | Soul | A child gardener for players who are mostly grown-ups. | Recorded as a question for the author's two-week play; a grown-up option is one list entry away (`gardener.schema.json`). |
| 3 | Soul | Gestures can feel like failing. | Generous thresholds; a missed gesture does nothing and says nothing; every act also has a button. |
| 4 | Accessibility | Gestures are not keyboard or screen-reader operable. | The ring's buttons do every act; the rose target is a focusable `role=button` with `aria-expanded`; one polite line says what the gardener did; axe passes on the choice, the scene and the ring (e2e). |
| 5 | Motion | Walking and swaying. | `prefers-reduced-motion`: the gardener is placed at once (tested); the global rule shortens the rest. |
| 6 | Two tabs | A gardener changed in one tab is not shown in another until reload (storage announces `gardener`, the UI does not listen yet). | Deferred: harmless (nothing is lost) and rare; noted for the next touch of the Shell. |
| 7 | Correctness | Half the weeds pulled, then the tab closed: nothing written, the weeds come back. | By design (G3): care is the finished job; nothing earned is lost. |
| 8 | Testing | jsdom has no `PointerEvent`: test pointers carried no coordinates, and `svelte/motion` read `matchMedia` at import, failing every file. | A `PointerEvent` polyfill in the planet tests; the walk is a small interval instead of `Tween`. Lessons in `testing.md` and `code.md`. |
| 9 | Process | The first look in the browser was the **old** garden: the preview's service worker served the cached build, as a player's would until *Refresh*. | Cleared for the check; it is exactly what calm-refresh exists for. |
| 10 | Design | The first stand-in had a shading arc that read as a smile on the planet. | Removed after looking. |
| 11 | Art | Painted art cannot simply be recoloured for every skin tone, hair and clothes choice the way the code stand-in is. | The board makes the first look; **how the other looks are drawn is open for the author** (STYLE.md §3b). |
| 12 | Testing | The first tablet run failed to connect while Chrome cold-started, and the connect sat **before** the `try`: Chrome was left running on the tablet. | Stopped by hand at once; the script now opens `try` before the first adb command, retries the connect for 30 s and tolerates half-done setup. Lesson in `testing.md`. |
| — | Privacy | The gardener's look stays in `profile`; it is not in the rose file (tested); nothing is sent. | — |
## Gates and devices
Counts are on the merge (HANDOVER). The tablet (WAVE 10C, 2026-11-17): `pnpm test:android` **7 of 7**
by real touch: the gardener question (a boy, a cap), the town, the ring opened by a tap on her and
closed, pouring by tilting the can, a stroke across her petals, and offline with the server
unreachable. Afterwards Chrome was stopped (`pidof` empty) and both adb mappings removed. **Not verified:** a screen reader; Safari; a phone smaller
than the tablet; weeds and petals by real touch on the device (their days depend on the key).