Repository navigation
feat(macos): warn when Automation is missing, and toast key presses macOS blocks - #205
Merged
Merged
Conversation
…presses (#196) Key buttons on macOS go through osascript -> System Events, which needs Automation (System Events) and Accessibility. Either missing made the press fail silently; only the daemon log knew. - Proactive: AEDeterminePermissionToAutomateTarget (ctypes, no prompt) raises `automation_system_events_missing` through the #195 health channel, with fix steps naming Privacy & Security → Automation and, for the packaged app, `tccutil reset AppleEvents com.deckd.daemon`. - Reactive: osascript stderr is classified by its trailing error number ((-1743) Automation, (1002) Accessibility). A shared PermissionLedger holds refusals from the focus query, the keysink's startup probe and key presses; health_issues() re-checks a held refusal with an empty keystroke each poll, so it clears without a restart. - MacKeySink raises PermissionDenied; the server sends the requesting session an `action_error` frame, records outcome="permission_denied" in /actions/recent and /metrics, and re-polls health at once so the banner arrives with the toast. Macros stop at the refused step. - Health probes now run off the event loop (asyncio.to_thread). - Client: ActionErrorToast; banner labels the new `focus` primitive. - conftest stubs the Automation probe and ledger so tests never depend on the host's TCC state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- text paste: when the OS refuses ctrl+v, put the user's clipboard back immediately before the refusal propagates (it was left holding the widget text). - PermissionLedger: record_failure / record_success instead of faking return codes on the focus path; the keysink's startup probe reuses _probe_keystroke and is renamed _check_system_events (it checks both grants). - Docs: CONTEXT gains "Action error"; PLATFORM-PARITY's System Events row and ActionRecord's outcome list are current; REFERENCE notes the ok + permission_denied pairing and that --no-focus gets no banner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
On macOS, key buttons (Firefox New window sends ⌘N, for example) go through
osascript→ System Events. That needs two grants: Automation for System Events, and Accessibility. When either was missing, the press did nothing and only the daemon log said why. A missing Automation grant also left the deck stuck on the wrong app. #195 added a banner for Accessibility only.Now the phone tells you about both, before you press anything and again when a press is refused.
Banner before any press. The daemon asks TCC with
AEDeterminePermissionToAutomateTarget, which doesn't show the system prompt, whether it may control System Events. If not, it raisesautomation_system_events_missingthrough the #195 health channel. The fix steps name Privacy & Security → Automation → System Events. Automation can't be added with +, so for the packaged app they also givetccutil reset AppleEvents com.deckd.daemon.Failures caught as they happen. osascript stderr is classified by its trailing error number:
(-1743)is Automation,(1002)is Accessibility, and anything else is ignored. This covers the focus query, key presses and the startup check, so the banner still appears when the direct check can't tell or is wrong. A held refusal is re-checked with an empty keystroke on each health poll, so it clears without a restart. A healthy Mac never runs that extra check.Toast within a second. A refused key press sends an
action_errorframe to the phone that pressed it ("Key press blocked: deckd.app needs Accessibility permission.") and re-polls health straight away, so the toast and the banner arrive together. This coverskey:andtext:buttons, macro key steps, and manual-control keys and typing. A macro stops at the refused step. If a refused paste's Ctrl+V fails, the user's clipboard is put back. Refusals are recorded asoutcome="permission_denied"in/actions/recentand/metrics.Other changes:
confteststubs the permission checks, so test results no longer depend on the developer's own Mac grants.Worth a look:
ok(dispatched) and thenpermission_denied, the same pairing a failed macro already gets.--no-focusthere is no platform backend, so the toast appears but no banner does.Tests:
Still needs a human on a Mac (
human-verification-required):Closes #196.
Created with Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code