fix(#59): disable claude-code IDE auto-connect to stop spurious macOS Apple-Events prompt #68
Reference in New Issue
Block a user
Delete Branch "s60-59-apple-events-prompt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Fixes #59 — using the plugin triggered the macOS "control other applications" (Apple Events / Automation) permission prompt, which works fine when declined.
Root cause
The
claude-codeprovider spawns the bundledclaudeCLI (@cline/sdk->ai-sdk-provider-claude-code->@anthropic-ai/claude-agent-sdk). There is no AppleScript/osascript anywhere in the JS dependency tree (only the build-onlyvite); the Apple Event is sent by the spawnedclaudebinary, which contains 26osascriptcalls. Every one is user-action-gated (clipboard image, screenshot, terminal-setup, Claude-Desktop deep link, browser detection) except IDE auto-connect — the only path that fires without user action whenclaudeis launched inside the VS Code extension host (itosascriptstell application ...to identify/activate the editor). We only consume the turn text result and never use the IDE connection, so denying the prompt is harmless (exactly the symptom).Fix
Spawn the agent with the macOS IDE integration disabled, via the provider
options.envpassthrough inrunEditTurn(the sole agent-spawn site):CLAUDE_CODE_AUTO_CONNECT_IDE=0— hard-returns out of the binary auto-connect gate (mK("0") === true).CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL=1— skips the extension-install deep link (belt-and-suspenders).options.envis seeded with the fullprocess.env, so default environment inheritance is unchanged (login underHOME, proxy/CA vars preserved) — only the two switches are added. The env flows end-to-end into the spawned child (verified through the providergetBaseProcessEnvmerge and the agent SDKspawn).Verification
Generated with Claude Code
The claude-code provider spawns the bundled `claude` CLI via @cline/sdk → ai-sdk-provider-claude-code → @anthropic-ai/claude-agent-sdk. On macOS, when that subprocess is launched from inside the VS Code extension host it performs IDE auto-connect, which shells out to `osascript` (`tell application …`) to identify/activate the editor — raising the macOS "control other applications" (Apple Events / Automation) permission prompt. There is no AppleScript/osascript anywhere in the JS dependency tree (the only match is the build-only `vite`); the Apple Event is sent by the spawned `claude` binary, which contains 26 osascript calls. Every one is user-action-gated (clipboard image, screenshot, terminal-setup, Claude-Desktop deep link, browser detection) except the IDE auto-connect path, which is the only one that fires without user action when launched inside an IDE — exactly the reported symptom (appears on use, harmless when declined, since we never use the connection). Fix: spawn the agent with the macOS IDE integration disabled via the provider's `options.env` passthrough — `CLAUDE_CODE_AUTO_CONNECT_IDE=0` hard-returns out of the binary's auto-connect gate (`mK("0") === true`), and `CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL=1` skips the extension-install deep link. `options.env` is seeded with the full `process.env` so the default environment inheritance is unchanged (login under HOME, proxy/CA vars preserved) — only the two switches are added. The env flows end to end into the spawned child (verified through the provider's getBaseProcessEnv merge and the agent SDK's spawn). runEditTurn is the sole agent-spawn site, so this covers every flow. Unit test asserts the agent is constructed with the two switches set and the rest of the environment preserved. 250 unit + typecheck + build green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>