Fix presence recovery after websocket reconnect - #878
Merged
Merged
Conversation
… on reconnect InstRecordsClient._disconnectDevices() synthesized repo/disconnected_from_branch events for every cached device when the socket dropped, but never cleared the _connectedDevices cache itself. On reconnect, the server replays the full current device list via repo/connected_to_branch, but _watchConnectedDevices() filters those through _isDeviceConnected(), which still saw the stale entries as "already connected" and dropped every event as a duplicate - including the client's own connection. No client_connected ever fired again for the rest of the session, so presence (participant list, host-left detection) never recovered even though the document/CRDT channel reconnected fine. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Jvk8KKEPyv4b1LBKPxs4t
|
|
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
Fixed an issue where presence (participant/avatar list and host-left detection) would never recover after a websocket reconnect. The
InstRecordsClientwas caching connected devices and filtering out reconnection events from the server, preventing presence from being restored.Key Changes
InstRecordsClient._onConnectionDisconnected()to clear the device cache when the connection drops, rather than just reading from itrepo/connected_to_branchevents (sent on reconnect) to be treated as new connections instead of being filtered out as already-known devicesImplementation Details
The fix involves clearing the
_connectedDevicescache before synthesizing disconnect events. This ensures that when the websocket reconnects and the server replays the full list of currently-connected devices, those events are not deduplicated against stale cache entries. The disconnect events are still properly emitted using the devices that were cached before clearing, maintaining the correct disconnect notification behavior.https://claude.ai/code/session_018Jvk8KKEPyv4b1LBKPxs4t