From c2a7dc3bc10279e6dd94905098844b72de604e2e Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 25 Apr 2026 01:44:23 +0200 Subject: [PATCH] =?UTF-8?q?fix(notes):=20Stop=20button=20never=20transcrib?= =?UTF-8?q?ed=20=E2=80=94=20silent-cancel=20branch=20was=20always=20taken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause for "note recording, not working nor going into textbox / no progress etc". The click handler was wired with: recStop.addEventListener('click', stopRecording); addEventListener invokes the handler with the click Event as the first argument. My stopRecording(silent) signature uses that first arg as a boolean — and a non-null Event is truthy, so every Stop click hit the silent-cancel branch (mic off, stream closed, UI back to idle, but no .then-chain fires, no transcribeAudio, no /api/notes/from-voice). Symptom matched exactly: click Dictate → record → click Stop → mic indicator vanishes → editor stays empty → no Network activity for /api/notes/from-voice. Server logs from earlier transcribes were all from the Encounter / Dictation tabs (untouched flows), never Notes. Fix: wrap all three voice-button handlers so the Event isn't passed through. Only stopRecording cared about the first arg, but wrap all three for symmetry and so future signature changes don't reintroduce the same class of bug. recStart → function() { startRecording(); } recPause → function() { togglePauseRecording(); } recStop → function() { stopRecording(false); } SW cache bumped to pedscribe-v12-notes7. About the model: /api/notes/from-voice already reads `models.default` from app_settings (whatever you picked in Admin Panel → Models → Default Model). Confirmed in your DB it's set to "openrouter-vendor-model-sonnet-4.6". No new admin UI added. --- public/js/notes.js | 11 +++++++---- public/sw.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/public/js/notes.js b/public/js/notes.js index d81775d..04a6c32 100644 --- a/public/js/notes.js +++ b/public/js/notes.js @@ -126,13 +126,16 @@ _dirty = true; updateStatus('Saving…', 'saving'); scheduleAutosave(); }); - // Voice recording controls + // Voice recording controls. addEventListener passes the click Event + // as the first argument — wrap so the truthy Event doesn't get passed + // to stopRecording(silent) and trigger the silent-cancel branch + // (which shuts the mic without transcribing → "Stop does nothing"). var recStart = $('btn-note-rec-start'); var recPause = $('btn-note-rec-pause'); var recStop = $('btn-note-rec-stop'); - if (recStart) recStart.addEventListener('click', startRecording); - if (recPause) recPause.addEventListener('click', togglePauseRecording); - if (recStop) recStop.addEventListener('click', stopRecording); + if (recStart) recStart.addEventListener('click', function() { startRecording(); }); + if (recPause) recPause.addEventListener('click', function() { togglePauseRecording(); }); + if (recStop) recStop.addEventListener('click', function() { stopRecording(false); }); // Ctrl/Cmd+S still saves manually from the editor document.addEventListener('keydown', function(e) { diff --git a/public/sw.js b/public/sw.js index 7f66d43..cc5c573 100644 --- a/public/sw.js +++ b/public/sw.js @@ -4,7 +4,7 @@ // API calls always fresh (critical for medical data accuracy) // ============================================================ -var CACHE_NAME = 'pedscribe-v12-notes6'; +var CACHE_NAME = 'pedscribe-v12-notes7'; var SHELL_ASSETS = [ '/', '/index.html',