[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
+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.