Skip to content

fix: redirect to home after login (#2726)#2729

Open
Sushanth012 wants to merge 1 commit into
tinyhumansai:mainfrom
Sushanth012:main
Open

fix: redirect to home after login (#2726)#2729
Sushanth012 wants to merge 1 commit into
tinyhumansai:mainfrom
Sushanth012:main

Conversation

@Sushanth012
Copy link
Copy Markdown

@Sushanth012 Sushanth012 commented May 27, 2026

Issue Fixed

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.

Review Change Stack

@Sushanth012 Sushanth012 requested a review from a team May 27, 2026 05:44
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

AppShell now subscribes to a 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

Session Token Event Synchronization

Layer / File(s) Summary
Session token update event listener
app/src/App.tsx
A 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

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through event streams so bright,
Catching token updates mid-flight!
AppShell listens, storeSessionToken calls,
Session state syncs through digital halls. ✨

🚥 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%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch 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 eslint to 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/App.tsx`:
- Line 85: The handler function's event parameter in App.tsx is untyped; add a
TypeScript annotation to improve type safety by changing the signature for
handler to accept a CustomEvent with the expected shape (CustomEvent<{
sessionToken?: string }>) or, if the event can be non-CustomEvent, type it as
Event and cast when reading detail; update the handler definition (handler) and
any detail access sites to use the chosen typed event so sessionToken is
correctly typed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 899179b0-3e89-41e2-887a-24cd451a26dd

📥 Commits

Reviewing files that changed from the base of the PR and between 0fddf11 and c8d353c.

📒 Files selected for processing (1)
  • app/src/App.tsx

Comment thread app/src/App.tsx

// Listen for core-state:session-token-updated event from deep-link login, and update context
useEffect(() => {
const handler = (event) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add TypeScript type annotation for the event parameter.

The event handler's parameter lacks an explicit type annotation. For type safety and better IDE support, type it as CustomEvent with the expected detail shape:

const handler = (event: CustomEvent<{ sessionToken?: string }>) => {

Alternatively, if the event might not always be a CustomEvent, use Event and cast when accessing detail:

const handler = (event: Event) => {
  const sessionToken = (event as CustomEvent<{ sessionToken?: string }>).detail?.sessionToken;
🔧 Proposed fix with CustomEvent type
-    const handler = (event) => {
+    const handler = (event: CustomEvent<{ sessionToken?: string }>) => {
       const sessionToken = event.detail?.sessionToken;
       if (sessionToken) {
         storeSessionToken(sessionToken);
       }
     };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/App.tsx` at line 85, The handler function's event parameter in
App.tsx is untyped; add a TypeScript annotation to improve type safety by
changing the signature for handler to accept a CustomEvent with the expected
shape (CustomEvent<{ sessionToken?: string }>) or, if the event can be
non-CustomEvent, type it as Event and cast when reading detail; update the
handler definition (handler) and any detail access sites to use the chosen typed
event so sessionToken is correctly typed.

@Pixel20coder
Copy link
Copy Markdown

Issue Fixed

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.

Review Change Stack

still not working

Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sushanth012 heads up — there are merge conflicts on this PR, so I'll hold off on a full review until those are sorted out. I see CodeRabbit flagged a TypeScript issue with the event handler (untyped parameter) that also needs fixing. Once those are resolved, I'll give this a proper review.

The approach looks solid though — synchronizing the session token from the core event to React context is exactly what's needed to fix the redirect issue after login.

@graycyrus
Copy link
Copy Markdown
Contributor

@Sushanth012 this PR has merge conflicts with main — please rebase/resolve before review.

@graycyrus
Copy link
Copy Markdown
Contributor

This PR has merge conflicts with main — please rebase/resolve before review.

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.

Login does not automatically redirect user after successful authentication

3 participants