Skip to content

fix(tvos): focus the first On Deck item when entering from Next Up - #651

Merged
Quick104 merged 2 commits into
mainfrom
t3/fix-tvos-next-up-focus-first-item
Oct 13, 2026
Merged

Quick104 merged 2 commits into
mainfrom
t3/fix-tvos-next-up-focus-first-item

Conversation

@Quick104

@Quick104 Quick104 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: not checked yet (the v1.0 board couldn't be read during review)

On the tvOS Next Up screen the action panel sits above the third On Deck card. Pressing Down from the Auto-play toggle into On Deck briefly focused that third card. The screen's redirect then moved focus to the first card, so the move showed as a one-frame flash on the wrong card.

Approach

  • The On Deck row now sets prefersDefaultFocusOnFirstItem, so the focus engine enters the row on its first card. The programmatic redirect is gone: onDeckFocusRequest, focusFirstOnDeckItem(), and the Down branch on the Auto-play toggle. This keeps the screen on the native focus graph, as docs/tvos-focus.md asks.
  • Native entry only works when the first card is loaded. The old redirect scrolled the strip home before it claimed focus. Without that step, a row scrolled deep into its LazyHStack sent the next Down to the card under the panel. MediaRow gains scrollsToFirstItemWhenFocusLeaves, which scrolls the strip back to its first card once focus has left the row. On Deck opts in, and other rows are unchanged.
  • focusBelowActions() now only handles the Auto-play toggle. Without the toggle, Down enters On Deck natively.

Validation

  • tvOS 27 simulator, Debug builds of main, the first commit, and the fix, against a test server with 10 On Deck items, driven by remote key presses:
    • First Down into On Deck: main lands on the first card after a one-frame flash on card 3. This branch lands on the first card directly.
    • Move right 7 cards, Up, Down: the first commit landed on the card under the panel. With the fix, the strip returns home when focus leaves and Down lands on the first card. Main also lands on the first card.
  • Not run: the no-next-episode state (Keep Watching and Back only), and a physical Apple TV.
  • CI: see the checks on this PR.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-apple/pr-651/

Surface and build: tvOS Next Up screen, SiloTV Debug on a tvOS 27 simulator.

Risks

scrollsToFirstItemWhenFocusLeaves defaults to off, so rows other than On Deck behave as before. With it on, the strip waits one turn after focus reads nil, so a card-to-card move or a context-menu dismissal doesn't scroll it.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (Claude Agent SDK), running in T3 Code
  • Tool(s): Claude Code
  • Model(s): claude-sonnet-5-5 (first commit); claude-opus-5-5 (review, the scroll-home fix, and simulator verification)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: three read-only review passes on the first commit (diff and callers; contract, failure, and altitude; cleanup and conventions) and a simulator run on the head. Together they found one major defect: re-entry into a scrolled row landed on the wrong card. It's fixed in the second commit and verified on the simulator. A cross-provider round with Codex couldn't run because of rate limits.

Note

Focus first On Deck item when entering Next Up screen on tvOS

Replaces the screen-local focus-request counter in PlayerNextUpScreen with MediaRow configuration. The On Deck row now declares its first item as the default focus target and scrolls back to it when focus leaves the row.

  • Adds scrollToFirstItemIfUnfocused in MediaRow.swift. It defers one main-queue turn, then scrolls to the first item only if focus is still absent.
  • Removes focusFirstOnDeckItem, the on-deck focus request state, and the Down-move interception from the auto-play control handler in PlayerView.swift.
  • Behavioral Change: when no next-up episode exists, focusBelowActions no longer focuses the first On Deck item; it leaves focus unchanged. Pressing Down on the Auto-play control is no longer intercepted to force On Deck focus.

Macroscope summarized ab552ad.

- Let the focus engine enter the On Deck row on Down instead of redirecting the move, so the first card gets focus rather than the third.
- Drop the manual Down handler and the onDeckFocusRequest counter.
- Prefer default focus on the first On Deck item.
@silo-kody

silo-kody Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 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-10-06T12:55:28.124763Z 2a221ef PR opened
🔒 Security Review ✅ Completed 2026-10-06T12:55:03.942561Z 2a221ef 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.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b09b9d6f-e526-45c3-a016-0a4944372dad
📥 Commits

Reviewing files that changed from the base of the PR and between 2a221ef and ab552ad.

📒 Files selected for processing (2)
  • iosApp/iosApp/Components/MediaRow.swift
  • iosApp/iosApp/Screens/Player/PlayerView.swift
 ___________________________________________________________________________________________________
< Test your software, or your users will. Test ruthlessly. Don't make your users find bugs for you. >
 ---------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 12702e8d-1aff-43a7-8f90-285b50541961
📥 Commits

Reviewing files that changed from the base of the PR and between 6242652 and 2a221ef.

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

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The Player screen removes explicit focus requests for the first On Deck item. On tvOS, On Deck prefers native focus entry onto its first item. Moving down from the actions focuses Auto-play only when a next episode exists.

Changes: Player focus navigation

Layer / File(s) Summary
On Deck native focus entry
iosApp/iosApp/Screens/Player/PlayerView.swift
Down from the actions focuses Auto-play when a next episode exists. Otherwise, focus follows native movement into On Deck, which prefers its first item. The explicit focus request state and helper are removed. Auto-play no longer intercepts Down to request focus on On Deck.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: blurbery

Merge Risk: ⚪ Minimal · up to 2a221

Down navigation is configured to enter On Deck at its first card, while still targeting Auto-play when available. The inspected code and focus guidance support the intended behavior; no actionable merge-blocking risk is established.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main tvOS focus change: focusing the first On Deck item when entering from Next Up.
Description check Passed The description directly explains the focus defect, the implementation, validation results, risks, and scope of the changes.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a221ef827

ℹ️ 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".

// The panel sits above the third card, so a geometric Down entry
// would skip the first. Let the focus engine enter the row and
// land on its first card instead of redirecting the move.
prefersDefaultFocusOnFirstItem: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Mount the first card before native On Deck entry

When a user moves far enough right in On Deck, presses Up to return to the action panel, and then presses Down again, the horizontal row remains parked and its LazyHStack may have unloaded the first card. MediaRow.applyFocusRequest explicitly scrolls before claiming focus because focus writes to an unloaded card are dropped; replacing that request with defaultFocus neither mounts nor scrolls to the target, so re-entry can still land on a visible later card. Reset the row to the first card, or otherwise ensure it is mounted, before relying on native entry.

AGENTS.md reference: AGENTS.md:L43-L46

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on a tvOS 27 simulator. With 10 On Deck items I moved right to card 8, pressed Up to the Auto-play toggle, then Down. The strip stayed scrolled and focus landed on the card under the panel, not the first card. origin/main returns to the first card in the same steps.

I'm fixing it on this branch. The plan is to keep the native .defaultFocus entry and have On Deck scroll its strip back to the first card once focus has left the row, so the first card is loaded before the next Down. That avoids bringing back the programmatic redirect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ab552ad. MediaRow gains scrollsToFirstItemWhenFocusLeaves: once focus has left the row, the strip scrolls back to its first card, so native entry has a loaded target. On Deck opts in, and other rows keep the default (off).

Verified on the tvOS 27 simulator with the same steps: move right 7 cards, press Up (the strip snaps back to the first card), then Down. Focus lands on the first card. The first Down into the row still lands on the first card with no flash. Captures are on the evidence page linked in the PR body.

I'm leaving this thread for its author to resolve.

Quick104 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Silo's pull request guidance changed today (#658). A PR that changes what a user sees now needs before-and-after evidence in its Evidence section, and a PR with no visible change says Evidence: none, no user-visible change. This PR was opened before the rule existed, so it hasn't had a chance to meet it yet.

Missing here: A before-and-after recording of tvOS Next Up showing focus moving Down to the first On Deck card.

The rules are in Show visible changes, and the PR template shows the Evidence section layout. I've converted this PR to draft for now. Mark it ready for review once the Evidence section is filled in.


Generated by Claude Code

@Quick104
Quick104 marked this pull request as draft October 6, 2026 19:25

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on a tvOS 27 simulator. I built origin/main and this branch, ran both against a test server with 10 On Deck items, and drove them with remote key presses.

Native entry fixes what main gets wrong on a first Down. On main, Down from the Auto-play toggle lights the third On Deck card for about one frame, then the redirect moves focus to the first card. On this branch focus lands on the first card directly. I didn't see main skip the first card outright. The visible symptom there is the brief flash.

Findings:

  1. Re-entering a scrolled row lands on the wrong card (major, confirmed on the simulator). Move right through On Deck to card 8, press Up to the Auto-play toggle, then press Down. The strip stays scrolled, the first card isn't loaded, and focus lands on the card under the panel ("12 Dates of Christmas" in my run). Main returns to the first card in the same steps, because its focusRequest path scrolls the strip home before it claims focus. Details are in the existing thread on line 1194. I'm fixing this in a commit on this branch, so there's no need to change it yourself.

  2. Stale comment in MediaRow (minor). The focusRequest doc comment in MediaRow.swift still names PlayerView as its example caller. After this PR, PlayerView no longer passes focusRequest. I'm updating it in the same commit.

  3. PR description (minor). The summary says Down "skipped the first card", and the Testing section says nothing was run. I'll rewrite both with what the simulator runs showed and add the evidence link once the fix is verified.

The cross-provider review round couldn't run (rate limited twice), so these findings come from my own review and the simulator runs.


Review by Claude Code (claude-opus-5-5).

Native entry relies on the row's first card being loaded. After the
user scrolled On Deck and pressed Up, the strip stayed parked deep in
its LazyHStack, so the next Down landed on the card under the panel
instead of the first one.

MediaRow gains scrollsToFirstItemWhenFocusLeaves, which scrolls the
strip home once focus has left the row. On Deck opts in. Also drop the
stale PlayerView example from the focusRequest doc comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Copy link
Copy Markdown
Contributor Author

Review summary

Reviewed head: ab552ad (the PR's commit 2a221ef plus one fix commit from this review)

What the PR fixes. On main, Down from the Auto-play toggle into On Deck focuses the third card for about one frame before the redirect moves focus to the first card. This branch lets the focus engine enter the row on its first card, so the flash is gone. I didn't see main skip the first card outright, so the PR body now describes the flash.

Addressed in this review

  • Re-entry into a scrolled On Deck row landed on the card under the panel (major, confirmed on the simulator). Fixed in ab552ad: the strip scrolls back to its first card once focus leaves the row.
  • Stale focusRequest doc comment in MediaRow that named PlayerView as a caller. Fixed in the same commit.
  • PR body rewritten with the verified behavior, validation, Evidence link, and AI disclosure.

Remaining

  • Not run: the no-next-episode state (Keep Watching and Back only), and a physical Apple TV. The code path is the same native entry, but nobody has watched it run.
  • CI on ab552ad is still running.
  • The checklist's "I read and can explain the complete diff" box is for the author to tick.

Validated features: not checked. The v1.0 board couldn't be read during this review. The change only touches tvOS Next Up focus. MediaRow's new option defaults to off, so other rows are unaffected.

User manual: unaffected. The site describes the next-up screen but not its focus behavior.

Apple/Android parity: Android TV's Next Up panel also sits above On Deck cards 3–5, and its row uses plain geometric entry, so a Down from the panel probably lands on card 3 there. I haven't run it. I recommend a parity issue in silo-android to check and match first-card entry.

Cross-provider review: a Codex round was attempted twice and hit rate limits both times. It didn't run.

Fit: 7/10 · Readiness: 7/10 — conditional

  • Fit: the change moves the screen onto native focus entry, which docs/tvos-focus.md prefers, and removes a visible glitch. It stays in the Apple client at the right boundary, and the new MediaRow option is opt-in. It's held at 7 because Android TV likely has the same entry behavior and no parity issue is linked yet.
  • Readiness: the regression this review found is fixed and verified on the simulator. Before ready: CI must pass on ab552ad, and someone should check the no-next-episode state, ideally on a physical Apple TV.

Review by Claude Code (claude-opus-5-5).

@Quick104
Quick104 marked this pull request as ready for review October 13, 2026 02:04
@Quick104
Quick104 merged commit de1a120 into main Oct 13, 2026
7 of 8 checks passed
@Quick104
Quick104 deleted the t3/fix-tvos-next-up-focus-first-item branch October 13, 2026 02:04
/// pull the strip out from under the user.
private func scrollToFirstItemIfUnfocused(proxy: ScrollViewProxy) {
DispatchQueue.main.async {
guard focusedItemId == nil, let firstItem = items.first else { return }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Kody Rules high

Validate the captured generation and selection identity after the suspension before scrolling; otherwise a callback queued for a disappearing card can run after a context-menu restoration or membership refresh and act on stale focus state.

Also found in:

  • iosApp/iosApp/Components/MediaRow.swift:176-176

Kody rule violation: Bind delayed presentation work to selection identity and current content

guard generation == focusRestorationGeneration,
      focusedItemId == nil,
      lastFocusedItemId == departedItemId,
      let firstItem = items.first else { return }
Prompt for LLM

File iosApp/iosApp/Components/MediaRow.swift:

Line 177:

Validate the captured generation and selection identity after the suspension before scrolling; otherwise a callback queued for a disappearing card can run after a context-menu restoration or membership refresh and act on stale focus state.

**Also found in:**
- `iosApp/iosApp/Components/MediaRow.swift:176-176`

Suggested Code:

            guard generation == focusRestorationGeneration,
                  focusedItemId == nil,
                  lastFocusedItemId == departedItemId,
                  let firstItem = items.first else { return }

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Quick104 added a commit that referenced this pull request Oct 13, 2026
The scroll-home-on-focus-leave handler from #651 read the row's
@focusstate in an onChange attached directly to the strip. That made
the strip's body depend on focus, so every move between cards
re-evaluated the LazyHStack and every card in it, which is what
TVRowFocusObserver exists to prevent.

The handler now lives in a TVRowFocusLeaveObserver modifier that takes
the binding, attached only to rows that set
scrollsToFirstItemWhenFocusLeaves. The strip still scrolls back to its
first card once focus leaves the row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Oct 13, 2026
#651 removed focusFirstOnDeckItem() and let the focus engine enter On
Deck on Down, but the Stop Shuffling button on the Next Up screen still
called it, so SiloTV no longer compiled. Down from that button is now
left to the focus engine too, which enters On Deck at its first card
the same way it does from the actions row.

Closes #753

Co-authored-by: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Oct 13, 2026
#651 removed focusFirstOnDeckItem() and let the focus engine enter On
Deck on Down, but the Stop Shuffling button on the Next Up screen still
called it, so SiloTV no longer compiled. Down from that button is now
left to the focus engine too, which enters On Deck at its first card
the same way it does from the actions row.

Closes #753

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c49b1cf)
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