Repository navigation
Refine tvOS playback selection and direct navigation - #83
Conversation
|
Warning Review limit reached
Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe PR revises playback label formatting, adds tvOS focused-card direct playback and selector persistence, routes episode playback destinations, improves subtitle focus handling, and replaces single subtitle overlay references with owned attachment registries. ChangesPlayback label formatting
tvOS direct playback and navigation
Subtitle overlay lifecycle
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 084d441d0c
ℹ️ 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".
| var subtitleOverlay: SubtitleOverlayView? { | ||
| subtitleOverlayAttachments.currentOverlay |
There was a problem hiding this comment.
Migrate macOS surfaces before removing overlay setters
When building the SiloMac target, the macOS surfaces still assign to the old mutable overlay property (iosApp/iosApp/macOS/AVPlayerSurface.swift:12,19 and iosApp/iosApp/macOS/PlayerSurface.swift:51), but this change makes subtitleOverlay get-only here and applies the same pattern to PlayerCore. That leaves both macOS player surfaces uncompilable; update the NSViewRepresentable surfaces to use the new attach/detach API or keep a compatible setter.
Useful? React with 👍 / 👎.
| router.presentPlayer( | ||
| contentId: id, | ||
| startFromBeginning: false, | ||
| resumePosition: resumePosition, | ||
| returnToContentId: id == detail.contentId ? nil : id |
There was a problem hiding this comment.
Preserve selector choices for the current rail episode
When this handler is invoked for the rail card that represents the current episode, it starts playback via presentPlayer without fileId, preferredAudioTrackIndex, or preferredSubtitleTrackIndex, so a user who changed Version/Audio/Subtitles on the detail page gets the default file/tracks by pressing Select on the highlighted current episode card. The main Play path and the new Play/Pause shortcut preserve those choices via playbackFileId(for:); this current-episode branch should do the same or remain a no-op.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
iosApp/iosApp/Screens/Player/CoreMedia/PlayerSurface.swift (1)
88-97: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winDetach from the previous player before re-attaching.
When
attach(player:)is called with a differentPlayerCore(player swap viaupdateUIView), the old player's registry retains a stale entry for this view. Bothownerandoverlayweak references remain alive (the view and its overlay are still allocated), sopruneReleasedEntrieswon't clean them up. The old player'ssubtitleOverlaycomputed property can then return this view's overlay even though itsrendererhas been repointed to the new player — risking subtitle rendering through the wrong renderer session.During Next Up transitions where the outgoing player stays alive (mini-player), this stale entry is actively reachable.
🔧 Proposed fix: detach before player swap
func attach(player: PlayerCore) { if attachedPlayer === player { return } + attachedPlayer?.detachSubtitleOverlay(owner: self) attachedPlayer = player player.attach(to: displayLayer)🤖 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/Player/CoreMedia/PlayerSurface.swift` around lines 88 - 97, Update attach(player:) to detach the existing attachedPlayer before assigning a different player, while preserving the early return when it is the same instance. Invoke the existing player detachment/overlay cleanup API so the old player's registry removes this view, then attach the new player and rewire subtitleOverlay.renderer and attachSubtitleOverlay as currently done.
🧹 Nitpick comments (4)
iosApp/iosApp/Screens/Personal/FavoritesView.swift (1)
83-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract shared
playAction(for:)to eliminate duplication across browse views.The identical
playAction(for: BrowseItem)implementation appears inFavoritesView,WatchlistView,CatalogGrid,CollectionDetailView, andTVCatalogGrid. A shared helper (e.g., a free function orViewextension takingBrowseItemandAppRouter) would centralize theisDirectlyPlayableguard andpresentPlayercall, ensuring future changes propagate to all entry points.♻️ Proposed shared helper
// e.g., in a shared file like PlaybackActions.swift or as an extension on View `@MainActor` func browseItemPlayAction(for item: BrowseItem, router: AppRouter) -> (() -> Void)? { `#if` os(tvOS) guard SiloMediaType.isDirectlyPlayable(item.type) else { return nil } return { router.presentPlayer( contentId: item.contentId, posterURL: item.posterUrl, backdropURL: item.backdropUrl ) } `#else` return nil `#endif` }Then each call site becomes:
- playAction: playAction(for: item), + playAction: browseItemPlayAction(for: item, router: router),🤖 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/Personal/FavoritesView.swift` around lines 83 - 97, Extract the duplicated playAction(for:) logic from FavoritesView, WatchlistView, CatalogGrid, CollectionDetailView, and TVCatalogGrid into one shared `@MainActor` helper accepting BrowseItem and AppRouter. Preserve the tvOS isDirectlyPlayable guard, presentPlayer arguments, and non-tvOS nil behavior, then update each view to call the shared helper.iosApp/iosApp/Components/EpisodeThumbCard.swift (1)
344-352: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate helper — same body as
TVMediaCard.applyTVCardPlayPauseAction.This
applyEpisodePlayPauseActionis structurally identical to the privateapplyTVCardPlayPauseActioninTVMediaCard.swift(per the upstream-contract snippet). Consider consolidating into one sharedViewextension (e.g.applyPlayPauseCommand(_:)) used by both card types so future tweaks to this pattern don't need to be applied twice.♻️ Suggested consolidation
-private extension View { - `@ViewBuilder` - func applyEpisodePlayPauseAction(_ action: (() -> Void)?) -> some View { - if let action { - self.onPlayPauseCommand(perform: action) - } else { - self - } - } +// Shared, e.g. in a common file: +extension View { + `@ViewBuilder` + func applyPlayPauseCommand(_ action: (() -> Void)?) -> some View { + if let action { + self.onPlayPauseCommand(perform: action) + } else { + self + } + } +}🤖 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/Components/EpisodeThumbCard.swift` around lines 344 - 352, Remove the duplicated applyEpisodePlayPauseAction helper and consolidate the shared optional play/pause action behavior into a single View extension, such as applyPlayPauseCommand(_:). Update both the episode card and TVMediaCard call sites, including applyTVCardPlayPauseAction, to use the shared helper and preserve the existing nil behavior.iosApp/iosApp/Screens/Browse/CatalogGrid.swift (1)
62-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated
playAction(for:)across multiple browse/collection views.This exact
#if os(tvOS)+isDirectlyPlayable+presentPlayer(...)block is repeated verbatim inCollectionDetailView.swiftin this PR, and (per cross-file evidence) inFavoritesView.swift,WatchlistView.swift, andTVCatalogGrid.swift. Consider hoisting this into a single helper (e.g. anAppRouterextension or a free function takingrouter+item) so the direct-play gating logic has one source of truth.♻️ Suggested consolidation
extension AppRouter { `#if` os(tvOS) func directPlayAction(for item: BrowseItem) -> (() -> Void)? { guard SiloMediaType.isDirectlyPlayable(item.type) else { return nil } return { [weak self] in self?.presentPlayer( contentId: item.contentId, posterURL: item.posterUrl, backdropURL: item.backdropUrl ) } } `#endif` }Callers then become
router.directPlayAction(for: item)(returnsnilautomatically on non-tvOS since the method itself is#if os(tvOS)-gated — non-tvOS call sites would need their ownnilfallback or a non-tvOS stub).🤖 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/CatalogGrid.swift` around lines 62 - 76, Consolidate the duplicated tvOS direct-play logic from playAction(for:) and the corresponding browse/collection views into one shared helper, preferably an AppRouter method named directPlayAction(for:). Preserve the isDirectlyPlayable guard, player arguments, weak router capture, and non-tvOS nil behavior, then update all affected callers to use the shared helper.iosApp/iosApp/Screens/Personal/WatchlistView.swift (1)
83-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract duplicated
playAction(for:)into a shared helper.The same
playAction(for:)method is copy-pasted across at least 7 files (WatchlistView,FavoritesView,CatalogGrid,CollectionDetailView,MediaCard,TVCatalogGrid,TVMediaCard), all producing an identicalrouter.presentPlayer(contentId:posterURL:backdropURL:)closure gated bySiloMediaType.isDirectlyPlayable. Extracting this to anAppRouterextension would give a single source of truth for the direct-play contract.♻️ Proposed extraction
// In a shared file, e.g. AppRouter+DirectPlay.swift extension AppRouter { func directPlayAction(for item: BrowseItem) -> (() -> Void)? { `#if` os(tvOS) guard SiloMediaType.isDirectlyPlayable(item.type) else { return nil } return { presentPlayer( contentId: item.contentId, posterURL: item.posterUrl, backdropURL: item.backdropUrl ) } `#else` return nil `#endif` } }Each call site then becomes:
- playAction: playAction(for: item), + playAction: router.directPlayAction(for: item),and the per-file
playAction(for:)methods can be deleted.🤖 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/Personal/WatchlistView.swift` around lines 83 - 97, Extract the duplicated playAction(for:) logic into a shared AppRouter extension method named directPlayAction(for:), preserving the tvOS availability guard and presentPlayer closure behavior. Update WatchlistView and the other listed call sites to invoke router.directPlayAction(for:), then remove their local playAction(for:) implementations.
🤖 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/Detail/DetailPlaybackFormatting.swift`:
- Around line 482-483: Unify forced-track detection between subtitleDetail and
subtitlePillSummary. Replace the direct track.forced == true check in
subtitleDetail with the shared isForced(track) logic, or otherwise route both
subtitleDetail and subtitlePillSummary through the same helper so title-based
forced detection is handled consistently.
- Around line 641-647: Update containsAccessibilityMarker to also detect the
phrase “hearing impaired,” matching the substring behavior of
SubtitleAutoResolver.titleIndicatesHearingImpaired while preserving the existing
SDH, CC, and HI checks, so subtitlePillSummary does not append a redundant
“(SDH)”.
In `@iosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerSurface.swift`:
- Around line 30-35: Update AVPlayerLayerView.attach(backend:) to detach the
subtitle overlay from the currently stored backend before replacing it with the
new backend, then register it with the new backend as needed. Keep
updateUIView’s attachment flow unchanged and ensure repeated backend swaps do
not leave the overlay in the old backend’s registry.
---
Outside diff comments:
In `@iosApp/iosApp/Screens/Player/CoreMedia/PlayerSurface.swift`:
- Around line 88-97: Update attach(player:) to detach the existing
attachedPlayer before assigning a different player, while preserving the early
return when it is the same instance. Invoke the existing player
detachment/overlay cleanup API so the old player's registry removes this view,
then attach the new player and rewire subtitleOverlay.renderer and
attachSubtitleOverlay as currently done.
---
Nitpick comments:
In `@iosApp/iosApp/Components/EpisodeThumbCard.swift`:
- Around line 344-352: Remove the duplicated applyEpisodePlayPauseAction helper
and consolidate the shared optional play/pause action behavior into a single
View extension, such as applyPlayPauseCommand(_:). Update both the episode card
and TVMediaCard call sites, including applyTVCardPlayPauseAction, to use the
shared helper and preserve the existing nil behavior.
In `@iosApp/iosApp/Screens/Browse/CatalogGrid.swift`:
- Around line 62-76: Consolidate the duplicated tvOS direct-play logic from
playAction(for:) and the corresponding browse/collection views into one shared
helper, preferably an AppRouter method named directPlayAction(for:). Preserve
the isDirectlyPlayable guard, player arguments, weak router capture, and
non-tvOS nil behavior, then update all affected callers to use the shared
helper.
In `@iosApp/iosApp/Screens/Personal/FavoritesView.swift`:
- Around line 83-97: Extract the duplicated playAction(for:) logic from
FavoritesView, WatchlistView, CatalogGrid, CollectionDetailView, and
TVCatalogGrid into one shared `@MainActor` helper accepting BrowseItem and
AppRouter. Preserve the tvOS isDirectlyPlayable guard, presentPlayer arguments,
and non-tvOS nil behavior, then update each view to call the shared helper.
In `@iosApp/iosApp/Screens/Personal/WatchlistView.swift`:
- Around line 83-97: Extract the duplicated playAction(for:) logic into a shared
AppRouter extension method named directPlayAction(for:), preserving the tvOS
availability guard and presentPlayer closure behavior. Update WatchlistView and
the other listed call sites to invoke router.directPlayAction(for:), then remove
their local playAction(for:) implementations.
🪄 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: 9f1744c7-b548-47a7-95ec-75743edb508e
📒 Files selected for processing (29)
iosApp/Tests/DetailVersionSelectionTests.swiftiosApp/iosApp/Components/EpisodeThumbCard.swiftiosApp/iosApp/Components/MediaCard.swiftiosApp/iosApp/Components/MediaRow.swiftiosApp/iosApp/Navigation/AppRouter.swiftiosApp/iosApp/Networking/Models.swiftiosApp/iosApp/Screens/Browse/CatalogGrid.swiftiosApp/iosApp/Screens/Collections/CollectionDetailView.swiftiosApp/iosApp/Screens/Detail/DetailPlaybackFormatting.swiftiosApp/iosApp/Screens/Detail/ItemDetailViewModel.swiftiosApp/iosApp/Screens/Home/SectionRow.swiftiosApp/iosApp/Screens/Personal/FavoritesView.swiftiosApp/iosApp/Screens/Personal/WatchlistView.swiftiosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerBackend.swiftiosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerSurface.swiftiosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swiftiosApp/iosApp/Screens/Player/CoreMedia/PlayerSurface.swiftiosApp/iosApp/Screens/Player/PlayerView.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleOverlayView.swiftiosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swiftiosApp/iosApp/tvOS/Navigation/TVMainTabView.swiftiosApp/iosApp/tvOS/Screens/Components/TVCatalogGrid.swiftiosApp/iosApp/tvOS/Screens/Components/TVMediaCard.swiftiosApp/iosApp/tvOS/Screens/Detail/TVEpisodeRail.swiftiosApp/iosApp/tvOS/Screens/Detail/TVItemDetailView.swiftiosApp/iosApp/tvOS/Screens/Detail/TVMovieDetailView.swiftiosApp/iosApp/tvOS/Screens/Detail/TVPlaybackSelectorRow.swiftiosApp/iosApp/tvOS/Screens/Detail/TVSeasonDetailView.swiftiosApp/iosApp/tvOS/Screens/Detail/TVSeriesDetailView.swift
- Introduced a new test to ensure subtitle labels do not duplicate title-based markers. - Updated subtitle formatting logic to prevent redundancy in displayed titles. - Enhanced subtitle overlay management in AVPlayer and PlayerSurface classes for better resource handling. - Improved tvOS detail view to manage playback state more effectively for current episodes.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6ffe06624
ℹ️ 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".
| /// types such as series and seasons still open their detail screen. | ||
| static func isDirectlyPlayable(_ type: String) -> Bool { | ||
| isMovieLibrary(type) | ||
| || isAudiobook(type) |
There was a problem hiding this comment.
Route audiobook shortcuts through the audio player
When the focused item is an audiobook, this now returns true, so the new tvOS Play/Pause handlers in the browsing/home surfaces call router.presentPlayer(...) and open the video PlayerView. Audiobook playback elsewhere is explicitly routed through AudioPlaybackStore (for example the audiobook detail and play deep-link paths), and PlayerView has no audiobook-specific path, so pressing Play/Pause on an audiobook card opens the wrong player instead of starting audio. Route audiobook items to the audio store or keep them out of this video-player shortcut.
Useful? React with 👍 / 👎.
Summary
This PR collects a set of focused tvOS UI and playback-flow fixes made during device testing:
Playback selector presentation
Auto:when selection is automatic.4k.tvicon with the generictvicon so non-4K content is represented correctly.SRTname.Focus and episode navigation
Direct playback from browsing surfaces
Focused playable cards now handle the Siri Remote Play/Pause command independently from Select:
Subtitle continuity through Next Up
The pre-end Next Up UI swaps the full-screen player surface for a mini-player and then mounts a new full-screen surface when Keep Watching is selected.
Device launch logs showed that playback and the selected subtitle track remained active, but the outgoing mini-player could remain the last writer to a single weak subtitle-overlay reference. Once that surface deallocated, the subtitle pump had no overlay and stopped rendering.
This PR replaces that single weak reference with a small weak attachment registry:
This fixes the ownership problem directly without restarting the video session or changing the selected subtitle track.
Validation
git diff --checkxcodebuild build -project Silo.xcodeproj -scheme SiloTV -destination 'generic/platform=tvOS' -derivedDataPath /tmp/silo-apple-subtitle-fix CODE_SIGNING_ALLOWED=NOSummary by CodeRabbit
New Features
Improvements
Bug Fixes