diff --git a/.agents/FEATURES.md b/.agents/FEATURES.md index 880dd99..b1fa758 100644 --- a/.agents/FEATURES.md +++ b/.agents/FEATURES.md @@ -8,6 +8,7 @@ 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 | Merged to `main`; built, not deployed. Invisible until the author writes | [letter-slot.md](features/letter-slot.md) | [feature-letter-slot.md](reviews/feature-letter-slot.md) | +| The in-game sunset: move the chair, half a minute of silence, then the real sunset's time | 1 | Merged to `main`; built, not deployed | [chair-sunset.md](features/chair-sunset.md) | [feature-chair-sunset.md](reviews/feature-chair-sunset.md) | | A calm refresh: a waiting new version is offered in one line, never swapped in by itself | 0 | Merged to `main`; built, not deployed | [calm-refresh.md](features/calm-refresh.md) | [feature-calm-refresh.md](reviews/feature-calm-refresh.md) | | The CPU guard: full runs wait for, then refuse, a busy machine | 0 | Merged to `main` | — | [fix-cpu-guard.md](reviews/fix-cpu-guard.md) | | Keep her safe: the browser's promise, save her to a file, bring her back | 0–1 | Merged to `main`; built, not deployed | [keep-her-safe.md](features/keep-her-safe.md) | [feature-keep-her-safe.md](reviews/feature-keep-her-safe.md) | diff --git a/.agents/GAP_ANALYSIS.md b/.agents/GAP_ANALYSIS.md index 2d85ff8..2d33e6b 100644 --- a/.agents/GAP_ANALYSIS.md +++ b/.agents/GAP_ANALYSIS.md @@ -56,7 +56,8 @@ sentences). Nothing in Phase 1 is visible to the player yet. | ~~G1.1~~ | ~~No module computes the sun (CLAUDE.md §7); polar and DST traps only predicted~~ | Closed 2026-11-01 on `feature/sun`. `engine/src/sun/sun.ts`: 26 published days in 6 cities within 2 min, polar day and night at Tromsø, 50 tests, 5 of 5 put-back bugs caught. Both traps measured (CLAUDE.md §8). | | ~~G1.2~~ | ~~The player cannot choose a city; no time-zone guess; no sunset time on screen~~ | Closed 2026-11-02 on `feature/sunset-place`. 7,342 public-domain towns searched on the device, a guess for every zone a browser reports, the town kept in IndexedDB, tonight's sunset in the garden. 299 unit, 10 e2e, offline choosing and changing a town; 6 of 6 put-back bugs caught. | | ~~G1.4~~ | ~~No rose~~ | Closed 2026-11-02 on `feature/rose-care`: care with a touch of skill (water by holding, shade, weeds, petals), growth from days of care, drift, moods, her numbers; the care log in IndexedDB, replayed by the engine. Tuning R2/R4/R5/R6 is the author's. 7 of 7 put-back bugs caught after two test holes were closed. | -| G1.5 | The day's sentence and the folded petal; the in-game sunset with the chair | Open. The sentence needs the library (G0.18). | +| G1.5 | The day's sentence and the folded petal | Open. Needs the library (G0.18). | +| ~~G1.6~~ | ~~The in-game sunset: move the chair, watch it again~~ | Closed 2026-11-02 on `feature/chair-sunset`: half a minute with nothing to press, then the real sunset's time; Escape and a tap leave; the offline suite watches one with the server gone. 4 of 4 put-back bugs caught. | | G1.3 | Towns have no Czech names (*Vídeň*) | Open. Natural Earth has none; arrives with Czech copy. | ## Design questions — answered diff --git a/.agents/features/chair-sunset.md b/.agents/features/chair-sunset.md new file mode 100644 index 0000000..face65f --- /dev/null +++ b/.agents/features/chair-sunset.md @@ -0,0 +1,53 @@ +# The in-game sunset — move the chair, watch it again + +Status: built on `feature/chair-sunset`. ROADMAP Phase 1: *the in-game sunset — move the chair, watch +it again — as comfort and rehearsal; it tells the player when the real one is tonight.* CLAUDE.md §1, +§7 (*silence is a feature: sunset … has moments with no buttons at all*). Review: +[`feature-chair-sunset.md`](../reviews/feature-chair-sunset.md). + +## 1. Why and what, in the player's terms + +Under tonight's sunset line there is **Move the chair**. The garden turns into a quiet scene: the chair +on the hillside, the sky going from day to amber to coral to dusk, the sun sinking behind the western +horizon. **Half a minute, and nothing to press.** Then one line says when the real one is tonight, and +two quiet choices: *Watch it again*, *Back to the rose*. + +It is a rehearsal, never a replacement: it counts for nothing, logs nothing, and its last words point +at the real sky. + +## 2. Technical architecture + +```mermaid +flowchart LR + shell["Shell.svelte
Move the chair"] --> scene["ChairSunset.svelte
dialog: sky + sun in CSS,
garden-sunset and chair stand-ins"] + scene -->|"after 30 s"| line["SunsetLine
tonight's real sunset"] + line --> engine["engine nextInvitation"] +``` + +| # | Decision | Why | +|:--|:--|:--| +| C1 | The sky and the sun are **drawn in code** (CSS gradients and one disc) behind the garden layer, which is transparent above its horizon. | STYLE.md S5: the sky is never painted, so the same layer serves the real-time sky later. | +| C2 | **No visible button for 30 s.** Escape, or a tap anywhere, comes back early; a screen-reader-only line says so. | Silence (CLAUDE.md §7) without a trap: a keyboard or screen-reader user is never stuck. | +| C3 | It is a modal dialog; focus goes into it and returns to *Move the chair*. | Accessibility is not a phase. | +| C4 | **Nothing is logged.** No event kind, no count. | Rehearsal, not achievement; the real sunset's event (`sunset`, CLAUDE.md §6.2) belongs to the real one. | +| C5 | With reduced motion, the scene shows dusk at once, still, for the same half minute. | Global `prefers-reduced-motion` rule in `tokens.css`. | + +## 3. Risk analysis + +| Risk | Answer | +|:--|:--| +| **Dependence**: the screen sunset replaces the real one. | Its last line is the real sunset's time; nothing rewards watching it. | +| **A trap**: a full-screen scene with no buttons. | C2, C3; tested by keyboard. | +| **Motion** for people sensitive to it. | C5. | +| Privacy, reachability | None: nothing is stored or sent. | + +## 4. Verification matrix + +| Case | Kind | Where | +|:--|:--|:--| +| Move the chair opens a labelled dialog with no button in it; after 30 s, the real sunset's line, *Watch it again*, *Back to the rose* | unit | `ui/test/chair-sunset.test.ts` | +| Escape and a tap come back early; focus returns to *Move the chair* | unit | same | +| Watch it again starts it over | unit | same | +| With no town and no guess, the line asks for a town | unit | same | +| Built app: watch it with the clock driven; axe during and after | e2e | `e2e/shell.spec.ts` | +| Offline: watch an in-game sunset with the server gone (CLAUDE.md §3) | offline | `e2e/offline.spec.ts` | diff --git a/.agents/reviews/feature-chair-sunset.md b/.agents/reviews/feature-chair-sunset.md new file mode 100644 index 0000000..f96f4ad --- /dev/null +++ b/.agents/reviews/feature-chair-sunset.md @@ -0,0 +1,40 @@ +# Review — `feature/chair-sunset` + +Adversarial self-review (CLAUDE.md §5.3). Analysis: [`features/chair-sunset.md`](../features/chair-sunset.md). +Reviewed 2026-11-02 on Node 22.11.0, Windows 10. There is no PR: the only remote is Gitea. + +## Gates + +Counts are on the merge; HANDOVER repeats them. New: ui +7, e2e +1 (watch, again, Escape, focus, +axe during and after), and the offline suite now watches an in-game sunset with the server gone, +which CLAUDE.md §3 has always promised. + +**The app changed** (CLAUDE.md §5.4): *Move the chair* under tonight's sunset line. Rebuilt by the +e2e and offline runs; **not deployed** (G0.13). Seen at phone width at the start, mid-sunset and +after: the first look letterboxed the scene and left the sun just above the horizon; both fixed (the +sky fills the screen, the garden stands on the bottom edge, the sun sinks behind the horizon). + +## Bug drills + +| Put back | Result | +|:--|:--| +| Buttons shown during the sunset | CAUGHT: 3 | +| Escape does nothing | CAUGHT | +| The half minute never ends | CAUGHT: 4 | +| Focus not given back to *Move the chair* | CAUGHT | + +## Findings + +| # | Area | Finding | Resolution | +|:--|:--|:--|:--| +| 1 | Accessibility | A full-screen scene with no buttons can trap a keyboard or screen-reader user. | Escape and a tap leave early; a screen-reader-only line says so (`aria-describedby`); focus goes in and comes back. Tested; axe passes during and after. Not tried with a real screen reader. | +| 2 | Soul | A screen sunset could stand in for the real one. | Its last words are the real sunset's time; it logs and counts nothing. | +| 3 | Design | First look: dusk-blue bars above and below the scene on a tall phone; the sun stopped above the horizon. | Fixed after the screenshots. | +| 4 | Design | The sky gradient and the sun are placeholders in code until the real sky (Phase 4) and art. | Accepted: the layer split (STYLE.md S5) is what the real sky needs. | +| 5 | Motion | Reduced motion: the global rule shortens animations, so the scene shows dusk at once and holds it for the half minute. | Accepted (C5); not seen with the setting on. | +| 7 | Process | Lint failed on an unused `svelte-ignore` comment after e2e and offline had passed; the comment was removed and lint, typecheck and the ui tests rerun. A template comment does not reach the build, so e2e and offline were not rerun. | Fixed. | +| 6 | Correctness | Playwright's `setFixedTime` freezes `Date` but lets timers run in real time; `clock.install` drives them. | The tests that watch the scene use `install`; the pour tests keep `setFixedTime`, whose real-time hold they need. | + +## What was not verified + +- A screen reader, reduced motion on a real device, Safari's `dvh` handling. diff --git a/.agents/reviews/fix-cpu-guard.md b/.agents/reviews/fix-cpu-guard.md index 3cce4ca..8d3e87d 100644 --- a/.agents/reviews/fix-cpu-guard.md +++ b/.agents/reviews/fix-cpu-guard.md @@ -39,7 +39,7 @@ that is not a whole number in range is refused, never quietly the default. | 2 | `ROSEA_CPU_MAX=100` is a way round the rule. | Documented as for dedicated machines only, in CLAUDE.md §5.7 and the lesson. An override nobody can use would push people to edit the script instead. | | 3 | The guard adds 2 s to every full run on a quiet machine. | Accepted. | | 4 | Filtered runs (`pnpm --filter X test`) and drills are not guarded. | By design: they are not full runs. | -| 5 | Its own 2 s sample could read its own start-up as load. | It samples after Node has started. Not measured on a quiet machine: this one was busy all session. Beside Windows' counter it read 2–11 points lower, never higher. | +| 5 | Its own 2 s sample could read its own start-up as load. | It samples after Node has started. Later, on a quiet machine, it read 2.4–4.1 % beside Windows' 1.5–3.3 %; busy, 2–11 points lower. Close enough for an 80 % line. | ## Not verified diff --git a/HANDOVER.md b/HANDOVER.md index f9a7922..7dc2838 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -12,8 +12,8 @@ Rewritten at the end of each session (CLAUDE.md §5.1). Gitea hashes match. Analysis: [`.agents/features/phase0-workspace.md`](.agents/features/phase0-workspace.md). Review, with counts and the mutation results: [`.agents/reviews/feature-phase0-workspace.md`](.agents/reviews/feature-phase0-workspace.md). -- **Gates:** all pass on this machine. Unit tests: 389 (cpu-guard 13, identity 5, schema 16, - content 71, storage 51, art-prep 56, engine 136, ui 41). E2E: 14. Offline: 1. `lint:copy`: 19 files, 0 problems. +- **Gates:** all pass on this machine. Unit tests: 396 (cpu-guard 13, identity 5, schema 16, + content 71, storage 51, art-prep 56, engine 136, ui 48). E2E: 15. Offline: 1. `lint:copy`: 20 files, 0 problems. `validate:library`: 13 of 13 fixtures rejected. - **Built, not deployed:** there is no host yet. - **Roadmap and gameplay docs:** `docs/ROADMAP.md` and `docs/GAMEPLAY.md` are on @@ -71,6 +71,12 @@ Rewritten at the end of each session (CLAUDE.md §5.1). *Refresh*. Nothing reloads by itself. With this, fixes can reach a phone once the app is hosted. Review: [`.agents/reviews/feature-calm-refresh.md`](.agents/reviews/feature-calm-refresh.md). +- **The in-game sunset (Phase 1):** merged to `main`. *Move the chair* under tonight's sunset line + opens a quiet scene: the sky drawn in code from day to dusk, the sun setting behind the garden, + half a minute with nothing to press; then the real sunset's time, *Watch it again*, *Back to the + rose*. Escape or a tap leaves early. Review: + [`.agents/reviews/feature-chair-sunset.md`](.agents/reviews/feature-chair-sunset.md). + **Phase 0 is not finished.** The roadmap's Phase 0 is more than the workspace. Its gate needs 60 verified sentences (G0.18) and one illustration through the art pipeline (G0.24). The pipeline and the board are built; the first real picture is not made yet. Also open: a GitHub remote (G0.13). The Letter slot is built (G0.25). diff --git a/e2e/offline.spec.ts b/e2e/offline.spec.ts index 4ba65ce..6b9320d 100644 --- a/e2e/offline.spec.ts +++ b/e2e/offline.spec.ts @@ -78,7 +78,8 @@ test('the shell opens from the service worker with the server gone', async ({ br // coming back days later with no signal. await page.close(); const again = await context.newPage(); - await again.clock.setFixedTime(Date.parse('2026-03-29T12:00:00+02:00')); + // An installed clock, so the in-game sunset's half minute can be run below. + await again.clock.install({ time: Date.parse('2026-03-29T12:00:00+02:00') }); await again.goto(server.url); await expect(again.getByRole('heading', { level: 1 })).toHaveText(PRODUCT_NAME); await expect(again.locator('.sun p').first()).toHaveText(/in Plzeň\.$/); @@ -86,6 +87,12 @@ test('the shell opens from the service worker with the server gone', async ({ br await again.getByRole('button', { name: en.rose.numbers }).click(); await expect(again.locator('#rose-numbers')).toContainText(`${en.rose.daysOfCare}1`); + // Watching an in-game sunset with no network (CLAUDE.md §3, the offline suite). + await again.getByRole('button', { name: en.chair.move }).click(); + await again.clock.runFor(30_000); + await expect(again.getByRole('dialog').getByText(/in Plzeň\.$/)).toBeVisible(); + await again.keyboard.press('Escape'); + // 3. A deep link inside the scope falls back to the shell, not an error page. await again.goto(`${server.url}somewhere/deeper`); await expect(again.getByRole('heading', { level: 1 })).toHaveText(PRODUCT_NAME); diff --git a/e2e/shell.spec.ts b/e2e/shell.spec.ts index 1a8f923..2d97d3f 100644 --- a/e2e/shell.spec.ts +++ b/e2e/shell.spec.ts @@ -279,3 +279,31 @@ test.describe('keep her safe, in Prague at 08:00 on 1 March 2026', () => { } }); }); + +// --- The in-game sunset (.agents/features/chair-sunset.md) --------------------- +test.describe('the in-game sunset, in Prague at noon on 29 March 2026', () => { + test.use({ timezoneId: 'Europe/Prague', locale: 'en-US' }); + + test('move the chair: half a minute with nothing to press, then the real sunset\'s time; again; back', async ({ page }) => { + // An installed clock, so the scene's half minute can be run in a moment. + await page.clock.install({ time: Date.parse('2026-03-29T12:00:00+02:00') }); + await open(page); + await page.getByRole('button', { name: /^Not now/ }).click(); + await page.getByRole('button', { name: en.chair.move }).click(); + + const scene = page.getByRole('dialog', { name: en.chair.scene }); + await expect(scene).toBeVisible(); + await expect(scene.getByRole('button')).toHaveCount(0); + expect((await new AxeBuilder({ page }).analyze()).violations.map((v) => `${v.id}: ${v.help}`)).toEqual([]); + + await page.clock.runFor(30_000); + await expect(scene.getByText(/^Tonight the sun sets at .* in Prague\.$/)).toBeVisible(); + expect((await new AxeBuilder({ page }).analyze()).violations.map((v) => `${v.id}: ${v.help}`)).toEqual([]); + + await scene.getByRole('button', { name: en.chair.again }).click(); + await expect(scene.getByRole('button')).toHaveCount(0); + await page.keyboard.press('Escape'); + await expect(scene).toHaveCount(0); + await expect(page.getByRole('button', { name: en.chair.move })).toBeFocused(); + }); +}); diff --git a/packages/ui/src/Shell.svelte b/packages/ui/src/Shell.svelte index e9a9785..f031126 100644 --- a/packages/ui/src/Shell.svelte +++ b/packages/ui/src/Shell.svelte @@ -6,6 +6,7 @@ import { parseLetter } from './letter/parse.js'; import Rose from './rose/Rose.svelte'; import type { RoseWiring } from './rose/types.js'; + import ChairSunset from './sunset/ChairSunset.svelte'; import SunsetLine from './sunset/SunsetLine.svelte'; import SunsetPlace from './sunset/SunsetPlace.svelte'; import type { SunsetChoice, SunsetWiring } from './sunset/types.js'; @@ -37,6 +38,15 @@ let kept = $state(true); let now = $state(0); let sunLine = $state(); + /** The in-game sunset is showing (chair-sunset.md). */ + let watching = $state(false); + let chairButton = $state(); + + async function stopWatching(): Promise { + watching = false; + await tick(); + chairButton?.focus(); + } const place = $derived(choice?.kind === 'town' ? choice.town : (sunset?.guess ?? null)); // One zone for the sunset and the rose's days: the chosen town's, else the device's (rose.md R8). @@ -141,7 +151,11 @@

{en.sunset.notKept}

{/if} + + {#if watching} + + {/if} {/if} {#if blocks.length > 0} {en.letter.title} diff --git a/packages/ui/src/copy/en.ts b/packages/ui/src/copy/en.ts index daf6b03..1114e36 100644 --- a/packages/ui/src/copy/en.ts +++ b/packages/ui/src/copy/en.ts @@ -88,6 +88,15 @@ export const en = { /** When the device refuses to keep anything (a private window). Calm, and true. */ notKept: 'This device could not keep your choice, so the garden will ask again next time.' }, + chair: { + /** ROADMAP Phase 1: "move the chair, watch it again". */ + move: 'Move the chair', + scene: 'A sunset in the garden', + /** Read by screen readers only: the scene has no buttons on purpose (chair-sunset.md C2). */ + leave: 'Press Escape or tap to come back.', + again: 'Watch it again', + back: 'Back to the rose' + }, update: { /** One quiet line when a new version waits; nothing reloads by itself (calm-refresh.md U2). */ ready: 'A new version of the garden is ready.', diff --git a/packages/ui/src/sunset/ChairSunset.svelte b/packages/ui/src/sunset/ChairSunset.svelte new file mode 100644 index 0000000..4262fac --- /dev/null +++ b/packages/ui/src/sunset/ChairSunset.svelte @@ -0,0 +1,219 @@ + + + + + + + diff --git a/packages/ui/test/chair-sunset.test.ts b/packages/ui/test/chair-sunset.test.ts new file mode 100644 index 0000000..288cdd8 --- /dev/null +++ b/packages/ui/test/chair-sunset.test.ts @@ -0,0 +1,100 @@ +import type { NamedPlace } from '@rosea/engine'; +import { cleanup, fireEvent, render, screen, within } from '@testing-library/svelte'; +import { tick } from 'svelte'; +import { afterEach, describe, expect, it, vi } from 'vitest'; +import Shell from '../src/Shell.svelte'; +import { en } from '../src/copy/en.js'; +import { SUNSET_MS } from '../src/sunset/ChairSunset.svelte'; +import type { SunsetWiring } from '../src/sunset/types.js'; + +const brno: NamedPlace = { name: 'Brno', region: '', country: 'Czechia', lat: 49.2, lon: 16.61, timeZone: 'Europe/Prague' }; +const NOON = Date.parse('2026-03-29T12:00:00+02:00'); + +const wiring = (over: Partial = {}): SunsetWiring => ({ + guess: brno, + search: async () => [], + load: async () => ({ kind: 'town', town: brno }), + save: async () => undefined, + now: () => NOON, + ...over +}); + +/** Renders the garden with a town set and opens the in-game sunset; the scene's own timer is faked. */ +async function openScene(over: Partial = {}): Promise { + render(Shell, { sunset: wiring(over) }); + const move = await screen.findByRole('button', { name: en.chair.move }); + vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] }); + await fireEvent.click(move); + await tick(); + return screen.getByRole('dialog', { name: en.chair.scene }); +} + +afterEach(() => { + vi.useRealTimers(); + cleanup(); +}); + +describe('the in-game sunset (chair-sunset.md)', () => { + it('Move the chair opens a quiet scene: labelled, focused, and with nothing to press', async () => { + const scene = await openScene(); + expect(document.activeElement).toBe(scene); + expect(within(scene).queryAllByRole('button')).toEqual([]); + expect(scene.getAttribute('aria-describedby')).toBeTruthy(); + expect(document.getElementById(scene.getAttribute('aria-describedby')!)?.textContent).toBe(en.chair.leave); + }); + + it('after half a minute, it says when the real one is, and offers to watch again or go back', async () => { + const scene = await openScene(); + vi.advanceTimersByTime(SUNSET_MS - 1); + await tick(); + expect(within(scene).queryAllByRole('button')).toEqual([]); + vi.advanceTimersByTime(1); + await tick(); + expect(within(scene).getByText(/^Tonight the sun sets at .* in Brno\.$/)).toBeTruthy(); + expect(within(scene).getByRole('button', { name: en.chair.again })).toBeTruthy(); + expect(within(scene).getByRole('button', { name: en.chair.back })).toBeTruthy(); + }); + + it('Watch it again starts it over, with nothing to press again', async () => { + const scene = await openScene(); + vi.advanceTimersByTime(SUNSET_MS); + await tick(); + await fireEvent.click(within(scene).getByRole('button', { name: en.chair.again })); + await tick(); + expect(within(scene).queryAllByRole('button')).toEqual([]); + vi.advanceTimersByTime(SUNSET_MS); + await tick(); + expect(within(scene).getByRole('button', { name: en.chair.again })).toBeTruthy(); + }); + + it('Escape comes back early, and focus returns to Move the chair', async () => { + const scene = await openScene(); + await fireEvent.keyDown(scene, { key: 'Escape' }); + await tick(); + expect(screen.queryByRole('dialog')).toBeNull(); + expect(document.activeElement).toBe(screen.getByRole('button', { name: en.chair.move })); + }); + + it('a tap anywhere comes back early too', async () => { + const scene = await openScene(); + await fireEvent.click(scene); + await tick(); + expect(screen.queryByRole('dialog')).toBeNull(); + }); + + it('Back to the rose closes it after the sunset', async () => { + const scene = await openScene(); + vi.advanceTimersByTime(SUNSET_MS); + await tick(); + await fireEvent.click(within(scene).getByRole('button', { name: en.chair.back })); + await tick(); + expect(screen.queryByRole('dialog')).toBeNull(); + }); + + it('with no town and no guess, the words after it ask for a town', async () => { + const scene = await openScene({ guess: null, load: async () => ({ kind: 'device-zone' }) }); + vi.advanceTimersByTime(SUNSET_MS); + await tick(); + expect(within(scene).getByText(en.sunset.noTown)).toBeTruthy(); + }); +});