Repository navigation
feat(library): browse library sections and collections on v2 - #383
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code review summaryReviewed head: Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration. Verified findings: none. Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no Remaining: no open verified findings. Merge in stack order. Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack. Review by Claude Opus 5.5 ( |
141bc83 to
ff7d1da
Compare
278db7f to
fb0a56c
Compare
ff7d1da to
d449f74
Compare
The library landing page and the Collections tab still read
/api/v1/library/{id}/sections and /api/v1/library/{id}/collections. A 1.0
server answers both with 410, so every library page showed an error or an
empty tab. The v1 collections read also carried a tolerant three-shape
decoder that no v2 server sends.
SiloAPI.librarySections now calls the existing v2 listLibrarySections
client and returns the read with the owner it was fetched for. The startup
prefetcher checks that owner before it caches or returns the sections, as
Home already does. SiloAPI.libraryCollections calls getLibraryCollections
under a captured owner, rejects a tab for another library, refuses the
result after a profile switch, and maps the tab onto the existing section
model: admin groups become regular, user_collections become personal,
unknown kinds resolve as regular (as on Android), the ungrouped bucket goes
after the groups it sorts behind, and empty poster URLs become nil.
The v1 wire decoder (LibraryCollectionsWireResponse and its private wire
types) is deleted.
Stack-PR: W5-H
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Handle the ungrouped-free, group-free tab first with an early return and drop a redundant bounds clamp on the ungrouped insert position. Stack-PR: W5-H Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
fb0a56c to
26bbdbb
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Problem
The library landing page and the Collections tab still read two v1 routes:
GET /api/v1/library/{id}/sections(inventory row 50): the section shelves on the iOS/macOS library screen and the tvOS library landing page, loaded throughStartupContentPrefetcher.fetchLibrarySections.GET /api/v1/library/{id}/collections(row 59): the Collections tab on iOS/macOS (CollectionsView) and tvOS (TVLibraryCollectionsView).A 1.0 server answers every
/api/v1/*call except health with410 client_upgrade_required, so these pages show an error or an empty tab. The collections read also carried a tolerant decoder for three response shapes that no v2 server sends.Solution
SiloAPI.librarySectionscalls the existingAPIv2Client.librarySections(listLibrarySections) under a captured owner and returnsAPIv2LibrarySectionsRead. The prefetcher checks that the owner is still current before it caches or returns the sections, the same way Home does. The response keeps theSectionsResponseshape, so the three cache readers are unchanged.ResponseCacheis in-memory only, so the cache key does not need a version bump.APIv2Client.libraryCollectionTabnow takes a capturedauth, requires a profile (X-Profile-Idis required by the contract), runs underwithOwnerFence, accepts only 200, and rejects a tab whoselibrary_iddiffers from the one requested.SiloAPI.libraryCollectionsalso refuses the result if the profile changed while the read was in flight, because the tab contains the viewer's personal collections.APIv2LibraryModels.swiftmapsAPIv2LibraryCollectionTabonto the existingLibraryCollectionsResponse:admingroups become.regular,user_collectionsgroups become.userCollections, and any other kind becomes.regular. This matches Android (SectionApi.getLibraryCollections) and main's v1 behavior, and it never treats an unknown kind as personal.sort_orderdoes not exceed its own.poster_url("empty when none" in the contract) becomes nil.collection_typecomes from the curated definition with the same id.LibraryCollectionsWireResponseand its private wire types and tolerant-decode helpers are deleted.Both reads are GETs, so no mutation failure-outcome table applies.
Validation
LibraryBrowseV2Tests(new),CatalogV2Tests,CollectionsV2Tests,HomeSectionsAPITests,LibraryVisibilityTestsandHTTPClientDiagnosticsClassificationTests.LibraryBrowseV2Testsruns throughStubURLProtocoland covers the inputs to the tvOS library landing page and collections grid:X-Profile-Id, and stay bound to the profile they were read forscripts/ci/check-no-api-v1.shpassed. Owner-fence lines (withOwnerFence/sameCredentialIdentity) underiosApp/iosAppwent from 60 to 61.Risks and follow-ups
TVLibraryCollectionsView.loadCollectionsstill turns any error into an empty tab ("No collections yet"). This is existing behavior and this PR does not change it. A later change should show an error state instead.HTTPClientDiagnosticsClassificationTestsstill contains the/api/v1/library/{id}/sectionstemplate as a classification fixture that sends no request. Z1 owns the final guard allowlist.AI disclosure
Code and description written by Claude Opus 5.5 (
claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.Part 35 of 50 in the Apple API v2 stack. Base:
apiv2-stack/34-catalog-cursor-paging. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code