Skip to content

Add mixed library support to iOS and tvOS - #93

Merged
Quick104 merged 2 commits into
mainfrom
feature/mixed-libraries
Jul 22, 2026
Merged

Quick104 merged 2 commits into
mainfrom
feature/mixed-libraries

Conversation

@Quick104

@Quick104 Quick104 commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A server library of type mixed (movies + series in one folder) was silently dropped at decode (isSupportedLibrary filtering in LibrariesResponse) and never reached any UI. This PR surfaces it as a single browsable library — deliberately not split into per-type views:

  • tvOS: the mixed library appears as a row in both the Movies and Series cascade dropdowns, marked with a layers glyph so the dual listing reads as one library, not two. Selecting it gives the normal Recommended / Collections / Browse sections over the full merged catalog.
  • iOS: the library appears in the Libraries picker labeled "Movies & Series" and browses the same merged grid.
  • Narrowing is filtering, not navigation: a new Type facet (Movies / Series, single-select) is offered first in the filter panel/sheet, only for mixed libraries. Movies and series already share identical sort and facet vocabularies, so the merged grid needs no other filter changes.

Implementation

  • SiloMediaType.isMixedLibrary joins isSupportedLibrary; Library.isMixedLibrary convenience.
  • BrowseMediaType.mixed: no library-derived type scope (items come back merged), movie/series sort + facet vocabulary.
  • CatalogFacet.itemType + CatalogFilterState.mediaScope: single-select, lowers to the catalog type media-scope param rather than a rule group. It is user-chosen and valid by construction, so CatalogQueryBuilder emits it even on the iOS includeType: false path 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.
  • iOS BrowseViewModel resolves the media family from the cached user-libraries list in configure — a mixed library cannot be refined from its first item (whose concrete type is movie or series), so refine now guards .mixed.
  • Downstream (detail, playback, Top Shelf, home rows) needed no changes: everything already routes on per-item type.

Testing

  • LibraryVisibilityTests locks in mixed as a supported library type.
  • CatalogQueryBuilderTests.testMixedLibraryTypeScope covers the media-scope wire format (merged by default, facet always scopes, no rule group).
  • Silo (iOS), SiloTV, and SiloMac all build green; focused test suites pass.
  • Validated live on the tvOS simulator against the dev server's mixed "Sports" library (677 items): dropdown placement in both tabs, merged grid (series interleaved with movies), and a Type=Series server round-trip narrowing the grid.

Out of scope (cross-repo follow-ups)

  • silo-server: mixed libraries fall to the generic section defaults — no movie/series-scoped rows, so the Recommended pill is thinner than for dedicated libraries.
  • silo-android: Android TV orphans mixed libraries entirely (TvLibraryTabType.matches has no mixed case); phone shows them generically with no Type scope.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for mixed “Movies & Series” libraries across browsing, library selection, and TV navigation.
    • Introduced a new “Type” (movie/series) facet for mixed libraries.
  • Bug Fixes
    • Improved mixed-library filtering behavior by correctly scoping the Type facet within the active match logic.
    • Preserved filter state and selected type scope when reloading and using cached results.
    • Updated Movies/Series tab matching to include mixed libraries.

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]>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Mixed 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

Layer / File(s) Summary
Mixed library type contracts
iosApp/iosApp/Networking/Models.swift, iosApp/iosApp/Screens/Browse/Filtering/CatalogSortKey.swift, iosApp/Tests/LibraryVisibilityTests.swift
Mixed libraries are recognized as supported, mapped to .mixed, assigned movie/series sort behavior, and included in visibility expectations.
Mixed-library type filtering
iosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swift, iosApp/iosApp/Screens/Browse/Filtering/CatalogFacets.swift, iosApp/iosApp/Screens/Browse/Filtering/CatalogQueryBuilder.swift, iosApp/Tests/CatalogQueryBuilderTests.swift
A single-select item-type facet stores movie or series scope, renders fixed options and chips, affects cache keys, and emits scoped type rules in grouped catalog queries.
Browse media type restoration
iosApp/iosApp/Screens/Browse/BrowseView.swift, iosApp/iosApp/Screens/Browse/BrowseViewModel.swift, iosApp/Tests/BrowseViewModelTests.swift, iosApp/iosApp/Screens/Browse/LibrariesTabView.swift
Browse configuration receives or resolves library type metadata, reloads when configuration changes, hydrates state after media-type resolution, and preserves mixed media type during catalog loading.
Mixed-library presentation
iosApp/iosApp/Screens/Browse/LibrariesTabView.swift, iosApp/iosApp/tvOS/Navigation/TVCascadeSelector.swift, iosApp/iosApp/tvOS/Navigation/TVTopMenuBar.swift
iOS and tvOS library controls display mixed libraries with dedicated labels and icons, and movie and series tabs match them.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.63% which is insufficient. The required threshold is 80.00%. 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 matches the main change: adding mixed library support across iOS and tvOS.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/mixed-libraries

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

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
iosApp/Tests/CatalogQueryBuilderTests.swift (1)

50-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for cache discrimination and fixed Type options.

This test covers query emission, but not the new mediaScope cache-key fragment or CatalogFacets.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 win

Make the Type scope type-safe.

mediaScope is an unrestricted String, while this facet only supports movie and series. An invalid persisted or future caller value would be sent as type, then displayed as “Movies” because every value except series falls 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7d9e7b4 and 6a6b031.

📒 Files selected for processing (11)
  • iosApp/Tests/CatalogQueryBuilderTests.swift
  • iosApp/Tests/LibraryVisibilityTests.swift
  • iosApp/iosApp/Networking/Models.swift
  • iosApp/iosApp/Screens/Browse/BrowseViewModel.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogFacets.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogQueryBuilder.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogSortKey.swift
  • iosApp/iosApp/Screens/Browse/LibrariesTabView.swift
  • iosApp/iosApp/tvOS/Navigation/TVCascadeSelector.swift
  • iosApp/iosApp/tvOS/Navigation/TVTopMenuBar.swift

@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: 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".

@Quick104
Quick104 merged commit 9425957 into main Jul 22, 2026
1 check was pending
@Quick104
Quick104 deleted the feature/mixed-libraries branch July 22, 2026 14:04

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a6b031 and d6d227f.

📒 Files selected for processing (8)
  • iosApp/Tests/BrowseViewModelTests.swift
  • iosApp/Tests/CatalogQueryBuilderTests.swift
  • iosApp/iosApp/Screens/Browse/BrowseView.swift
  • iosApp/iosApp/Screens/Browse/BrowseViewModel.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogFilterState.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogQueryBuilder.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogSortKey.swift
  • iosApp/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

Comment on lines +31 to +46
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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.

Suggested change
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.

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