Repository navigation
Add mixed library support to iOS and tvOS - #93
Conversation
A server library of type "mixed" (movies + series in one folder) was silently dropped at decode and never reached any UI. It now surfaces as a single browsable library: - tvOS: the library appears in both the Movies and Series cascade dropdowns (with a layers glyph so the dual listing reads as one library) and browses as one merged grid. - iOS: the library appears in the Libraries picker labeled "Movies & Series" with the same merged grid. - A Type facet (Movies / Series, single-select) is offered first in the filter UI for mixed libraries only. It lowers to the catalog `type` media-scope param, always wins over the library-derived scope, and is emitted even on the iOS includeType:false path. Model changes: SiloMediaType.isMixedLibrary joins isSupportedLibrary; BrowseMediaType gains .mixed (no library-derived type scope, movie/series sort+facet vocabulary); CatalogFilterState gains mediaScope with chip, count, cache-key, and persistence support. iOS BrowseViewModel resolves the media family from the cached library list up front since a mixed library cannot be refined from its (movie or series) items. Validated on the tvOS simulator against the dev server's mixed library: dropdown placement, merged grid, and Type=Series server round-trip. Co-Authored-By: Claude Fable 5 <[email protected]>
📝 WalkthroughWalkthroughChangesMixed libraries are recognized as supported, propagated through browse configuration, exposed with movie/series filtering, encoded in catalog queries, and displayed consistently across iOS and tvOS. Tests cover visibility, media-type resolution, and grouped query behavior. Mixed library browsing
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant LibraryDetailView
participant BrowseView
participant BrowseViewModel
participant CatalogQueryBuilder
participant CatalogAPI
LibraryDetailView->>BrowseView: pass library type
BrowseView->>BrowseViewModel: configure library and type
BrowseViewModel->>BrowseViewModel: resolve mixed media type
BrowseViewModel->>CatalogQueryBuilder: provide filter state
CatalogQueryBuilder->>CatalogAPI: send grouped type rule
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
iosApp/Tests/CatalogQueryBuilderTests.swift (1)
50-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for cache discrimination and fixed Type options.
This test covers query emission, but not the new
mediaScopecache-key fragment orCatalogFacets.optionPairs(.itemType, ...). Add assertions proving movie and series selections produce different cache keys and exactly the expected fixed options.🤖 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 `@iosApp/Tests/CatalogQueryBuilderTests.swift` around lines 50 - 61, The testMixedLibraryTypeScope coverage should also validate cache discrimination and fixed item-type options. Add assertions using the relevant cache-key builder to confirm movie and series mediaScope selections produce different keys, and verify CatalogFacets.optionPairs(.itemType, ...) returns exactly the expected fixed Type options.iosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swift (1)
128-130: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winMake the Type scope type-safe.
mediaScopeis an unrestrictedString, while this facet only supportsmovieandseries. An invalid persisted or future caller value would be sent astype, then displayed as “Movies” because every value exceptseriesfalls through that branch. Use an enum or validate values during decoding/toggling.Also applies to: 221-222, 306-307
🤖 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 `@iosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swift` around lines 128 - 130, Make CatalogFilterState.mediaScope type-safe by replacing the unrestricted String? with an enum or enforcing validation during decoding and toggling so only movie, series, or nil can persist and reach the catalog type parameter. Update the related display logic and all referenced locations to handle the validated values explicitly, preventing invalid values from defaulting to “Movies.”
🤖 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.
Nitpick comments:
In `@iosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swift`:
- Around line 128-130: Make CatalogFilterState.mediaScope type-safe by replacing
the unrestricted String? with an enum or enforcing validation during decoding
and toggling so only movie, series, or nil can persist and reach the catalog
type parameter. Update the related display logic and all referenced locations to
handle the validated values explicitly, preventing invalid values from
defaulting to “Movies.”
In `@iosApp/Tests/CatalogQueryBuilderTests.swift`:
- Around line 50-61: The testMixedLibraryTypeScope coverage should also validate
cache discrimination and fixed item-type options. Add assertions using the
relevant cache-key builder to confirm movie and series mediaScope selections
produce different keys, and verify CatalogFacets.optionPairs(.itemType, ...)
returns exactly the expected fixed Type options.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: debac023-a066-41f6-9012-aa530d1950d6
📒 Files selected for processing (11)
iosApp/Tests/CatalogQueryBuilderTests.swiftiosApp/Tests/LibraryVisibilityTests.swiftiosApp/iosApp/Networking/Models.swiftiosApp/iosApp/Screens/Browse/BrowseViewModel.swiftiosApp/iosApp/Screens/Browse/Filtering/CatalogFacets.swiftiosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swiftiosApp/iosApp/Screens/Browse/Filtering/CatalogQueryBuilder.swiftiosApp/iosApp/Screens/Browse/Filtering/CatalogSortKey.swiftiosApp/iosApp/Screens/Browse/LibrariesTabView.swiftiosApp/iosApp/tvOS/Navigation/TVCascadeSelector.swiftiosApp/iosApp/tvOS/Navigation/TVTopMenuBar.swift
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a6b031d33
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@iosApp/iosApp/Screens/Browse/BrowseViewModel.swift`:
- Around line 31-46: In the configuration flow around resolveMediaType, when
libraryChanged is detected, immediately increment generation, reset currentPage,
hasMore, items, and filterState before awaiting metadata. Keep the
configuration-generation and cancellation guard intact, and avoid repeating the
same library-state reset after await; only apply the resolved media type and
final configuration after the guard succeeds.
🪄 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: 885a2713-2f97-4581-bf0d-150e71c5df69
📒 Files selected for processing (8)
iosApp/Tests/BrowseViewModelTests.swiftiosApp/Tests/CatalogQueryBuilderTests.swiftiosApp/iosApp/Screens/Browse/BrowseView.swiftiosApp/iosApp/Screens/Browse/BrowseViewModel.swiftiosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swiftiosApp/iosApp/Screens/Browse/Filtering/CatalogQueryBuilder.swiftiosApp/iosApp/Screens/Browse/Filtering/CatalogSortKey.swiftiosApp/iosApp/Screens/Browse/LibrariesTabView.swift
🚧 Files skipped from review as they are similar to previous changes (3)
- iosApp/iosApp/Screens/Browse/LibrariesTabView.swift
- iosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swift
- iosApp/iosApp/Screens/Browse/Filtering/CatalogSortKey.swift
| configurationGeneration += 1 | ||
| let myConfiguration = configurationGeneration | ||
| let libraryChanged = !hasConfigured || self.libraryId != libraryId | ||
| let resolvedMediaType = await resolveMediaType(libraryId: libraryId, libraryType: libraryType) | ||
| guard myConfiguration == configurationGeneration, !Task.isCancelled else { return false } | ||
|
|
||
| self.libraryId = libraryId | ||
| // Restore persisted sort/filters for this library + profile (no-op | ||
| // when the user turned "Preserve" off). | ||
| if let saved = BrowsePrefsStore.shared.savedState(libraryId: libraryId) { | ||
| filterState = saved | ||
| hasConfigured = true | ||
| mediaType = resolvedMediaType | ||
|
|
||
| if libraryChanged { | ||
| generation += 1 | ||
| currentPage = 0 | ||
| hasMore = true | ||
| items = [] | ||
| filterState = BrowsePrefsStore.shared.savedState(libraryId: libraryId) ?? .none |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Invalidate the prior library before awaiting metadata.
When the library type is uncached, resolveMediaType can await a network request while the previous library’s items remain visible and its in-flight load can still complete. Reset the generation and visible state immediately after detecting libraryChanged, before the await.
Proposed fix
configurationGeneration += 1
let myConfiguration = configurationGeneration
let libraryChanged = !hasConfigured || self.libraryId != libraryId
+ if libraryChanged {
+ generation += 1
+ currentPage = 0
+ hasMore = true
+ items = []
+ filterState = BrowsePrefsStore.shared.savedState(libraryId: libraryId) ?? .none
+ }
let resolvedMediaType = await resolveMediaType(libraryId: libraryId, libraryType: libraryType)
guard myConfiguration == configurationGeneration, !Task.isCancelled else { return false }
self.libraryId = libraryId
hasConfigured = true
mediaType = resolvedMediaType
- if libraryChanged {
- generation += 1
- currentPage = 0
- hasMore = true
- items = []
- filterState = BrowsePrefsStore.shared.savedState(libraryId: libraryId) ?? .none
- }
-
facets = FacetLoader.shared.cachedFacets(libraryId: libraryId)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| configurationGeneration += 1 | |
| let myConfiguration = configurationGeneration | |
| let libraryChanged = !hasConfigured || self.libraryId != libraryId | |
| let resolvedMediaType = await resolveMediaType(libraryId: libraryId, libraryType: libraryType) | |
| guard myConfiguration == configurationGeneration, !Task.isCancelled else { return false } | |
| self.libraryId = libraryId | |
| // Restore persisted sort/filters for this library + profile (no-op | |
| // when the user turned "Preserve" off). | |
| if let saved = BrowsePrefsStore.shared.savedState(libraryId: libraryId) { | |
| filterState = saved | |
| hasConfigured = true | |
| mediaType = resolvedMediaType | |
| if libraryChanged { | |
| generation += 1 | |
| currentPage = 0 | |
| hasMore = true | |
| items = [] | |
| filterState = BrowsePrefsStore.shared.savedState(libraryId: libraryId) ?? .none | |
| configurationGeneration += 1 | |
| let myConfiguration = configurationGeneration | |
| let libraryChanged = !hasConfigured || self.libraryId != libraryId | |
| if libraryChanged { | |
| generation += 1 | |
| currentPage = 0 | |
| hasMore = true | |
| items = [] | |
| filterState = BrowsePrefsStore.shared.savedState(libraryId: libraryId) ?? .none | |
| } | |
| let resolvedMediaType = await resolveMediaType(libraryId: libraryId, libraryType: libraryType) | |
| guard myConfiguration == configurationGeneration, !Task.isCancelled else { return false } | |
| self.libraryId = libraryId | |
| hasConfigured = true | |
| mediaType = resolvedMediaType | |
| facets = FacetLoader.shared.cachedFacets(libraryId: libraryId) |
🤖 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 `@iosApp/iosApp/Screens/Browse/BrowseViewModel.swift` around lines 31 - 46, In
the configuration flow around resolveMediaType, when libraryChanged is detected,
immediately increment generation, reset currentPage, hasMore, items, and
filterState before awaiting metadata. Keep the configuration-generation and
cancellation guard intact, and avoid repeating the same library-state reset
after await; only apply the resolved media type and final configuration after
the guard succeeds.
Summary
A server library of type
mixed(movies + series in one folder) was silently dropped at decode (isSupportedLibraryfiltering inLibrariesResponse) and never reached any UI. This PR surfaces it as a single browsable library — deliberately not split into per-type views:Implementation
SiloMediaType.isMixedLibraryjoinsisSupportedLibrary;Library.isMixedLibraryconvenience.BrowseMediaType.mixed: no library-derivedtypescope (items come back merged), movie/series sort + facet vocabulary.CatalogFacet.itemType+CatalogFilterState.mediaScope: single-select, lowers to the catalogtypemedia-scope param rather than a rule group. It is user-chosen and valid by construction, soCatalogQueryBuilderemits it even on the iOSincludeType: falsepath and it wins over the library-derived scope. Wired through chips, active-count badge, cache key, and per-library persistence.TVLibraryTabType.matches(): movies and series tabs both accept mixed; cascade rows swap in the layers glyph for mixed libraries.BrowseViewModelresolves the media family from the cached user-libraries list inconfigure— a mixed library cannot be refined from its first item (whose concrete type is movie or series), so refine now guards.mixed.type.Testing
LibraryVisibilityTestslocks in mixed as a supported library type.CatalogQueryBuilderTests.testMixedLibraryTypeScopecovers the media-scope wire format (merged by default, facet always scopes, no rule group).Out of scope (cross-repo follow-ups)
TvLibraryTabType.matcheshas no mixed case); phone shows them generically with no Type scope.🤖 Generated with Claude Code
Summary by CodeRabbit