After a failed sign-in token refresh, focus is lost and the return route is not preserved. Find the cause, fix it, and add regression coverage.
Fix session recovery
CompletedA3S I reproduced the issue. The failure branch cleared the recovery target before redirecting and skipped focus restoration for the trigger.
Plan3 / 3 complete- Reproduce sign-in recovery issue
- Repair route and focus recovery
- Add regression coverage and verify
Delivery statusTask is ready for reviewVerified- 12
- Passed
- 0
- Pending
- 0
- Failed
- 0
- Risks
Review analysisLocated recovery-state cleanup orderingThe failure branch cleared the recovery target before redirecting, while focus restoration depended on an unmounted trigger. The fix preserves a stable return path and restores focus after navigation commits.
Execution record4 steps · 4.8sInspect recovery pathsrc/auth/session.ts · src/routes/sign-in.tsxComplete
- Action
- Read 2 source files and 1 test file
- Finding
- The failure branch cleared the return path too early
Update recovery implementationsrc/auth/session.ts+18 −6
src/auth/session.ts − const target = session.returnTo;+ const target = normalizeReturnPath(returnTo); await refreshSessionToken();+ navigate(target);+ restoreTriggerFocus();Confirm workspace test runnpm test -- sessionApproved
Your approval is requiredApplies only to this operation- Action
npm test -- session- Reason
- The command starts a local test process and reads the current workspace.
- Scope
- Current task workspace; no writes outside it.
Run regression tests12 passed · 0 failedPassed
Test log
npm test -- session
Completed4 records · All retained#01stdout$ npm test -- session
#02stdoutPASS tests/session.test.ts
#03stdoutRestores focus after failure · Preserves return route · Announces recovery state
#04stdoutTests: 12 passed, 0 failed
Parallel checks2 checks complete- Regression coverageTest review · Complete
- Keyboard focus reviewAccessibility check · Complete
The recovery path and its regression tests now pass.