Skip to content

fix(tv): let Back on Switch Profile return to the screen it came from - #969

Draft
Quick104 wants to merge 7 commits into
mainfrom
fix/issue-917-back-cancels-profile-switch
Draft

Quick104 wants to merge 7 commits into
mainfrom
fix/issue-917-back-cancels-profile-switch

Conversation

@Quick104

@Quick104 Quick104 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On Android TV, choosing Switch Profile (from the profile menu or from Settings' profile row) and then pressing Back on Who's watching? closed Silo. Back is supposed to return to the screen the picker was opened from. The switch replaced the whole back stack with the picker and closed the open profile, so the picker was the only screen left and Back went to the system.

Closes #917
Related issue: Silo-Server/silo-apple#1200 (the Apple TV fix for the same bug)
Validation tasks: unblocks #320 C6 (Android TV: Back returns to the previous usable screen)

Other clients: Apple Silo-Server/silo-apple#1200; Roku N/A (its picker is pushed over the open profile, and Back already returns to it); Web N/A (no remote Back that closes the app)

Approach

Back on a picker that Switch Profile opened now cancels the switch. As decided for the Apple fix, it reopens the same profile with the proof it already had (no PIN prompt), on the page the switch started from. Android TV only.

  • Capture. Switch Profile reads the open profile's identity (id, PIN proof and identity generation) in one snapshot before clearing it, as before. It keeps a way back in memory only if its own clear was the only identity change since that snapshot. The way back is tied to that picker's back-stack entry. Sign-out, Change Account to another account, a server switch and session expiry all replace the picker, so Back there can't use it, and entering any profile drops it. The token is never written to saved state. A second Switch Profile press while one is running is ignored.
  • Back. The picker handles Back for the whole switch: while the profile is still closing (a press there runs once the way back exists), once the way back is ready, and while Back reopens the profile (further presses wait). A handler at the navigation level covers the frames after Main's handlers go and before the picker registers its own, and holds Back while a cancelled switch re-enters Main, until Main reports the restored page is showing (Main starts on Home, where Back closes Silo). The PIN pad and the picker's dialogs are their own windows and keep handling Back first. Back reopens the profile through ProfileRepository.selectProfile, fenced to the scope the switch's clear left. A profile chosen, an account switched or a cast identity installed since makes it fail, and the picker stays. It then runs the same steps as choosing a tile, and also reloads card overlays and card presentation, which the switch had cleared. If Silo left the foreground or the picker went while the profile reopened, the reopen is undone with a clear fenced to the reopen's own scope: ProfileRepository.clearProfile takes an optional expected scope, checked before the identity transition (as clearStaleProfile does, so a rejected clear fires no gates) and again inside it, so the undo can't reach an identity that replaced it. Existing callers pass none and behave as before.
  • Page. The shell passes its current page to Switch Profile, and the reopened Main opens that page once (Settings, a library tab, Calendar, For You and so on). It reuses the one-shot savedStateHandle hand-off that Manage Servers already uses. Pages whose routes have arguments reopen on Home.
  • Manage mode. Entering Manage on that picker drops the way back, because a profile edited or deleted there may no longer match the proof the switch kept.
  • Leaving the app. Leaving the foreground drops the way back, including one a switch or a Back still in flight would publish or finish. A picker found on return needs a profile choice, and its PIN, again.

The phone app does not have this bug. It opens its picker over the current screen without closing the profile, and Back already returns there. Checked on unfixed main (see Validation), so the phone is unchanged.

Validation

Target: a Silo dev deployment built from silo-server main, with an account holding three profiles ("qa917", "Kids", and "Locked" with a PIN), Profile Selection set to Ask Every Time. Debug builds on an Android TV 1080p emulator and a Pixel 7 emulator, both API 36.

  • Reproduced on unfixed main (40d34e6d9). Signed in as "Locked" on Calendar, profile menu → Switch Profile → Back closed Silo; the foreground activity became the TV launcher. Settings → profile row → Back did the same.
  • Fixed (6091fb9e6, and the main flow again on a32e0f01a). The same steps return to Calendar and to Settings as "Locked", with no PIN prompt. Focus lands on the page (the Following filter on Calendar, General in Settings). Movies → Switch Profile → Back returns to Movies, and For You to For You, with focus on the first card.
  • Review fixes (fa9424500, on a fresh sandbox from silo-server main, Android TV 1080p emulator, API 36). Before them, two Backs sent in the same instant on the picker closed Silo, and so did Switch Profile followed by Back about 300 ms later (three runs out of three). After: both return to Calendar as "Locked" in every checked run (fifteen double-Back trials at the final build), and so does Settings' profile row. After a restore, Back walks Calendar → bar → Home and then closes Silo as before. Single Back, the PIN pad, Change account, Manage, leaving with Home, and the launch picker behave as listed below. A Back injected in the same millisecond as Switch Profile still closed Silo in one of two runs; a remote can't send presses that close together.
  • Unchanged behavior, checked on the fix:
    • Back on the launch picker still closes Silo.
    • Leaving Silo with Home while the Switch Profile picker is up, then returning: Back closes Silo.
    • Back on the PIN pad closes only the PIN pad, and the next Back cancels the switch.
    • Change account → Back returns to the picker, and the next Back cancels the switch.
    • Manage on that picker drops the way back (a profile may be edited or deleted there): Manage → Done → Back closes Silo, as on the launch picker.
  • Phone, unfixed main: Calendar → Switch profile → Back returns to Calendar as the same profile. Tablet and foldable run the same phone navigation, which this PR doesn't change.
  • :androidTvApp:assembleDebug builds, :androidTvApp:testDebugUnitTest passes, and :androidApp:compileDebugKotlin builds against the shared change. One test added, for the shared fence: ProfileRepositoryTest checks that a fenced clear leaves an identity that replaced its scope, without starting an identity transition, and clears when the scope still holds. It fails on 6706144ee, where the rejected clear still started a transition. The TV navigation itself has no tests, per the repository's testing rules.

Evidence: https://evidence.siloserver.org/r/silo-android/issue-917/

Risks

  • Main is rebuilt on return, so a library tab's section (Collections, Browse), For You's Watchlist or Favorites choice, and scroll position are not restored. The Apple fix restores the section and the For You choice. Those screens are being changed in other open work, so this PR restores only the page.
  • A secondary page opened from Settings (Favorites, Watchlist, History, Collections) reopens on its own, so Back from it then goes to Home instead of Settings.
  • The closed profile's token stays in memory while the picker is up. A token the server has since retired (for example after the PIN changed on another device) fails on the first request, and the existing recovery returns to the picker.

Follow-ups

  • Change Account → choosing the account that's already open also opens Who's watching "as Switch Profile", but without a way back, so Back there still closes Silo. Not covered here.
  • After Back from Change Account, the picker shows with nothing focused until a D-pad press. main does the same from the launch picker, so this PR leaves it alone.

Council review

Rounds: 2, last reviewed 6706144; fa9424500 answers round 2

Member Round 1 (1d3a56d) Round 2 (6706144)
Sol (gpt-6.2-sol, medium) 5/10 7/10
Opus (claude-opus-5-5, medium) 7/10 7.5/10
Gemini (gemini-4-neon, medium) 8/10 9/10

Fixed: Back handled through the whole switch and while Main re-enters (double Back, fast Back, Back during the clear), a fenced undo that doesn't start a transition when rejected (all three members raised it in round 2), a guard against a second Switch Profile press, the way back dropped when a profile is entered, and a queued Back replayed only while the picker is showing. Answered: a token refresh doesn't break the fence (the interceptor's refresh leaves the credential epoch alone), the NonCancellable reopen can't be discarded between its check and entering Main, and the SiloCast standby overlay takes no Back on any screen. Left for the maintainer: pushing the picker over Main instead of clearing first.

AI Disclosure

  • Harness: Claude Code running in T3 Code
  • Tool(s): Claude Code, GitHub CLI, agent-device (emulator control), silo-evidence
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; not yet verified by a human. Review fixes (560f3ba18, and the later commits) by Claude Code (claude-opus-5-5) in maintainer review sessions.
  • Adversarial review: Before implementing, gpt-6.1-sol (Codex, xhigh) attacked the plan and claude-opus-5-5 (high) cut it down; that shaped the identity snapshot, the foreground revision, and the one-page restore. A background review by gpt-6.1-sol of a32e0f0 returned two findings, fixed in 560f3ba18. The maintainer review's code review (three finders and a validation check) and two council rounds are summarized under Council review.

🤖 Generated with Claude Code

Quick104 and others added 2 commits November 15, 2026 23:01
Switch Profile on Android TV replaced the whole back stack with
Who's watching and cleared the profile, so Back closed the app. Back on
that picker now reopens the same profile with the proof it already had
(no PIN prompt) on the page the switch started from. The launch picker,
and a picker found after leaving the app, still close the app on Back.

Closes #917

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A profile edited or deleted in Manage mode may no longer match the
proof the switch kept, so entering Manage drops the way back, and Back
in Manage mode no longer reopens the closed profile. The close-again
fallback also skips a cast identity, whose id isn't this TV's profile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 16, 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 Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T04:13:28.184597Z a32e0f0 PR opened
🔒 Security Review ✅ Completed 2026-11-16T04:15:43.259438Z a32e0f0 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.

@silo-triage silo-triage Bot added bug Something isn't working impact: usability Core flow broken or severely blocked needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish labels Nov 16, 2026
// switched or a cast identity installed since makes this ScopeChanged.
val result = profileRepository.selectProfile(back.profileId, back.profileToken, back.clearedScope)
if (result != ProfileCommitResult.Committed) return@launch
if (revision != foregroundRevision || navController.currentBackStackEntry?.id != back.pickerEntryId) {

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 critical

Profile-switch cancellation can navigate after losing identity ownership

An identity transition after selectProfile commits can cause navigation and content seeding for a replacement identity. Capture the committed authentication generation and validate it against the current authority before navigating or publishing related side effects.

Also found in:

  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt:635-635

Kody rule violation: Revalidate asynchronous ownership before publication, launch, and cleanup

Prompt for LLM
File androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt, line 630:

Profile-switch cancellation can navigate after losing identity ownership

Also verify that the committed profile selection still owns the current authentication generation immediately before entering Main. `selectProfile` suspends, and another identity transition can occur after it commits while the foreground revision and picker entry remain unchanged; in that case this callback can navigate and seed content for a replacement identity. Capture the committed generation and validate it against the current authority before publishing navigation and related side effects.

**Also found in:**
- `androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt:635-635`

Kody rule violation: [Revalidate asynchronous ownership before publication, launch, and cleanup](https://kodus.siloserver.org/settings/code-review/1247142403/kody-rules/8ee8ffaf-7856-4c08-a084-f52e4c5e5f57?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

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

​

​

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.

🤖 Claude Code (claude-opus-5-5)

Fixed by 560f3ba on this branch. After selectProfile commits, Back enters Main only while the live identity is still that commit's own: the same server and profile, the generation exactly one past the switch's clear, and no remote-playback identity. Otherwise it neither enters nor clears. 6706144 also fences the undo clear to the scope that commit left, so it can't reach an identity that replaced it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the update. The fix keeps Back scoped to the identity created by the profile switch, and the undo clear is likewise fenced so it cannot clear a replacement identity.

Comment on lines +1571 to +1573
val pickerEntryId = navController.currentBackStackEntry?.id
activeProfileReset.clearActiveProfile()
val cleared = tokenManager.snapshotCurrentScope()

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 Bug high

Back remains unhandled while the profile reset is in progress

Pressing Back while clearActiveProfile() is suspended can still exit the app. Install the Back handler before displaying the picker and defer cancellation until the reset completes.

Prompt for LLM
File androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt, lines 1571-1573:

Back remains unhandled while the profile reset is in progress

The picker is displayed before the suspending profile reset finishes and before its Back handler is installed, so pressing Back during that interval still exits the app. Install a handler before displaying the picker and defer cancellation until the reset completes.

Talk to Kody by mentioning @kody

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

​

​

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.

🤖 Claude Code (claude-opus-5-5)

Fixed by 560f3ba and 6706144. The picker handles Back from the moment Switch Profile opens it. A press during the clear reopens the profile once the clear finishes, and a navigation-level handler covers the frames before the picker registers its own. On an Android TV emulator, Switch Profile followed by Back about 300 ms later now returns to the page it came from three out of three times, where it had closed Silo before.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the update. Commits 560f3ba18 and 6706144ee reportedly address the Back-handling gap, and the emulator check passed three out of three attempts. I haven’t independently verified the fix.

Comment on lines +1581 to +1587
switchReturn = TvProfileSwitchReturn(
profileId = closing.profileId!!,
profileToken = closing.profileToken,
clearedScope = cleared,
shellRoute = shellRoute,
pickerEntryId = pickerEntryId,
)

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 Bug high

In-flight switch can restore the return path after Manage starts

Manage can invalidate switchReturn while clearActiveProfile() is suspended, allowing the reset to reinstate an old profile proof. Prevent publication after Manage starts, including when Add Profile opens directly from the picker.

Prompt for LLM
File androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt, lines 1581-1587:

In-flight switch can restore the return path after Manage starts

Manage mode can start while `clearActiveProfile()` is suspended, before `switchReturn` is published, so its invalidation runs too early and the completed reset reinstates the old profile proof. Prevent publishing the return after Manage has started, including when Add Profile opens directly from the picker.

Talk to Kody by mentioning @kody

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

​

​

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.

🤖 Claude Code (claude-opus-5-5)

Fixed by 560f3ba. The switch reads a revision before it starts, and entering Manage bumps it, so a clear that finishes after Manage started doesn't publish a way back.

Add Profile straight from the picker keeps the way back on purpose. Creating a profile doesn't change the closed profile or its proof, and Back from the new-profile form returns to the picker, where Back still cancels the switch.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The revision check addresses the reported race: if Manage starts while the profile clear is in flight, the switch should no longer publish the return path.

Keeping the return path when Add Profile opens directly from the picker is a deliberate distinction. If Back from the form returns to the picker without changing the closed profile or its proof, the next Back can still cancel the switch.

I haven’t independently verified commit 560f3ba18 or those navigation paths.

Comment on lines +790 to +791
val switchProfileFromHere: () -> Unit = {
onSwitchProfile(currentRoute.takeIf { '{' !in it })

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 Bug medium

Switch Profile loses parameterized originating screens

Back reopens Home instead of the originating screen when currentRoute is parameterized. Preserve the destination arguments and reconstruct the route when restoring the shell.

Prompt for LLM
File androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/shell/TvMainShell.kt, lines 790-791:

Switch Profile loses parameterized originating screens

Switching from a parameterized destination such as request detail discards its route, so Back reopens Home instead of the screen the user came from. Preserve the concrete destination arguments and reconstruct the route when restoring the shell.

Talk to Kody by mentioning @kody

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

​

​

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.

🤖 Claude Code (claude-opus-5-5)

This is a known limit, listed under Risks in the PR body. A page whose route carries arguments (a request's detail page, for example) reopens on Home, because rebuilding it needs the original arguments, not just the route pattern. Those pages are rare places to start Switch Profile from, so this PR leaves it; a fuller restore can follow if it turns out to matter.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The Home fallback for parameterized routes is an intentional, documented limitation of this PR. I’ll withdraw the suggestion as a required change; restoring those destinations can be considered as a follow-up if it becomes important.

@Quick104
Quick104 marked this pull request as draft November 16, 2026 04:57
Quick104 and others added 3 commits November 19, 2026 10:58
Back on the picker waits while Switch Profile is still closing the
profile instead of leaving the app. Manage mode, or Silo leaving the
foreground, now also stops a switch still in flight from saving a way
back. Back's reopen and its undo run to the end even if the screen is
torn down, and only enter or undo the profile while the reopen's own
commit is still the live identity.

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

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

🤖 Claude Code (claude-opus-5-5)

Maintainer review of a32e0f0. The approach matches the Apple TV fix and I'm keeping it. Four findings below. I'm fixing all of them in commits on this branch, so there's no need to change anything yourself. A summary with scores follows once the fixes are pushed and checked on an emulator.

A second Back while Back was reopening the profile reached the system and
closed Silo, because the picker stopped handling Back as soon as the reopen
started. The picker now handles Back from the moment Switch Profile opens
it until the reopen finishes: a press during the clear runs once the way
back exists, and further presses wait for the reopen. A handler registered
at the navigation level also covers the frames after Main's handlers go and
before the picker registers its own, where a quick Back closed Silo.

Undoing a reopen that is no longer wanted now clears the profile only while
the reopen's own selection is still the live identity, through an optional
expected-scope fence on ProfileRepository.clearProfile, like selectProfile's.
A second Switch Profile press while one is running is ignored, and entering
any profile drops the way back and its proof.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added size/L 200–499 added + deleted lines (all files); change volume, not priority. and removed size/M 50–199 added + deleted lines (all files); change volume, not priority. labels Nov 23, 2026
@silo-kody

silo-kody Bot commented Nov 23, 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 ❌
⚠️ 5 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Validate download ownership before publishing subtitle bytes
  • Bind playback markers to the actual playing file
  • Share route-aware audio decisions and preserve original-format decoder fallback
  • Apply playback route eligibility consistently at admission and media loading
  • Serialize cache read-modify-write operations

Main starts on Home and only then opens the page a cancelled switch
restores. A Back in those first frames reached the system and closed
Silo, so a quick double Back on the picker still could. Main now reports
the restored page once it has composed, and Back is held until then.

A fenced clear that its scope no longer allows now returns before the
identity transition starts, as clearStaleProfile does, so the identity
that replaced it sees no gates. A Back pressed during the clear is
replayed only while the picker is still showing.

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

silo-kody Bot commented Nov 23, 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 ❌

Comment on lines +1105 to +1108
// no screen does. It also holds Back while a cancelled switch re-enters
// Main, until Main reports the restored page is showing.
BackHandler(enabled = reenteringMain || (switchState != null && switchState?.pickerEntryId == currentEntry?.id)) {
if (!reenteringMain) onSwitchPickerBack()

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 Bug high

Restoration Back hold loses priority to the shell's handlers

Later-registered shell handlers can process a second Back on the initial Home frame before the restored page is ready. Suppress the shell and nested navigation Back handlers during restoration, or register BackHandler at a higher priority.

Prompt for LLM
File androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt, lines 1105-1108:

Restoration Back hold loses priority to the shell's handlers

The hold is registered before the nested shell's Back handlers, so those later handlers take priority and can process a second Back on the initial Home frame before the restored page is ready. Suppress the shell and nested navigation Back handlers during restoration or register the hold at a higher priority.

Talk to Kody by mentioning @kody

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

​

​

@Quick104

Copy link
Copy Markdown
Contributor Author

🤖 Claude Code (claude-opus-5-5)

Maintainer review summary

Reviewed head: fa9424500. The branch also carries 560f3ba18 (fixes from an earlier review session) and a merge of main.

Fit: 8/10 · Readiness: 9/10 — conditional (assuming CI is green)

  • Fit. This fixes a core navigation failure on Android TV (Back on Who's watching closed Silo) and matches the Apple TV fix. It's 8 rather than higher because the TV closes the profile and then rebuilds it on Back, which takes a fair amount of state handling. The phone avoids that by leaving the profile open under the picker. See the first open item.
  • Readiness. I checked it live on an Android TV emulator against a fresh sandbox, the new shared test fails on the previous head, and the validation-board check ran. No substantive concern remains in the code.

Addressed in this review

  • A second Back while the profile reopened, or a quick Back right after Switch Profile, closed Silo. Back is now handled for the whole switch, and also while Main re-enters and restores the page (6706144ee, fa9424500).
  • The undo for a reopen that's no longer wanted could clear an identity that replaced it. ProfileRepository.clearProfile now takes an optional expected scope. It is checked before the identity transition, so a rejected clear fires no gates, and again inside it.
  • A second Switch Profile press is ignored while one is running. The way back is dropped when a profile is entered. A Back pressed during the clear is replayed only while the picker is still showing.
  • Kody's comments: three are fixed (replied in each thread). The fourth, routes with arguments reopening on Home, is a known limit listed under Risks.

Open for the maintainers

  1. Boundary. Pushing the picker over Main without closing the profile, as the phone does, would remove most of the reopen machinery. The cost is keeping the old profile's session live while the picker is up, and departing from the Apple TV fix. This PR keeps parity with Apple.
  2. Change Account → the account that's already open also opens Who's watching "as Switch Profile", but without a way back, so Back there still closes Silo. It isn't covered here.
  3. Back in Main's first frames. Choosing any profile tile and pressing Back within about 300 ms closes Silo, because Main starts on Home with the bar focused. main does the same. Whether that's a defect at all is a judgment call.

Checks

  • Validation board: no passed case regresses. Validation tasks: unblocks #320 C6 is correct.
  • Tests: :androidTvApp:testDebugUnitTest 1415 tests, 0 failures. ProfileRepositoryTest passes, and its new fenced-clear case fails on 6706144ee. :androidApp:compileDebugKotlin builds against the shared change.
  • User manual: unaffected. The Switch profiles section says nothing about Back on Who's watching.
  • Other clients: Apple fix(tvos): return to the previous screen on Back from Switch Profile silo-apple#1200 is linked. Roku and Web are N/A, as the PR body says.
  • Council: Sol (gpt-6.2-sol, medium) 5/10, then 7/10. Opus (claude-opus-5-5, medium) 7/10, then 7.5/10. Gemini (gemini-4-neon, medium) 8/10, then 9/10. Round 2 reviewed 6706144ee, and fa9424500 answers its findings. Details are in the PR body under Council review.

Evidence: https://evidence.siloserver.org/r/silo-android/issue-917/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: usability Core flow broken or severely blocked needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Back on Switch Profile exits the app (Android TV)

1 participant