Repository navigation
feat(search): include episodes in All results on servers that support it - #630
Conversation
Search "All" with audiobooks hidden sent type=video, which covers movies and series only, so episodes never appeared (a search for "Pilot" showed No results). Servers that advertise video_with_episodes_scope in GET /api/v2/catalog/search/capabilities now get type=video_with_episodes for that case, and the same value as the people media_scope. Older servers keep video, because they ignore the new value on the catalog and reject it on people search. The Watch Party picker, which reuses the search model, keeps video. The capabilities read that already gated people search is now shared by the title and people lookups and runs once per search model. BrowseItem decodes series_id, series_title, season_number, and episode_number. The iOS and tvOS catalog grids caption episode cards with the series name and "S01E02 · Pilot", reusing EpisodeCardCaption from Home, and an episode card opens its series on that episode directly. Resynced the API v2 contract fixtures to the server commit that adds the scope (09c4ac176, from the server pull request that adds it); they need one more resync once that commit lands on server main.
…ties can't be read When the server stopped answering during a search, the capabilities read timed out after 15 seconds and Search quietly fell back to type=video. Once the server came back, an episode such as "Grilled" showed No results. The 401 in the server log was for that abandoned request: the server checked the session after the client had already disconnected, so the client never received the 401. The capabilities read uses the same authenticated path as the catalog and people reads and refreshes on a 401 like they do. Search now narrows All to video only when the server actually answers without video_with_episodes_scope, or has no capabilities read (a v1-only server, or a 404). A timeout, lost connection, or refused credentials fails the search with the usual Try Again error, and the failed read is not kept, so the retry asks again. While a new search waits for capabilities, titles, or people, Search shows the result grid's loading state (poster placeholders on iOS and macOS, a spinner on tvOS) instead of a blank page. The view model now decides which state the screen shows, and the view switches on that.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (30)
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 |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| } | ||
|
|
||
| static func isEpisode(_ item: SectionItem) -> Bool { | ||
| static func isEpisode(_ item: some EpisodeCaptionSource) -> Bool { |
There was a problem hiding this comment.
Episode caption loss occurs in iosApp/iosApp/Components/EpisodeCardCaption.swift because the generalized isEpisode(_:) predicate handles catalog rows but recognizes only the lowercased string "episode" without trimming whitespace, rejecting accepted "episodes" values and whitespace-padded episode types. Use a shared API normalization helper that trims whitespace, compares case-insensitively, and recognizes both "episode" and "episodes".
Kody rule violation: Use consistent API normalization and production-equivalent decoding
Prompt for LLM
File iosApp/iosApp/Components/EpisodeCardCaption.swift:
Line 27:
Episode caption loss occurs in iosApp/iosApp/Components/EpisodeCardCaption.swift because the generalized isEpisode(_:) predicate handles catalog rows but recognizes only the lowercased string "episode" without trimming whitespace, rejecting accepted "episodes" values and whitespace-padded episode types. Use a shared API normalization helper that trims whitespace, compares case-insensitively, and recognizes both "episode" and "episodes".
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Not changing. The predicate is unchanged from main (item.type.lowercased() == "episode"); this PR only widens its parameter from SectionItem to the protocol. The server emits episode rows with the literal type episode: catalog search builds them as 'episode'::text (the search indexer and exact-episode search), and Home section rows use the same value. No v2 endpoint sends episodes or a padded type for an item, so there is nothing for the extra normalization to match.
There was a problem hiding this comment.
Agreed—this suggestion is a false positive. I incorrectly assumed that episodes and whitespace-padded values were accepted item types without evidence.
Given the server contract you described, item.type.lowercased() == "episode" handles the emitted value correctly. Widening the parameter to EpisodeCaptionSource doesn’t change that behavior, so no normalization change is warranted for this PR.
#630 and #575 each added seriesId, seriesTitle, seasonNumber and episodeNumber to BrowseItem. Both landed on main, so the struct declares them twice and neither the iOS nor the tvOS app compiles. Keep the copy #575 placed beside the progress fields, which the Watch Party series row initializer passes in that order, and drop the duplicate arguments in init(sectionItem:). Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Related issue: Silo-Server/silo-server#1249
Validation tasks: changes #337 C1
Dependency: the server side is Silo-Server/silo-server#1995. This PR works against servers with or without it (it checks a capability flag), so it can merge in either order. Its API v2 fixtures are synced from that PR's branch; run
scripts/sync-apiv2-fixtures.shonce more after the server PR merges.Search "All" with audiobooks hidden sent
type=video, which covers movies and series only, so episodes never appeared: a search for "Pilot" showed No results. On servers that advertise the newvideo_with_episodesscope, "All" now includes episodes, captioned with their series and episode code.Approach
video_with_episodes_scopeinGET /api/v2/catalog/search/capabilitiesgettype=video_with_episodesfor "All", and the same value as the peoplemedia_scope. Older servers keepvideo, because they ignore the new value on the catalog and reject it on people search. The Watch Party picker keepsvideo.video; a server without the read (404 or v1-only) offers no extra features.BrowseItemdecodesseries_id,series_title,season_numberandepisode_number. iOS and tvOS grids caption episode cards with the series name and "S01E02 · Pilot", and an episode card opens its series on that episode.Validation
build-for-testingon this branch: pass.scripts/ci/check-no-api-v1.sh: pass.main(6242652): the full iOS unit suite ran 2,691 tests. The only failures areArtworkURLTests.testDeliveryCapabilityOnIOSUsesV2RouteAndResetsandImageSizeCapabilityTests.testResetClearsCapability, which fail the same way onmain. tvOSbuild-for-testingand the macOS build succeed.Simulator screenshots (iOS 26.5, tvOS 26.5):
Risks
None identified for older servers; they keep today's behaviour.
Checklist
AI Disclosure
mainat medium effort, checking behaviour, platform guards (iOS, tvOS, macOS), tests and commit hygiene. It found that on iOS and macOS a tapped episode result loaded the episode page before redirecting to the series, because the card handled the tap itself. Episode cards now open the series directly. It also noted the fixtures pin a branch-only server commit, which the dependency note above covers.Note
Include episodes in All search results on servers that support episode search
The Search screen now checks the server's search capabilities before an All-filter search. If the server exposes the new episode-search scope, the All filter uses the episode-inclusive scope; otherwise it keeps the video-only scope.
SiloAPI.catalogSearchFeaturesreturns normalized people and episode-scope support; 404 or server-update-required responses map to unsupported features, while other errors propagate (SiloAPI.swift)SearchViewModelresolves the media scope once per search, shares one cached in-flight capability read across concurrent title and people work, and retries after a failed read (SearchViewModel.swift)BrowseItemand section-item converters now carry series id, series title, season, and episode number. Episode cards show the series title as the primary caption and the episode code/title as secondary (Models.swift, EpisodeCardCaption.swift)SearchContentStatewith a platform-specific loading view while a search is pending (SearchView.swift)SearchViewModel.loadSearchFeaturesandmediaScopeMacroscope summarized e4df997.