Repository navigation
fix(tvos): keep the playback HUD's focus owner stable across replans - #207
Conversation
Selecting a subtitle or audio track from the tvOS playback HUD could blank the HUD, drop it back on the Info tab, and leave the remote driving the video behind the menu — a Down press then snapped the HUD to Video. Three host-layer causes, all of which predate the HUD's own focus graph: - Under Protocol V3 a track change issues a server replan, which sets `isLoading`. `TVPlayerControls` was mounted on `!isLoading`, so the selecting press unmounted the open HUD and destroyed its `@State` and `@FocusState`, resetting the remembered tab and reseeding focus. The controls host now stays mounted through a replan while the HUD is up; replacement loads still tear it down, and close the HUD explicitly as they reset published state. - `selectSubtitle` / `selectAudio` end in `scheduleHideControls()`, which re-armed the auto-hide that `openHUD`'s `pinControlsVisible()` had cancelled. The 5s hide then pulled the HUD's host out from under it. `scheduleHideControls` now re-pins instead while the HUD is presented; `closeHUD` restores normal auto-hide. - `TVPressCaptureView` mounted on `!showControls` alone, so once that auto-hide fired the fullscreen press sink sat beneath the open HUD — two owners for one press, the hybrid docs/tvos-focus.md forbids. Its Down handler calls `openSettingsHUD()`, which is what forced the tab to Video. It is now also gated on `!isHUDPresented`. Menu handling is reordered to match: `isHUDPresented` is checked before the `isLoading` escape so Menu during a HUD-initiated replan closes the HUD rather than exiting the player. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughtvOS player handling now preserves the transport HUD during loading and replanning. It suppresses competing press capture, pins controls while the HUD is open, clears the HUD for replacement loads, and closes the HUD before Menu dismisses the player. ChangestvOS HUD flow
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant tvOSMenu
participant PlayerView
participant PlayerViewModel
participant PressCaptureView
tvOSMenu->>PlayerView: Menu press
PlayerView->>PlayerViewModel: closeHUD()
PlayerViewModel-->>PlayerView: Clear HUD presentation state
PlayerViewModel->>PlayerView: Keep controls mounted during HUD loading
PlayerView->>PressCaptureView: Suppress press capture while HUD is presented
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Problem
Selecting a subtitle (or audio) track from the tvOS playback HUD misbehaved: the HUD would blank and come back on the Info tab, and in some timings the remote stopped moving through the menu entirely — Left/Right skipped the video behind it, and Down snapped the HUD to the Video tab.
The HUD's own focus graph (
TVPlayerInfoHUD) is fine and followsdocs/tvos-focus.md. All three causes are in the host layer, and all three surfaced when Protocol V3 made a track change into a server replan.Causes and fixes
1. A replan unmounted the open HUD. Under V3,
selectSubtitle/selectAudiogo throughattemptProtocolV3Replan, which setsisLoading.TVPlayerControlswas mounted on!isLoading, so the selecting press tore down the HUD mid-press, destroying its@State/@FocusState— including the rememberedactiveHUDTab— and reseeded focus from scratch on remount.The controls host now stays mounted through a replan while the HUD is presented. Replacement loads still unmount as before, and now close the HUD explicitly in
resetPublishedLoadStatesince its content belongs to the outgoing item.2. Track selection re-armed the auto-hide the HUD had cancelled. Both selection paths end in
scheduleHideControls(), undoing thepinControlsVisible()thatopenHUD()set. Five seconds later the hide fired and pulled the HUD's host out from under it.scheduleHideControlsnow re-pins instead of scheduling whileisHUDPresented;closeHUD()calls back in after clearing the flag, restoring the normal lifecycle.3. The press sink could mount beneath the open HUD.
TVPressCaptureViewwas gated on!showControlswithout regard for the HUD, so once (2) fired, the fullscreen sink and the HUD's focus graph were two owners for the same presses — the hybriddocs/tvos-focus.mdwarns against. Its Down handler callsopenSettingsHUD(), which is what forced the tab to Video. Now also gated on!isHUDPresented.Menu handling is reordered to match:
isHUDPresentedis checked before theisLoadingescape, so Menu during a HUD-initiated replan closes the HUD rather than exiting the player. A stalled load stays escapable — the first Menu closes the HUD, the next falls through.Validation
SiloTVcompiles clean (generic/platform=tvOS).PlaybackProtocolV3Tests+AetherPlaybackBoundaryTestspass.SiloTestssuite, and hands-on confirmation of the corrected focus behavior on the device. Worth a manual pass on hardware before merge.No behavior change on iOS or macOS — the mount gates and press sink are tvOS-only, and
openHUDhas no non-tvOS callers.🤖 Generated with Claude Code
Summary by CodeRabbit