diff --git a/app/(tabs)/profile.tsx b/app/(tabs)/profile.tsx index fedcf2b..bcb0164 100644 --- a/app/(tabs)/profile.tsx +++ b/app/(tabs)/profile.tsx @@ -56,7 +56,7 @@ function MenuItem({ export default function ProfileScreen() { const { user, logout } = useAuth(); - const { updateVoiceApiType } = useVoice(); + const { updateVoiceApiType, stopSession, isActive } = useVoice(); const [deploymentId, setDeploymentId] = useState(''); const [deploymentName, setDeploymentName] = useState(''); const [showDeploymentModal, setShowDeploymentModal] = useState(false); @@ -150,11 +150,17 @@ export default function ProfileScreen() { }, [tempDeploymentId]); const saveVoiceApiType = useCallback(async () => { + // Stop active voice session if any before changing API type + if (isActive) { + console.log('[Profile] Stopping active voice session before API type change'); + stopSession(); + } + await api.setVoiceApiType(tempVoiceApiType); setVoiceApiType(tempVoiceApiType); updateVoiceApiType(tempVoiceApiType); setShowVoiceApiModal(false); - }, [tempVoiceApiType, updateVoiceApiType]); + }, [tempVoiceApiType, updateVoiceApiType, isActive, stopSession]); const openTerms = () => { router.push('/terms');