Typing mode silently does nothing since sandbox was added (Nov 2025)
- Dominant language
- Swift
- Stars
- 2.9k
- Forks
- 226
- PR merge metrics
- No merged PRs in 30d
Description
Hey, I had an agent fix this for me because it was broken on my machine. Anything below here was written by the agent, including the fix. It was small enough, so I thought it doesn't matter that much.
---
## Summary
Typing mode fails silently in every sandboxed build of Hex. The App Sandbox blocks Hex's Apple Events to System Events before macOS can show a permission prompt, so there is no error and no dialog. Typing does nothing while paste mode keeps working.
## Environment
- Hex 0.8.4 (build 91)
- macOS 26.5 (Tahoe)
## Root cause
1. Typing mode runs an AppleScript from `PasteboardClient.swift` (`simulateTypingWithAppleScript`):
`tell application "System Events" to keystroke "..."`
2. A normal app needs user consent (Automation permission) to send Apple Events to System Events. A sandboxed app additionally needs the target listed in `com.apple.security.temporary-exception.apple-events`.
3. `Hex.entitlements` turns on `com.apple.security.app-sandbox` but never lists System Events in that exception array. The sandbox denies the event before TCC is ever involved, so no consent prompt appears and the call fails with `errAEEventNotPermitted`.
4. Hex logs the failure and swallows it: `[com.kitlangton.Hex:Pasteboard] Error executing AppleScript typing fallback`.
What I checked on the affected machine:
- The TCC database has no `kTCCServiceAppleEvents` row for `com.kitlangton.Hex`. That fits: the prompt never fired.
- Manually inserting an allow row for Hex → `com.apple.systemevents` changed nothing. The denial happens before TCC.
- The same `keystroke` AppleScript works when run from an unsandboxed process with the same Accessibility grants. The problem is Hex's sandbox, not the machine or macOS setup.
## Why it regressed
- Typing mode shipped 2025-03-01 (`1806e5d`) with no sandbox. It worked.
- `app-sandbox` arrived 2025-11-13 in #71 (`05456c7`). Every release since breaks typing mode for all users.
Paste mode survives because its primary strategy posts CGEvents directly, which needs only Accessibility.
## Suggested fix
List System Events in `Hex.entitlements`:
```xml
com.apple.security.temporary-exception.apple-events
com.apple.systemevents
```
Re-signing the shipped app ad-hoc without `app-sandbox` restores typing mode completely, which backs up the diagnosis.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with Hex.entitlements and PasteboardClient.swift, especially simulateTypingWithAppleScript and the logged AppleScript failure. Run a sandboxed Hex build and verify the entitlement change restores typing mode while paste mode continues to work. Done means typing no longer silently does nothing in sandboxed releases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, swift
- Domain
- desktop, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100