fix: resync voice state after LiveKit reconnect #289

Merged
hodlbod merged 1 commits from userAdityaa/flotilla:fix/287-livekit-voice-reconnect into dev 2026-06-02 16:00:11 +00:00
Collaborator

Reason

On a flaky network, LiveKit reconnects in the background and may log a track/participant mismatch in the console. More importantly for Flotilla, it does not emit join/leave events during reconnect, so our participant list and camera/screen-share UI could stay wrong after the connection came back.

Solution

On RoomEvent.Reconnected, resync participant media and local session flags from the LiveKit room and refresh video tiles. If the call fully drops, show a Reconnect button that joins again with a fresh token.

Related to: https://github.com/livekit/client-sdk-js/issues/1163

closes #287

**Reason** On a flaky network, LiveKit reconnects in the background and may log a track/participant mismatch in the console. More importantly for Flotilla, it does not emit join/leave events during reconnect, so our participant list and camera/screen-share UI could stay wrong after the connection came back. **Solution** On `RoomEvent.Reconnected`, resync participant media and local session flags from the LiveKit room and refresh video tiles. If the call fully drops, show a Reconnect button that joins again with a fresh token. Related to: https://github.com/livekit/client-sdk-js/issues/1163 closes #287
hodlbod reviewed 2026-06-01 15:15:57 +00:00
@@ -94,1 +94,4 @@
// LiveKit does not emit ParticipantConnected/Disconnected during reconnect.
const resyncAfterReconnect = (room: LiveKitRoom) => {
const next = new Map<string, {muted: boolean; cameraOn: boolean}>()
Owner

Let's make this a named type instead of repeating the ad-hoc type in a bunch of places

Let's make this a named type instead of repeating the ad-hoc type in a bunch of places
@@ -95,0 +101,4 @@
participantMediaState.set(next)
const session = get(currentVoiceSession)
if (session?.room !== room) return
Owner

This will never match I would imagine, because it's checking identity equality, not value equality right?

This will never match I would imagine, because it's checking identity equality, not value equality right?
hodlbod marked this conversation as resolved
@@ -240,0 +248,4 @@
class="center tooltip tooltip-top btn btn-sm btn-square btn-success"
onclick={onReconnect}>
<Icon icon={PhoneCallingRounded} size={4} />
</Button>
Owner

Is there any way to do this automatically? Adding a button to make the software work the way its supposed to is probably not a good pattern.

Is there any way to do this automatically? Adding a button to make the software work the way its supposed to is probably not a good pattern.
userAdityaa added 1 commit 2026-06-02 06:32:03 +00:00
userAdityaa force-pushed fix/287-livekit-voice-reconnect from 1f5a219734 to 7dfe24d264 2026-06-02 06:32:03 +00:00 Compare
hodlbod merged commit ee3da3893c into dev 2026-06-02 16:00:11 +00:00
hodlbod deleted branch fix/287-livekit-voice-reconnect 2026-06-02 16:00:11 +00:00
Sign in to join this conversation.