fix(js): treat session notifications as hints, read the daemon's state - #29675
Merged
chrisnojima merged 5 commits intoSep 23, 2026
Merged
Conversation
…tate loggedIn, loggedOut and HTTPSrvInfoUpdate are sent from separate goroutines and can reach the GUI out of order, so none of them sets the session any more. Each starts a fresh bootstrap-status read, and only the latest read's reply applies; a superseded read settles with the newer one. The session is also re-read after login RPCs return and when the network comes back. A reply for a different user while logged in logs out first, clearing the old account's stores. A logged-out reply during an account switch is still ignored, and is applied once the switch ends. Reachability tracking is dropped: the service is no longer asked to start it or send its notifications; a network change still nudges gregor through checkReachability. The http server address survives a logout.
A cancelled login (the PromptNewDeviceName hand-off, or a non-RPC error) left userSwitching set, which withholds the logged-out session forever. Also drop the bootstrap re-read on loggedIn: only a bootstrap reply sets it now.
The payload carries the address and token and the config store applies it; only loggedIn/loggedOut are hints to re-read the daemon.
chrisnojima
added this pull request to stack #29680
September 23, 2026 19:54
chrisnojima
removed this pull request from stack #29680
September 23, 2026 19:56
chrisnojima
added this pull request to stack #29681
September 23, 2026 19:56
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.
Stack 3/7 on #29650.
Why
loggedOutandloggedInfrom a quick logout and login, or from an account switch, can reach JS reversed. Master's JS setloggedInstraight from them and could end up believing the older one.userSwitchingstays set, so the logged-out status the switch withheld is never applied and the routers stay held.What this changes
stores/daemon.tsx: each bootstrap-status read gets a sequence number, and only the reply to the latest read applies.refreshSessionFromDaemon(reason)starts a read that supersedes any read in flight.NotifySession.loggedInandloggedOutnow only triggerrefreshSessionFromDaemon. Nothing sets the session from a notification.loginand provisioning re-read the session when the RPC returns instead of callingsetLoggedIn(true).onBootstrapStatusChanged: a logged-in reply for a uid other than the one held logs the old account out first, then applies the reply to fresh stores. TheuserSwitchingguard now runs before the identity is written.reachability: false.checkReachabilitystays asnudgeGregor, because the call makes the service re-dial gregor.httpSrvis kept across logout, because it belongs to the process rather than an account.Judgment calls
loggedInandloggedOutare hints that trigger a daemon re-read. A fresh login shows onegetBootstrapStatusround trip later; a failed latest read changes nothing until the next hint, reconnect or online edge.HTTPSrvInfoUpdateapplies its address and token at once and does not re-read the session.userSwitching. That covers a cancelled login, including abandoning the new-device-name prompt, and any non-RPC error. When a switch ends, the current status is applied again, so the logged-out status it withheld takes effect.Tests
stores/tests/daemon.test.ts: overlapping refreshes drop the older reply in either arrival order, a handshake read superseded by a refresh settles with the newer status, a failed refresh is logged, andhandshakeGenerationsurvivesresetState.constants/init/shared.test.ts:userSwitchinggatingstores/tests/config.test.ts:httpSrvsurvives logout, and neither notifications nor login results set the session.Each guard was mutation-checked.