Skip to content

fix(catalog): preserve library scope in detail and watch reads - #310

Merged
Quick104 merged 2 commits into
mainfrom
codex/issue-309-library-detail-scope
Sep 16, 2026
Merged

Quick104 merged 2 commits into
mainfrom
codex/issue-309-library-detail-scope

Conversation

@Quick104

@Quick104 Quick104 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Android omitted the browsing library from detail and watch reads, so catalog.scope_versions_to_library could not narrow version pickers on phone or TV.

Carry the selected library through detail routes, series/episode navigation, video, audiobook, reader metadata, and Android-to-Android SiloCast launches. Send library_id on catalog item, version, episode, season-list, season-episode, and watch reads. Home, search, external links, and global recommendations remain unscoped. External links open an unscoped destination even when the same item is already open from a library.

Scoped reads bypass the existing content-only offline cache and Home warmups, including the phone player's cached artwork fallback. Version pickers consume the server response without a capability probe. Android has no getSeriesSeason call; season navigation uses the season-list and season-episode operations covered here.

Fixes #309.

Validation on ac6f52f1:

  • GitHub Unit tests and Lint checks passed on ac6f52f1. Fresh Codex and CodeRabbit reviews found no actionable issues; Macroscope correctness passed and all review threads are resolved. Its separate auto-merge eligibility check is neutral because of the change scope.
  • Both phone and TV debug APKs built successfully.
  • All 4,735 unit tests passed across shared, android-shared, phone, and TV modules.
  • Debug lint passed for android-shared, phone, and TV; release vital lint passed for both apps.
  • Build supply-chain checks and policy self-tests passed; git diff --check passed.
  • Regression coverage checks two libraries and unscoped requests, cache isolation on success and failure, independence from Home warmups, both phone watch-metadata paths, and scoped/legacy cast messages.

Limitations: scoped detail reads require a live response because the offline cache has no library key. Live-server behavior with the setting enabled and disabled, physical-device navigation, and LAN casting were not exercised. The optional cast field is backward compatible; older Android and current Apple receivers ignore it and require their own update to retain this context. No server change is needed for the Android cast protocol extension.

Note

Preserve library scope across catalog detail, watch, and navigation reads

  • Adds an optional library identifier to Android and TV routes for item detail, video player, audiobook player, and book reader, propagating it from library selections through detail, episode, series, cast, and player navigation.
  • ViewModels (ItemDetailViewModel, PlayerViewModel, ReaderViewModel, AudiobookPlayerViewModel, and TV equivalents) read the library id from saved state or launch args and forward it to all catalog, season, episode, prefetch, and watch-detail requests.
  • CatalogRepository.kt scoped methods bypass the unscoped content cache and home warmup/in-flight paths, calling the live API directly; unscoped reads retain existing cache behavior.
  • CatalogV2Api and WatchDetailV2Api attach library_id only when supplied; SiloCastPlaybackRequest adds a serializable library id with legacy messages decoding as unscoped.
  • Risk: library-scoped reads in CatalogRepository no longer read or write the unscoped detail, season, or episode cache, so scoped reads always hit the network; see CatalogLibraryScopeTest for cache isolation and warmup independence coverage.

Macroscope summarized ac6f52f.

AI Disclosure

  • Harness: Codex desktop agent harness.
  • Tool(s): Codex; GitHub reviews from Codex, Macroscope, and CodeRabbit.
  • Model(s): gpt-6-astra for implementation and local review; remote review model identifiers were not provided.
  • Involvement: AI-assisted.
  • Adversarial review: inspected the complete diff against current main, tracing phone/TV navigation, catalog and watch requests, cache ownership, external links, and cast compatibility. Fixed the missing cast context and unscoped artwork fallback found by Codex review. Explained why global recommendation navigation must remain unscoped; that review thread is now resolved. No local subagents were used.

Summary by CodeRabbit

  • New Features
    • Library context is now preserved when browsing content from a specific library.
    • Item details, seasons, episodes, playback, audiobook listening, and book reading use the selected library context.
    • Casting and TV playback now retain the originating library.
    • Library-scoped requests prevent content and playback metadata from being mixed between libraries.
  • Bug Fixes
    • Improved navigation and deep-link handling for identical content across different libraries.
  • Tests
    • Added coverage for library-scoped catalog requests, playback metadata, navigation data, and cast messages.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 6a2fac65-d254-4350-9e38-bc1acb747023

📥 Commits

Reviewing files that changed from the base of the PR and between c459bde and ac6f52f.

📒 Files selected for processing (34)
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/AudiobookPlayerViewModel.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/video/VideoPlaybackStartRequest.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/Routes.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/MainScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/detail/ItemDetailScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/detail/ItemDetailViewModel.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/libraries/LibrariesScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/LocalWatchMetadata.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileVideoPlaybackStarter.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerViewModel.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/ReadyWatchMetadata.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/reader/ReaderViewModel.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/LocalWatchMetadataTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/ReadyWatchMetadataTest.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/di/AndroidTvModule.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAudiobookRouting.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvRoute.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvItemDetailScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvItemDetailViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/libraries/TvLibrariesScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvVideoPlaybackStarter.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/shell/TvMainShell.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/cast/SiloCastMessage.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/network/api/CatalogApi.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/network/apiv2/CatalogV2Api.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/network/apiv2/WatchDetailV2Api.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/repository/CatalogRepository.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/cast/SiloCastMessageTest.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/repository/CatalogLibraryScopeTest.kt

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The change propagates an optional libraryId from Android and TV library navigation into catalog and watch-detail requests. Scoped catalog reads use library_id API parameters and bypass unscoped caches and Home warm-up paths. Playback routes, cast messages, readers, and metadata loaders preserve the value. Existing unscoped flows remain supported.

Library-scoped catalog contracts Summary
Catalog API and repository scoping
shared/src/commonMain/kotlin/org/siloserver/silo/network/..., shared/src/commonMain/kotlin/org/siloserver/silo/repository/..., shared/src/commonTest/kotlin/org/siloserver/silo/repository/CatalogLibraryScopeTest.kt
Catalog and watch-detail APIs accept libraryId. Scoped reads send library_id, avoid unscoped caches, and do not join Home warm-up requests.
Android navigation and playback propagation
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/..., androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/..., android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/...
Android library selections pass libraryId through detail, reader, audiobook, player, and cast routes. Detail and playback ViewModels forward it to repository calls.
TV navigation and playback propagation
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/...
TV library selections pass libraryId through item-detail and playback routes. TV ViewModels include it in catalog and playback requests.
Cast compatibility and request validation
shared/src/commonMain/kotlin/org/siloserver/silo/cast/SiloCastMessage.kt, shared/src/commonTest/kotlin/org/siloserver/silo/cast/SiloCastMessageTest.kt, androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/*Test.kt
Cast payloads preserve optional library identifiers. Tests verify scoped values and legacy payloads without a library identifier.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant LibraryScreen
  participant Navigation
  participant PlayerOrDetailViewModel
  participant CatalogRepository
  participant CatalogAPI
  LibraryScreen->>Navigation: select item with libraryId
  Navigation->>PlayerOrDetailViewModel: provide libraryId
  PlayerOrDetailViewModel->>CatalogRepository: request content with libraryId
  CatalogRepository->>CatalogAPI: send library_id query parameter
  CatalogAPI-->>CatalogRepository: return scoped content
  CatalogRepository-->>PlayerOrDetailViewModel: return content
Loading

Suggested reviewers: rxwatcher

Merge Risk: ⚪ Minimal · up to ac6f5

Library context is propagated through the scoped catalog, playback, cast, and navigation paths while unscoped paths remain unscoped.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.02% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 106 functions across 34 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #309 requires library context to flow from library browsing to detail and watch reads. The Android phone and TV navigation paths now carry nullable library IDs into item detail, player, audioboo…
Out of Scope Changes check ✅ Passed The changed navigation, repository, API, playback-context, TV, cast, and test code supports Issue #309. The added library ID on playback and cast models preserves context for related watch and catalog…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving library scope for catalog detail and watch reads.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-309-library-detail-scope

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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-16T21:27:22.014742Z ac6f52f Manual request
ℹ️ 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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@macroscopeapp

macroscopeapp Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This cross-platform fix threads library identity through navigation, playback, casting, and catalog/watch requests, while scoped reads bypass shared caches and warmups. The additive wire changes are well-tested, but the breadth and altered network/cache behavior affect existing phone and TV paths.

You can add or adjust custom eligibility rules. Learn more.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f8a5303b1

ℹ️ 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".

@Quick104

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: ac6f52f12d

ℹ️ 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".

@Quick104

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Quick104
Quick104 merged commit e35edbf into main Sep 16, 2026
6 checks passed
@Quick104
Quick104 deleted the codex/issue-309-library-detail-scope branch September 16, 2026 21:42
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.

Send library_id on item detail and watch reads for library-scoped versions

1 participant