From 799cbb7eca38ac8a351c6ea24bf7267054b45e54 Mon Sep 17 00:00:00 2001 From: Nathan Esquenazi Date: Wed, 8 Apr 2026 18:55:57 -0700 Subject: [PATCH] fix: update sound/notification globals in password branch + close AudioContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent review findings: - _soundEnabled/_notificationsEnabled not updated in the password-save early-return branch of saveSettings() — fixed - AudioContext never closed after oscillator finishes — added osc.onended callback to ctx.close() preventing resource accumulation Co-Authored-By: Claude Opus 4.6 (1M context) --- static/messages.js | 1 + static/panels.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/static/messages.js b/static/messages.js index 9900880..32cde89 100644 --- a/static/messages.js +++ b/static/messages.js @@ -379,6 +379,7 @@ function playNotificationSound(){ gain.gain.setValueAtTime(0.3,ctx.currentTime); gain.gain.exponentialRampToValueAtTime(0.01,ctx.currentTime+0.3); osc.start(ctx.currentTime);osc.stop(ctx.currentTime+0.3); + osc.onended=()=>ctx.close(); }catch(e){console.warn('Notification sound failed:',e);} } diff --git a/static/panels.js b/static/panels.js index 06f74e5..aa4b383 100644 --- a/static/panels.js +++ b/static/panels.js @@ -1059,6 +1059,8 @@ async function saveSettings(andClose){ await api('/api/settings',{method:'POST',body:JSON.stringify({...body,_set_password:pw.trim()})}); window._sendKey=sendKey||'enter'; window._showTokenUsage=showTokenUsage; + window._soundEnabled=body.sound_enabled; + window._notificationsEnabled=body.notifications_enabled; showToast('Settings saved (password set — login now required)'); _settingsDirty=false; _settingsThemeOnOpen=theme; const bar=$('settingsUnsavedBar'); if(bar) bar.style.display='none';