Skip to content

Build the audit recommendations: safer backups, faster Phrase Bank, deeper TC101–TC109, card links, Library groups, header title on scroll - #139

Merged
BigSimmo merged 16 commits into
mainfrom
claude/project-thread-jd5e60
Nov 21, 2026
Merged

BigSimmo merged 16 commits into
mainfrom
claude/project-thread-jd5e60

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

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 REPHRASED or 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 budget script runs in code-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.ts runs axe WCAG 2.x A/AA plus label-in-name on all 10 main routes. axe-core is pinned at 4.13.0. The scan found and fixed one mismatch, the prev/next names.
  • HSTS: server.mjs sends it only on HTTPS, by x-forwarded-proto or 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-phrase token. 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.yml runs 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 REPHRASED or 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.

Written for commit 0634bfd. Summary will update on new commits.

View guided diff

…month drill cap

- Export backups through the share sheet (Save to Files) where files can be
  shared, falling back to a download link. The backup reminder only records
  a backup when the share finishes or the download starts; closing the
  share sheet records nothing. The reminder nudge stays up on cancel.
- Restore keeps a snapshot of the replaced data (tc_restore_snapshot,
  device-only, never in backups) and Settings > Backup offers Undo restore
  for 30 days.
- Reject backup files over 5 MB before reading them; a backup from a newer
  app version asks the reader to update first; versions 1 and 2 restore.
- Backup format v2 adds tc_start_opened, tc_recent_cards and
  tc_welcome_dismissed.
- Saved-phrase guard: a committed hashed snapshot of every saveable phrase
  fails the tests when one disappears without a REPHRASED or retired entry.
- Cap drill review intervals at 180 days ("In ~6 months").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
…p situation

- Bring the nine newer cards up to the depth of older cards: instruction-style
  minimum moves (library summaries updated to match), depth dials, more
  phrase groups (patients/clients/families, in writing, high stakes), and
  extra not-for, decision tree, ladder, scenario, calibration, mistake,
  recovery, chain, related-technique, checklist and example-note entries.
  Existing phrase text is unchanged; only additions.
- Add a ninth Help me right now situation, "They're very distressed or might
  not be safe", led by Emotion before facts (TC098) with a Safety first note
  pointing to the organisation's protocol and 000. Its lines live in a new
  TC098 "Checking in on safety" phrase group.
- Add a scope note ("This app helps with words, not clinical risk
  decisions") to the Help picker and the Library welcome.
- Every new safety line carries a CLINICAL REVIEW NEEDED comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
Card text cites other techniques by bare id ("Apologise (TC101)",
"TC003, then TC001"). A small pure parser (lib/card-refs.ts, unit tested)
splits such text into plain runs and references; CardRefText renders each
known reference as a link to /card/TCxxx that names the technique. When the
author's words already name the card they become the link; a bare id is
replaced by a light chip carrying the title. Unknown ids stay as written,
self-references are not linked, and text inside a button (related rows,
depth dial) shows the titles without nesting a link. Decision-tree rows that
cite a card split the copy button to just the phrase so the link is real.

Covers Skip it when, decision tree, calibration, chains, method, depth dial,
practice tasks and related reasons. Card data is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
Connection (54), Clarity (28) and Resilience (16) now show as short groups
under their own headings, named by what the reader wants to do ("Draw them
out", "Raise a problem or say no", "Repair after a misstep"). Grouping lives
in lib/category-groups.ts (ids only, so it stays on the light first-paint
path) and a new GroupedCardList component; library.tsx only swaps its list
for it. Filters, search and Start-here sort apply within groups; flat sorts
stay one list. A test keeps every card in exactly one group.

Moves clearly misplaced cards into Connection: TC007 No one-upping and TC009
Anti-boomerasking (from Resilience), TC012 Full-attention signal and TC015
Premature advice restraint (from Clarity).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
iOS large-title pattern. Pages mark their visible title with
usePageTitleRef(); the header watches it with an IntersectionObserver and
fades its own copy of the name in only once that title is under the bar,
so "Saved" over "Saved", the card title twice on phones and "Phrase Bank"
twice on desktop are gone. A screen-reader-only h1 (PageIntro and Drill on
phones) counts as not drawn, so those pages keep the header title. The
header copy is aria-hidden where a page h1 exists; the card's header h1
keeps its role. The "TC Reference" eyebrow is hidden from md up, where the
sidebar carries the name, and the sidebar now says "TC Reference" to match.
Reduced motion snaps via the existing app-header rule.

Also removes the serif from Saved phrases (shared file with this change).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
Every sayable line now uses Inter through one token (--app-font-phrase,
applied by .phrase-text): search results, Saved and drill recall no longer
switch to Georgia. Serif stays only on the printed/shared quote card. The
best line on Use it (and the ladder's best rung) gets a light green wash
via --best-tint; weak stays neutral. Measured contrast: Best label 6.2:1
light / 8.4:1 dark, line text >= 12:1.

Also holds the card cross-reference link and chip styles (index.css).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
…can, HSTS

- Precompute the Phrase Bank count at build time (virtual:phrase-bank-summary,
  same aggregation as the page via the new phrase-aggregate.ts) so the intro,
  the page's LCP element, paints before the text index loads.
- Cold loads render the first 24 rows, then fill the first page in idle
  batches; return visits render every row on the first frame.
- Add scripts/check-bundle-budget.mjs (gzip budgets ~10% over current for
  entry JS, vendor JS, main CSS, card-text-data) and run it after the build
  in code-review.yml.
- Add e2e/a11y.spec.ts: axe-core 4.13.0 WCAG 2.x A/AA plus
  label-content-name-mismatch on every main route; fix the prev/next card
  button names it flagged.
- Send HSTS only for requests that arrived over HTTPS (x-forwarded-proto or
  TLS socket), with a server test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
The new 'They're very distressed or might not be safe' situation, the
TC098 'Checking in on safety' lines, the safety not-for lines on TC105,
TC108 and TC109, and the scope notes move to their own pull request so
they can be clinically reviewed before release. The dormant safetyNote
support stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
…design round

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: be2e2206-167e-4dea-a898-1483d2b7cafd
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@gitar-bot

gitar-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Gitar is working

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

Gitar

…v1 restores

- Remove any older restore snapshot before saving a new one, and retry a
  restore once without the snapshot if storage runs out, so Undo can never
  bring back data from before an earlier restore.
- Backups use the share sheet only on iPhone and iPad; Android and desktop
  download as before. A failed share reports failure instead of a download
  without a user gesture.
- Restoring a version 1 backup keeps Start here progress, recent cards and
  the welcome flag, which v1 files never carried.
- Method steps don't link a card to itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxPPxjtHCQRLDHwTbGHhTp
@BigSimmo
BigSimmo marked this pull request as ready for review November 21, 2026 19:42
@BigSimmo
BigSimmo merged commit 7309cc2 into main Nov 21, 2026
5 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T19:43:34.298030Z 0634bfd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants