Repository navigation
fix(auth): return to the open page after signing back in - #629
Conversation
When the server revoked a session, the app sent the person to Sign in and, after they signed back in as the same profile, opened Home instead of the page they were on (for example a series detail). AppRouter.expiredSession() cleared the navigation path and leaving the authenticated state closed the iOS detail card, and nothing remembered them. The iOS sign-in screen also never showed the session-expired notice the router already set; only the tvOS screen rendered it. The router now records the signed-in server, verified account and profile when it enters the main screens. On session expiry it keeps the navigation path and, on iOS, the open detail card with its nested path. resetToHome() restores them once, and only when the same server, account and profile sign back in. Profile ids are unique only within an account, so all three must match; a different account or profile, an unknown owner, or a server change or explicit sign-out starts at Home. The iOS sign-in screen shows "You were signed out of <server>. Sign in again." in its lead line, using the same copy as the tvOS chip. Tests cover restore for the same owner, no restore for another profile, the same profile id on another account, an unknown owner, a second sign-in, and a server change. Found during the Series validation, silo-apple#337.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (6)
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. Comment |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| guard !path.isEmpty || presentedItemDetail != nil else { return nil } | ||
| return SessionReturnPoint(owner: authenticatedOwner, path: path, | ||
| itemDetail: presentedItemDetail, itemDetailPath: itemDetailPath) | ||
| #else | ||
| guard !path.isEmpty else { return nil } | ||
| return SessionReturnPoint(owner: authenticatedOwner, path: path) |
There was a problem hiding this comment.
Root-page selection loss in iosApp/iosApp/Navigation/AppRouter.swift returns the same profile to Home after session expiration on Search, a library tab, or a TV personal root: MainTabView initializes local selectedDestinationID to Home, TVMainTabView stores selectedRoot/personalRoot locally, authentication termination removes both shells, and the empty-stack guard discards the return point. Persist and restore shell selection alongside the navigation paths in SessionReturnPoint.
Prompt for LLM
File iosApp/iosApp/Navigation/AppRouter.swift:
Line 965 to 970:
Root-page selection loss in iosApp/iosApp/Navigation/AppRouter.swift returns the same profile to Home after session expiration on Search, a library tab, or a TV personal root: MainTabView initializes local selectedDestinationID to Home, TVMainTabView stores selectedRoot/personalRoot locally, authentication termination removes both shells, and the empty-stack guard discards the return point. Persist and restore shell selection alongside the navigation paths in SessionReturnPoint.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Not changing in this PR. It restores the navigation path and, on iOS, the open detail card with its nested path, so a page pushed from any tab comes back on top after the same profile signs in again. The root tab under it starts at Home: on iOS the selection is view state in MainTabView (MainTabDestinationID, including per-library tabs that are re-resolved against the visible menu), and on tvOS selectedRoot and personalRoot live in TVMainTabView. Restoring them means having both shells report their selection to the router and re-validate it against the menu after sign-in, which is a separate change across both platforms. It is a reasonable follow-up.
There was a problem hiding this comment.
Understood. The PR restores pushed navigation and the iOS detail card; restoring the underlying root selection requires a separate change across both shells, including revalidation against the post-sign-in menu.
I’d treat the suggestion as a non-blocking follow-up, not a required change for this PR. The remaining limitation is that an unpushed root page returns to Home, and restored pushed pages have Home underneath them.
Would you like me to create a follow-up issue for root-selection restoration on iOS and tvOS?
Problem
Related issue: N/A
Validation tasks: changes #337 C5
When the server revoked a session, the app sent the person to Sign in and, after they signed back in as the same profile, opened Home instead of the page they were on. The iOS sign-in screen also never showed the session-expired notice the router already set; only tvOS showed it. Now the app explains why sign-in is needed and returns to the open page.
Approach
resetToHome()restores them once, and only when the same server, account and profile sign back in. Profile ids are unique only within an account, so all three must match. A different account or profile, an unknown owner, a server change or an explicit sign-out starts at Home.Validation
scripts/ci/check-no-api-v1.sh: pass.main(6242652): the full iOS unit suite ran 2,691 tests. The only failures areArtworkURLTests.testDeliveryCapabilityOnIOSUsesV2RouteAndResetsandImageSizeCapabilityTests.testResetClearsCapability, which fail the same way onmain. tvOSbuild-for-testingand the macOS build succeed.Simulator screenshots (iOS 26.5, tvOS 26.5):
Risks
None identified.
Checklist
AI Disclosure
mainat medium effort, checking behaviour, platform guards (iOS, tvOS, macOS), tests and commit hygiene. It checked profile switches, sign-out and server changes clear the saved screens, and platform guards. No findings.Note
Fix iOS/tvOS auth to restore open screens after re-signing in from an expired session
AppRouter.expiredSessionsaves the current navigation path (plus iOS item-detail state) in memory, then routes the user to sign-in.SessionOwnervalue type backed byAuthService.accountID. Any other owner starts at Home, and the point is consumed once.resetToLogin,resetToServerSetup, andresetAfterServerResolutionall discard the saved point.AppRouter.LoginNotice.messageon iOS, macOS, and tvOS (LoginView.swift, TVLoginView.swift).Macroscope summarized df0b713.