"The two riskiest moments are the first millisecond and the last. Everything else is bookkeeping."
Down, Speak, Up
One dictation splits cleanly at the hotkey. On key-down you capture two things at once: a target snapshot (who has focus right now) and the audio stream (with the mic already warm). On key-up you finalize the transcript, clean it, and insert it into the target you snapshotted. The controller is small on purpose:
DictationController.start(mode):
snapshot = TargetCapture.snapshot() # frontmost app, focused element, selection
Audio.start() # begin capture with a short pre-roll
DictationController.stop():
audio = Audio.finish() # add a short tail so last syllable survives
text = STT.finalize(audio)
clean = Cleanup.run(text, snapshot)
Insertion.insert(clean, into: snapshot)
The First Millisecond: Pre-Roll
Humans start talking before their finger finishes pressing. If capture begins exactly at key-down, the first syllable is already gone — "send it" becomes "end it." The fix is a pre-roll: keep a short rolling buffer so the audio you finalize includes the ~half-second before the key registered. But pre-roll fights privacy — a true rolling buffer means the mic is always live between dictations. Firekeeper's honest tradeoff is to request mic permission at launch and start the engine fast rather than keep an always-on buffer, because a visible-recording-only rule beats a hidden always-listening one.
The Last Millisecond: The Tail
The mirror problem is at the end. People release the key the instant they finish the last word — sometimes a hair early. Cut the audio exactly at key-up and the final syllable clips. So capture keeps running for a short tail (Firekeeper uses roughly a quarter-second) after key-up before it finalizes. Two tiny time-shifts, front and back, are the difference between "transcription is broken" and "transcription is perfect."