Skip to content

[PM-35118] fix: Prevent vault timeout from re-firing for already-soft-logged-out accounts#2571

Draft
morganzellers-bw wants to merge 4 commits intomainfrom
pm-35118-vault-timeout-issue-claude
Draft

[PM-35118] fix: Prevent vault timeout from re-firing for already-soft-logged-out accounts#2571
morganzellers-bw wants to merge 4 commits intomainfrom
pm-35118-vault-timeout-issue-claude

Conversation

@morganzellers-bw
Copy link
Copy Markdown
Contributor

@morganzellers-bw morganzellers-bw commented Apr 24, 2026

🎟️ Tracking

PM-35118

📔 Objective

After setting Vault Timeout to Immediate + Log Out, the account is soft-logged-out on foreground (PM-11472 design, access token removed but account kept in state for email pre-fill). However, checkSessionTimeouts was re-firing the timeout on every subsequent foreground event because hasPassedSessionTimeout always returns true for .immediately (0 seconds elapsed ≥ 0). This caused the app to navigate the user back to the landing screen even while they were mid-way through re-authenticating on the login screen.

Fix: Add && !account.isLoggedOut to the shouldTimeout guard in checkSessionTimeouts. account.isLoggedOut is !isAuthenticated, which (after PM-35285) correctly returns true for soft-logged-out accounts. This prevents the timeout from re-firing for accounts that are already logged out.

Test corrections included:

  • Two existing tests (lockAccount, logoutAccount) needed stateService.isAuthenticated[userId] = trueMockStateService defaults isAuthenticated to false, so without it the accounts appeared already-logged-out and the timeout was skipped.
  • One existing test (timedOut_activeAccount_handleActiveUser) was vacuously passing because the closure assertion was never reached; hardened with an explicit handleActiveUserCalled flag.
  • One router test (didTimeout_sessionExpired_logout) was asserting .landing but production actually returns .landingSoftLoggedOut — the old assertion only passed because authRepository.activeAccount was unset, forcing getAccount() through the catch path.

Screenshots

Before & After Videos
pm-35118-after-720.mov
pm-35118-before-720.mov

@morganzellers-bw morganzellers-bw added the ai-review Request a Claude code review label Apr 24, 2026
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug labels Apr 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.21%. Comparing base (3ecf4ce) to head (6db8a42).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...d/Core/Auth/Repositories/AuthRepositoryTests.swift 90.47% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2571    +/-   ##
========================================
  Coverage   87.20%   87.21%            
========================================
  Files        1894     1895     +1     
  Lines      167519   167756   +237     
========================================
+ Hits       146087   146302   +215     
- Misses      21432    21454    +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the one-line fix in AuthRepository.checkSessionTimeouts that prevents handleActiveUser/logout from re-firing for accounts already in the soft-logged-out state, plus the accompanying test changes. Verified account.isLoggedOut is derived from !isAuthenticated via profileItem(from:), so the guard correctly suppresses the redundant timeout for .immediately after PM-35285. Confirmed the router test correction (.landing.landingSoftLoggedOut) matches production behavior in AuthRouter+Redirects.swift:312, and the test hardening (explicit handleActiveUserCalled flag, setting stateService.isAuthenticated = true where MockStateService defaults to false) addresses real test-quality issues described in the PR body.

Code Review Details

No findings.

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

Labels

ai-review Request a Claude code review app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant