Skip to content

fix(hotkey): stop modifier-only shortcut from firing on unrelated Shift+key combos - #815

Merged
altic-dev merged 2 commits into
altic-dev:mainfrom
YuriNachos:YuriNachos/w3-fluidvoice
Aug 10, 2026
Merged

altic-dev merged 2 commits into
altic-dev:mainfrom
YuriNachos:YuriNachos/w3-fluidvoice

Conversation

@YuriNachos

Copy link
Copy Markdown
Contributor

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 GlobalHotkeyManager was re-entrant. While the
configured 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 flagsChanged actually being for the configured modifier, so
releasing 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

  • 🐞 Bug fix

Related Issue or Discussion

Fixes #688

Testing

  • Tested on Intel Mac
  • Tested on Apple Silicon Mac
  • Tested on macOS version: macOS 26.6 (Tahoe, Darwin 25.6.0)
  • Ran linter locally: swiftlint --strict --config .swiftlint.yml Sources → 0 violations in 139 files
  • Ran formatter locally: swiftformat is not a CI check for this repo (swiftlint --strict is the authoritative gate)
  • Ran tests locally: xcodebuild test … -only-testing:FluidDictationIntegrationTests/HotkeyShortcutTests → 43 passed, 0 failures (under a U.S. input source)

Screenshots / Video

  • No UI/visual changes; screenshots/video are not applicable.

Notes

Pure logic fix in the modifier-only state machine — no UI, no hardware, no recording-pipeline
change. HotkeyHoldModeType was made internal and the start/finish decision was extracted into
ModifierOnlyShortcutFlagsDecision.evaluate to make the state machine unit-testable (the manager
can'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.

…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-apps

greptile-apps Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Greptile Summary

The 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.

  • Adds explicit modifier-only shortcut ownership tracking.
  • Gates arming on the modifier represented by the current flagsChanged event.
  • Adds regression coverage for Shift combinations, clean taps, sibling modifiers, and multiple primary modifiers.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "fix active modifier shortcut ownership" | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +105 to +107
guard isActiveModifierOnlyPress || isModeKeyPressed,
expectedModifierKeyCodes.contains(keyCode),
!pressedKeyCodes.contains(keyCode)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@altic-dev

Copy link
Copy Markdown
Owner

oh wow - were you able to reproduce this or is it just a guess and a fix? Thanks for the PR!

@YuriNachos

Copy link
Copy Markdown
Contributor Author

Yes — reproduced it before writing the fix. The regression test in Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift covers the exact path: with the primary hotkey set to a single modifier, holding Shift+key re-armed the start block because the modifier-only start path was re-entrant (releasing the extra modifier shrank the pressed-modifier set back to just the configured one). That test fails on the old code and passes after the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Left Option modifier-only hotkey falsely triggers recording on Shift+Enter

2 participants