Skip to content

tvOS player HUD: rebuild menus on the native focus graph - #42

Merged
Quick104 merged 1 commit into
mainfrom
feature/tvos-player-hud-native-focus
Jul 2, 2026
Merged

Quick104 merged 1 commit into
mainfrom
feature/tvos-player-hud-native-focus

Conversation

@Quick104

@Quick104 Quick104 commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Rebuilds the internals of the tvOS player info HUD (TVPlayerInfoHUD.swift, −927/+534 lines) so the tvOS focus engine owns all d-pad movement, replacing the hand-rolled focus mesh. The visual design is unchanged, and TVPlayerControls/PlayerView needed no changes — the HUD's API and Menu-button stepping are the same.

  • Every interactive row is a real Button styled by shared ButtonStyles (HUDRowButtonStyle, HUDTabPillStyle) using the established @Environment(\.isFocused) + .focusEffectDisabled() idiom from TVPillButtonStyle. All per-row onMoveCommand handlers, the hand-maintained neighbor tables (playbackFields/syncFields, moveUp/moveDown/moveLeft/moveRight, fieldBefore/fieldAfter), and per-press @FocusState mutation are deleted. Columns are .focusSection()s, so row-to-row and column-to-column movement come from focus-engine geometry.
  • Tab bar rail: pills keep focus-driven selection but the bar gains .defaultFocus($focusedTab, activeTab, priority: .userInitiated) so Up from a pane lands on the active pill — without it, native movement lands on the nearest pill and switches tabs as a side effect. Same rails pattern as TVLoginView / CalendarDayShelf.
  • Booleans are one-press toggles: HDR passthrough, Auto-play next, Text outline, and "Save for this Apple TV" flip directly on Select instead of the old open-dialog → navigate → pick → close round-trip.
  • Submenus keep the overlay look, gain native movement: the picker dialog and Subtitle Appearance dialog still present over the dimmed .disabled pane (that disable is what contains focus), but their manual up/down routing, scroll tracking, and focus-nil reseeding hacks are gone. @FocusState survives only for the two uses docs/tvos-focus.md sanctions: seeding focus when a dialog opens (onto the current selection) and restoring it to the originating row on close.
  • Info/Stats panes unchanged: they keep the composite HUDScrollablePane (single focusable that pages scroll content), the sanctioned exception for read-only scrollable text.

Why

Focus behavior in the HUD's menus and submenus was erratic — dead stops, traps, and inconsistent movement. The old code mixed models (focusable rows + FocusState routing on every press), which is exactly the hybrid anti-pattern docs/tvos-focus.md forbids. Rebuilding on the native graph fixes the movement bugs by construction instead of patching neighbor tables.

Reviewer notes

  • Builds green: SiloTV scheme, tvOS simulator (xcodebuild … CODE_SIGNING_ALLOWED=NO).
  • Needs an on-device d-pad pass before merge; the specific behaviors to exercise:
    • Up from a pane lands on the active tab pill (rail), not a neighbor.
    • Left/Right hops between Tracks/Options and Playback/Sync columns.
    • Focus returns to the originating row after closing a picker / the appearance dialog / the AI subtitles menu.
    • Menu still steps picker → appearance dialog → HUD → controls → exit.
  • If column bridging misbehaves at some seam, the playbook fix is a single boundary onMoveCommand there — not a return to per-row wiring.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved TV interface navigation across player info, tabs, pickers, and settings panes.
    • Active options and tabs now receive focus more reliably when using the remote.
  • Bug Fixes

    • Fixed several focus and up/down navigation issues in player dialogs and track lists.
    • Improved selection behavior for subtitle, audio, and chapter rows, including unavailable track handling.

The info HUD's panes and submenus hand-implemented all d-pad movement:
every row was a focusable Text with a four-direction onMoveCommand and
per-field FocusState routing through hand-maintained neighbor tables.
Any mismatch between those tables and the visible rows produced dead
stops or focus traps, and every submenu re-implemented the same scheme.
This is the hybrid model docs/tvos-focus.md forbids.

Rework the HUD so the tvOS focus engine owns movement:

- Every interactive row is a real Button styled by shared ButtonStyles
  (HUDRowButtonStyle / HUDTabPillStyle, using @Environment(\.isFocused)
  + focusEffectDisabled, same idiom as TVPillButtonStyle). All per-row
  onMoveCommand handlers and neighbor tables are deleted; columns are
  .focusSection()s.
- The tab bar keeps focus-driven selection and gains a
  defaultFocus(priority: .userInitiated) rail so Up from a pane lands
  on the active pill instead of the nearest one (which would switch
  tabs as a side effect).
- Booleans (HDR passthrough, auto-play next, text outline, save for
  this Apple TV) become one-press toggle rows instead of picker
  dialogs.
- Picker dialogs and the subtitle appearance dialog keep the
  overlay-over-disabled-pane presentation (that is what contains
  focus) but movement inside them is native; @focusstate remains only
  to seed focus on open and restore it on close.
- Info/Stats keep the composite HUDScrollablePane, the sanctioned
  exception for read-only scrollable content.

Net -927/+534 lines. Visual design is unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 2, 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: 8cca328e-3e74-4c6f-a741-22c748d353cb

📥 Commits

Reviewing files that changed from the base of the PR and between b67de10 and 83647cc.

📒 Files selected for processing (1)
  • iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift

📝 Walkthrough

Walkthrough

TVPlayerInfoHUD.swift is refactored to shift tvOS HUD focus management from custom focusable/move-command logic to native tvOS focus engine primitives (defaultFocus, .focused bindings, onExitCommand). Shared Button-based row chrome components replace bespoke focused-row implementations across panes and dialogs.

Changes

tvOS HUD Focus Refactor

Layer / File(s) Summary
Shared row chrome and tab bar focus rail
iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
Adds HUDRowButtonStyle/HUDRowButtonBody, HUDSettingRow, HUDToggleRow, HUDCircleButtonStyle, and refactors TabPill/tab bar to use Button + defaultFocus for Up navigation.
VideoPane setting rows and picker wiring
iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
VideoPane's Field enum is reduced; Playback/Sync rows (Quality, Aspect, HDR, Audio delay, Subtitle delay, Auto-play) use HUDSettingRow/HUDToggleRow with .focused bindings; manual neighbor-traversal helpers removed; picker open/close focus restoration simplified.
HUDPickerDialog focus binding
iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
Picker options rendered via HUDPickerOptionRow with .focused bindings, defaultFocus, and onExitCommand replacing manual scroll/move-focus logic.
SubtitleAppearanceDialog row conversion
iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
Field enum updated; scroll content converted to HUDSettingRow/HUDToggleRow with .focused bindings; defaultFocus seeding added; Menu exit handling updated; manual move helpers removed.
SubtitlesPane, AudioPane and shared track rows
iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
Focus state simplified to Option-based; overlay gating added; primary/secondary track lists switched to HUDTrackRow buttons with disabled state handling; options rows converted to HUDSettingRow/HUDToggleRow.
ChaptersPane and shared HUDTrackRow/HUDChapterRow
iosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
Removes onMoveToTabs parameter; HUDChapterRow and HUDTrackRow converted to Button-based rows using HUDRowButtonStyle with environment-driven focus styling.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • Silo-Server/silo-apple#1: Both PRs modify focus behavior/styling in TVPlayerInfoHUD.swift, overlapping in the same tvOS HUD focus/row code paths including HUDTrackRow.
✨ 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/tvos-player-hud-native-focus

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

@Quick104
Quick104 merged commit 750f7ef into main Jul 2, 2026
1 check was pending
@Quick104
Quick104 deleted the feature/tvos-player-hud-native-focus branch July 2, 2026 02:43
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