Fix voice broken by Notification.requestPermission + tighten sleep regex

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.
This commit is contained in:
2026-06-02 11:12:26 +00:00
parent 13792b3ced
commit 85d3447ccc
+4 -12
View File
@@ -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();