From 85d3447ccca61076b29cb580b38c76174c7c9e11 Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Tue, 2 Jun 2026 11:12:26 +0000 Subject: [PATCH] Fix voice broken by Notification.requestPermission + tighten sleep regex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause 1: Notification.requestPermission() on startup (3s delay) opened a browser permission dialog while JARVIS was still speaking the welcome greeting. This aborted the SpeechRecognition session. Because isSpeaking=true at that moment, onend did not reschedule a restart — mic went permanently silent. Fix: removed the startup requestPermission() call entirely. Root cause 2: Same requestPermission() inside _focusWindow() called on every enterVoiceMode() — could abort the recognition session on each wake. Fix: only create notification when permission already granted, never request. Root cause 3: SLEEP_CMDS matched bare words like offline and sleep that appear in normal commands (check if server is offline, put device to sleep, etc.) Fix: tightened to require explicit phrasing — go offline, sleep mode, shut down jarvis, good night jarvis, etc. --- public_html/index.html | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/public_html/index.html b/public_html/index.html index 0e5c128..e858b75 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -1760,7 +1760,7 @@ function _drawTopo() { var isAsleep = false; var _sleepRefreshTimer = null; -var SLEEP_CMDS = /\b(good\s*night|go\s*to\s*sleep|sleep\s*(mode|now)?|shut\s*(down|off)\s*(jarvis|for\s*the\s*night)?|offline|stand\s*by|power\s*down|hibernate|signing\s*off)\b/i; +var SLEEP_CMDS = /\b(good\s*night(\s*jarvis)?|go\s*to\s*sleep|sleep\s*mode|shut\s*(down|off)\s*(jarvis|for\s*the\s*night)|go\s*offline|going\s*offline|jarvis\s*(go\s*)?(offline|sleep|shutdown)|stand\s*by\s*mode|power\s*down(\s*jarvis)?|signing\s*off)\b/i; function enterSleepMode() { if (isAsleep) return; @@ -1833,13 +1833,9 @@ function _focusWindow() { if (++_flashCount >= 8) { clearInterval(_titleFlash); document.title = _origTitle; } }, 400); - // Browser Notification API — fires even when window is minimized - if ('Notification' in window) { - if (Notification.permission === 'granted') { - new Notification('JARVIS', { body: 'Wake word detected — system online.', icon: '/favicon.ico', tag: 'jarvis-wake', requireInteraction: false }); - } else if (Notification.permission !== 'denied') { - Notification.requestPermission(); - } + // Notify if already have permission — never request during voice activity + if ('Notification' in window && Notification.permission === 'granted') { + try { new Notification('JARVIS', { body: 'Wake word detected.', tag: 'jarvis-wake', requireInteraction: false }); } catch(e) {} } } @@ -2215,10 +2211,6 @@ function showApp(name, greeting, silent = false) { } }, 12000); startListening(); - // Request notification permission for wake-word alerts when minimized - if ('Notification' in window && Notification.permission === 'default') { - setTimeout(() => Notification.requestPermission(), 3000); - } loadNetwork(); loadHA(); checkAgentStatus();