Built Flash Leaf from scratch as a mobile-friendly PWA: a card-style… #1

Merged
cmoriarty merged 4 commits from osf/201-a-web-based-game-that-is-also-a-mobile into main 2026-11-18 20:34:14 -05:00
Owner

What was done

  • Built Flash Leaf from scratch as a mobile-friendly PWA: a card-style quiz game where you identify North American trees from a leaf photograph, on Vite + TypeScript with no UI framework.
  • Bundled a catalog of 19 tree species — a leaf and a whole-tree photo each, all public-domain/CC0 with source and license recorded in src/data/species.ts — so the game runs offline with no runtime data dependency.
  • Each question shows the leaf photo with exactly four options, each labeled with the common and botanical name and never "none"; a hint button reveals the whole-tree photo, and scoring is 100 points correct, 50 with the hint, 0 wrong.
  • The tree of the day is one shared puzzle per UTC day, picked deterministically from the date so every player sees the same tree; it is playable once per day and reveals the species' historical tidbit after you answer.
  • Practice mode offers unlimited seeded-random questions with a session summary, and day-to-day stats (points, correct/wrong, hints, streak) are stored on the device with no accounts or backend.
  • The app is an installable, fully offline PWA: a web manifest with icons and a service worker that precaches the shell and all 38 photographs, so a full session works with the network off.
  • Verified with 45 unit tests and 10 Playwright browser tests, all passing, and a judge who opened the app in both dev and production, drove a full practice and tree-of-the-day session, and checked text contrast and a 375px phone layout with no faults found.
  • Not done: stats live only on the device — there are no accounts, sync, or leaderboards — and the daily puzzle follows the UTC calendar, so a player near midnight can be a day ahead of or behind their local date.

How to review

  1. Check out the work branch: git checkout osf/201-a-web-based-game-that-is-also-a-mobile.
  2. Install the pinned Node and dependencies: nvm use then npm install.
  3. Run the checks: npm test (45 unit tests) and npx playwright test (10 browser tests) — both should pass.
  4. See it working: npm run dev, open http://127.0.0.1:5173, and answer a question — the home screen shows the tree-of-the-day card and a practice button, and tapping Hint reveals the whole-tree photo.
  5. See it offline: npm run build then npm run preview (http://127.0.0.1:4173), load it once, switch the browser to offline, and start a practice question — it still loads and shows the leaf photo.
  6. Read first: src/data/species.ts (the catalog) and e2e/smoke.spec.ts (what the browser checks).

Code review

Reviewed the Flash Leaf PWA (Vite + TypeScript, no framework) against its six delta specs, design, and tasks. The code is clean and well-layered (pure, unit-tested core in src/lib; thin DOM render functions in src/ui; hand-rolled service worker with a build-generated precache list), the commit carries no generated/cached files, and every spec requirement is implemented and covered by a test. All 44 Vitest unit tests and 10 Playwright e2e tests pass. I found two minor issues: the species license test's regex was too permissive to reject non-commercial licenses, which I fixed (anchored match that now rejects CC BY-NC/ND while still accepting every bundled license; species.test.ts passes); and the daily selection uses day-of-year modulo catalog length (a deliberate, documented design choice) which is consecutive within a year but jumps one step at the Dec 31 -> Jan 1 boundary, which I left for the team to decide.

Left for you

  • minor, src/lib/daily.ts:20: dailyIndex is dayOfYearUtc(date) % species.length, so consecutive UTC dates select consecutive catalog entries within a year, but the index jumps at the Dec 31 -> Jan 1 boundary (2026-12-31 -> index 3, 2027-01-01 -> index 0 rather than 4; 2024-12-31 -> index 4, 2025-01-01 -> index 0). This is a minor deviation from the tree-of-the-day spec's 'Consecutive UTC dates SHALL select consecutive entries of the catalog, cycling through the catalog in order'. It is a deliberate design choice (design.md decision 4 names day-of-year explicitly) and the spec's own test only walks within a single year, so I left it for the team to decide rather than override the settled design.

Fixed before the commit

  • minor, src/data/species.test.ts:65: The freely-licensed check used /public domain|cc0|cc[- ]by|gfdl|odbl/i, whose cc[- ]by alternative matches the 'CC BY' prefix of non-commercial licenses, so a 'CC BY-NC' (not freely licensed) value would have passed the test. The bundled catalog contains no NC licenses, so the test passed and the data is correct, but the regex was not strict enough to catch a future NC entry. Fixed by anchoring the match to the start and requiring the license type to end before any '-NC'/'-ND' restriction: /^(public domain|cc0|cc[- ]by(?:-sa)?|gfdl|odbl)(?:\s|$)/i. Verified it still accepts every bundled license and now rejects CC BY-NC / CC BY-ND / All Rights Reserved; species.test.ts passes.

Tests

All 32 scenarios of a-web-based-game-that-is-also-a-mobile-f-pr13wa have a tagged test.

Left untested on purpose:

  • quiz-gameplay/Fresh question hides the tree: Covered by the quiz-screen e2e test written in task 6.2, which asserts that a fresh practice question shows the leaf photograph and the 4 options with the whole-tree photograph not visible.
  • quiz-gameplay/Hint reveals the tree: Covered by the quiz-screen e2e test written in task 6.2, which asserts that using the hint makes the whole-tree photograph visible.
  • species-dataset/Photographs load without a network: Covered by the offline e2e test written in task 7.3, which loads the app with the network disabled and asserts that every file under public/photos/ is present in the service-worker cache, so every bundled photograph renders from bundled assets offline.

The test lint found, in the run's tests on the last check:

Recorded, not decided

  • e2e/smoke.spec.ts:8 B6 in the app loads and shows the Flash Leaf title: test has no // spec: <capability>/<scenario> tag, on itself, its describe or its file's top
  • src/lib/session.test.ts:99 B6 in advances to a fresh unanswered question that carries the score over: test has no // spec: <capability>/<scenario> tag, on itself, its describe or its file's top
  • src/lib/session.test.ts:121 B6 in completes after the single tree-of-the-day question and cannot advance further: test has no // spec: <capability>/<scenario> tag, on itself, its describe or its file's top
  • src/lib/session.test.ts:214 B6 in records nothing when the session carries no stats store: test has no // spec: <capability>/<scenario> tag, on itself, its describe or its file's top
  • src/lib/stats.test.ts:76 B6 in stores the records under the versioned key: test has no // spec: <capability>/<scenario> tag, on itself, its describe or its file's top
  • src/placeholder.test.ts:4 B6 in runs the unit test runner: test has no // spec: <capability>/<scenario> tag, on itself, its describe or its file's top

Braid run

  • Workflow: Braid's OpenSpec flow, change a-web-based-game-that-is-also-a-mobile-f-pr13wa (36 steps)
  • Model: vLLM · qwen3.8-27b
  • Time: 2 h 43 m from start to this pull request, 2 h 58 m of it in the model
  • Tokens: 39.2M input, 179k output, 467k reasoning, over 633 model calls
  • Pre-flight estimate: fits, p50 251k / p80 329k tokens against a 224k-token step allowance
  • CI: no CI ran on the checked code: the project has no CI (no workflow under .forgejo/workflows, .gitea/workflows or .github/workflows); what only CI tests went unverified
  • Run: run_01M7RDNDTYF0XAMKANQNPR13WA

Opened by Braid.

## What was done - Built Flash Leaf from scratch as a mobile-friendly PWA: a card-style quiz game where you identify North American trees from a leaf photograph, on Vite + TypeScript with no UI framework. - Bundled a catalog of 19 tree species — a leaf and a whole-tree photo each, all public-domain/CC0 with source and license recorded in `src/data/species.ts` — so the game runs offline with no runtime data dependency. - Each question shows the leaf photo with exactly four options, each labeled with the common and botanical name and never "none"; a hint button reveals the whole-tree photo, and scoring is 100 points correct, 50 with the hint, 0 wrong. - The tree of the day is one shared puzzle per UTC day, picked deterministically from the date so every player sees the same tree; it is playable once per day and reveals the species' historical tidbit after you answer. - Practice mode offers unlimited seeded-random questions with a session summary, and day-to-day stats (points, correct/wrong, hints, streak) are stored on the device with no accounts or backend. - The app is an installable, fully offline PWA: a web manifest with icons and a service worker that precaches the shell and all 38 photographs, so a full session works with the network off. - Verified with 45 unit tests and 10 Playwright browser tests, all passing, and a judge who opened the app in both dev and production, drove a full practice and tree-of-the-day session, and checked text contrast and a 375px phone layout with no faults found. - **Not done:** stats live only on the device — there are no accounts, sync, or leaderboards — and the daily puzzle follows the UTC calendar, so a player near midnight can be a day ahead of or behind their local date. ## How to review 1. Check out the work branch: `git checkout osf/201-a-web-based-game-that-is-also-a-mobile`. 2. Install the pinned Node and dependencies: `nvm use` then `npm install`. 3. Run the checks: `npm test` (45 unit tests) and `npx playwright test` (10 browser tests) — both should pass. 4. See it working: `npm run dev`, open http://127.0.0.1:5173, and answer a question — the home screen shows the tree-of-the-day card and a practice button, and tapping Hint reveals the whole-tree photo. 5. See it offline: `npm run build` then `npm run preview` (http://127.0.0.1:4173), load it once, switch the browser to offline, and start a practice question — it still loads and shows the leaf photo. 6. Read first: `src/data/species.ts` (the catalog) and `e2e/smoke.spec.ts` (what the browser checks). ## Code review Reviewed the Flash Leaf PWA (Vite + TypeScript, no framework) against its six delta specs, design, and tasks. The code is clean and well-layered (pure, unit-tested core in src/lib; thin DOM render functions in src/ui; hand-rolled service worker with a build-generated precache list), the commit carries no generated/cached files, and every spec requirement is implemented and covered by a test. All 44 Vitest unit tests and 10 Playwright e2e tests pass. I found two minor issues: the species license test's regex was too permissive to reject non-commercial licenses, which I fixed (anchored match that now rejects CC BY-NC/ND while still accepting every bundled license; species.test.ts passes); and the daily selection uses day-of-year modulo catalog length (a deliberate, documented design choice) which is consecutive within a year but jumps one step at the Dec 31 -> Jan 1 boundary, which I left for the team to decide. **Left for you** - minor, `src/lib/daily.ts:20`: dailyIndex is dayOfYearUtc(date) % species.length, so consecutive UTC dates select consecutive catalog entries within a year, but the index jumps at the Dec 31 -> Jan 1 boundary (2026-12-31 -> index 3, 2027-01-01 -> index 0 rather than 4; 2024-12-31 -> index 4, 2025-01-01 -> index 0). This is a minor deviation from the tree-of-the-day spec's 'Consecutive UTC dates SHALL select consecutive entries of the catalog, cycling through the catalog in order'. It is a deliberate design choice (design.md decision 4 names day-of-year explicitly) and the spec's own test only walks within a single year, so I left it for the team to decide rather than override the settled design. **Fixed before the commit** - minor, `src/data/species.test.ts:65`: The freely-licensed check used /public domain|cc0|cc[- ]by|gfdl|odbl/i, whose cc[- ]by alternative matches the 'CC BY' prefix of non-commercial licenses, so a 'CC BY-NC' (not freely licensed) value would have passed the test. The bundled catalog contains no NC licenses, so the test passed and the data is correct, but the regex was not strict enough to catch a future NC entry. Fixed by anchoring the match to the start and requiring the license type to end before any '-NC'/'-ND' restriction: /^(public domain|cc0|cc[- ]by(?:-sa)?|gfdl|odbl)(?:\s|$)/i. Verified it still accepts every bundled license and now rejects CC BY-NC / CC BY-ND / All Rights Reserved; species.test.ts passes. ## Tests All 32 scenarios of `a-web-based-game-that-is-also-a-mobile-f-pr13wa` have a tagged test. Left untested on purpose: - `quiz-gameplay/Fresh question hides the tree`: Covered by the quiz-screen e2e test written in task 6.2, which asserts that a fresh practice question shows the leaf photograph and the 4 options with the whole-tree photograph not visible. - `quiz-gameplay/Hint reveals the tree`: Covered by the quiz-screen e2e test written in task 6.2, which asserts that using the hint makes the whole-tree photograph visible. - `species-dataset/Photographs load without a network`: Covered by the offline e2e test written in task 7.3, which loads the app with the network disabled and asserts that every file under public/photos/ is present in the service-worker cache, so every bundled photograph renders from bundled assets offline. The test lint found, in the run's tests on the last check: **Recorded, not decided** - `e2e/smoke.spec.ts:8` B6 in `the app loads and shows the Flash Leaf title`: test has no `// spec: <capability>/<scenario>` tag, on itself, its describe or its file's top - `src/lib/session.test.ts:99` B6 in `advances to a fresh unanswered question that carries the score over`: test has no `// spec: <capability>/<scenario>` tag, on itself, its describe or its file's top - `src/lib/session.test.ts:121` B6 in `completes after the single tree-of-the-day question and cannot advance further`: test has no `// spec: <capability>/<scenario>` tag, on itself, its describe or its file's top - `src/lib/session.test.ts:214` B6 in `records nothing when the session carries no stats store`: test has no `// spec: <capability>/<scenario>` tag, on itself, its describe or its file's top - `src/lib/stats.test.ts:76` B6 in `stores the records under the versioned key`: test has no `// spec: <capability>/<scenario>` tag, on itself, its describe or its file's top - `src/placeholder.test.ts:4` B6 in `runs the unit test runner`: test has no `// spec: <capability>/<scenario>` tag, on itself, its describe or its file's top ## Braid run - **Workflow:** Braid's OpenSpec flow, change `a-web-based-game-that-is-also-a-mobile-f-pr13wa` (36 steps) - **Model:** vLLM · qwen3.8-27b - **Time:** 2 h 43 m from start to this pull request, 2 h 58 m of it in the model - **Tokens:** 39.2M input, 179k output, 467k reasoning, over 633 model calls - **Pre-flight estimate:** fits, p50 251k / p80 329k tokens against a 224k-token step allowance - **CI:** no CI ran on the checked code: the project has no CI (no workflow under `.forgejo/workflows`, `.gitea/workflows` or `.github/workflows`); what only CI tests went unverified - **Run:** [run_01M7RDNDTYF0XAMKANQNPR13WA](http://openspecflow.internal.underthere.xyz/run/run_01M7RDNDTYF0XAMKANQNPR13WA) _Opened by Braid._
cmoriarty deleted branch osf/201-a-web-based-game-that-is-also-a-mobile 2026-11-18 20:34:15 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
braid-testing/flash-leaf!1
No description provided.