Fix mobile "Add another account" redirect loop via sessionStorage backup#209
Merged
sirjamesgray merged 1 commit intoMay 11, 2026
Conversation
… loop Agent-Logs-Url: https://github.com/WeWriteApp/WeWrite/sessions/c77ef93d-f613-41f5-9b66-57cf17616c00 Co-authored-by: sirjamesgray <16139439+sirjamesgray@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
sirjamesgray
May 11, 2026 03:14
View session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
74efc0d
into
copilot/fix-switch-account-dropdown-action
3 checks passed
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.
On iOS PWA (and some Android PWA), clicking "Add another account" immediately bounced back to the dashboard. The existing
?switchAccount=1URL param guard was unreliable becausewindow.location.hrefin PWA standalone mode can behave as a soft navigation — keepingAuthProviderin its already-resolved state (isLoading: false, isAuthenticated: true) — leaving a timing window where the redirect guard fires beforeuseSearchParams()reflects the new URL.Changes
MobileAccountMenu.tsx— writesessionStorage.setItem('wewrite_adding_account', '1')synchronously before thewindow.location.hrefnavigation. The flag is always set prior to any React effect on the destination page.login-form.tsx— extend the redirect guard to also checksessionStorageas a fallback whenhasSearchParammisses the URL param:login-form.tsx— add a cleanupuseEffectthat removes the flag on unmount, preventing it from leaking into future unrelated visits to the login page.