Repository navigation
feat(audiobooks): redesign audiobook library around resume and series progression - #116
Conversation
… progression Audiobook libraries previously reused the video-shaped library page: a backdrop carousel hero (audiobooks have square covers and no backdrops), movie-style default sections, and a browse grid whose primary audiobook axes (author, narrator, series) were buried as filters. Backend: - New next_in_series section type: surfaces the next unstarted book, by series_index, in series the profile has finished a book of, ordered by most recent finish. Registered as a library-staple recipe. - New GET /api/v1/catalog/audiobook-groups endpoint: grouped browse by author/narrator/series with book count, total duration, per-profile progress counts, and poster URLs for cover stacks. - Audiobook library defaults: continue-listening is featured (renders as the Now Listening hero) with next-in-series directly after it. A data migration upgrades existing audiobook libraries, skipping layouts where an admin already featured a section. Frontend: - NowListeningHero replaces HeroBanner for audiobook libraries: resume deck with chapter position, hours left, ambient color from the cover, and one-click resume; remaining in-progress books render as the Continue Listening row. - Library tab gains Books/Series/Authors/Narrators browse axes persisted via the type param; selecting a group drops into the Books grid with the matching filter applied. - "Recommended" tab is labeled "Home" for audiobook libraries; audiobook continue cards use square covers and hr/min time-left formatting. - Shared audiobook chapter/file/duration helpers extracted to web/src/lib/audiobooks (deduplicated from AudiobookContent). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds grouped audiobook browsing (author/narrator/series), a next-in-series recommendation pipeline and section type, a DB migration to seed featured and next-in-series sections, shared audiobook utilities, UI components (NowListeningHero, AudiobookGroupsView), and routing/hooks to surface grouped and audiobook-first browse behavior. ChangesAudiobook Library Home & Browse Redesign
Estimated code review effort 🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec4db6edb3
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ORDER BY fs.last_finished_at DESC | ||
| LIMIT $3` |
There was a problem hiding this comment.
Apply library scoping before limiting next-in-series candidates
For library-scoped audiobook sections, this LIMIT is applied to the user's global recently finished series before fetchNextInSeriesSection resolves and filters those content IDs to the requested library. If a profile has many more-recent finished series in another audiobook library, those candidates consume the capped result set and the current library can render an empty or truncated “Next in Your Series” row even though it has valid next books. Push the library/access filter into this query or continue fetching until enough candidates survive the library filter.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0149c57 — library scoping (library id / allowed ids / disabled ids) is now pushed into the candidate query's LATERAL via NextInSeriesQuery, so candidates from other libraries no longer consume the limit. The 3× over-fetch remains only to cover post-resolution content-rating filtering.
| sort, | ||
| limit: String(GROUPS_FETCH_LIMIT), |
There was a problem hiding this comment.
Page or search audiobook groups beyond the first 500
This hard-coded fetch limit means the UI only ever receives the first 500 groups for an axis, and AudiobookGroupsView filters that partial list client-side. In libraries with more than 500 authors/narrators/series, groups after the first page cannot be displayed or found by the filter box even though the API reports a larger total. Add pagination/offset handling or a server-side search parameter before filtering locally.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0149c57 — fetchAudiobookGroups now pages through the endpoint (500/page) until the server-reported total is reached, bounded at 20 pages, so the client-side filter box sees the complete list.
| UPDATE page_sections ps | ||
| SET featured = FALSE, | ||
| updated_at = NOW() | ||
| FROM media_folders mf | ||
| WHERE ps.scope = 'library' | ||
| AND ps.library_id = mf.id | ||
| AND lower(mf.type) IN ('audiobook', 'audiobooks') | ||
| AND ps.section_type = 'continue_watching' | ||
| AND ps.config->>'continue_type' = 'listening' | ||
| AND ps.featured; |
There was a problem hiding this comment.
Preserve preexisting featured sections on rollback
The down migration clears every featured continue-listening section in audiobook libraries, not just rows that this migration changed. If an admin already had Continue Listening featured before the upgrade (or featured it after), rolling back silently removes their library hero state. Track the rows updated by the up migration or restrict the down step so preexisting/admin-set featured values are preserved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0149c57 — the Up now writes marker keys into config (featured_by_migration on the row it features, seeded_by_migration on the row it inserts) and the Down reverts only marked rows, so pre-existing/admin-set featured state and hand-created next_in_series sections survive a rollback. The migration is unreleased, so amending it in place is safe.
| const files = useMemo( | ||
| () => (detail?.type === "audiobook" ? audiobookFilesFromVersions(detail.versions) : []), | ||
| [detail], |
There was a problem hiding this comment.
Ignore stale detail data before starting hero playback
useCatalogItemDetail keeps previous data while a new deck.content_id is loading, but this memo accepts any audiobook detail as the file list for the current deck. After switching libraries or after the featured item changes, clicking Resume before the new detail fetch completes can call startPlayback with the new contentId but the previous book's files/credits. Gate the detail-derived files and metadata on detail.content_id === deck.content_id before using them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0149c57 — detail-derived files/credits/progress are now gated on fetchedDetail.content_id === deck.content_id, so a Resume click during a deck change falls through to the detail-page link (?play=1) instead of starting playback with the previous book's files.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
web/src/hooks/queries/audiobookGroups.ts (1)
1-40: ⚡ Quick winRename this hook module to follow the hook filename convention.
web/src/hooks/queries/audiobookGroups.tsexportsuseAudiobookGroups; naming ituseAudiobookGroups.tswould align with the repository hook convention and improve discoverability.As per coding guidelines,
web/src/hooks/**/*.ts: “UseuseThing.tsnaming convention for React hooks.”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/hooks/queries/audiobookGroups.ts` around lines 1 - 40, The file is misnamed for a React hook module; rename the module to useAudiobookGroups.ts to match the repository hook filename convention, keep the exported symbols (useAudiobookGroups and fetchAudiobookGroups) unchanged, and update any imports/exports that currently reference audiobookGroups.ts (including any barrels or re-exports) so they point to useAudiobookGroups.ts to avoid broken imports.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@migrations/sql/20260609222830_audiobook_library_home_redesign.sql`:
- Around line 102-118: The Down migration currently DELETEs from page_sections
and UPDATEs featured for all audiobook libraries (queries referencing
page_sections ps and media_folders mf), which can clobber pre-existing data;
change these statements to only target rows that this migration previously
created/modified by filtering on a migration marker stored in
page_sections.config (e.g., a specific key/value like config->>'migrated_by' =
'20260609222830_audiobook_library_home_redesign' or similar). Update the DELETE
and UPDATE WHERE clauses to join on media_folders as before but also require
that ps.config contains that migration marker so only rows touched by the Up are
removed/reverted, and ensure the revert restores any changed flags only for
those marked rows.
In `@web/src/components/audiobooks/AudiobookGroupsView.tsx`:
- Around line 127-129: The initial sort state in AudiobookGroupsView is set once
and won't change when groupBy changes; add a useEffect that watches groupBy and
calls setSort(groupBy === "series" ? "name" : "count") so the sort state resets
to the intended default whenever groupBy changes (referencing the sort and
setSort state variables and the groupBy prop).
In `@web/src/hooks/queries/audiobookGroups.ts`:
- Around line 10-24: The hard cap GROUPS_FETCH_LIMIT (500) in
fetchAudiobookGroups prevents fetching more than 500 groups; change the function
to accept an optional limit parameter (or read limit from options) instead of
always using GROUPS_FETCH_LIMIT, and pass that value into the URLSearchParams so
callers can request larger pages or server-driven pagination; update the
function signature (fetchAudiobookGroups) and its callers to provide a limit or
to handle server pagination/continuation tokens as needed.
---
Nitpick comments:
In `@web/src/hooks/queries/audiobookGroups.ts`:
- Around line 1-40: The file is misnamed for a React hook module; rename the
module to useAudiobookGroups.ts to match the repository hook filename
convention, keep the exported symbols (useAudiobookGroups and
fetchAudiobookGroups) unchanged, and update any imports/exports that currently
reference audiobookGroups.ts (including any barrels or re-exports) so they point
to useAudiobookGroups.ts to avoid broken imports.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9d6249d9-5613-459c-a834-c186f20bbd7f
📒 Files selected for processing (32)
internal/api/handlers/audiobook_groups.gointernal/api/router.gointernal/catalog/audiobook_groups.gointernal/catalog/audiobook_next_repo.gointernal/sections/defaults.gointernal/sections/defaults_test.gointernal/sections/fetcher.gointernal/sections/recipe_equivalence_test.gointernal/sections/recipes/library_staples.gointernal/sections/types.gomigrations/sql/20260609222830_audiobook_library_home_redesign.sqlweb/src/api/types.tsweb/src/components/ContinueWatchingCard.tsxweb/src/components/LibraryHeader.tsxweb/src/components/NowListeningHero.tsxweb/src/components/SectionItemCard.tsxweb/src/components/SectionRow.tsxweb/src/components/audiobooks/AudiobookGroupsView.tsxweb/src/hooks/queries/audiobookGroups.tsweb/src/hooks/queries/catalog.tsweb/src/hooks/queries/keys.tsweb/src/lib/audiobooks/chapters.tsweb/src/lib/audiobooks/duration.tsweb/src/lib/audiobooks/files.tsweb/src/lib/sectionTypes.tsweb/src/pages/ItemDetail/AudiobookContent.tsxweb/src/pages/LibraryBrowse.test.tsxweb/src/pages/LibraryBrowse.tsxweb/src/pages/LibraryPage.tsxweb/src/pages/LibraryRecommended.tsxweb/src/pages/libraryPageSearchParams.test.tsweb/src/pages/libraryPageSearchParams.ts
- Push library scoping into the next-in-series candidate SQL so finished series whose next book lives in another library can't consume the candidate limit and starve a library-scoped section (Codex P2). - Paginate the audiobook groups fetch until the server-reported total is reached (500/page, 20-page bound) so client-side filtering sees the complete author/narrator/series list (Codex P2, CodeRabbit). - Make the redesign migration rollback-safe: rows the Up touches carry config markers (featured_by_migration / seeded_by_migration) and the Down reverts only marked rows, leaving admin-set featured state and hand-created next_in_series sections alone (Codex P2, CodeRabbit). - Gate NowListeningHero's detail-derived files/credits on the detail matching the deck item, so Resume can't start the new book with the previous book's files while keepPreviousData shows stale detail (Codex P2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Addressed the review in 0149c57: next-in-series candidates are now library-scoped in SQL, the groups fetch pages past 500, the migration Down only reverts rows the Up marked, and NowListeningHero ignores stale keepPreviousData detail before starting playback. Two findings intentionally not changed:
Verified after the changes: |
… progression (#116) * feat(audiobooks): redesign audiobook library around resume and series progression Audiobook libraries previously reused the video-shaped library page: a backdrop carousel hero (audiobooks have square covers and no backdrops), movie-style default sections, and a browse grid whose primary audiobook axes (author, narrator, series) were buried as filters. Backend: - New next_in_series section type: surfaces the next unstarted book, by series_index, in series the profile has finished a book of, ordered by most recent finish. Registered as a library-staple recipe. - New GET /api/v1/catalog/audiobook-groups endpoint: grouped browse by author/narrator/series with book count, total duration, per-profile progress counts, and poster URLs for cover stacks. - Audiobook library defaults: continue-listening is featured (renders as the Now Listening hero) with next-in-series directly after it. A data migration upgrades existing audiobook libraries, skipping layouts where an admin already featured a section. Frontend: - NowListeningHero replaces HeroBanner for audiobook libraries: resume deck with chapter position, hours left, ambient color from the cover, and one-click resume; remaining in-progress books render as the Continue Listening row. - Library tab gains Books/Series/Authors/Narrators browse axes persisted via the type param; selecting a group drops into the Books grid with the matching filter applied. - "Recommended" tab is labeled "Home" for audiobook libraries; audiobook continue cards use square covers and hr/min time-left formatting. - Shared audiobook chapter/file/duration helpers extracted to web/src/lib/audiobooks (deduplicated from AudiobookContent). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(audiobooks): address review feedback on library redesign - Push library scoping into the next-in-series candidate SQL so finished series whose next book lives in another library can't consume the candidate limit and starve a library-scoped section (Codex P2). - Paginate the audiobook groups fetch until the server-reported total is reached (500/page, 20-page bound) so client-side filtering sees the complete author/narrator/series list (Codex P2, CodeRabbit). - Make the redesign migration rollback-safe: rows the Up touches carry config markers (featured_by_migration / seeded_by_migration) and the Down reverts only marked rows, leaving admin-set featured state and hand-created next_in_series sections alone (Codex P2, CodeRabbit). - Gate NowListeningHero's detail-derived files/credits on the detail matching the deck item, so Resume can't start the new book with the previous book's files while keepPreviousData shows stale detail (Codex P2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
… progression (#116) * feat(audiobooks): redesign audiobook library around resume and series progression Audiobook libraries previously reused the video-shaped library page: a backdrop carousel hero (audiobooks have square covers and no backdrops), movie-style default sections, and a browse grid whose primary audiobook axes (author, narrator, series) were buried as filters. Backend: - New next_in_series section type: surfaces the next unstarted book, by series_index, in series the profile has finished a book of, ordered by most recent finish. Registered as a library-staple recipe. - New GET /api/v1/catalog/audiobook-groups endpoint: grouped browse by author/narrator/series with book count, total duration, per-profile progress counts, and poster URLs for cover stacks. - Audiobook library defaults: continue-listening is featured (renders as the Now Listening hero) with next-in-series directly after it. A data migration upgrades existing audiobook libraries, skipping layouts where an admin already featured a section. Frontend: - NowListeningHero replaces HeroBanner for audiobook libraries: resume deck with chapter position, hours left, ambient color from the cover, and one-click resume; remaining in-progress books render as the Continue Listening row. - Library tab gains Books/Series/Authors/Narrators browse axes persisted via the type param; selecting a group drops into the Books grid with the matching filter applied. - "Recommended" tab is labeled "Home" for audiobook libraries; audiobook continue cards use square covers and hr/min time-left formatting. - Shared audiobook chapter/file/duration helpers extracted to web/src/lib/audiobooks (deduplicated from AudiobookContent). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(audiobooks): address review feedback on library redesign - Push library scoping into the next-in-series candidate SQL so finished series whose next book lives in another library can't consume the candidate limit and starve a library-scoped section (Codex P2). - Paginate the audiobook groups fetch until the server-reported total is reached (500/page, 20-page bound) so client-side filtering sees the complete author/narrator/series list (Codex P2, CodeRabbit). - Make the redesign migration rollback-safe: rows the Up touches carry config markers (featured_by_migration / seeded_by_migration) and the Down reverts only marked rows, leaving admin-set featured state and hand-created next_in_series sections alone (Codex P2, CodeRabbit). - Gate NowListeningHero's detail-derived files/credits on the detail matching the deck item, so Resume can't start the new book with the previous book's files while keepPreviousData shows stale detail (Codex P2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Resolves GHSA-68fv-2mgg-jv7q (Dependabot alert Silo-Server#116). postcss, @tailwindcss/node and css-tree all accept ^1.2.1, so only the resolved version and integrity change; no override is needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Audiobook libraries reuse the video-shaped library page wholesale: a cinematic backdrop-carousel hero (audiobooks have square covers and no backdrops to fill it), default sections copied from the movie list, and a browse grid where the axes audiobook listeners actually navigate by — author, narrator, series — are buried as filters. The usage pattern is inverted from movies: ~90% of opens are "resume the book I'm in," and the next pick is driven by series order and author/narrator loyalty, not genre browsing.
Approach
Keep the Home / Library / Collections architecture; replace what fills it for audiobook libraries.
Home tab
featuredin audiobook library defaults and renders as a newNowListeningHero: a resume deck for the most recent in-progress book (square cover as blurred backdrop, ambient color from the cover, chapter position like "Chapter 32 of 75 · The Tower", hours left, one-click Resume), with the remaining in-progress books as the row beneath.next_in_seriessection type (backend + recipe registration): per series the profile has finished a book of, surface the lowest-indexed later book not yet started, ordered by most recent finish. Cards show a "Book N · Series Name" eyebrow. This is the audiobook equivalent of TV's On Deck.Library tab
typesearch param, mirroring the series-library Series/Episodes toggle).GET /api/v1/catalog/audiobook-groupsendpoint: groups by author/narrator/series with book count, total duration, per-profile in-progress/finished counts, and up to four poster URLs for cover stacks. Selecting a group drops into the Books grid with the matching author/narrator/series filter applied (names match case-insensitively, same semantics as the facet filters).Migration
20260609222830_audiobook_library_home_redesign.sqlupgrades existing audiobook libraries: features the first continue-listening section (only when the admin hasn't already featured something) and inserts a next-in-series section after it (only when none exists). Fresh libraries get the new defaults fromDefaultLibrarySectionsForType.Shared cleanup
web/src/lib/audiobooks/and reused byAudiobookContent,NowListeningHero, and the continue cards (previously duplicated inline).useCatalogWindowgains anenabledoption so grouped axis views don't fetch the books grid behind themselves.Risks / follow-up
next_in_seriessections and the grouped browse endpoint are new client-visible API surface. silo-android and silo-apple need follow-up to render them; until then they should tolerate the unknown section type (it resolves like any other section).next_in_serieshas no dismissal surface yet (next_up has one); can be added if "stop suggesting this series" demand shows up.LOWER(BTRIM(series_name)), consistent with the existing facet and filter behavior — books missingseries_indexare excluded from progression.Testing
GOWORK=off go test ./internal/...passes (playback GPU-probe tests flake under parallel load on the dev Mac, pass in isolation — unrelated).tsc -b, ESLint (0 errors), prettier on touched files,pnpm run build, andmake verify-local-pathsall clean.defaults_test.go,recipe_equivalence_test.go,libraryPageSearchParams.test.ts(axis round-trip + unknown-value fallback),LibraryBrowse.test.tsx.AI use
Implemented end-to-end by Claude (Fable 5) via Claude Code, from a design direction approved by the maintainer; design exploration, code, migration, and tests are AI-authored and locally verified as above.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
UI/UX Improvements
Tests