Build the audit recommendations: safer backups, faster Phrase Bank, deeper TC101–TC109, card links, Library groups, header title on scroll
Merged
BI
8d ago+10335+10335+01234567890123456789012345678901234567890123456789-255-255-012345678901234567890123456789
Requested by josh · project thread
Summary
This builds the recommendations from the PWA and design audit (#137), which josh approved. The distress Help situation and its safety wording are in a separate PR so they can be clinically reviewed first.
Data safety
- Backups: saving a backup uses the iPhone share sheet when files can be shared, and falls back to a download otherwise. The backup is only recorded when it is actually saved, so cancelling no longer silences the 30-day reminder. The reminder's "Back up now" button had the same bug, which is also fixed.
- Restore: before a restore, the current data is snapshotted (
tc_restore_snapshot, never itself backed up). Settings → Backup offers "Undo restore" for 30 days.- Files over 5 MB are rejected before they are read.
- Backup format v2 reads v1. A newer-version file gets a clear "update the app first" message.
- Start here progress, recent cards and the welcome flag are now included in backups.
- Saved-phrase guard: a hashed snapshot of every saveable phrase is checked by a test, which fails if a phrase disappears without a
REPHRASEDor retired entry. The test explains how to fix it. - Drill: review gaps are capped at 180 days ("In ~6 months").
Speed, CI and security
- Phrase Bank: the line count is computed at build time, so the intro paints at once, and rows render progressively. With real network and CPU throttling, mobile perf goes from 73 to 89 and TBT from 343 ms to 110 ms.
- Bundle budget: a new
budgetscript runs incode-review.yml. Current sizes are entry 34.3, vendor 59.4, CSS 12.7 and card-text 178.5 KB gz, all at about 90% of budget. - Accessibility scan: new
e2e/a11y.spec.tsruns axe WCAG 2.x A/AA plus label-in-name on all 10 main routes.axe-coreis pinned at 4.13.0. The scan found and fixed one mismatch, the prev/next names. - HSTS:
server.mjssends it only on HTTPS, byx-forwarded-protoor a TLS socket.
Content
- TC101–TC109 get full section sets in the depth and style of the older cards: an instruction-style minimum move, depth dial, more phrase groups, scenarios, mistakes, recovery and related techniques. Each card grows by 6–7 KB.
- No existing phrase text changed. The saved-phrase snapshot is refreshed to cover the new lines.
Design
- Card cross-references such as "(TC011)" become links or title chips (
card-refs.ts,card-ref-text.tsx). - Library groups: Connection (54), Clarity (28) and Resilience (16) show named subgroups. TC007, TC009, TC012 and TC015 moved into Connection.
- Header title: it appears only after the page's own title scrolls away (iOS large-title pattern). The sidebar now says "TC Reference".
- Phrase typeface: Inter everywhere through a
--app-font-phrasetoken. Serif stays only on the share image and print card. The Best example and the ladder's Best rung get a light green tint (contrast ≥ 6.2:1).
Before/after screenshots are in the project files under pwa-audit/round2/ (design/before|after, data-safety/, content/, perf.md).
Checks
- Passed, fresh on the merged branch:
- format:check, lint and typecheck
- App tests: 71 files, 969 tests
- Production build and card build check
- Bundle budget
- Playwright iphone-chromium: 34/34, including the new axe spec, run three times
- Not run here: WebKit e2e.
e2e-webkit.ymlruns it, including the new axe spec for the first time. - Not verified: a physical iPhone share sheet, VoiceOver or Dynamic Type.
Generated by Claude Code
Summary by cubic
Builds the approved PWA and design audit recommendations across data safety, performance, and design.
Data safety
- Backups use the share sheet on iPhone and iPad only; Android and desktop download as before, a failed share reports failure, and a backup counts only when actually saved so cancelling keeps the reminder up.
- Restore snapshots the current data first (clearing any older snapshot so Undo never brings back pre-earlier-restore data), with "Undo restore" available for 30 days.
- Files over 5 MB are rejected before reading; backup format v2 reads v1 and keeps Start here progress, recent cards and the welcome flag; newer-version files ask for an app update.
- A saved-phrase snapshot test fails CI if a phrase disappears without a
REPHRASEDor retired entry; drill review gaps cap at ~6 months.
Performance, CI and design
- Phrase Bank paints its intro immediately via a build-time count and renders rows progressively, cutting TBT from 343 ms to 110 ms on throttled mobile.
- CI now runs a bundle budget check and an axe WCAG A/AA scan on all 10 main routes; the server sends HSTS only over HTTPS.
- TC101–TC109 gain full section sets matching the older cards' depth; no existing phrase text changed.
- Card cross-references become links (without self-links), the Library shows named subgroups, the header page name follows the iOS large-title pattern, and phrase text uses one typeface.