Skip to content

fix(auth): return to the open page after signing back in - #629

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:fix/return-after-reauth
Oct 6, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:fix/return-after-reauth

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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

  • The router records the signed-in server, 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, a server change or an explicit sign-out starts at Home.
  • The iOS sign-in screen shows "You were signed out of . Sign in again.", the same copy as the tvOS notice.

Validation

  • Unit tests for restore with the same owner, and no restore for another profile, the same profile id on another account, an unknown owner, a second sign-in and a server change: pass.
  • Manual, iPhone simulator: after revoking the session on a person page, the sign-in screen showed the notice, and signing in as the same profile returned to that page.
  • scripts/ci/check-no-api-v1.sh: pass.
  • All 22 app fixes from this validation run, merged together on main (6242652): the full iOS unit suite ran 2,691 tests. The only failures are ArtworkURLTests.testDeliveryCapabilityOnIOSUsesV2RouteAndResets and ImageSizeCapabilityTests.testResetClearsCapability, which fail the same way on main. tvOS build-for-testing and the macOS build succeed.
  • Local builds used Swift 6.3.3, which needs the ThumbHash type annotations from fix(build): annotate ThumbHash cosine tables so Swift 6.3.3 can type-check them #608 to compile. That change was applied locally and is not part of this PR.

Simulator screenshots (iOS 26.5, tvOS 26.5):

a12-reauth

Risks

None identified.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code, running in T3 Code
  • Tool(s): Claude Code subagents, xcodebuild, Xcode Simulator (simctl, Maestro), GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: A separate Claude Code reviewer agent (claude-opus-5-5) read this branch's diff against main at 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

  • When a session expires, AppRouter.expiredSession saves the current navigation path (plus iOS item-detail state) in memory, then routes the user to sign-in.
  • On Home reset, the saved point is restored only when the same server, account, and profile sign back in, tracked via the new SessionOwner value type backed by AuthService.accountID. Any other owner starts at Home, and the point is consumed once.
  • resetToLogin, resetToServerSetup, and resetAfterServerResolution all discard the saved point.
  • Session-expired sign-in screens now show a server-specific message from AppRouter.LoginNotice.message on iOS, macOS, and tvOS (LoginView.swift, TVLoginView.swift).
  • Adds SessionReturnNavigationTests.swift covering all restore and discard cases.
  • Behavioral Change: restoration is in-memory only, so a saved point is lost if the app restarts between expiry and sign-in.

Macroscope summarized df0b713.

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

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c294600-4010-4780-8007-54b2139236f5
📥 Commits

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

📒 Files selected for processing (6)
  • iosApp/Tests/SessionReturnNavigationTests.swift
  • iosApp/iosApp/Navigation/AppRouter.swift
  • iosApp/iosApp/Screens/Auth/AuthService.swift
  • iosApp/iosApp/Screens/Auth/LoginView.swift
  • iosApp/iosApp/Screens/Auth/TVLoginView.swift
  • iosApp/iosApp/Screens/Auth/TVSignInPresentation.swift
  • 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.

@silo-kody

silo-kody Bot commented Oct 5, 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 ❌

@Rhainland Rhainland mentioned this pull request Oct 5, 2026
11 tasks
Comment on lines +965 to +970
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)

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

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.

​

​

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.

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.

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 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?

@Quick104
Quick104 merged commit 2db42f3 into Silo-Server:main Oct 6, 2026
5 of 6 checks passed
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.

2 participants