Handle Accessibility permission and keep cmdX running when its menu bar icon is hidden (macOS 26) - #22
Open
rubnogueira wants to merge 1 commit into
Conversation
…ar icon is hidden The key interceptor requires Accessibility permission and its lifetime was tied to the SwiftUI MenuBarExtra scene, so ⌘X/⌘V silently stopped working when permission was missing/revoked and the app quit outright when its menu bar icon was hidden on macOS 26 (Tahoe). Accessibility permission: - Check AXIsProcessTrusted() on launch and prompt when access is missing. - Poll so the status stays live and the interceptor auto-starts the moment access is granted (no relaunch). - Show a live permission status card in the popover with a Grant Access button. - KeyInterceptor publishes hasAccessibilityPermission; start() guards on it instead of failing silently. Survive the menu bar icon being hidden (macOS 26): - Replace the single MenuBarExtra scene with a classic AppKit NSStatusItem owned by AppDelegate, an empty Settings scene, and applicationShouldTerminateAfterLastWindowClosed == false, so the app runs as a background agent whose lifetime no longer depends on the menu bar item. Keep the event tap alive: - Prevent App Nap with a held ProcessInfo activity token (idle sleep allowed). - Re-enable the tap when the system disables it (timeout / user input). Also update the update notification text, which referenced opening the menu bar to install updates.
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.
Closes #21
Closes #14
What this does
Makes the key interceptor robust to the two things that were silently breaking ⌘X/⌘V, and surfaces Accessibility permission in the UI.
Accessibility permission
AppDelegatechecksAXIsProcessTrusted()and shows the system prompt when access is missing.KeyInterceptorpublisheshasAccessibilityPermission;start()guards on it instead of failing silently.Survive the menu bar icon being hidden (macOS 26 / Tahoe)
MenuBarExtrascene, so hiding/removing the menu bar item on Tahoe tore the scene down and terminated the whole process.NSStatusItemowned byAppDelegate, an emptySettingsscene, andapplicationShouldTerminateAfterLastWindowClosed == false. The icon still shows (and respects the OS show/hide setting), but the app now runs as a background agent whose lifetime no longer depends on the menu bar item.Keep the event tap alive
ProcessInfo.beginActivitytoken (still allows idle system sleep) — otherwise the throttled callback times out and the tap gets disabled when there's no visible UI.tapDisabledByTimeout/tapDisabledByUserInput), instead of leaving it dead.Misc
Testing
Notes for reviewers
NSApplicationDelegateclasses (AppDelegateWrapperand the unusedAppDelegate) into one.ContentViewis now hosted in theNSStatusItempopover rather than aMenuBarExtra.