fix: redirect to home after login (#2726)
Issue Fixed
- Fixes #2726: After successful login, users are now automatically redirected to their dashboard/home page.
What was broken
- After successful OAuth or magic link login, session state was patched to a non-React/global store instead of the React context, so UI and routing logic did not detect the new session and did not redirect users.
Fix
- Added a listener in the main app shell to handle the session token update event. It updates the React context (via
storeSessionToken). The routing guards then automatically route users home on login. - No changes to logout, signup, or other flows.
Summary by CodeRabbit
- Bug Fixes
- Enhanced session token management to properly synchronize token updates across the application, ensuring consistent session state during active sessions.
AppShell now subscribes to a Session Token Event Synchronization 🎯 2 (Simple) | ⏱️ ~8 minutes 🐰 A rabbit hops through event streams so bright,
Catching token updates mid-flight!
AppShell listens, storeSessionToken calls,
Session state syncs through digital halls. ✨ ✏️ Tip: You can configure your own custom pre-merge checks in the settings.📝 Walkthrough
Walkthrough
core-state:session-token-updated browser event via useEffect. When the event fires with a sessionToken in its details, the app updates its core session state by calling storeSessionToken. The listener is properly cleaned up when the component unmounts or the dependency changes.Changes
Layer / File(s)
Summary
Session token update event listener
app/src/App.tsxA
useEffect hook in AppShell registers a listener for the core-state:session-token-updated custom event. When fired with event.detail.sessionToken, it updates app session state via storeSessionToken() and cleans up the listener on unmount.Estimated code review effort
Poem
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name
Status
Explanation
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title 'fix: redirect to home after login' directly matches the main objective: automatically redirecting users to home after successful login.
Linked Issues check
✅ Passed
The code change adds a listener for session token updates and syncs React context, directly addressing issue
#2726's root cause of missing session state synchronization preventing post-login redirect.
Out of Scope Changes check
✅ Passed
The changes are narrowly scoped to session token synchronization in App.tsx, directly addressing the linked issue with no unrelated modifications.
Docstring Coverage
✅ Passed
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
⚔️ Resolve merge conflicts
main
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add
eslintto devDependencies.
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 @coderabbitai help to get the list of available commands and usage tips.
Issue Fixed
- Fixes Login does not automatically redirect user after successful authentication #2726: After successful login, users are now automatically redirected to their dashboard/home page.
What was broken
- After successful OAuth or magic link login, session state was patched to a non-React/global store instead of the React context, so UI and routing logic did not detect the new session and did not redirect users.
Fix
- Added a listener in the main app shell to handle the session token update event. It updates the React context (via
storeSessionToken). The routing guards then automatically route users home on login.- No changes to logout, signup, or other flows.
Summary by CodeRabbit
Bug Fixes
- Enhanced session token management to properly synchronize token updates across the application, ensuring consistent session state during active sessions.
still not working
@Sushanth012 this PR has merge conflicts with main — please rebase/resolve before review.
This PR has merge conflicts with main — please rebase/resolve before review.
Hi @Sushanth012 — thank you for taking the time to investigate this and open a PR! We appreciate the contribution.
After tracing the login flow carefully, we're closing this PR because the described issue does not exist in the current codebase. Here's the detailed reasoning:
Why this bug doesn't exist
The PR claims: session state is patched to a non-React/global store after login, so the React context never sees the new session and the redirect doesn't happen.
What the code actually does:
-
desktopDeepLinkListener.ts→applySessionToken()dispatches thecore-state:session-token-updatedcustom event after writing the token (line 100). -
CoreStateProvider.tsxalready listens for that exact event (theonSessionTokenUpdatedhandler inside auseEffect). When it fires, it callsrefresh()→fetchCoreAppSnapshot→commitState()— which is precisely the React context update path. The event was never ignored. -
The redirect to
/homeis already handled insidehandleAuthDeepLinkindesktopDeepLinkListener.ts. It polls the module-level snapshot to confirmcommitStatehas run (i.e.currentUser+sessionTokenare both populated), then setswindow.location.hash = '/home'.
What the PR's change would actually do
Adding a second listener for core-state:session-token-updated in AppShell that calls storeSessionToken() results in:
- A duplicate
storeSession()Tauri IPC call — the session was already stored byapplySessionToken. - A duplicate
refresh()call —CoreStateProvider's existing listener already triggers this.
This introduces a double-write race on every deep-link login rather than fixing anything.
If you're seeing a real redirect failure after login, it's likely environment-specific (timing, a stale build, etc.). Feel free to open a new issue with reproduction steps and we can look into it properly. Thanks again for the effort!