fix(notes): Stop button never transcribed — silent-cancel branch was always taken

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.
This commit is contained in:
Daniel 2026-04-25 01:44:23 +02:00
parent 1f0eb05900
commit c2a7dc3bc1
2 changed files with 8 additions and 5 deletions

View file

@ -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) {

View file

@ -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',