debug(voice): surface accept-call diagnostics via toast alerts

Console logs aren't visible to the agent on staging — switch to
useAlert toasts so the debug breadcrumbs appear directly in the UI.
Will revert once root cause is identified.
This commit is contained in:
Tanmay Deep Sharma
2026-05-03 14:12:22 +07:00
parent 81464a9087
commit 5aa1df81a8
2 changed files with 15 additions and 30 deletions
@@ -4,6 +4,7 @@ import { useRouter } from 'vue-router';
import { useStore } from 'vuex';
import { useCallSession } from 'dashboard/composables/useCallSession';
import { setWhatsappCallMuted } from 'dashboard/composables/useWhatsappCallSession';
import { useAlert } from 'dashboard/composables';
import WindowVisibilityHelper from 'dashboard/helper/AudioAlerts/WindowVisibilityHelper';
import Avatar from 'dashboard/components-next/avatar/Avatar.vue';
@@ -74,20 +75,13 @@ const handleEndCall = async () => {
};
const handleJoinCall = async call => {
// eslint-disable-next-line no-console
console.log('[CW Voice] handleJoinCall', {
call,
isJoining: isJoining.value,
hasActiveCall: hasActiveCall.value,
});
useAlert('[debug] handleJoinCall click handler fired');
if (!call) {
// eslint-disable-next-line no-console
console.warn('[CW Voice] handleJoinCall: no call object');
useAlert('[debug] handleJoinCall bailed: no call object');
return;
}
if (isJoining.value) {
// eslint-disable-next-line no-console
console.warn('[CW Voice] handleJoinCall: already joining (stuck flag?)');
useAlert('[debug] handleJoinCall bailed: already joining');
return;
}
const { conversation } = getCallInfo(call);
@@ -9,6 +9,7 @@ import {
cleanupWhatsappSession,
} from 'dashboard/composables/useWhatsappCallSession';
import { handleVoiceCallCreated } from 'dashboard/helper/voice';
import { useAlert } from 'dashboard/composables';
import Timer from 'dashboard/helper/Timer';
const isWhatsappCall = call => call?.provider === 'whatsapp';
@@ -122,44 +123,33 @@ export function useCallSession() {
};
const joinCall = async ({ conversationId, inboxId, callSid }) => {
// eslint-disable-next-line no-console
console.log('[CW Voice] joinCall', { conversationId, inboxId, callSid });
useAlert(`[debug] joinCall: callSid=${callSid} inboxId=${inboxId}`);
if (isJoining.value) {
// eslint-disable-next-line no-console
console.warn('[CW Voice] joinCall: isJoining flag stuck');
useAlert('[debug] joinCall bailed: isJoining flag stuck');
return null;
}
isJoining.value = true;
try {
const call = findCall(callSid);
// eslint-disable-next-line no-console
console.log('[CW Voice] joinCall: found call?', call);
useAlert(
`[debug] found call? provider=${call?.provider} callId=${call?.callId} hasSdpOffer=${Boolean(call?.sdpOffer)}`
);
if (isWhatsappCall(call)) {
// eslint-disable-next-line no-console
console.log('[CW Voice] joinCall: WhatsApp branch', {
callId: call.callId,
hasSdpOffer: Boolean(call.sdpOffer),
hasIceServers: Boolean(call.iceServers),
});
useAlert('[debug] taking WhatsApp accept path');
await whatsappSession.acceptIncomingCall({
callId: call.callId,
sdpOffer: call.sdpOffer,
iceServers: call.iceServers,
});
// eslint-disable-next-line no-console
console.log('[CW Voice] joinCall: WhatsApp accept POST returned OK');
useAlert('[debug] /accept POST succeeded');
callsStore.setCallActive(callSid);
durationTimer.start();
return { callId: call.callId };
}
// eslint-disable-next-line no-console
console.log(
'[CW Voice] joinCall: Twilio branch (provider not whatsapp)',
{
provider: call?.provider,
}
useAlert(
`[debug] taking Twilio path — provider mismatch: ${call?.provider}`
);
const device = await TwilioVoiceClient.initializeDevice(inboxId);
if (!device) return null;
@@ -181,6 +171,7 @@ export function useCallSession() {
return { conferenceSid: joinResponse?.conference_sid };
} catch (error) {
useAlert(`[debug] joinCall threw: ${error?.message || error}`);
// eslint-disable-next-line no-console
console.error('Failed to join call:', error);
// Tear down any half-built WebRTC state so the user's next click starts