Skip to content

Add watchdog for silently starved event taps - #38

Merged
andyhtran merged 1 commit into
mainfrom
fix-keyboard-tap
Jul 15, 2026
Merged

Add watchdog for silently starved event taps#38
andyhtran merged 1 commit into
mainfrom
fix-keyboard-tap

Conversation

@andyhtran

Copy link
Copy Markdown
Owner

Summary

  • Adds a 30-second watchdog timer to EventTapManager that detects event taps which are still registered and report as enabled, but have silently stopped receiving events from WindowServer
  • When prolonged keyboard silence (>90s) coincides with high WindowServer queue latency (>5s) — confirming events are queued but undelivered — the watchdog tears down and recreates the tap
  • Also catches simpler cases where tapIsEnabled returns false and re-enables or recreates as needed

Test plan

  • Build with just dev and confirm the app launches without issues
  • Verify hotkeys work normally (tap creation, key events firing)
  • Check logs for watchdog health-check entries running every 30s
  • Simulate tap death (e.g. revoke and re-grant Accessibility permission) and confirm recovery

🤖 Generated with Claude Code

The existing tapDisabledBy* callbacks only fire while the tap is being
serviced. A tap can starve silently — still registered, tapIsEnabled
true, but events queue in WindowServer undelivered. The watchdog polls
CGGetEventTapList every 30s; if the keyboard has been silent >90s AND
WindowServer reports >5s queue latency, it tears down and recreates
the tap.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@andyhtran
andyhtran merged commit eaf636d into main Jul 15, 2026
1 check passed
@andyhtran
andyhtran deleted the fix-keyboard-tap branch July 15, 2026 03:33
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.

1 participant