Skip to content

Conversation

erikhfj
Copy link
Member

@erikhfj erikhfj commented Nov 25, 2026 •

Closes #132
Closes #133
Closes #135

This PR combines the already-approved Track B stack (#142 → #141 → #140) and merges the latest main (including #138 / #131 and #139 / #130) so a single approval lands all three issues cleanly.

Included PRs & Summary

1. #132 — Accessibility fixes, CSP-safe manual theme toggle, and UI/UX polish (#140)

  • Dynamic document.title (WCAG 2.4.2): Updated per route, active search query, album title, loading, and error states (DiscoveryPage.tsx, AlbumDetailPage.tsx, CratePage.tsx).
  • Unique CrateButton accessible names without double-state announcement (CrateButton.tsx, AlbumCard.tsx, AlbumDetailPage.tsx): Album-specific action labels (Add to crate: <title> / Remove from crate: <title>) without aria-pressed.
  • ReviewForm error a11y, friendly errors & delete confirmation (ReviewForm.tsx, ReviewForm.css, AlbumDetailPage.tsx, e2e/tests/search.spec.ts): Linked errors via id="review-form-error", aria-invalid, and aria-describedby, focused 1-star radio on invalid submit, sanitized unexpected exceptions, and added inline two-step delete confirmation (Delete review → Confirm delete / Cancel, Escape cancels and restores focus).
  • CSP-safe manual light/dark theme toggle (ThemeToggle.tsx, useTheme.ts, client/public/theme-init.js, client/index.html): Header Dark mode toggle (aria-pressed) defaulting to OS prefers-color-scheme, persisted safely in localStorage, with external 298 B /project2/theme-init.js (zero unsafe-inline).
  • Touch targets >= 44px (2.75rem), CratePage & SearchForm fixes, and UX polish: Raised interactive targets to >= 2.75rem, restored focus on CratePage removal and final Load more, guarded SearchForm Escape capture, added client-side recent-search filtering, switched cover framing to object-fit: cover, and made artist/genre tags on AlbumDetailPage clickable <Link>s.

2. #133 — Hero image/mobile LCP optimization and Apache headers (#141, already approved & merged into this branch)

  • Optimized hero WebP assets: Desktop vinyl-hero.webp (1280×720, 39,164 B, -91.3%) and mobile vinyl-hero-mobile.webp (640×360, 13,394 B, -97.0%).
  • Responsive high-priority <picture> hero & tighter mobile layout: Replaced CSS ::before background with eager fetchPriority="high" <picture>, tightened mobile hero spacing, and added a mobile "Browse catalog" jump link to #catalogue.
  • Referrer privacy & Apache 2.4 / VM runbook (docs/VM-setup.md): Added referrerPolicy="no-referrer" + <meta name="referrer" content="no-referrer" />, and documented mod_deflate, Cache-Control, baseline security headers (CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy), NODE_ENV=production, and verification/rollback steps.

3. #135 — Final documentation sync, AI reflection, Lighthouse/a11y log, and screenshots (#142, already approved & merged into this branch)

  • AI usage reflection & log fixes (docs/AI-USAGE.md, README.md): Model versions, 2 concrete prompt-to-revision examples, benefits/risks/limits reflection, log defect fixes, and rows for #74 and #129–#135.
  • Refreshed Lighthouse 13.6.0, bundle sizes & a11y/zoom verification (docs/lighthouse-results.md, docs/architecture.md, docs/ui-specification.md, README.md): 12 local production-preview Lighthouse runs, @axe-core/playwright WCAG 2.1 A/AA checks (0 violations across 10 states), 200%/400% zoom & 320 px reflow checks (0 px overflow), and exact production asset sizes.
  • Technical doc discrepancy fixes & 9 recaptured UI screenshots (docs/images/*.png).

What was tested (post-merge with main)

  • pnpm install --frozen-lockfile && pnpm codegen && pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build — all passed cleanly (client/src/generated clean, 0 lint warnings).
  • Largest JS chunk: index-Bx0quCjo.js at 395,383 B (<= 512,000 B CI budget).

Copy link
Member

@evenkkl evenkkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. This is a big PR, but each part is easy to follow and the tests cover it well. I only looked at what this PR changes on top of #138.

About the #138 review

  • document.title: fixed. Discover, Album and Crate now set the title, including the loading and error states.
  • Focus on route change: not fixed. Focus still falls to <body> when the card link unmounts, and screen readers don't announce anything. It's fine to fix it in #138 or here, but one of them needs to do it before both are merged.
  • Error boundary for stale chunks: not part of this PR, still open on #138.

Looks good

  • Theme toggle: a static "Dark mode" label with aria-pressed is the right pattern, because the name doesn't change when the state does. The data-theme selectors and the :root:not([data-theme=…]) media queries cover both directions, and try/catch around localStorage matches userIdentity.
  • Anti-FOUC: %BASE_URL%theme-init.js becomes /project2/theme-init.js, and files in public/ are copied to the root of dist, so the path works on the VM. The script runs synchronously in <head> before first paint, and it is an external file, so it would also work under script-src 'self'. Note that the repo doesn't set a CSP anywhere yet, so the "CSP-safe" part is future-proofing for now.
  • Light-mode contrast: I checked the new colors. --danger on surface/bg/raised is 6.3–7.3:1, --muted is 5.6:1 or higher, --chip-text is 6.4:1, and the toggle border on the header is 4.3:1. They all pass AA.
  • 44px targets: buttons, the compact CrateButton, filter chips, nav links and the new artist and genre links are all at least 2.75rem.
  • CrateButton: "Add to crate: <title>" starts with the visible text, so label-content-name-mismatch passes, and each card now has a unique name.
  • Delete confirmation: focus moves to Cancel when it opens and back to "Delete review" on Cancel or Escape. On success, focus goes to the status message.
  • Error messages: the allowlist matches the server's real messages (Rating must be…, Comment must be…, Album not found., Review not found for this user.), and everything else falls back to the generic text.

Non-blocking

  1. aria-invalid on the <fieldset>. In ARIA 1.2, aria-invalid isn't supported on the group role, so most screen readers ignore it there. role="radiogroup" on the fieldset (or aria-invalid on the radios) would fix that. Moving focus to the first star together with the role="alert" already covers the important part.
  2. The comment is marked invalid for every non-rating error. commentHasError is error && !ratingError, so a network error or "Album not found." also sets aria-invalid on the textarea. I would only set it when the message starts with "Comment must be".
  3. Escape is caught on window. While the confirmation is open, pressing Escape anywhere, even inside the textarea, cancels it and moves focus. An onKeyDown on the confirmation group would limit it to the group.
  4. Focus after a failed refresh. If the delete works but onChanged() fails, the confirmation unmounts and focus falls to <body>. Moving focus to the "Try again" button would fix that.
  5. No confirmation when adding to the crate. Without aria-pressed, the only feedback is the name changing on the focused button, and many screen readers don't announce that. A visually hidden role="status" saying "Added <title> to your crate" would make it clear.
  6. No way back to "follow system". After the first click, the stored theme is used forever. That's fine for now, but worth knowing.
  7. Duplicated theme blocks. The dark variables are written twice in global.css, and the light card and detail rules are written twice in AlbumCard.css and AlbumDetailPage.css. They will drift apart easily. A short comment saying "keep in sync" would help.

#137 E2E impact

The impact is smaller than the description says. #137's tests don't use any CrateButton or aria-pressed locators, so removing those doesn't break anything. Only the new "validates, publishes, edits, and cleans up a review" test needs Confirm delete added after its two Delete review clicks. search.spec.ts will also get a small merge conflict on the same two lines in the first test, since both PRs change them.

@erikhfj
Copy link
Member Author

erikhfj commented Nov 26, 2026

Thanks for the detailed review, @evenkkl! Rebased onto the updated #138 (which now includes route-change <main> focus and RouteErrorBoundary) and addressed all 6 polish items in 87269e0:

  • role="radiogroup" on rating <fieldset>: Added role="radiogroup" in ReviewForm.tsx so aria-invalid is ARIA 1.2 compliant, and updated the role queries in ReviewForm.test.tsx and AlbumDetailPage.test.tsx.
  • Narrowed commentHasError: Restricted commentHasError to Boolean(error && error.startsWith('Comment must be')) so network errors or "Album not found." do not mark the comment textarea invalid.
  • Scoped Escape for delete confirmation: Removed the window keydown listener and moved Escape handling onto the confirmation buttons so pressing Escape inside the textarea no longer cancels confirmation or hijacks focus.
  • Focus after delete + failed refresh: Added a ref to the "Retry album refresh" button so when delete succeeds and onChanged() fails (unmounting the confirmation group), focus moves directly to "Retry album refresh" instead of falling back to <body>.
  • Crate live-region announcement: Added a visually hidden role="status" aria-live="polite" announcement in CrateButton.tsx (Added <title> to your crate. / Removed <title> from your crate.).
  • Theme CSS sync comments: Added brief /* Keep in sync with ... */ comments on the duplicated manual/media-query theme blocks in global.css, AlbumCard.css, and AlbumDetailPage.css.

Added unit tests covering each item and verified locally with pnpm codegen && pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build.

@erikhfj erikhfj force-pushed the feat/132-a11y-theme-and-ux-polish branch from f9925a6 to 87269e0 Compare November 26, 2026 19:37
evenkkl
evenkkl previously approved these changes Nov 26, 2026
Copy link
Member

@evenkkl evenkkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good. I checked 87269e0 and the rebase.

  • Rebase: clean. git range-diff shows 6bba797 matches the old f9925a6, except that ThemeToggle now sits next to RouteErrorBoundary in App.tsx. Nothing else changed. #138 now also handles focus on route change and the error boundary, so everything from the first review is covered.
  • role="radiogroup": done, and the tests find it by its accessible name "Rating".
  • commentHasError: done. Server "Rating must be…" errors now mark the rating group too, which is a good addition.
  • Escape: handled on the two confirmation buttons now, so Escape in the textarea no longer does anything.
  • Focus after a failed refresh: moves to "Retry album refresh". The effect checks for that before it focuses the status message, so the two don't compete.
  • Crate announcement: done.
  • Sync comments: added to all three files.

One small non-blocking thing: the role="status" span in CrateButton only renders once there is a message. Some screen readers, VoiceOver in particular, don't announce a live region that is added together with its text. If you render the span all the time and only change its text, it gets announced reliably. This can be a follow-up.

@erikhfj erikhfj changed the base branch from feat/131-client-routing-and-cache to main November 26, 2026 20:15
@erikhfj erikhfj dismissed evenkkl’s stale review November 26, 2026 20:15

The base branch was changed.

…d-delivery

docs: #135 final documentation sync, AI reflection, Lighthouse/a11y log, and screenshots
…headers

perf: #133 optimize hero image/mobile LCP and configure Apache headers
@erikhfj erikhfj changed the title feat: #132 accessibility fixes, CSP-safe manual theme toggle, and UI/UX polish feat: #132 a11y/theme/UX polish, #133 hero LCP & Apache headers, and #135 final docs/screenshots Nov 26, 2026
@erikhfj
Copy link
Member Author

erikhfj commented Nov 26, 2026

@evenkkl Already-approved #141 (#133) and #142 (#135) have been merged into this branch, and the latest main (including #138 and #139) has been merged in with only the 1-line README.md catalog-limitations conflict resolved (keeping both #139's unaccent wording and #142's musicBrainzArtistId note).

Full local validation (pnpm install --frozen-lockfile && pnpm codegen && pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build) passed cleanly. One single approval here on #140 will land all three PRs (#132, #133, #135) onto main!

Copy link
Member

@evenkkl evenkkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I checked the merges:

  • Merges: the #141 head (9326b6d) and the #142 head (ea155ef) are the exact commits that were approved. git show --remerge-diff shows no changes in either merge apart from the automatic result. So nothing new was added and nothing was lost.
  • Merge with main: README.md was the only conflict, and it is resolved correctly. It keeps #139's unaccent wording, drops the old "not accent-insensitive" line, and uses #142's musicBrainzArtistId note instead of the old "matched by name" line. The note matches musicBrainzCatalog.ts.
  • CI on 77371f1: format/lint/typecheck/test/build and the PostgreSQL integration tests pass. Deploy is skipped, as it should be on a PR.

@erikhfj erikhfj merged commit 999fab5 into main Nov 26, 2026
3 checks passed
Copy link
Member

@robertky robertky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. The updated PR includes the accessibility and UX improvements, hero image and Apache header changes, and the final documentation updates. The earlier review feedback has been addressed, and the latest format, lint, typecheck, test, build, and PostgreSQL integration checks are passing.

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
3 participants