fix: pairing reconnect sends stale groupId
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 37s

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 <noreply@anthropic.com>
This commit is contained in:
ordinarthur 2026-04-14 13:10:36 +02:00
parent d8721b6d0c
commit b407e6ce95
2 changed files with 7 additions and 3 deletions

View File

@ -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;

View File

@ -64,6 +64,10 @@ export class SignalingClient {
};
}
updateProfile(updates: Partial<ProfileData>): void {
this.profile = { ...this.profile, ...updates };
}
send(msg: ClientMessage): void {
if (this.ws?.readyState === WebSocket.OPEN) {
this.ws.send(JSON.stringify(msg));