hex/src/linux/dictation
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Dax 689e5b35e9
labs: keep the microphone open after dictating (#1701)
* labs: keep the microphone open after dictating

With Release microphone while idle on, a capture that ends now leaves the
microphone open for a Labs window (`labs.keep_microphone_open` +
`labs.keep_microphone_open_seconds`: 30 s, 1, 3, 5, or 30 minutes, default
1 minute), so the next dictation takes the warm path with its pre-roll
instead of the cold open's asynchronous start. Off, every listener closes
exactly as before, and with the release setting off the lab does nothing.

One `audio::linger::MicrophoneLinger` decides it for macOS, Windows, and
Linux: the first idle pass after a capture arms the window, a capture clears
it, and only a later idle pass past the window closes, once nothing records,
no client dictates, no release tail runs, and no capture copies the
microphone. Windows and Linux move their repeated `release_while_idle &&
!wants_audio()` closes into that one check; macOS reconciles through it. The
switch takes the Labs state word's last free bit; the window has no room
there, so it lives in its own atomic, both written by `labs::apply`.

Also moves Linux's Live typing glue into `linux/dictation/typing.rs`, since
`linux/dictation.rs` was at the source cap, and regenerates the Labs goldens
for the new card.

* labs: release the lingering microphone where the old sites did

Review fixes for keep-microphone-open:

* macOS reconcile_input keeps origin/dev's branches: with a capture sink
  open and an inactive input, recovery is still requested, and the lab's
  window is cleared while a sink holds the microphone.
* A digital-silence finish closes a lingering microphone instead of
  skipping recovery, so the next press opens a fresh stream. macOS does it
  in reopen_silent_stream; Linux's moved to linux/dictation/silence.rs
  (which also keeps linux/dictation.rs under the source cap). Windows has
  no digital-silence path.
* Windows and Linux run the release check at the old event sites (a
  submitted finish, a cancel, a discard before the open, a client's end)
  through one small macro, so a press handled in the same pass still sees
  a closed microphone when the lab is off. That check also releases a
  microphone an interrupted recording left open, which the old
  latch-based sites never did.
* Docs: drop the "exactly as before" claims, describe the extra close, the
  Annotate capture-sink and local-API windows, macOS ending the window on
  a stream interruption, and the Linux poll rather than an idle wait.
* clear() is real code now (the silence close); state()/apply() say why
  the switch bit and the window atomic are written separately.

* labs: keep the lab's windows and spots exact

Follow-ups from review:

* Windows releases the microphone when a pending client dictation's start
  gives up at the first chunk, which the old site closed too.
* macOS leaves a lingering microphone alone when a digital-silence finish
  lands while a capture sink copies it, so Annotate gets no gap.
* The Linux silence test's released case opens the input first, so it really
  covers "lab off, release while idle: no reopen, stream stays open".
* Docs say where a digital-silence finish ends the window (macOS and Linux,
  not with a capture sink on macOS) and that Windows can linger on a
  zero-only stream.
2026-11-11 18:12:08 -05:00
..
gap.rs linux: pad short mic gaps and reopen digitally silent streams (#1499) 2026-11-07 13:04:30 -05:00
shortcuts.rs labs: second dictation shortcut on linux and windows (#1651) 2026-11-10 14:40:02 -05:00
silence.rs labs: keep the microphone open after dictating (#1701) 2026-11-11 18:12:08 -05:00
typing.rs labs: keep the microphone open after dictating (#1701) 2026-11-11 18:12:08 -05:00