Skip to content

Fix presence recovery after websocket reconnect - #878

Merged
KallynGowdy merged 1 commit into
developfrom
claude/presence-recovery-reconnect-7q3gn5
Aug 4, 2026
Merged

KallynGowdy merged 1 commit into
developfrom
claude/presence-recovery-reconnect-7q3gn5

Conversation

@KallynGowdy

Copy link
Copy Markdown
Member

Summary

Fixed an issue where presence (participant/avatar list and host-left detection) would never recover after a websocket reconnect. The InstRecordsClient was caching connected devices and filtering out reconnection events from the server, preventing presence from being restored.

Key Changes

  • Modified InstRecordsClient._onConnectionDisconnected() to clear the device cache when the connection drops, rather than just reading from it
  • This allows the server's replayed repo/connected_to_branch events (sent on reconnect) to be treated as new connections instead of being filtered out as already-known devices
  • Added comprehensive test case to verify that connected events are re-emitted for previously-known devices after a reconnect

Implementation Details

The fix involves clearing the _connectedDevices cache 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

… 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
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@KallynGowdy
KallynGowdy merged commit f9a45de into develop Aug 4, 2026
18 of 19 checks passed
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.

3 participants