From 4a529a304c1eb51e31c9a1fe0d34cdf24d2cee70 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 3 Apr 2026 14:37:29 +0000 Subject: [PATCH] fix: prevent group call participants from disconnecting when another member answers/rejects In group calls (e.g. Alice calls Bob and Charlie), when Bob accepts the call, a CallAnswerEvent is gift-wrapped to all group members including Charlie. Charlie's CallManager, still in IncomingCall state, was treating ANY CallAnswerEvent as "answered elsewhere" (intended for multi-device scenarios) and ending the call prematurely. The fix checks whether the answering/rejecting peer is actually the current user (signer.pubKey) before treating it as an "answered/rejected elsewhere" event. If it's a different group member, we simply ignore it and keep ringing. https://claude.ai/code/session_01EYzWB93PZRqw15QuQadCf4 --- .../amethyst/commons/call/CallManager.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/call/CallManager.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/call/CallManager.kt index 2a3749158..f3672bc6d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/call/CallManager.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/call/CallManager.kt @@ -215,9 +215,12 @@ class CallManager( } is CallState.IncomingCall -> { - // Another device of this user answered the call — stop ringing. if (callId != current.callId) return - transitionToEnded(current.callId, current.peerPubKeys(), EndReason.ANSWERED_ELSEWHERE) + if (answeringPeer == signer.pubKey) { + // Another device of this user answered the call — stop ringing. + transitionToEnded(current.callId, current.peerPubKeys(), EndReason.ANSWERED_ELSEWHERE) + } + // Otherwise another group member answered — we keep ringing. } is CallState.Connected -> { @@ -273,9 +276,12 @@ class CallManager( } is CallState.IncomingCall -> { - // Another device of this user rejected the call — stop ringing. if (callId != current.callId) return - transitionToEnded(current.callId, current.peerPubKeys(), EndReason.REJECTED) + if (rejectingPeer == signer.pubKey) { + // Another device of this user rejected the call — stop ringing. + transitionToEnded(current.callId, current.peerPubKeys(), EndReason.REJECTED) + } + // Otherwise another group member rejected — we keep ringing. } else -> {