Repository navigation
fix(hotkey): stop modifier-only shortcut from firing on unrelated Shift+key combos - #815
Conversation
…ft+key combos The modifier-only start path was re-entrant: releasing an extra modifier (e.g. Shift) while the configured modifier (e.g. Left Option) stayed held shrank the pressed-modifier set back to the configured modifier and re-triggered start, erasing the "another key was pressed" flag. The configured modifier's subsequent release then read as a clean tap and falsely started recording (altic-dev#688). A same-family sibling press while the configured modifier was armed had the same effect. Gate the start in both decision branches on (1) the flagsChanged belonging to the configured modifier's family and (2) no modifier-only press already being active, so neither an unrelated-modifier release nor a same-family sibling press can re-arm and wipe the interrupt flag. A genuine tap and multi-modifier chords still start. Extract the modifier-only start/finish decision into a pure, unit-testable ModifierOnlyShortcutFlagsDecision.evaluate so regression tests can exercise the state machine without instantiating the global event-tap manager. Fixes altic-dev#688 Co-Authored-By: Claude <[email protected]>
Greptile SummaryThe PR extracts modifier-only hotkey decisions into testable logic and ties an active press to its exact shortcut, preventing unrelated modifier releases from re-arming an interrupted press.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3b13444bc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| guard isActiveModifierOnlyPress || isModeKeyPressed, | ||
| expectedModifierKeyCodes.contains(keyCode), | ||
| !pressedKeyCodes.contains(keyCode) |
There was a problem hiding this comment.
Tie modifier release to the active shortcut
With more than one primary modifier-only shortcut configured, such as Left Option and Right Option, releasing the second modifier while the first is still held now falls through the first shortcut because the new start guard no longer consumes/re-arms it, then this finish check treats the second shortcut as active solely because both behaviors use holdModeType == .transcription. In hold/automatic mode that clears modifierOnlyKeyDown/isKeyPressed and stops the active recording before the originally held modifier is released; the release should be matched against the actual active shortcut/key codes, not just the mode type.
Useful? React with 👍 / 👎.
|
oh wow - were you able to reproduce this or is it just a guess and a fix? Thanks for the PR! |
|
Yes — reproduced it before writing the fix. The regression test in |
Description
When the primary dictation hotkey is a single modifier (e.g. Left Option), an unrelated
Shift+key combo (Shift+Enter, Shift+R) could falsely start recording.
Root cause: the modifier-only start path in
GlobalHotkeyManagerwas re-entrant. While theconfigured modifier was held together with an extra modifier (Shift), releasing the extra
modifier shrank the pressed-modifier set back to just the configured modifier, which re-triggered
the start block and reset the "another key was pressed" flag. The subsequent release of the
configured modifier then looked like a clean tap and started recording.
The fix gates the start on the
flagsChangedactually being for the configured modifier, soreleasing an unrelated modifier can no longer re-arm the press or erase the interrupt flag. A
genuine tap (and multi-modifier chords) still work. The start/finish decision was extracted into a
pure, unit-testable helper so a regression test could be added without instantiating the full
global event-tap manager.
Type of Change
Related Issue or Discussion
Fixes #688
Testing
swiftlint --strict --config .swiftlint.yml Sources→ 0 violations in 139 filesswiftformatis not a CI check for this repo (swiftlint --strict is the authoritative gate)xcodebuild test … -only-testing:FluidDictationIntegrationTests/HotkeyShortcutTests→ 43 passed, 0 failures (under a U.S. input source)Screenshots / Video
Notes
Pure logic fix in the modifier-only state machine — no UI, no hardware, no recording-pipeline
change.
HotkeyHoldModeTypewas made internal and the start/finish decision was extracted intoModifierOnlyShortcutFlagsDecision.evaluateto make the state machine unit-testable (the managercan't be constructed in a test). Behavior-equivalence of the extraction was verified against the
original method; the only intentional behavior change is the new start guard.