Skip to content

fix(tv): make Back out of the top-bar chrome reach content, Home and exit - #204

Merged
RXWatcher merged 8 commits into
Silo-Server:mainfrom
RXWatcher:fix/tv-shell-back-reachability
Aug 11, 2026
Merged

RXWatcher merged 8 commits into
Silo-Server:mainfrom
RXWatcher:fix/tv-shell-back-reachability

Conversation

@RXWatcher

Copy link
Copy Markdown
Contributor

Three changes to the TV top-bar focus model. All confirmed from device traces rather than inferred.

1. Back ping-ponging left Home and exit unreachable

From a trace:

back        root_panel close   -> content focus
back        root_panel request -> menu focused -> root_panel preview
back        root_panel close   -> content focus

Back from content climbed to the bar, the tab's cascade opened by dwell on arrival, and the next Back saw an open panel and closed it straight back to content. Two presses, no progress, MenuBack never reached — Home and exit were not reachable by Back at all.

The distinction that matters is not which call site armed dwell suppression, but why focus arrived:

  • Up from content = browsing → the cascade should open
  • Back from content = leaving → it must not

2. Back inside a cascade now returns to content

Back inside a cascade closed the panel and parked focus on the tab above it, so leaving the chrome took three presses and the middle one navigated Home. "Back doesn't exit the menus" was an accurate description of the model.

onBack() now closes the panel without claiming focus and the shell moves focus to content in the same press. The panel's own close action still returns to the bar, which is where that belongs. TvShellFocusStateTest asserted the old contract (bar nudged on a panel Back); updated to assert the opposite, since not claiming focus is the point.

3. Dwell suppression was armed on every trip up from content

menuFocusTarget was doing two jobs: naming which bar element to land on, and marking that element's dwell preview suppressed. An ordinary content-to-bar Up carries a target too, so every trip up armed the Back-close suppression and left that tab unable to reopen its own cascade. Only closePanel() now sets the new menuFocusSuppressesDwell flag.

An earlier attempt expired the suppression on a 600 ms timer. That fixed the symptom and broke the cause — a Back-close would reopen the panel once the timer elapsed. Removed, now that suppression is armed only where it belongs.

Back from a bar that holds focus solely because a cascade was just dismissed now returns to content instead of walking the viewer along the bar to Home, gated on barFocusFromPanelClose, which clears as soon as focus leaves the bar — so an ordinary bar Back keeps the QA back-stack model.

Possibly related, unverified

#66 and #133(1) both describe Back overshooting to Home from browse → detail. That is the navigation back-stack rather than this chrome model, so I am not claiming these close them — but they are worth a retest against this branch by whoever can reproduce them.

Verification

:androidTvApp:testDebugUnitTest — 975 tests, 0 failures. Confined to TvMainShell, TvShellFocusState, TvTopMenuBar and their test.

RXWatcher and others added 3 commits August 10, 2026 19:04
Carried onto the telemetry branch so testers exercise the fixes, not just the
instrumentation. Three changes, all in the top-bar focus model:

- menuFocusTarget was doing two jobs: naming which bar element to land on, and
  marking that element's dwell preview suppressed. An ordinary content-to-bar
  Up carries a target too, so every trip up from content armed the Back-close
  suppression and left that tab unable to reopen its own cascade. Only
  closePanel() sets the new menuFocusSuppressesDwell flag.

- An earlier attempt expired the suppression on a 600 ms timer. That fixed the
  symptom and broke the cause: a Back-close would reopen the panel once the
  timer elapsed. Removed, now that suppression is armed only where it belongs.

- Back from a bar that holds focus solely because a cascade was just dismissed
  now returns to content instead of walking the viewer along the bar to Home.
  Gated on barFocusFromPanelClose, which clears as soon as focus leaves the
  bar, so an ordinary bar Back keeps the QA back-stack model.

Verified: :androidTvApp:assembleDebug, :androidTvApp:lintDebug. Behavioural and
timing-dependent, so not unit tested; the existing tvShellBackAction tests still
compile and still assert the unchanged MenuBack path via the new parameter's
default. Unproven on a device beyond the Shield — which is why it ships on the
build that now reports what the focus model actually did.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit e6e738a4919b34c60c45dc557528fee9c9131ac8)
Back inside a cascade closed the panel and parked focus on the tab above it,
so leaving the chrome took three presses and the middle one navigated Home.
"Back doesn't exit the menus" was an accurate description of the model.

onBack() now closes the panel without claiming focus and the shell moves focus
to content in the same press. The panel's own close action still returns to the
bar, which is where that belongs.

TvShellFocusStateTest asserted the old contract (bar nudged on a panel Back);
updated to assert the opposite, since not claiming focus is the point.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 62d980e13b00c71aacee7628ebdf6e5f77c2f66b)
Confirmed from a trace rather than inferred. Back from content climbed to the
bar, the tab's cascade opened by dwell on arrival, and the next Back saw an
open panel and closed it straight back to content:

  back        root_panel close   -> content focus
  back        root_panel request -> menu focused -> root_panel preview
  back        root_panel close   -> content focus

Two presses, no progress, MenuBack never reached — so Home and exit were
unreachable by Back at all.

Mine: when suppression was narrowed to closePanel() only, it was also stripped
from the Back-from-content path, where it was doing real work. The distinction
that matters is not which call site but why focus arrived:

  Up from content   = browsing -> the cascade should open
  Back from content = leaving  -> it must not

Both carry a target; only the intent differs. MoveFocusToMenu now suppresses.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit b44e1d8f6405eea588a3d1bffc67d3525d7bd938)
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@RXWatcher, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 30 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c460c6a-2747-4f3b-a30c-185f467ea650

📥 Commits

Reviewing files that changed from the base of the PR and between 8a29750 and c120f38.

📒 Files selected for processing (5)
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/components/TvCascadeSelector.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/shell/TvMainShell.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/shell/TvShellFocusState.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/shell/TvTopMenuBar.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/shell/TvShellFocusStateTest.kt

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.

RXWatcher and others added 5 commits August 10, 2026 23:44
…ad path

Three review findings, all re-confirmed on the new main.

Back could strand focus nowhere. On a loading or empty rail the content group
has no focusable child, so claimContentFocus returned false, the panel it had
just made invisible could no longer take focus, and the D-pad went dead. The
claim's return value was being treated as proof of arrival, which is exactly
what #208's ratchet exists to stop. moveFocusToContent now uses
requestFocusUntilObserved against contentHasFocus, and when content genuinely
has nothing to focus the shell puts focus back on the bar with dwell
suppressed and reports the failed handoff. The shell dismantles the previous
focus owner, so the shell owes a real successor — a loading state should not
have to invent a focusable control to satisfy shell navigation.

A dwell PREVIEW was routed as an entered cascade. Resting on a tab long enough
to open the preview, without pressing Down, left focus on the bar but
openPanel non-null; Back then closed it AND threw the viewer into content from
a menu they were still browsing, costing them the trip back up to reach Home.
tvShellBackAction now takes panelEntered and returns ClosePanelPreview, which
dismisses the preview and moves nothing.

barFocusFromPanelClose / MoveFocusToContent were unreachable from production:
the flag is set only by closePanel(true), whose sole production caller was
TvCascadeSelector.onClose, and the selector never invokes it — Back is
centralised in the shell, deliberately, and more so under Android 16 callback
ordering. Deleted rather than wired up; adding a competing Back handler inside
an always-composed selector would risk double consumption. closePanel now
takes no argument and never moves focus.

Mutation-checked: removing the preview branch fails both new routing tests.
androidTvApp 996, all green, debug APK assembles.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Follow-up review of the previous commit found four issues with the fixes
themselves.

panelEntersFocus is INTENT, set before the selector's asynchronous focus
request runs. An empty panel, an unattached requester or a silently failed
claim all leave focus on the bar while that flag says otherwise, so Back
classified them as entered and threw the viewer into content from a bar they
never left. Routing now asks panelHasFocus, reported by the selector as its
rows and pills gain and lose focus. That signal already existed and was wired
to a no-op comment in the shell — the same class of mistake the branch is
fixing elsewhere.

The observed handoff could yank focus off content that had just taken it: the
final attempt inspects focus in the same frame it requested it, so an accepted
claim reporting asynchronously looked like failure. It now waits one more frame
and re-checks before falling back to the bar.

The bar fallback passed no target, so menuFocusSuppressesDwell had no button to
suppress and the tab it focused could reopen its preview a moment later. It now
passes the selected target.

Also corrects comments in three files that still described the deleted
panel-close focus behaviour.

Mutation-checked earlier work still holds; two existing tests had to be updated
because they asserted on intent, which is exactly the bug. androidTvApp 998,
all green, debug APK assembles.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@RXWatcher
RXWatcher merged commit 4033ce5 into Silo-Server:main Aug 11, 2026
3 checks passed
RXWatcher added a commit that referenced this pull request Aug 11, 2026
… through search (#215)

* fix(tv): stop Back stranding you when the bar never takes focus

Back from content on a tab root asks the bar to take focus via a token bump,
and nothing checks whether it landed. When it does not, every subsequent Back
re-evaluates to the same request: MenuBack is never reached and Home and exit
become unreachable.

Reproduced on a Google TV Streamer — four consecutive 'focus request -> menu'
one second apart with no 'focused -> menu' between them.

The state now records that the handoff was asked for, and a second Back
escalates to MenuBack rather than repeating a request that is evidently not
working. The flag clears when the bar reports focus or when a panel close hands
focus somewhere deliberate, so the normal climb-to-bar step is unchanged.

#204 gave the content direction an observed handoff with a fallback; this is
the same failure in the bar direction, which it did not cover.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tv): stop Search Back looping the same way

Back on Search is consumed to send focus to the search field. If the field
never reports focus, every Back repeats that and Search cannot be left — the
same unobserved-claim loop as the bar handoff.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tv): never let the handoff escalation exit the app

MenuBack on Home means 'exit', so escalating there turned a Back the viewer
expected to move focus into quitting Silo. Observed on the Streamer: Back from
a cascade dropped straight out to the Google TV home screen.

Escalate only where MenuBack navigates.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tv): Back out of a cascade lands on the tab, not the search icon

The bar skipped the whole focus request when the explicit target was
unavailable, so nothing was focused and Compose's default search landed on the
first bar element — the search icon. Back out of a cascade therefore appeared
to 'go to search', and pressing centre opened it.

Availability now gates only the explicit target; the request still runs and
falls back to the selected entry.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tv): arm dwell suppression on the Back-close that actually runs

Telemetry from the Streamer shows the loop: close -> root_panel, focused ->
menu, then preview -> root_panel ~250ms later, and the next Back spent closing
that preview. MenuBack is never reached, so Home is unreachable.

Crucially there is no 'request -> menu' between the close and the focus —
Compose restores focus to the anchor itself when the panel leaves composition,
so the explicit request never ran and suppressDwellPreview was never armed.
#204 removed the path that used to arm it, treating it as dead.

ClosePanel now requests the anchor with suppression, and the shell stops
claiming content on that branch: it was fighting a restore it could not win,
and losing it silently was what dropped the suppression.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tv): keep the anchor tab after backing out of its cascade

Back took the ClosePanelPreview branch (panelHasFocus false even after enter),
which deliberately moves no focus. With no explicit request the bar falls back
to selectedEntryRequester() — the selected tab, or the search icon when the
route is Search — so backing out of Movies' cascade landed on Home.

Request the anchor with dwell suppressed on that branch too.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tv): stop Back flashing through search on its way out of a cascade

Closing a cascade removes the focused node, and Compose recovers focus a
frame before any request of ours can land — it picks the bar's first
child, the search icon. Nothing written to state can win that frame:
arming suppression, restricting focusability and pointing the group's
enter at the anchor were all applied a recomposition too late, and one
attempt at making the request immediate regressed where focus rests.

So move focus while the panel is still composed, then close it. There is
no recovery left to lose. The deferred request stays as the fallback for
when the bar has not installed its hook.

Verified on a Google TV Streamer: Movies cascade -> Back now rests on the
Movies tab with no intermediate claim, where before it flashed through
search and, without the suppression, re-previewed the cascade it had just
dismissed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(tv): honour the anchor claim's result instead of assuming it landed

requestFocus() returns whether the claim was accepted, so
runCatching{}.isSuccess threw the real answer away — it is true for any
call that merely did not throw. A refused claim therefore looked like a
move: suppression was armed, the panel closed, and the deferred fallback
was skipped, leaving focus nowhere until the next Back. Route it through
claimFocusOrReport, which returns acceptance and reports a refusal
instead of swallowing it.

Found by Codex review of #215.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(tv): name the anchor claim what it is — accepted, not arrived

claimFocusOrReport returns acceptance; its own docs are explicit that
accepted is not arrival. Calling the result 'moved' claimed more than the
helper can know. The behaviour is unchanged — acceptance is still the
right gate, because it separates a claim that took from one that
definitely needs the deferred retry.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(tv): pin that the bar-handoff escalation never exits from Home

MenuBack on Home means EXIT, so escalating an unanswered handoff there
turns the second Back into a silent app exit — which an earlier cut of
this branch did, and which is worse than the stranding the escalation
fixes. The guard existed; nothing held it in place.

Raised by CodeRabbit on #215.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: rxwatcher <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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