You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(tvos): return to the previous screen on Back from Switch Profile - #1200
Closes#1164
Related issue: N/A
Validation tasks: unblocks #310 C6; changes #310 C2, #310 C5, #304 C3, #308 C5, #333 C2, #335 C2 (minor: these switch profiles, and choosing a profile works as before; the picker opened from Settings now starts with a profile focused)
Other clients: Android Silo-Server/silo-android#917; Roku N/A (Roku's picker is pushed over the open profile, and Back already returns to it); Web N/A (no remote Back that closes the app)
On Apple TV, choosing Switch Profile and then pressing Back (Menu) on Who's watching? closed the app. Back is supposed to return to the screen the picker was opened from. The switch closes the open profile and replaces the whole tab shell with the picker. The picker had no Back handler, so Menu went to tvOS.
Opened from Settings, the picker also started with nothing focused, so Back went to tvOS even once the picker could handle it.
Approach
Back on a picker that Switch Profile opened now cancels the switch. As decided for this issue, it reopens the same profile with the proof it already had (no PIN prompt), on the same page. This is Apple TV only.
AppRouter.switchProfile() captures the open profile (AuthService.openProfileForSwitch), the pushed screens (the existing SessionReturnPoint) and the shell page (TVShellPlace: tab, Watchlist/Favorites/Requests page, library section). It keeps them in memory while that picker is up. The switch still marks selection required and closes the profile as before. Quitting on the picker still shows it at the next launch.
ProfileSelectionView handles Menu only while that return exists and nothing is pushed over the picker. On any other picker, including the one at launch, Menu still goes to tvOS.
AppRouter.cancelProfileSwitch() reopens the profile through AuthService.reopenProfile. That reuses the existing activateProfile commit: HTTP identity barrier, cache reset, Top Shelf mirror, remembered profile, selection-required cleared. The commit is fenced in the token store against a different account and against any profile opened since the switch. It then runs the same capability refresh as a profile selection and goes back through resetToHome(), which already restores pushed screens for the same owner. TVMainTabView starts on the saved page. Player settings refresh in the background afterwards.
The switch swaps to the picker without the stack crossfade, as the account flows already do, so the picker opened from Settings gets focus.
The way back is dropped when:
any route change happens, including another account's picker;
the app goes to the background, so a picker found later needs a profile choice and its PIN again (a switch or Back still in flight then gives up too, and a profile already reopened is closed again);
the reopen fails (the picker stays, takes focus again, and Back goes to tvOS).
Back is ignored while the picker is opening a profile, checking a PIN, lending the primary profile to Add Profile, or showing the remember offer.
Validation
Reproduced on unfixed main (8ba9c514) on an Apple TV 4K simulator against a Silo dev deployment built from silo-server main. The account had three profiles, one with a PIN. Movies → profile menu → Switch Profile → Menu closed the app. Settings → profile row → Menu did the same, and that picker showed nothing focused.
On the fix (06e1db46), the same steps returned to Movies and to Settings as the same profile, with focus on the page.
A PIN profile opened on Series came back to Series with no PIN prompt. The server log showed one PIN check (the one typed) and no 4xx responses.
Unchanged behavior, checked live:
Menu on the launch picker still closes the app.
Leaving the app on the Switch Profile picker and coming back leaves Menu closing the app.
Menu on the PIN pad closes only the PIN pad.
Change Account → Menu returns to the picker.
Quitting on the picker shows it again at the next launch.
127 SiloTVTests across the session-return, account, profile-launch, profile-menu, password-change, remote-playback, profile-verification and server-connect classes pass.
After the review fixes, the head (120cad1b) was checked again on a new sandbox and simulator: Movies, Settings, the PIN profile on Series, and the picker after leaving the app. The same 127 tests pass.
7ed2ea93 changes only the case where the picker Back was pressed on is replaced while the profile reopens: the profile now closes again. That case can't be produced from the remote. The head builds for tvOS, iOS and macOS, and the paths checked above take the same branch.
Silo (iOS) and SiloMac build. Their code paths are unchanged apart from a shared helper extracted in AuthService and an opt-in parameter on TokenStore.activateProfile.
The closed profile's token stays in memory only 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.
Watchlist, Favorites and Requests restoring was checked in code only: those pages weren't in this account's profile menu.
AI Disclosure
Harness: Claude Code in T3 Code
Tool(s): Claude Code, GitHub CLI, agent-device (simulator control), silo-build, silo-evidence
Model(s): claude-opus-5-5
Involvement: Fully AI-generated; not yet verified by a human
Adversarial review: Before implementing, gpt-6.1-sol (Codex, xhigh) attacked the plan and claude-opus-5-5 (high) cut it down. From the cut: dropped a library-visibility check that would have sent library tabs to Home, and moved invalidation to authState.didSet. From the attack: guarded against the Add Profile temporary context, captured the profile after a remote-playback identity ends, kept personal pages and library sections, and made Back path-aware. A high-level code review (three finders plus a validation check, claude-opus-5-5 and claude-sonnet-5-5) led to the second commit: drop the way back on leaving the app, restore focus after a failed reopen, ignore a second Switch Profile press, bind the switch to the captured profile, restore the page only for the same picker, and fall back to Home when a restored library tab can't load. A simplify pass replaced a nested conditional. The background adversarial review (gpt-6.1-sol, xhigh, reviewed 06e1db46) found two issues, both fixed in 120cad1b. Back waited on a player-settings request with the picker disabled; it now restores the page first. Leaving the app didn't stop a switch or Back already in flight; it now does. The same commit answers the Codex, Kody and CodeRabbit findings on those paths and adds a token-store fence so a late Back can't replace a profile chosen meanwhile.
Return to previous screen on Back from tvOS Switch Profile
On tvOS, a successful Switch Profile now records the closed profile and the current shell location (root, personal page, pill selections) so Back can restore them.
Back on the root picker cancels the switch: it reopens the captured profile with its saved token, restores the prior shell location via TVMainTabView.swift, and resets to Home.
The saved return is invalidated when the app backgrounds (ContentView.swift), on auth-state changes, or when the foreground session changes, and reopening is refused if a temporary identity or another open profile blocks activation.
Picker content is disabled and cannot take focus while cancellation is in progress, and Back is ignored during PIN entry, Add Profile preparation, or management flows in ProfileSelectionView.swift.
TokenStore.activateProfile and AuthService.activateProfile gain a requiringNoOpenProfile option so reopening fails when a profile is already open.
Back on the "Who's watching?" picker that Switch Profile opened exited the
app. The switch closes the profile and replaces the tab shell with the
picker, which had no Back handler, so Menu went to the system.
The switch now keeps the closed profile, its proof and the page it was on
in memory while that picker is up. Back reopens the same profile without
asking for its PIN and returns to the same tab, personal page, library
section or pushed screen (Settings). The picker opened at launch still
leaves Back to the system, and quitting on the picker still shows it at
the next launch.
From Settings the picker opened with nothing focused, so Back still
reached the system; the switch now swaps stacks without the crossfade.
Fixes#1164
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups for the Back-on-Switch-Profile fix:
- Leaving the app drops the saved return, so a picker resumed later
needs a profile choice (and its PIN) again.
- A failed reopen keeps the picker, puts focus back on it and returns
Back to the system.
- A second Switch Profile press while one runs is ignored.
- The switch closes only the profile it captured.
- The page is restored only if the picker is still the one Back was
pressed on.
- A restored library tab falls back to Home if the libraries can't load.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
On tvOS, switching profiles now records the closed profile and the current session and shell location. The profile picker can cancel the switch and reopen the profile, subject to activity checks. The app clears saved return state after route changes or when it enters the background.
Changes: Profile-switch return flow
Layer / File(s)
Summary
Capture and reopen the switched profile iosApp/iosApp/Screens/Auth/AuthService.swift, iosApp/iosApp/Navigation/AppRouter.swift
AuthService can capture and reopen the profile closed for a switch. Explicit selection can now check that the open profile matches an expected profile ID.
Route and restore the previous location iosApp/iosApp/Navigation/AppRouter.swift, iosApp/iosApp/tvOS/Navigation/TVMainTabView.swift, iosApp/iosApp/ContentView.swift
AppRouter stores switch-return state and restores the session and shell location after reopening. TVMainTabView publishes and restores shell state. Route changes and backgrounding clear saved return state.
The picker allows cancellation only when profile selection, PIN verification, management preparation, and temporary management-context operations are inactive. The picker is disabled and focus is withheld during cancellation.
sequenceDiagram
participant ProfileSelectionView
participant AppRouter
participant AuthService
participant TVMainTabView
ProfileSelectionView->>AppRouter: cancelSwitch when cancellation is allowed
AppRouter->>AuthService: reopen saved profile
AuthService-->>AppRouter: reopened profile
AppRouter->>AppRouter: refresh authenticated content and player settings
AppRouter->>TVMainTabView: provide saved shell location
TVMainTabView->>AppRouter: publish restored shell location
Loading
Suggested reviewers:blurbery, rhainland, zzebrahz
Merge Risk: Low · up to 06e1d
On Apple TV, Back from Switch Profile now returns to the previous screen. In a rare timing case, backgrounding the app during the switch can leave a Back return that should have been discarded, so the picker lets Back reopen the previous profile instead of requiring a fresh choice. The impact is narrow and easy to fix with a small guard, so this is mergeable with that follow-up.
Security architecture risk: Moderate · up to 06e1d
A backgrounding race can leave the previous profile reopenable without its PIN after leaving the app, despite the intended foreground-only restriction. Exposure is limited to the same Apple TV and the previously open account and profile.
Retained concerns
Medium · security · inferred: Backgrounding does not revoke in-flight profile-switch authority. If the app backgrounds while switchProfile is awaiting profile deactivation, forgetProfileSwitchReturn clears only the current property. The switch can subsequently publish a new return containing the retained proof without checking whether background invalidation occurred. Returning to a picker does not reset that flow, so a subsequent viewer with control of the same TV can press Back and reopen the previous PIN-protected profile without entering its PIN, provided the captured proof remains valid. Before this PR, the picker had no equivalent no-PIN return path.
Security review details
Security Blast Radius
inferred — The identified path requires control of the same Apple TV after a profile switch overlaps backgrounding. Its authority is the captured profile’s existing proof under the captured account, not an arbitrary profile or another account. Effective server access remains bounded by acceptance of that proof.
Security Findings and Attack Paths
inferred — The introduced revocation failure is: switch awaits completion; background clears the return; switch completion republishes it; foreground handling leaves the picker unchanged; Back reactivates the captured proof without a PIN. Clearing a stored return is therefore insufficient to enforce its intended foreground-only lifetime.
Trust Boundaries and Controls
observed — At profile activation, temporary ownership is refused and the current account identity must equal the captured account. Saved navigation is restored only for the same server, account and profile. Route assignments clear published return state. These are meaningful containment controls, but they do not check the foreground lifetime of pending return publication.
Hardening Proposals
proposed — Represent the no-PIN return as revocable authority shared by the pending switch and cancellation operations. Invalidate it on background and ownership-changing routes, reject stale publication and activation, and retain selection-required when reopening is refused.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix (Back on Switch Profile returns to the previous screen on tvOS), which matches the main change: the picker's Menu handling, the saved return state, and the reopen logic in AppR…
Linked Issues check
[#1164] The only directly linked issue asks that Back on the Apple TV Switch Profile picker return to the previous screen with focus on a usable element, and that exit remain the top-level Back behavi…
Out of Scope Changes check
Every listed change connects to the Switch Profile Back path. AuthService changes (openProfileForSwitch, reopenProfile, ClosedProfile, optional expectedProfileID in beginExplicitProfileSelection, and …
Description check
The description is specific and on-topic. It names the Apple TV Switch Profile bug (Menu on the picker closed the app), explains the approach (saved open profile, shell page, and session return point;…
Full details: Title check
Explanation
The title names the fix (Back on Switch Profile returns to the previous screen on tvOS), which matches the main change: the picker's Menu handling, the saved return state, and the reopen logic in AppRouter, AuthService, and ProfileSelectionView. It is specific and follows the conventional-commit style.
Full details: Linked Issues check
Explanation
[#1164] The only directly linked issue asks that Back on the Apple TV Switch Profile picker return to the previous screen with focus on a usable element, and that exit remain the top-level Back behavior. The reviewed changes implement this from the summary: AppRouter.switchProfile() captures the open profile (AuthService.openProfileForSwitch), the pushed screens (SessionReturnPoint), and the shell place (TVShellPlace). ProfileSelectionView handles Menu only while that return exists and nothing is pushed over the picker. AppRouter.cancelProfileSwitch() reopens the profile via AuthService.reopenProfile and calls resetToHome(), which restores pushed screens. TVMainTabView restores the saved shell place. The Settings-opened picker is made focusable by switching without the stack crossfade. The launch picker keeps Menu going to tvOS, which matches the issue's top-level exit rule. The PR description reports simulator validation of the Movies, Settings, and PIN-profile cases. Limits: the summary does not show test files, so the reported 127 SiloTVTests pass is taken from the PR description and was not verified in the diff. Watchlist, Favorites, and Requests restoration was checked in code only, per the PR description. These gaps do not affect the issue's stated behavior.
Full details: Out of Scope Changes check
Explanation
Every listed change connects to the Switch Profile Back path. AuthService changes (openProfileForSwitch, reopenProfile, ClosedProfile, optional expectedProfileID in beginExplicitProfileSelection, and the shared capability-refresh helper) support capturing and restoring the closed profile. The completeRequestedProfileSwitch return-type change and the tvOS retry after ending the remote identity support capturing the profile underneath a remote-playback identity. TVShellPlace and TVPersonalRootDestination visibility support restoring the shell page. The ContentView background call and the route-change clearing in the auth observer support the stated discard rules. The ProfileSelectionView changes gate Menu and block cancellation during PIN, management, and remember-offer states, which the issue's usable-focus and top-level exit expectations require. The Apple TV-only scope is stated in the PR description and is consistent with the tvOS-gated changes in the summary. No unrelated change appears in the summary.
Full details: Description check
Explanation
The description is specific and on-topic. It names the Apple TV Switch Profile bug (Menu on the picker closed the app), explains the approach (saved open profile, shell page, and session return point; reopen on cancel; picker focus from Settings), and lists validation steps and risks. It matches the changeset in AppRouter, AuthService, ProfileSelectionView, and TVMainTabView.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
…eopen
Review follow-ups for Back on Switch Profile:
- Leaving the app now also stops a switch or a Back still in flight. A
switch finishing afterwards keeps no way back, and a Back that already
reopened the profile closes it again and stays on the picker.
- The reopen commits only while no profile is open, checked in the same
token-store turn as the account, so a profile chosen meanwhile wins.
- Back restores the page before refreshing player settings, so a slow
server can't leave the picker disabled with nothing focused.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
When Back's reopen finishes after the picker it was pressed on was
replaced (a same-account rebuild that asks for a fresh choice), the
profile now closes again instead of staying open behind the new screen.
Home that something else already opened is left alone.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 3 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:
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
bugSomething isn't workingimpact: usabilityCore flow broken or severely blockedneeds-reviewNeeds maintainer review to resolve uncertain classification, scope, or changed evidence.priority: P2Limited scope, workaround exists, or polishsize/L200–499 added + deleted lines (all files); change volume, not priority.
1 participant
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.
Problem
Closes #1164
Related issue: N/A
Validation tasks: unblocks #310 C6; changes #310 C2, #310 C5, #304 C3, #308 C5, #333 C2, #335 C2 (minor: these switch profiles, and choosing a profile works as before; the picker opened from Settings now starts with a profile focused)
Other clients: Android Silo-Server/silo-android#917; Roku N/A (Roku's picker is pushed over the open profile, and Back already returns to it); Web N/A (no remote Back that closes the app)
On Apple TV, choosing Switch Profile and then pressing Back (Menu) on Who's watching? closed the app. Back is supposed to return to the screen the picker was opened from. The switch closes the open profile and replaces the whole tab shell with the picker. The picker had no Back handler, so Menu went to tvOS.
Opened from Settings, the picker also started with nothing focused, so Back went to tvOS even once the picker could handle it.
Approach
Back on a picker that Switch Profile opened now cancels the switch. As decided for this issue, it reopens the same profile with the proof it already had (no PIN prompt), on the same page. This is Apple TV only.
AppRouter.switchProfile()captures the open profile (AuthService.openProfileForSwitch), the pushed screens (the existingSessionReturnPoint) and the shell page (TVShellPlace: tab, Watchlist/Favorites/Requests page, library section). It keeps them in memory while that picker is up. The switch still marks selection required and closes the profile as before. Quitting on the picker still shows it at the next launch.ProfileSelectionViewhandles Menu only while that return exists and nothing is pushed over the picker. On any other picker, including the one at launch, Menu still goes to tvOS.AppRouter.cancelProfileSwitch()reopens the profile throughAuthService.reopenProfile. That reuses the existingactivateProfilecommit: HTTP identity barrier, cache reset, Top Shelf mirror, remembered profile, selection-required cleared. The commit is fenced in the token store against a different account and against any profile opened since the switch. It then runs the same capability refresh as a profile selection and goes back throughresetToHome(), which already restores pushed screens for the same owner.TVMainTabViewstarts on the saved page. Player settings refresh in the background afterwards.The way back is dropped when:
Back is ignored while the picker is opening a profile, checking a PIN, lending the primary profile to Add Profile, or showing the remember offer.
Validation
main(8ba9c514) on an Apple TV 4K simulator against a Silo dev deployment built from silo-servermain. The account had three profiles, one with a PIN. Movies → profile menu → Switch Profile → Menu closed the app. Settings → profile row → Menu did the same, and that picker showed nothing focused.06e1db46), the same steps returned to Movies and to Settings as the same profile, with focus on the page.SiloTVTestsacross the session-return, account, profile-launch, profile-menu, password-change, remote-playback, profile-verification and server-connect classes pass.120cad1b) was checked again on a new sandbox and simulator: Movies, Settings, the PIN profile on Series, and the picker after leaving the app. The same 127 tests pass.7ed2ea93changes only the case where the picker Back was pressed on is replaced while the profile reopens: the profile now closes again. That case can't be produced from the remote. The head builds for tvOS, iOS and macOS, and the paths checked above take the same branch.Silo(iOS) andSiloMacbuild. Their code paths are unchanged apart from a shared helper extracted inAuthServiceand an opt-in parameter onTokenStore.activateProfile.Evidence: https://evidence.siloserver.org/r/silo-apple/issue-1164/
Risks
AI Disclosure
authState.didSet. From the attack: guarded against the Add Profile temporary context, captured the profile after a remote-playback identity ends, kept personal pages and library sections, and made Back path-aware. A high-level code review (three finders plus a validation check, claude-opus-5-5 and claude-sonnet-5-5) led to the second commit: drop the way back on leaving the app, restore focus after a failed reopen, ignore a second Switch Profile press, bind the switch to the captured profile, restore the page only for the same picker, and fall back to Home when a restored library tab can't load. A simplify pass replaced a nested conditional. The background adversarial review (gpt-6.1-sol, xhigh, reviewed06e1db46) found two issues, both fixed in120cad1b. Back waited on a player-settings request with the picker disabled; it now restores the page first. Leaving the app didn't stop a switch or Back already in flight; it now does. The same commit answers the Codex, Kody and CodeRabbit findings on those paths and adds a token-store fence so a late Back can't replace a profile chosen meanwhile.🤖 Generated with Claude Code
Note
Return to previous screen on Back from tvOS Switch Profile
TokenStore.activateProfileandAuthService.activateProfilegain arequiringNoOpenProfileoption so reopening fails when a profile is already open.Macroscope summarized 7ed2ea9.