Skip to content

Conversation

erikhfj
Copy link
Member

@erikhfj erikhfj commented Sep 9, 2026

Summary

Completes #22 (and remains the vehicle for the M3 integration). Three slices, now all in this branch:

  1. Subject filter wired via usePreferences (sessionStorage, t19.preferences) — choice survives reload
  2. Sort integrated (from feat: Sorting of books with sessionStorage persistence #29, by rachelks) — both preference changes now consistently reset to the first book (subject and sort behave identically; documented choice)
  3. Favorites integrated (from feat: add persistent favorites and overview #28, by robertky) — FavoritesView + BookCard favorite props

Also folded in the #29 review notes: isSortOption now derives from SORT_OPTIONS (single source of truth) and DEFAULT_SORT is no longer exported.

Tests (51 green across 12 files)

  • Subject/sort change → refetch (subject) / no refetch (sort), reset observable: navigate first, change preference, assert back at first book + 1 / 3
  • Restore from sessionStorage for subject AND sort (corrupt storage falls back safely)
  • Favorites persist, restore, remove (robertky's suite)
  • Snapshot regenerated for the integrated viewer

Checklist

  • npm run format:check — passes
  • npm run lint — 0 warnings
  • npm test — 51 passed
  • npm run build — passes

Closes #22.

AI-assisted: implementation generated with AI assistance, reviewed and verified.

- App: hardcoded SUBJECT replaced by usePreferences (sessionStorage,
  t19.preferences); SubjectFilter rendered above the viewer
- subject change resets the book index so the stale index can never point
  outside the new list
- test setup: sessionStorage and localStorage cleared between tests
- tests: subject change refetches exactly once for the new subject,
  choice restored from sessionStorage on mount, corrupt storage falls
  back to the default subject; snapshot updated deliberately

Partial #22: subject filter wired; sort (#20) and favorites (#21) wiring
follows when those merge.
@erikhfj erikhfj requested a review from a team as a code owner September 9, 2026 16:15
@erikhfj erikhfj added this to the M3 — Persistence & choices milestone Sep 9, 2026
@erikhfj erikhfj added type: feature New functionality or requirement area: ui React components, presentation, navigation area: storage Web Storage API (localStorage / sessionStorage) priority: high Required for first delivery ai-assisted Substantial AI-generated code (documented per spec) status: in-review PR is open and awaiting review labels Sep 9, 2026
@erikhfj erikhfj requested review from rachelks and robertky September 9, 2026 16:15
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.

PR #26 has now been merged, so this PR currently conflicts with main. Could you rebase it onto the latest main and resolve the conflict?

After the rebase, this PR should only contain the subject-change reset and its related tests, since navigation and the jump list are already in main. Please let CI run again afterwards, and I can review it then.

Resolved App.tsx in favor of main's favorites integration (FavoritesView,
BookCard favorite props) and re-applied the subject-change index reset.
The subject-change test now navigates first so the reset is observable:
changing subject returns to the first book at 1 / N. Snapshots regenerated.
Resolved in favor of main's sort integration (SortSelect, sortedBooks)
and applied consistent reset UX: changing subject OR sort returns to the
first book, so both preference changes behave identically. Both reset
tests now navigate first, making the reset observable (position and
heading asserted). Also consolidated the review notes: isSortOption now
derives from SORT_OPTIONS (single source of truth) and DEFAULT_SORT is no
longer exported. Snapshots regenerated.
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 after the rebase.

@robertky robertky merged commit ec2fdcf into main Sep 12, 2026
1 check passed
Sign in to join this conversation on GitHub.
Labels
ai-assisted Substantial AI-generated code (documented per spec) area: storage Web Storage API (localStorage / sessionStorage) area: ui React components, presentation, navigation priority: high Required for first delivery status: in-review PR is open and awaiting review type: feature New functionality or requirement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Wire preferences together and verify reload persistence
2 participants