Skip to content

Commit 66a3a96

Browse files
committed
fix(voip): stash callId on accept-failed so lifecycle.end can resolve it
Blocker 2: handleAcceptFailedEvent only forwarded the deep-link payload without setting nativeAcceptedCallId. The downstream deepLinking saga (handleVoipAcceptFailed) calls callLifecycle.end('error'), which resolves the native callId via `callId ?? nativeAcceptedCallId`. With neither set, end() has no callUuid and the CallKit/Telecom session is never torn down. Mirror the success path: call setNativeAcceptedCallId(payload.callId) before opening the failure deep link so the saga's lifecycle.end() can issue voipNative.call.end with the right id. Adds a unit test asserting the failed-accept path stashes the callId.
1 parent 155bcb7 commit 66a3a96

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

app/lib/services/voip/MediaCallEvents.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,20 @@ describe('createVoipEventDispatcher — acceptFailed', () => {
261261

262262
expect(handled).toBe(true);
263263
});
264+
265+
// Blocker 2 regression: failed-accept must stash the native callId so the
266+
// downstream callLifecycle.end('error') (from deepLinking saga) can resolve
267+
// it via `callId ?? nativeAcceptedCallId`. Otherwise the CallKit/Telecom
268+
// session is never ended.
269+
it('sets nativeAcceptedCallId so subsequent lifecycle.end can resolve the callId', () => {
270+
const dispatch = createVoipEventDispatcher(makeTestAdapters());
271+
const payload = buildIncomingPayload({ callId: 'failed-needs-id', host: 'https://workspace-b.example.com' });
272+
273+
dispatch({ type: 'acceptFailed', payload, fromColdStart: false });
274+
275+
expect(mockSetNativeAcceptedCallId).toHaveBeenCalledTimes(1);
276+
expect(mockSetNativeAcceptedCallId).toHaveBeenCalledWith('failed-needs-id');
277+
});
264278
});
265279

266280
describe('createVoipEventDispatcher — hold', () => {

app/lib/services/voip/MediaCallEvents.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ function handleAcceptSucceededEvent(payload: VoipPayload, adapters: MediaCallEve
6868

6969
function handleAcceptFailedEvent(payload: VoipPayload, adapters: MediaCallEventsAdapters): boolean {
7070
mediaCallLogger.debug(`${TAG} VoipAcceptFailed event:`, payload);
71+
// Pre-bind: stash the native callId in the store so the subsequent
72+
// callLifecycle.end('error') (issued from deepLinking saga) can resolve
73+
// it via `callId ?? nativeAcceptedCallId`. Without this, end() has no
74+
// callUuid and the native CallKit/Telecom session is not torn down.
75+
useCallStore.getState().setNativeAcceptedCallId(payload.callId);
7176
adapters.onOpenDeepLink({
7277
host: payload.host,
7378
callId: payload.callId,

0 commit comments

Comments
 (0)