Skip to content

fix(cua-driver-rs)(macos): don't raise a terminal-attributed TCC prompt from call check_permissions - #1760

Merged
f-trycua merged 1 commit into
mainfrom
fix/call-tcc-attribution-daemon-relaunch
May 30, 2026
Merged

fix(cua-driver-rs)(macos): don't raise a terminal-attributed TCC prompt from call check_permissions#1760
f-trycua merged 1 commit into
mainfrom
fix/call-tcc-attribution-daemon-relaunch

Conversation

@f-trycua

@f-trycua f-trycua commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Problem (observed live)

cua-driver call check_permissions (default prompt:true) raised the AX / Screen-Recording dialog in-process. Run from a terminal, macOS attributes that dialog to the terminal (LaunchServices' "responsible" process), not to com.trycua.driver — so the prompt reads "Terminal/Gumbranch would like to control this computer" and the grant lands on the terminal, never on the driver. The user then "keeps getting asked for permissions despite having granted" because the grant went to the wrong app. (#1491)

Fix

When we're a bundle CLI spawned from a terminal (should_use_daemon_proxy) and no daemon is up to route through, degrade check_permissions to report-only (force prompt:false) and print the one launch that grants correctly:

open -n -g -a CuaDriver --args serve

which raises the dialog as CuaDriver and stays alive while the user grants.

Deliberately no auto-spawn from call: a first attempt auto-launched that daemon on every call, but the first-launch permissions gate lags socket creation, so launch_daemon_and_wait timed out, fell back to an in-process (terminal) prompt, and open -n piled up zombie daemons that re-prompted in a loop. Report-only + guidance avoids all of that.

The mcp path is unchanged — it already routes through a LaunchServices-launched daemon (run_mcp_via_daemon_proxy), so its prompts already attribute to CuaDriver.

Depends on

Known separate issue (not fixed here)

serve launched via open -n -g -a CuaDriver --args serve lags socket creation on first launch (the permissions gate's re-exec cycle), while terminal-foreground serve is instant. Filing separately — it's why the auto-spawn approach was abandoned and is the remaining rough edge in the grant flow.

Verified

  • From a terminal: call check_permissions reports status + the grant hint, raises no prompt, spawns no daemon (regression gone).
  • open -n -g -a CuaDriver --args serve launches the daemon from the bundle (ppid=1) → prompts attribute to com.trycua.driver.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Resolved macOS permission prompt issue where checks could trigger unexpected prompts in certain conditions.

Review Change Stack

…pt from `call`

`cua-driver call check_permissions` (prompt:true) raised the AX/Screen-
Recording dialog in-process. Run from a terminal, macOS attributes that
dialog to the *terminal* (LaunchServices' "responsible" process), not to
com.trycua.driver — so the prompt reads e.g. "Terminal would like to
control this computer" and the grant lands on the terminal, never on the
driver. (#1491)

When we're a bundle CLI spawned from a terminal (should_use_daemon_proxy)
and no daemon is up to route through, degrade `check_permissions` to
report-only (force prompt:false) and print the one launch that grants
correctly:

  open -n -g -a CuaDriver --args serve

which raises the dialog AS CuaDriver and stays alive while the user grants.
We deliberately do NOT auto-spawn that daemon from `call`: a one-shot call
shouldn't leave a background daemon behind, and the first-launch
permissions gate can lag socket creation (spawning on every call piled up
zombie daemons + re-prompted in a loop).

The `mcp` path is unchanged — it already routes through a LaunchServices-
launched daemon (run_mcp_via_daemon_proxy), so its prompts already
attribute to CuaDriver.

Verified: from a terminal, `call check_permissions` now reports status +
the grant hint with no prompt and no spawned daemon; `open -n -g -a
CuaDriver --args serve` raises the correctly-attributed dialog and serves.
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored May 29, 2026 5:52pm

Request Review

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a3ff0545-8514-4bb6-8ea2-de642d41f670

📥 Commits

Reviewing files that changed from the base of the PR and between 057fdf1 and f7c770d.

📒 Files selected for processing (1)
  • libs/cua-driver/rust/crates/cua-driver/src/cli.rs

📝 Walkthrough

Walkthrough

On macOS, the CLI now conditionally rewrites JSON arguments for the check_permissions tool within run_call to suppress prompts when daemon-proxy mode is selected but no daemon is listening, preventing TCC dialogs from being raised by an incorrectly attributed process.

Changes

macOS check_permissions prompt conditional rewrite

Layer / File(s) Summary
Conditional JSON rewrite for check_permissions prompt
libs/cua-driver/rust/crates/cua-driver/src/cli.rs
On macOS, when check_permissions has prompt enabled (default true), no daemon is listening, and daemon-proxy mode would be used, the CLI rewrites the JSON arguments to set prompt: false before dispatch, preventing a misattributed TCC prompt.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • trycua/cua#1561: The macOS CLI change that rewrites check_permissions's JSON prompt flag directly addresses reported TCC/attribution behavior for check_permissions invocations.

Possibly related PRs

  • trycua/cua#1396: Both PRs modify check_permissions JSON prompt handling in the macOS/CLI invocation path to control TCC dialog prompting when daemon/proxy mode is inactive.
  • trycua/cua#1479: The macOS run_call fix for rewriting check_permissions JSON arguments is directly tied to the daemon proxy/TCC attribution workflow that PR introduces.
  • trycua/cua#1565: Both PRs change how macOS permissions prompts are triggered; this PR forces check_permissions JSON to disable prompt in the CLI path, while that PR adds an NSPanel-based onboarding gate.

Poem

🐰 A prompt in the wrong hand's a terrible thing,
So we rewrite in JSON what macOS shall bring—
When the daemon lies sleeping, we silence the call,
And let prompt: false save attribution through all! 🔐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: preventing a TCC prompt attribution issue on macOS in the check_permissions function, which is the core fix in this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/call-tcc-attribution-daemon-relaunch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant