editors: never auto-prompt for Web MIDI on load (privacy)

editor.html + pm_e-2.html called _ensureMidi() (requestMIDIAccess{sysex:true}, which always
prompts) on page load. Gate it behind a permission query — only auto-reconnect if MIDI is
already granted (querying does not prompt); otherwise wait for the user to click the connect
badge / Device-audio button. (editor-beta.html already had no on-load MIDI call.)
This commit is contained in:
Me Here 2026-06-02 08:31:43 -05:00
parent 390c974a5f
commit 46397627e4
2 changed files with 1805 additions and 4 deletions

View file

@ -1719,10 +1719,14 @@ refreshFeatureBoxes();
$("continueMode").checked = continueMode; $("continueMode").checked = continueMode;
$("timersOn").checked = timersOn; $("timersOn").checked = timersOn;
$("logSessions").checked = loggingOn; $("logSessions").checked = loggingOn;
// Connect to a PM_K-1 / PM_X-1 over USB-MIDI on load so the header badge reflects the link // Never prompt for Web MIDI on load. Only auto-reconnect if the user ALREADY granted it (querying
// (Chrome remembers the grant; first visit prompts once). updateDevBadge runs via _wireMidi. // the permission does NOT prompt); otherwise just show the badge — the "connect device" badge and
if (navigator.requestMIDIAccess) _ensureMidi().then(updateDevBadge).catch(() => updateDevBadge()); // the Device-audio button request access on an explicit click.
else updateDevBadge(); if (navigator.requestMIDIAccess && navigator.permissions && navigator.permissions.query) {
navigator.permissions.query({ name: "midi", sysex: true })
.then(p => { if (p.state === "granted") _ensureMidi().then(updateDevBadge).catch(() => updateDevBadge()); else updateDevBadge(); })
.catch(() => updateDevBadge());
} else updateDevBadge();
requestAnimationFrame(drawLoop); requestAnimationFrame(drawLoop);
/*@BUILD:include:src/chrome.js@*/ /*@BUILD:include:src/chrome.js@*/
</script> </script>

1797
pm_e-2.html Normal file

File diff suppressed because it is too large Load diff