Repository navigation
tvOS player HUD: rebuild menus on the native focus graph - #42
Merged
Merged
Conversation
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]>
|
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 (1)
📝 WalkthroughWalkthroughTVPlayerInfoHUD.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. ChangestvOS HUD Focus Refactor
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This was referenced Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andTVPlayerControls/PlayerViewneeded no changes — the HUD's API and Menu-button stepping are the same.Buttonstyled by sharedButtonStyles (HUDRowButtonStyle,HUDTabPillStyle) using the established@Environment(\.isFocused)+.focusEffectDisabled()idiom fromTVPillButtonStyle. All per-rowonMoveCommandhandlers, the hand-maintained neighbor tables (playbackFields/syncFields,moveUp/moveDown/moveLeft/moveRight,fieldBefore/fieldAfter), and per-press@FocusStatemutation are deleted. Columns are.focusSection()s, so row-to-row and column-to-column movement come from focus-engine geometry..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 asTVLoginView/CalendarDayShelf..disabledpane (that disable is what contains focus), but their manual up/down routing, scroll tracking, and focus-nil reseeding hacks are gone.@FocusStatesurvives only for the two usesdocs/tvos-focus.mdsanctions: seeding focus when a dialog opens (onto the current selection) and restoring it to the originating row on close.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 +
FocusStaterouting on every press), which is exactly the hybrid anti-patterndocs/tvos-focus.mdforbids. Rebuilding on the native graph fixes the movement bugs by construction instead of patching neighbor tables.Reviewer notes
SiloTVscheme, tvOS simulator (xcodebuild … CODE_SIGNING_ALLOWED=NO).onMoveCommandthere — not a return to per-row wiring.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes