From e836634cff4ef9dd15c8b6eca53e88a209b685f6 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 16 May 2026 01:59:42 -0400 Subject: [PATCH] fix: save/restore mic state on PTT mode toggle (I-4) When enabling PTT mode, save current mic state before muting. When disabling PTT, restore saved state instead of unconditionally unmuting. Prevents surprising unmute if user had manually muted before switching to PTT. --- src/app/features/call/CallControls.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/features/call/CallControls.tsx b/src/app/features/call/CallControls.tsx index f750bf533..d0971cc8b 100644 --- a/src/app/features/call/CallControls.tsx +++ b/src/app/features/call/CallControls.tsx @@ -64,13 +64,16 @@ export function CallControls({ callEmbed }: CallControlsProps) { const microphoneRef = useRef(microphone); useEffect(() => { microphoneRef.current = microphone; }, [microphone]); - // Handle PTT mode toggle mid-call + // Handle PTT mode toggle mid-call — save/restore mic state (I-4) const pttModeRef = useRef(pttMode); + const micBeforePTTRef = useRef(null); useEffect(() => { if (pttMode && !pttModeRef.current) { + micBeforePTTRef.current = microphoneRef.current; callEmbed.control.setMicrophone(false); } else if (!pttMode && pttModeRef.current) { - callEmbed.control.setMicrophone(true); + callEmbed.control.setMicrophone(micBeforePTTRef.current ?? true); + micBeforePTTRef.current = null; } pttModeRef.current = pttMode; }, [pttMode, callEmbed]);