Skip to content

fix(tvos): keep the playback HUD's focus owner stable across replans - #207

Merged
Quick104 merged 1 commit into
mainfrom
claude/tvos-playback-hud-focus-behavior-6a6dd1
Aug 29, 2026
Merged

Quick104 merged 1 commit into
mainfrom
claude/tvos-playback-hud-focus-behavior-6a6dd1

Conversation

@Quick104

@Quick104 Quick104 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

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 follows docs/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 / selectAudio go through attemptProtocolV3Replan, which sets isLoading. TVPlayerControls was mounted on !isLoading, so the selecting press tore down the HUD mid-press, destroying its @State/@FocusState — including the remembered activeHUDTab — 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 resetPublishedLoadState since 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 the pinControlsVisible() that openHUD() set. Five seconds later the hide fired and pulled the HUD's host out from under it.

scheduleHideControls now re-pins instead of scheduling while isHUDPresented; closeHUD() calls back in after clearing the flag, restoring the normal lifecycle.

3. The press sink could mount beneath the open HUD. TVPressCaptureView was gated on !showControls without 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 hybrid docs/tvos-focus.md warns against. Its Down handler calls openSettingsHUD(), which is what forced the tab to Video. 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. A stalled load stays escapable — the first Menu closes the HUD, the next falls through.

Validation

  • SiloTV compiles clean (generic/platform=tvOS).
  • Signed device build succeeds; installed and launched on an Apple TV 4K (3rd gen), tvOS device build.
  • PlaybackProtocolV3Tests + AetherPlaybackBoundaryTests pass.
  • Not yet done: the full SiloTests suite, 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 openHUD has no non-tvOS callers.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved the tvOS player HUD behavior during loading and content changes.
    • The transport controls now remain available while in-HUD loading or replanning is underway.
    • Presses are routed consistently while the HUD is open, preventing accidental dismissal.
    • Menu now closes the HUD before dismissing a loading player.
    • Replacing the current item automatically closes the options HUD.

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-29T01:35:26.369340Z d23d573 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Quick104
Quick104 merged commit 1c4ef72 into main Aug 29, 2026
1 check was pending
@Quick104
Quick104 deleted the claude/tvos-playback-hud-focus-behavior-6a6dd1 branch August 29, 2026 01:34
@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 986b5bd9-3386-45cf-9d50-14326737fb27

📥 Commits

Reviewing files that changed from the base of the PR and between 08a55ec and d23d573.

📒 Files selected for processing (2)
  • iosApp/iosApp/Screens/Player/PlayerView.swift
  • iosApp/iosApp/Screens/Player/PlayerViewModel.swift

📝 Walkthrough

Walkthrough

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

Changes

tvOS HUD flow

Layer / File(s) Summary
HUD state and control visibility
iosApp/iosApp/Screens/Player/PlayerViewModel.swift
Replacement loads clear isHUDPresented. Control auto-hide remains disabled while the HUD is presented and resumes after closure.
HUD view and Menu interactions
iosApp/iosApp/Screens/Player/PlayerView.swift
The controls host remains mounted during HUD loading. The press-capture view is suppressed while the HUD is presented. Menu closes the HUD before it dismisses a loading player.

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
Loading

Suggested reviewers: zzebrahz, olivertgwalton

✨ 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 claude/tvos-playback-hud-focus-behavior-6a6dd1

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

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