From f32989d5bb0afd962bbbdb2a9ce231dda89fc831 Mon Sep 17 00:00:00 2001 From: Frank Song Date: Sun, 3 May 2026 15:03:17 +0800 Subject: [PATCH] fix: voice-mode pref toggle-off now stops the recognizer (#1491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user disables 'Hands-free voice mode' in Settings while voice mode is active, the button hides but the SpeechRecognition keeps running — the user can't stop it because the button is invisible. Fix: _applyVoiceModePref() now checks if voice mode is active and calls _deactivate() when the pref is toggled off. Move _voiceModeActive declaration above the function to avoid TDZ. Also removes a duplicate window._applyVoiceModePref assignment. --- static/boot.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/static/boot.js b/static/boot.js index 4c9f1ce7..a54f75a5 100644 --- a/static/boot.js +++ b/static/boot.js @@ -470,14 +470,17 @@ window._micPendingSend=window._micPendingSend||false; try{ return localStorage.getItem('hermes-voice-mode-button')==='true'; } catch(_){ return false; } } + let _voiceModeActive=false; + function _applyVoiceModePref(){ - modeBtn.style.display = _voiceModePrefEnabled() ? '' : 'none'; + const enabled = _voiceModePrefEnabled(); + modeBtn.style.display = enabled ? '' : 'none'; + if(!enabled && _voiceModeActive) _deactivate(); } _applyVoiceModePref(); // Expose so the settings pane can re-apply immediately on toggle. window._applyVoiceModePref = _applyVoiceModePref; - let _voiceModeActive=false; let _voiceModeState='idle'; // idle | listening | thinking | speaking let _recognition=null; let _silenceTimer=null;