fix: restore cross-app hotkey via HID tap + active tap options#66
Merged
quiet-node merged 3 commits intomainfrom Apr 8, 2026
Merged
fix: restore cross-app hotkey via HID tap + active tap options#66quiet-node merged 3 commits intomainfrom
quiet-node merged 3 commits intomainfrom
Conversation
The double-tap Control hotkey stopped working whenever focus left Thuki or its launch terminal. Two independent bugs combined to cause this. Bug 1: CGEventTapLocation::Session filtered by window server focus Since macOS 15 Sequoia, Session-level taps only receive events while the tap process (or its parent terminal) has focus. Switching to any other app silently stops all event delivery with no error. Fixed by using CGEventTapLocation::HID, which operates before the window server routing layer and receives all keypress events regardless of which app is active. Bug 2: CGEventTapOptions::ListenOnly disabled by secure input mode ListenOnly taps are disabled by macOS secure input mode, which activates when iTerm has "Secure Keyboard Entry" enabled or any password field is focused. macOS sends TapDisabledByUserInput and halts delivery. Fixed by using CGEventTapOptions::Default (active tap). We return CallbackResult::Keep so no events are blocked. Additional changes: - Add Input Monitoring (kTCCServiceListenEvent) as a required permission alongside Accessibility and Screen Recording. The IOHIDCheckAccess/IOHIDRequestAccess FFI and three new Tauri commands wire it into the existing permission infrastructure. - Add Input Monitoring as step 2 in OnboardingView (between Accessibility and Screen Recording, no restart required). - Improve tap retry logic: distinguish tap-death (reinstall immediately) from creation failure (wait + limited retries). - Handle TapDisabledByTimeout/TapDisabledByUserInput in callback by stopping the run loop to trigger an immediate reinstall. - Document the HID + Default tap requirement in CLAUDE.md so these settings are never accidentally reverted. Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
a8fb8d8 to
1b21c1e
Compare
Owner
Author
Code reviewFound 1 issue:
thuki/src-tauri/src/permissions.rs Lines 66 to 72 in 1b21c1e The comment should say HID level, not Session level (or omit the tap-level qualification entirely, since the function is not tap-level-specific). 🤖 Generated with Claude Code If this code review was useful, please react with 👍. Otherwise, react with 👎. |
…nted doc The doc comment incorrectly stated the permission was required for a CGEventTap at Session level. The tap runs at HID level since the fix in this branch. Updated to reflect the actual implementation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
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.
Summary
CGEventTapconfiguration mistakes inactivator.rs, both required to fixWhat broke and why
CGEventTapLocation::Session(was the main culprit)Session-level taps sit above the macOS window server routing layer. Since macOS 15 Sequoia, the window server applies focus-based filtering: a Session-level tap only receives events while the tap's own process has focus. Switching to any other app produces zero callbacks with no errors. Fixed by switching to
CGEventTapLocation::HID, which operates before the window server layer and receives all events regardless of focus — the same approach used by Karabiner-Elements and BetterTouchTool.CGEventTapOptions::ListenOnly(secondary issue)ListenOnlytaps are killed by macOS secure input mode. When iTerm's "Secure Keyboard Entry" is enabled (or any password field is focused), macOS sendsTapDisabledByUserInputand stops all event delivery. Fixed by switching toCGEventTapOptions::Default. We still returnCallbackResult::Keepin the callback so no events are blocked.Other changes
TapExitReasonenum to distinguish intentional stop, creation failure, and macOS-disabled tap — enabling correct retry behaviorrun_loop_with_retryto loop while active, retry immediately onTapDied, back off onCreationFailedTapDisabledByTimeout/TapDisabledByUserInputhandling in callback (these sentinel values cannot be in the event mask bitmask — causes a shift-left overflow panic)IOHIDCheckAccess/IOHIDRequestAccess)CLAUDE.mdwith a "DO NOT CHANGE" warning documenting both required tap settingsTest plan
bun run test:allpasses with 100% coveragebun run validate-buildcompletes with zero warnings and zero errors🤖 Generated with Claude Code