From b407e6ce95416d1d3be5385ef2b9e7d41e204fda Mon Sep 17 00:00:00 2001 From: ordinarthur <@arthurbarre.js@gmail.com> Date: Tue, 14 Apr 2026 13:10:36 +0200 Subject: [PATCH] fix: pairing reconnect sends stale groupId SignalingClient captured the profile at construction time, so after pair-code-resolved updated the store, the reconnect still sent the old groupId. Added updateProfile() method and call it before reconnecting. Co-Authored-By: Claude Opus 4.6 --- web/src/hooks/useSignaling.ts | 6 +++--- web/src/lib/signaling.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/web/src/hooks/useSignaling.ts b/web/src/hooks/useSignaling.ts index 388683b..b84534a 100644 --- a/web/src/hooks/useSignaling.ts +++ b/web/src/hooks/useSignaling.ts @@ -247,9 +247,9 @@ export function useSignaling(joinCode?: string) { break; case "pair-code-resolved": { // Store the groupId and reconnect to join the group room - const profileStore = useProfileStore.getState(); - profileStore.setGroupId(msg.groupId); - // Reconnect so the hello message includes the new groupId + useProfileStore.getState().setGroupId(msg.groupId); + // Update the signaling client's profile so reconnect sends the new groupId + signalingRef.current?.updateProfile({ groupId: msg.groupId }); signalingRef.current?.disconnect(); setTimeout(() => signalingRef.current?.connect(), 500); break; diff --git a/web/src/lib/signaling.ts b/web/src/lib/signaling.ts index 79af95c..6c1249a 100644 --- a/web/src/lib/signaling.ts +++ b/web/src/lib/signaling.ts @@ -64,6 +64,10 @@ export class SignalingClient { }; } + updateProfile(updates: Partial): void { + this.profile = { ...this.profile, ...updates }; + } + send(msg: ClientMessage): void { if (this.ws?.readyState === WebSocket.OPEN) { this.ws.send(JSON.stringify(msg));