Skip to content

fix(collections): route library user collections correctly - #312

Open
Rhainland wants to merge 1 commit into
Silo-Server:mainfrom
Rhainland:codex/fix-mobile-user-collection-routing
Open

Rhainland wants to merge 1 commit into
Silo-Server:mainfrom
Rhainland:codex/fix-mobile-user-collection-routing

Conversation

@Rhainland

@Rhainland Rhainland commented Sep 18, 2026

Copy link
Copy Markdown

Opening a personal collection published in a library's Collections tab failed because the phone client treated every card as a server-managed library collection. The resulting catalog request used the wrong source and returned Catalog source not found.

This change carries each card's collection kind into the detail route. Library-managed cards use library_collection, while published personal cards use user_collection. The detail view model keeps library collections read-only, preserves the selected library for item navigation, and uses the matching repository for initial loading, retry, refresh, and pagination. Legacy library routes and unscoped personal collection routes keep their existing behavior.

Library-scoped personal collection requests now include library_id. The opaque continuation records that scope and rejects reuse under a different library before sending a request.

Validation

  • ./gradlew test — passed across shared, phone, and TV modules with Android Studio's bundled JDK 21 and an English locale
  • ./gradlew :shared:testDebugUnitTest :androidApp:testDebugUnitTest :androidApp:assembleDebug — passed
  • Shared debug unit tests: 1,375 passed
  • Phone debug unit tests: 673 passed
  • Manual check on an isolated API 36 Pixel 7 emulator against disposable local data: personal and server collection cards opened successfully, back navigation retained the Movies library context, and the final catalog requests returned 2xx responses without a catalog 404

Risk and follow-up

The new route argument is optional, so saved or legacy library routes still default to library_collection. Personal collection routes without a library remain manageable and omit library_id. No server, Apple client, Android TV behavior, or visual design changes are included.

Related issue: N/A — narrow fix

AI disclosure

  • Harness: OpenAI Codex desktop
  • Implementation: GPT-5 performed the diagnosis, implementation, automated testing, emulator validation, and pull request preparation.
  • Independent review: gpt-6-astra with medium reasoning reviewed the complete change for route compatibility, repository selection, library scoping, management permissions, and pagination. It found that library-scoped personal collection requests omitted library_id; the implementation and regression tests were updated to preserve that scope and bind it to the continuation. No other introduced defects were reported.
  • Other AI tooling: none.

Summary by CodeRabbit

  • New Features

    • Library collection details now retain their collection type when navigating and loading content.
    • User and regular library collections use the appropriate scoped content and pagination behavior.
    • Collection browsing preserves library context across subsequent pages.
  • Bug Fixes

    • Prevented mismatched library scopes from being used with continuation links.
  • Tests

    • Added coverage for library-scoped navigation, collection loading, pagination, and personal collections.

@coderabbitai

coderabbitai Bot commented Sep 18, 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: 6dbf3a49-9422-43f2-be39-d3f581e55c4d

📥 Commits

Reviewing files that changed from the base of the PR and between e35edbf and 09e5912.

📒 Files selected for processing (11)
  • 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/collections/CollectionDetailViewModel.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/collections/LibraryCollectionsScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/libraries/LibrariesScreen.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/CollectionRouteTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/collections/CollectionDetailViewModelTest.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/network/api/CollectionApi.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/repository/CollectionRepository.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/network/apiv2/CollectionsV2Test.kt

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


📝 Walkthrough

Walkthrough

The change adds source-aware library collection routes, passes complete collection objects through Android navigation, and preserves library scope across collection API requests, cursor pagination, and detail loading. Tests cover user library, regular library, and personal collection behavior.

Changes

Library collection scoping

Layer / File(s) Summary
Collection API scope propagation
shared/src/commonMain/kotlin/org/siloserver/silo/network/api/CollectionApi.kt, shared/src/commonMain/kotlin/org/siloserver/silo/repository/CollectionRepository.kt, shared/src/commonTest/kotlin/org/siloserver/silo/network/apiv2/CollectionsV2Test.kt
Collection requests and continuations now carry libraryId. Mismatched continuation scopes return invalid_cursor. Tests verify scoped and unscoped requests.
Scoped collection routes and navigation
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/Routes.kt, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/collections/LibraryCollectionsScreen.kt, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/libraries/LibrariesScreen.kt, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/MainScreen.kt, androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/CollectionRouteTest.kt
Library collection routes now include source. Collection click callbacks now pass LibraryCollection objects. Route tests cover user, regular library, and personal collection URLs.
Collection detail loading and pagination
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/collections/CollectionDetailViewModel.kt, androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/collections/CollectionDetailViewModelTest.kt
The view model selects collection loading paths from the route source. User library collections use CollectionRepository with libraryId; other library collections retain SectionRepository. Tests cover metadata, pagination, refresh, and manageability.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant LibraryCollectionsScreen
  participant MainScreen
  participant CollectionDetailViewModel
  participant CollectionRepository
  participant CollectionApi
  LibraryCollectionsScreen->>MainScreen: pass LibraryCollection and libraryId
  MainScreen->>CollectionDetailViewModel: navigate with source and libraryId
  CollectionDetailViewModel->>CollectionRepository: load scoped collection items
  CollectionRepository->>CollectionApi: request items with library_id
  CollectionApi-->>CollectionDetailViewModel: return items and scoped continuation
Loading

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to 09e59

No merge-blocking issue was identified in the scoped collection routing changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: correcting routing for library user collections. It is concise, specific, and related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@greptile-apps

greptile-apps Bot commented Sep 18, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the new source and library scope remain consistent across navigation, loading, refresh, pagination, and item navigation.

Reviews (1) · Last reviewed commit: "fix(collections): route library user col..."

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.

1 participant