fix(web): hide signed-out toast for first-time visitors - #2775
Merged
Conversation
A 401 on first load is "not signed in", not session expiry. Only announce sign-out when this browser has authenticated before. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First-time visitors (incognito / new users) were immediately seeing You've been signed out. Please sign in again. on staging, next to the Welcome modal.
The API error interceptor treated every
401/410as session expiry. A brand-new browser can still get those statuses (SuperTokens session refresh on the first API call, or a protected route with no session). That is “not signed in,” not “you were signed out.”The toast now only appears when this browser has authenticated before (
hasUserEverAuthenticated). SuperTokens session wiring listens only to lifecycleonHandleEvents, notpostAPIHookpayloads that reuse theREFRESH_SESSIONname.Simplicity
Gate stays as two one-line checks at the interceptor and profile catch. No new helpers or modules. SuperTokens
apiDomainnow uses the origin (BACKEND_BASEURL), matching the backend.Automated validation
401does not callsession.signOutor show the toast; returning visitor still does.401stays quiet; returning visitor still toasts.bun run test:web— passbun run lint— pass (existing repo warnings only)Independent review
Fresh read-only review of the full
origin/maindiff: no confirmed findings. Logout still clears local auth state; interceptorsignOutkeeps the flag so a returning expired session still gets the toast.Test plan
bun packages/scripts/src/testing/test-parallel.ts web -- packages/web/src/api/util/api.util.test.ts packages/web/src/auth/compass/user/hooks/useLoadProfile.test.tsbun packages/scripts/src/testing/test-parallel.ts web -- packages/web/src/auth/compass/session/SessionProvider.test.tsxbun run test:webbun run lint