Repository navigation
Dictation: modifier-only shortcut (⌥⌘ alone) - #29
Merged
Merged
Conversation
added 18 commits
November 23, 2026 14:44
Why: the user asked for a two-key shortcut and pressed ⌘⌥ in the recorder; modifier-only combos were silently ignored (Carbon cannot register them). What: DictationShortcut.keyCode is nullable (null = modifiers only, stored as dictation_modifiers without dictation_key_code; old prefs load unchanged; invalid masks fall back to ⌃⌥Espace); the channel gains registerModifiers and the aborted event; the controller registers through registerModifiers, reports needsAccessibility when refused and retries on each apply; an aborted press discards the dictation it started without any output or error, while a toggled dictation's stop press is decided on release so an aborted chord leaves it running; during a meeting an aborted press is abandoned (no interval saved, the microphone text goes to the note). Réglages records ⌥⌘ chords, refuses a single modifier with a French message, shows the Accessibility need next to the shortcut and re-registers when the permission comes back. Proof: the modifier-only specs (preferences, controller, channel, recorder, accessibility) and the existing dictation/settings specs pass (390).
Why: Carbon RegisterEventHotKey cannot register a shortcut without a key, so ⌥⌘ needs to be watched natively. What: registerModifiers installs global and local NSEvent monitors on flagsChanged, keyDown and mouse downs (refused with ACCESSIBILITY_REQUIRED unless AXIsProcessTrusted); pressed when exactly the chosen modifiers become held by adding a key, released when one goes up, aborted (no released) on any key or mouse button down or an extra modifier while held; a key pressed with modifiers held taints the chord until all are up; caps lock, fn and numeric pad flags are ignored. Escape cancel is armed without modifiers only for these shortcuts. Registering a keyed shortcut or unregistering removes the monitors. Proof: flutter build macos --debug compiles and links; not run live.
Why: pressing the dictation shortcut during a meeting dropped the id of the sentence in progress; when that sentence had already been checkpointed, its final text was saved under a new id and the note got two lines (seen with an aborted ⌥⌘ press in a scratch test). What: beginDictation no longer clears the microphone phrase; the sentence's done replaces its provisional row. The recorder hint now says two modifiers alone are accepted. Proof: scratch test (deleted) went from two rows to one; dictation specs pass (119).
…dictation Why: review of PR #29: any ⌘⌥+key opened the microphone and an aborted press split a meeting sentence; a lost release or a forgotten toggle could keep a dictation open forever; Accessibility granted with Settings closed left the shortcut dead until relaunch. What: registerModifiers passes holdMs (from holdThreshold, the single source); the controller handles tapped (toggle start/stop) and treats pressed as an already-confirmed hold (no threshold recount); noSpeechTimeout (8 s, only before the first speech, ends silently) and maxDictationDuration (3 min, ends and delivers the text so far) bound every dictation; on app resume a shortcut refused for Accessibility is retried, Settings open or not. Proof: the new specs (channel, modifier-only controller, time limits, accessibility resume) and the dictation/core/settings specs pass (463).
…event counters Why: a key down consumed by another app's hotkey (⌘⌥D, ⌘⌥Esc) is not delivered to a global NSEvent monitor, so a quick chord looked like a clean tap of ours. What: after exactly the chosen modifiers go down the press is undecided and nothing is emitted for holdMs; a clean release before -> tapped; a clean hold to the threshold -> pressed then released; any key, mouse button or extra modifier -> nothing (aborted after pressed). Cleanliness is checked against CGEventSource.counterForEventType(.hidSystemState) for key and mouse downs, snapshotted at chord down and at pressed; monitors stay for flagsChanged and early rejection. Proof: throwaway probe (F19 posted with CGEvent while a Carbon hotkey held it: hotkey fired, global monitor saw nothing, keyDown counter +1); flutter build macos --debug links. Not run live.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On first real use, pressing ⌘⌥ alone in the shortcut recorder did nothing: modifier-only combos were ignored silently, and Carbon hotkeys cannot register them.
What
dictation_modifierswith nodictation_key_code; existing prefs load unchanged.registerModifiers {modifiers, holdMs}. Native side watches NSEvent monitors and decides "nothing else happened" with the system-wide HID event counters, so a key consumed by another app's hotkey (⌘⌥D, ⌘⌥Esc) still counts. Nothing is emitted during holdMs; a clean quick tap →tapped; a clean hold →pressedat the threshold, thenreleased; any key, mouse button or extra modifier → no event (before the threshold) oraborted(after).ACCESSIBILITY_REQUIREDis surfaced in the setting row; registration is retried when the app becomes active, so a grant works without relaunch.Checked
Not checked