fix(#59): disable claude-code IDE auto-connect to stop spurious macOS Apple-Events prompt #68

Merged
benstull merged 1 commits from s60-59-apple-events-prompt into main 2026-06-26 20:12:24 +00:00
Owner

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-code provider spawns the bundled claude CLI (@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-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 IDE auto-connect — the only path that fires without user action when claude is launched inside the VS Code extension host (it osascripts tell 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.env passthrough in runEditTurn (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.env is seeded with the full process.env, so 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 getBaseProcessEnv merge and the agent SDK spawn).

Verification

  • New unit test asserts the agent is constructed with both switches set and the rest of the environment preserved.
  • 250 unit + typecheck + build green. E2E is unaffected (it stubs the turn and never reaches the real spawn path).
  • Operator smoke (Apple-Events / TCC): on a fresh macOS Automation-TCC state, exercise a Claude edit and confirm the "control other applications" prompt no longer appears and the edit still works — inherently a GUI gesture per the issue acceptance criteria.

Generated with Claude Code

## 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-code` provider spawns the bundled `claude` CLI (`@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-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 IDE auto-connect** — the only path that fires without user action when `claude` is launched inside the VS Code extension host (it `osascript`s `tell 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.env` passthrough in `runEditTurn` (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.env` is seeded with the full `process.env`, so 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 `getBaseProcessEnv` merge and the agent SDK `spawn`). ## Verification - New unit test asserts the agent is constructed with both switches set and the rest of the environment preserved. - 250 unit + typecheck + build green. E2E is unaffected (it stubs the turn and never reaches the real spawn path). - **Operator smoke (Apple-Events / TCC):** on a fresh macOS Automation-TCC state, exercise a Claude edit and confirm the "control other applications" prompt no longer appears and the edit still works — inherently a GUI gesture per the issue acceptance criteria. Generated with Claude Code
benstull added 1 commit 2026-06-26 20:12:11 +00:00
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>
benstull merged commit e671c4bf03 into main 2026-06-26 20:12:24 +00:00
benstull deleted branch s60-59-apple-events-prompt 2026-06-26 20:12:24 +00:00
Sign in to join this conversation.