[ui] LetterSlot: Add the page for A Letter from the Gardener, shown once the author writes it
docs/LETTER.md holds slots as comments only, so the player sees no change
until the author writes. The app bundles the letter at build time, a small
Markdown subset renders without {@html}, only https: and tel: become links,
and lint:copy now reads the letter. Review found turbo replaying a stale
build after the letter changed; docs/LETTER.md is now in its cache key.
This commit is contained in:
@@ -7,3 +7,4 @@ One row per feature, with its analysis document (CLAUDE.md §5.1). Gaps live in
|
||||
|:--|:--|:--|:--|:--|
|
||||
| Workspace, contracts, gates, PWA shell | 0 | Merged to `main` 2026-11-01 (`d11d242`); built, not deployed. Phase 0 gate still open | [phase0-workspace.md](features/phase0-workspace.md) | [feature-phase0-workspace.md](reviews/feature-phase0-workspace.md) |
|
||||
| Roadmap and gameplay docs, read against the code | 0 | Merged 2026-11-01; Q1–Q7 answered by the author | — | [docs-roadmap-gameplay.md](reviews/docs-roadmap-gameplay.md) |
|
||||
| The Letter slot: page at `#letter`, empty `docs/LETTER.md` | 0 | On `feature/letter-slot`; built, not deployed. Invisible until the author writes | [letter-slot.md](features/letter-slot.md) | [feature-letter-slot.md](reviews/feature-letter-slot.md) |
|
||||
|
||||
@@ -40,7 +40,8 @@ workspace part of Phase 0 is in
|
||||
| G0.22 | No CI | Open. Every gate ran on this machine only. With G0.13. |
|
||||
| G0.23 | Source maps are built and would be published | Open. `sourcemap: true`; maps are not precached. Decide with G0.13 whether the repository is public. If not, use `'hidden'`. |
|
||||
| G0.24 | No art pipeline: `docs/ART.md`, `art/STYLE.md` (drafted with the author), `art/manifest.json` for Phase 1 assets, SVG placeholders, `tools/art-prep` | Open. **Phase 0 gate**: one illustration goes through prompt, paste, automatic checks, review and the author's approval into `art/final/`. |
|
||||
| G0.25 | No slot for *A Letter from the Gardener* | Open. A page and an empty `docs/LETTER.md` the author fills; agents write no part of its voice. |
|
||||
| ~~G0.25~~ | ~~No slot for *A Letter from the Gardener*~~ | Closed 2026-11-01 on `feature/letter-slot`. `docs/LETTER.md` holds slots as comments only; the page opens at `#letter` once it has words. 16 ui tests, and e2e on both the empty and a temporary written letter. Mutations caught: the link while empty, any link scheme, focus not moving, *heal* in the letter. |
|
||||
| G0.27 | The quiet door to real help has no numbers (§5.6 rule 5) | Open. The slot is in `docs/LETTER.md`. Support lines are real-world facts the author must verify, per country, so the door exists only once the letter does. |
|
||||
| ~~G0.26~~ | ~~Not decided: how the sunset invitation reaches the player on the web~~ | Closed 2026-11-01 by the author (Q6): in-app only on the web, no push server; local notifications through the Tauri shell in Phase 6. Recorded in ROADMAP Phase 0 and CLAUDE.md §8. |
|
||||
|
||||
## Design questions — answered
|
||||
@@ -58,3 +59,4 @@ Raised by GAMEPLAY.md and ROADMAP.md, answered by the author 2026-11-01. Details
|
||||
| ~~Q6~~ | When the notification decision is due | Phase 0, in-app only (G0.26) |
|
||||
| ~~Q7~~ | Which phase holds the Amicitia bridge | Phase 3 |
|
||||
| Q8 | "Nearby days give a little more" | Open as a rule for the Phase 1 Soul review: a gap's cost is never shown |
|
||||
| Q9 | May the Letter name the book and its author for the one sentence of inspiration (GAMEPLAY §7)? | Open. `lint:copy` refuses those names in the letter as everywhere in the product. A yes needs a written, letter-only exemption. |
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# The Letter slot
|
||||
|
||||
Status: on `feature/letter-slot`, reviewed in
|
||||
[`feature-letter-slot.md`](../reviews/feature-letter-slot.md). Gap: G0.25. Roadmap: Phase 0, *a slot for A Letter
|
||||
from the Gardener — the author writes it; agents only scaffold the page.*
|
||||
|
||||
---
|
||||
|
||||
## 1. Why and what, in the player's terms
|
||||
|
||||
*A Letter from the Gardener* is the help section. It holds the deeper why, it can be
|
||||
re-read at any time, and it is never needed to play (GAMEPLAY §4). It also holds the
|
||||
quiet door to real help (CLAUDE.md §5.6 rule 5).
|
||||
|
||||
This branch makes the place for it, not the letter itself. The author writes
|
||||
`docs/LETTER.md` in plain Markdown, and the app shows it as a page. **Until the author
|
||||
writes something, the player sees no change at all**: there is no link to an empty
|
||||
page, no "coming soon" and no dead control.
|
||||
|
||||
## 2. Technical architecture
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
letter[("docs/LETTER.md<br/>the author's words")]
|
||||
app["apps/rosea<br/>App.svelte<br/>imports it ?raw at build time"]
|
||||
ui["packages/ui<br/>letter/parse.ts → blocks<br/>Letter.svelte, Shell.svelte"]
|
||||
lint["scripts/lint-copy.ts"]
|
||||
letter -- "bundled, precached" --> app --> ui
|
||||
lint -. scans .-> letter
|
||||
```
|
||||
|
||||
### Decisions
|
||||
|
||||
| # | Decision | Why |
|
||||
|:--|:--|:--|
|
||||
| L1 | `docs/LETTER.md` is the only copy of the letter. The app imports it with Vite's `?raw` at build time. | No runtime fetch, so the letter is in the precached bundle and opens offline. One file means the author edits one place, in Markdown. |
|
||||
| L2 | The scaffold holds only HTML comments: one slot per thing the docs say the letter carries. Comments are dropped when the page is built, so the scaffold renders as nothing. | Agents never write the letter's voice. A heading is voice too, so the slots are comments, not headings. |
|
||||
| L3 | A small Markdown subset is parsed into blocks in `packages/ui/src/letter/parse.ts`: headings, paragraphs, lists, *emphasis* and links. Everything else is shown as plain text. The component renders the blocks with Svelte, **never `{@html}`**. | No HTML is ever built from text, so nothing in the file can inject markup or script, and the CSP stays `'self'`. The parser lives in `ui` because it is presentation, and `ui → content` is not an allowed dependency. |
|
||||
| L4 | Only `https:` and `tel:` become links. Anything else, including `http:`, `javascript:` and `data:`, stays text. External links open in a new tab, with `rel="noopener noreferrer"`. | The support door needs web and phone links. Nothing else does. |
|
||||
| L5 | The page is reached by a link on the home view, at `#letter`. The link exists **only when the letter has content**. With an empty letter, `#letter` shows the home view. | Hash routing works offline without a server rule. An entry point to an empty page is a dead control. |
|
||||
| L6 | `lint:copy` scans `docs/LETTER.md` with the full list, though it lives in `docs/`. | It is player-facing. The `docs/` exemption (§5.6 rule 4) is for design documents, where the words are being discussed. |
|
||||
| L7 | When the view changes, focus moves to the new view's heading. | A screen-reader user hears where they are. A hash change alone announces nothing. |
|
||||
| L8 | `docs/LETTER.md` is in turbo's `globalDependencies`. | Found in review: without it, a changed letter replayed the cached build (`lessons/technical.md`). |
|
||||
|
||||
## 3. Risk analysis
|
||||
|
||||
| Risk | Where | Defence |
|
||||
|:--|:--|:--|
|
||||
| A forbidden or medical word reaches a player through the letter | `docs/LETTER.md` | L6, with a test that the script reads the file. |
|
||||
| The letter names the book | The "one sentence of inspiration" (GAMEPLAY §7) | `lint:copy` refuses *Saint-Exupéry* and the title in the letter as everywhere else. If the author wants the letter to name its source, that is a decision to write down (Q9), not an exemption made by an agent. |
|
||||
| Markup or script injected through the file | The renderer | L3 and L4, with tests for `<script>`, `javascript:` and raw HTML. |
|
||||
| An empty page feels broken or turns the player away | Before the author writes | L5: there is no way to reach it. |
|
||||
| A link sends the player's address somewhere | Support links | `referrer: no-referrer` is already set, and `noreferrer` is on each link. Leaving the app is the player's own choice, made with a tap. |
|
||||
| Someone in crisis cannot find the door | Support lines | Not solved here: the numbers are real-world facts the author must verify. The slot exists, and G0.27 tracks the rest. |
|
||||
|
||||
Guilt, comparison, rejection, dependence: looked for and none found. The page asks
|
||||
nothing and counts nothing.
|
||||
|
||||
## 4. Gap analysis and the designed solution
|
||||
|
||||
| Gap | Solution |
|
||||
|:--|:--|
|
||||
| No page for the letter | `Letter.svelte`, reached at `#letter` (L5) |
|
||||
| No file for the author | `docs/LETTER.md`, slots only (L2) |
|
||||
| The letter escapes `lint:copy` | L6 |
|
||||
| No support lines | Slot only; verified numbers are the author's (G0.27) |
|
||||
|
||||
## 5. Verification matrix
|
||||
|
||||
| Case | Kind | Where |
|
||||
|:--|:--|:--|
|
||||
| The scaffold, being only comments, parses to zero blocks | unit | `packages/ui/test/letter-parse.test.ts` |
|
||||
| Headings, paragraphs across lines, lists, emphasis, links parse as blocks | unit | same |
|
||||
| `<script>` and raw HTML stay text; `javascript:`, `data:`, `http:` links stay text | unit | same |
|
||||
| `https:` and `tel:` links render as links with `noopener noreferrer` | unit | `packages/ui/test/Shell.test.ts` |
|
||||
| Empty letter: no link to it, and `#letter` shows home | unit + e2e | `Shell.test.ts`, `e2e/shell.spec.ts` |
|
||||
| A letter with content: the link appears, opens the page, *Back* returns, focus moves | unit | `Shell.test.ts` |
|
||||
| `lint:copy` reads `docs/LETTER.md` and fails on a forbidden word in it | script, run | the review |
|
||||
| The built app still renders, offline included | e2e, offline | existing suites |
|
||||
| The written-letter branch of the e2e test, with a temporary sample letter | e2e, run once | the review |
|
||||
| A changed letter rebuilds the app (`cache miss`) | e2e, run | the review |
|
||||
@@ -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` | none yet | The image pipeline. |
|
||||
| [`code.md`](code.md) | 1 | TypeScript, Svelte, async ordering, Rust. |
|
||||
| [`technical.md`](technical.md) | 3 | The browser and the build as platforms. |
|
||||
| [`testing.md`](testing.md) | 3 | What makes a test worth having, and how a passing test lies. |
|
||||
| [`code.md`](code.md) | 2 | TypeScript, Svelte, async ordering, Rust. |
|
||||
| [`technical.md`](technical.md) | 4 | The browser and the build as platforms. |
|
||||
| [`testing.md`](testing.md) | 4 | 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) | 2 | Workflow, commits, credentials, honesty about what shipped. |
|
||||
|
||||
|
||||
@@ -20,3 +20,18 @@ fixed the same way. Check with `grep -n $'\xc2\xa0' file` (the two UTF-8 bytes)
|
||||
`sed -n Np file | od -c`. Do not use `grep -P '\xA0'`: it matches the last byte of `≠`
|
||||
and other characters, and raised a false alarm on the review document. Keep
|
||||
`no-irregular-whitespace` on.
|
||||
|
||||
## A Svelte 5 effect that short-circuits never tracks what it skipped
|
||||
|
||||
**What happened.** `Shell.svelte` moved focus with
|
||||
`$effect(() => { if (moved) heading?.focus(); })`. `moved` is a plain variable and was
|
||||
`false` on the first run, so the effect never read `heading` and had no dependencies.
|
||||
When the view changed and `heading` was bound to the new `<h1>`, nothing re-ran. The
|
||||
Shell test caught it: the focus stayed on `<body>`.
|
||||
|
||||
**Why it bit.** An effect tracks only the state it actually reads on each run. A
|
||||
condition that returns early hides every read after it.
|
||||
|
||||
**How to apply it.** In an effect, read the state you depend on before any early
|
||||
return or `&&` (`const target = heading; if (moved) target?.focus();`). Test the
|
||||
re-run, not just the first run.
|
||||
|
||||
@@ -40,3 +40,18 @@ needed for non-CSS style languages or TS features that emit code (enums, decorat
|
||||
|
||||
**How to apply it.** Leave `svelte.config.js` as `export default {}` until a component
|
||||
needs SCSS or emitted TS. Add the preprocessor in the same commit as that need.
|
||||
|
||||
## Turbo's cache does not see a file the app imports from outside its package
|
||||
|
||||
**What happened.** The app imports `docs/LETTER.md?raw`. With a sample letter written
|
||||
into the file, `pnpm test:e2e` printed `@rosea/app:build: cache hit` and tested the
|
||||
*old* bundle, so the link to the letter was missing. Turbo hashes a package's own
|
||||
files, and `docs/` belongs to no package. Adding `docs/LETTER.md` to
|
||||
`globalDependencies` in `turbo.json` turned it into a `cache miss`, and the test passed.
|
||||
|
||||
**Why it bit.** A build cache keyed on the wrong inputs gives a stale bundle that looks
|
||||
fresh. This is CLAUDE.md §5.4 again, caused by the build tool and not the service worker.
|
||||
|
||||
**How to apply it.** Any file the app bundles from outside its package goes into
|
||||
`globalDependencies` or the task's `inputs`, in the same commit as the import. To
|
||||
check, change the file, run the build, and look for `cache miss`.
|
||||
|
||||
@@ -43,3 +43,18 @@ firing has not been tested. Without the run, a review can only say "I believe".
|
||||
**How to apply it.** For every guard a branch adds, apply the inverse change, run the
|
||||
one suite that should catch it, record CAUGHT or MISSED, and restore the file with
|
||||
`git checkout`. Commit first, so the restore is exact.
|
||||
|
||||
## Fill an empty slot for one run, to test the state it will have later
|
||||
|
||||
**What happened.** The Letter's e2e test branches: no link while `docs/LETTER.md` is
|
||||
empty, and the page opens once it is written. Only the empty branch could run, because
|
||||
the author has not written the letter. One run with a temporary sample letter took the
|
||||
other branch. It found the stale-cache bug (`technical.md`), and then passed the
|
||||
written-letter page, axe included, in a real browser. The scaffold was restored
|
||||
afterwards.
|
||||
|
||||
**Why it bit.** A test written for a future state passes trivially until that state
|
||||
arrives. Then it fails for the first time on the author's machine, with the author's words.
|
||||
|
||||
**How to apply it.** When a test branches on content that does not exist yet, fill the
|
||||
content temporarily, run the suite, restore it, and record the run in the review.
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# Review — `feature/letter-slot`
|
||||
|
||||
Adversarial self-review (CLAUDE.md §5.3). Analysis:
|
||||
[`features/letter-slot.md`](../features/letter-slot.md). Reviewed 2026-11-01 on
|
||||
Node 22.11.0, Windows 10. There is no PR: the only remote is Gitea, and this session
|
||||
cannot open one there.
|
||||
|
||||
## Gates — counts, not exit codes
|
||||
|
||||
| Gate | Result |
|
||||
|:--|:--|
|
||||
| `pnpm lint` | exit 0 |
|
||||
| `pnpm typecheck` | exit 0; `svelte-check` 0 errors **0 warnings** in ui and app (a bare `href="#"` warning was fixed) |
|
||||
| `pnpm test` | **130 passed**: schema 15, content 47, engine 52, ui 16 (was 3) |
|
||||
| `pnpm lint:copy` | **12 files** checked (was 9: `parse.ts`, `Letter.svelte`, `docs/LETTER.md`), 0 problems |
|
||||
| `pnpm validate:library` | 0 entries; 13 of 13 fixtures rejected |
|
||||
| `pnpm test:e2e` | **7 passed** (was 6), on the scaffold letter |
|
||||
| `pnpm test:offline` | **1 passed** |
|
||||
|
||||
**Built, not deployed** (§5.4): there is no host. The change is **deliberately
|
||||
invisible**: with the scaffold letter, the built page looks exactly as before. The
|
||||
bundle is 8 precache entries, 42.74 KiB.
|
||||
|
||||
**The written-letter branch, run once.** `docs/LETTER.md` was given a temporary sample
|
||||
letter (headings, a paragraph across lines, *emphasis*, an `https:` and a `tel:` link).
|
||||
e2e: 7 passed, including the page opening from the link, axe with no violations, and
|
||||
*Back*. Offline: 1 passed. The scaffold was then restored and both suites ran again
|
||||
green. That run found finding 1.
|
||||
|
||||
## Test honesty — bugs put back
|
||||
|
||||
| Bug put back | Suite | Result |
|
||||
|:--|:--|:--|
|
||||
| `ALLOWED_HREF = /.*/` (any link scheme) | ui unit | CAUGHT: 2 failed |
|
||||
| The letter link shown while the letter is empty | ui unit | CAUGHT: 2 failed |
|
||||
| same | e2e | CAUGHT: `toHaveCount(0)` failed |
|
||||
| The focus effect reads `heading` only after `if (moved)` | ui unit | CAUGHT: focus stayed on `<body>`. This was the first draft's real bug (finding 2). |
|
||||
| *heal* in the body of `docs/LETTER.md` | `lint:copy` | CAUGHT: `docs/LETTER.md:36 'heal' (medical)` |
|
||||
| `docs/LETTER.md` missing from turbo's cache key | e2e, written letter | CAUGHT, as the real finding 1 |
|
||||
|
||||
Not caught by any test: removing `docs/LETTER.md` from `lint:copy`'s file list. Only
|
||||
the quoted file count (12) would show it. See finding 6.
|
||||
|
||||
## Findings
|
||||
|
||||
| # | Area | Finding | Resolution |
|
||||
|:--|:--|:--|:--|
|
||||
| 1 | **Correctness** | Turbo hashed only the app package, so after the letter changed, `test:e2e` printed `cache hit` and tested the **old bundle**. A deploy from a warm cache would ship the old letter. | **Fixed**: `docs/LETTER.md` is in `globalDependencies` (L8). Shown as `cache miss` after the change. Lesson: `technical.md`. |
|
||||
| 2 | Correctness | The first focus effect returned before reading `heading`, so it never re-ran and focus never moved. | **Fixed** before review, caught by the Shell test. Lesson: `code.md`. |
|
||||
| 3 | **Offline** | The letter opens offline, because it is bundled. A support line given as an `https:` link does **not** work offline, but a `tel:` link does. | **Deferred** to G0.27, with the advice that each support line has a phone number. |
|
||||
| 4 | **Privacy** | An `https:` link in the letter takes the player to another site. Nothing leaves without their tap, the referrer is stripped (`no-referrer` on the page and `noreferrer` on the link), and it opens in a new tab. Which sites the letter links to is the author's choice. | **Accepted.** |
|
||||
| 5 | Correctness | The parser has blind spots. A numbered list (`1. …`) without blank lines collapses into one paragraph, and `snake_case_word` makes *case* italic. | **Accepted.** The scaffold says which Markdown works, and anything else shows as text, never as markup. |
|
||||
| 6 | Test honesty | No test proves `lint:copy` reads `docs/LETTER.md`. It was shown by the *heal* mutation, but deleting the path from `FILES` would pass silently. | **Accepted for now**: the review quotes the file count. Revisit if `lint:copy` grows a file list worth testing. |
|
||||
| 7 | Correctness | *Back* leaves `#garden` in the address bar. A bookmark at `#garden` or any unknown hash opens the garden. | **Accepted**: harmless, and any hash but `#letter` is home by design. |
|
||||
| 8 | **Soul** | Once the letter exists, the home view offers one link, *A Letter from the Gardener*. Looked for guilt, comparison, rejection and dependence: the page asks nothing, counts nothing, and is never required (GAMEPLAY §4). Found none. | — |
|
||||
| 9 | Copyright | The scaffold's comments mention "the book". They are stripped before the page and skipped by `lint:copy`. Whether the letter's own words may name the book is **Q9**, for the author. | **Open**, Q9. |
|
||||
|
||||
Looked for and found none:
|
||||
|
||||
- **Reachability.** The letter is one-way, from the author to every player. There is
|
||||
no input.
|
||||
- **Injection.** No `{@html}` anywhere. Raw HTML and `<script>` stay text (tests), and
|
||||
only `https:` and `tel:` become links (tests, plus a mutation). Svelte escapes
|
||||
attribute values.
|
||||
- **Correctness cases from §5.3.** Clock, DST, partial write and two tabs do not apply:
|
||||
there is no state. A tab closed on `#letter` reopens on the letter (test: *opens
|
||||
straight at #letter*).
|
||||
|
||||
## What was NOT verified
|
||||
|
||||
- **A screen reader.** axe passes on both views, and the focus move is unit-tested.
|
||||
Nobody has listened to it.
|
||||
- **Firefox, WebKit and a phone.** Desktop Chromium only.
|
||||
- **The author's real letter.** Only a sample has rendered.
|
||||
Reference in New Issue
Block a user