Skip to content

docs(cua-driver): "Process attribution" explainer (Session 0 on Windows + TCC on macOS)#1594

Open
f-trycua wants to merge 1 commit into
mainfrom
docs/cua-driver-process-attribution-explainer
Open

docs(cua-driver): "Process attribution" explainer (Session 0 on Windows + TCC on macOS)#1594
f-trycua wants to merge 1 commit into
mainfrom
docs/cua-driver-process-attribution-explainer

Conversation

@f-trycua
Copy link
Copy Markdown
Collaborator

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

Summary

Adds a Diataxis-style explanation page that disambiguates the two OS subsystems that decide what a cua-driver process can touch:

  • Windows session attribution (Session 0 vs 1+) — applies over SSH and to anything spawned by a service
  • macOS TCC (per-(bundle id, cdhash) grants) — applies to shell-spawned binaries that don't have the right responsible process

They look identical from the user's POV — "my tool calls return empty arrays" — but the mechanics are completely different, and the recipes in `windows-ssh.mdx` and `installation.mdx` deliberately don't go this deep.

What's in it

  • New section under `docs/content/docs/cua-driver/explanation/`, registered in the top-level cua-driver sidebar
  • New page `explanation/process-attribution.mdx` (~130 lines MDX, ~700 words):
    • Opening framing: tool effect depends on the responsible process, not the CLI
    • Windows session attribution: `query session` output, why SSH is Session 0, why desktop APIs are session-scoped, the daemon-proxy fix from fix(cua-driver-rs): proxy MCP through daemon on Windows/Linux when one is up #1580
    • macOS TCC: (bundle id, cdhash) keying, why a `cargo build` binary misses, the dev-build re-sign workaround, the responsible-process attribution problem and how `should_use_daemon_proxy` solves it via `open -n -g -a CuaDriver`
    • What `cua-driver doctor` reports about both subsystems (quotes the exact warning text from `doctor.rs`)
    • Symptoms-to-cause lookup table

Cross-links wired

  • `getting-started/windows-ssh.mdx` Session 0 paragraph → explainer
  • `getting-started/installation.mdx` "Grant TCC permissions" intro → explainer
  • `reference/cli-reference.mdx` `cua-driver doctor` section → explainer

Grounded in code

Test plan

  • Local fumadocs build doesn't break (verified by file structure parity with adjacent explanation/ pages — no fumadocs dev-server run, but the meta.json shape matches the sibling `getting-started/` pattern)
  • Vercel preview verifies sidebar registration + cross-links resolve

Closes CUA-537

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added new "Explanation" section detailing how process attribution affects tool visibility on Windows (session isolation, daemon-proxy) and macOS (TCC privacy grants).
    • Updated installation and CLI reference guides with cross-references to process attribution documentation.
    • Enhanced troubleshooting guidance with platform-specific behavior notes and diagnostic information.

Review Change Stack

…ws + TCC on macOS)

Adds a Diataxis-style explanation page that disambiguates the two OS
subsystems that decide what a cua-driver process can touch: Windows
session attribution (Session 0 vs 1+) and macOS TCC ((bundle id,
cdhash) grants). They look identical from the user's POV — "my tool
calls return empty arrays" — but the mechanics are completely
different, and the howtos in `windows-ssh.mdx` and `installation.mdx`
deliberately don't go this deep.

  * New section under `docs/content/docs/cua-driver/explanation/`,
    registered in the top-level cua-driver sidebar
    (`meta.json` adds "explanation" alongside "guide" and "reference").
  * New page `explanation/process-attribution.mdx` (~130 lines, ~700
    words MDX prose + two diagrams):
    - Opening framing: tool effect depends on the responsible process,
      not the CLI.
    - Windows session attribution: `query session` output, why SSH is
      Session 0, why desktop APIs are session-scoped, the daemon-proxy
      fix from PR #1580.
    - macOS TCC: (bundle id, cdhash) keying, why a `cargo build`
      binary misses, the dev-build re-sign workaround, the
      responsible-process attribution problem and how
      `should_use_daemon_proxy` solves it via `open -n -g -a CuaDriver`.
    - What `cua-driver doctor` reports about both subsystems.
    - Symptoms-to-cause lookup table.
  * Cross-links: `windows-ssh.mdx` Session 0 paragraph and
    `installation.mdx` "Grant TCC permissions" intro both link out to
    the new explainer for the deeper mechanics. `cli-reference.mdx`
    `cua-driver doctor` section also points there.

The page is grounded in `should_use_daemon_proxy` in
`libs/cua-driver-rs/crates/cua-driver/src/cli.rs` (the v0.2.7
cross-platform proxy router from PR #1580) and `doctor.rs` for the
exact warning text, so the docs stay synced with what the CLI actually
prints.

Closes CUA-537

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 20, 2026

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 20, 2026 9:25am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

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: 7745d2d0-121d-48a7-98e6-f52cf9fae300

📥 Commits

Reviewing files that changed from the base of the PR and between baf87e6 and 7a018db.

📒 Files selected for processing (6)
  • docs/content/docs/cua-driver/explanation/meta.json
  • docs/content/docs/cua-driver/explanation/process-attribution.mdx
  • docs/content/docs/cua-driver/guide/getting-started/installation.mdx
  • docs/content/docs/cua-driver/guide/getting-started/windows-ssh.mdx
  • docs/content/docs/cua-driver/meta.json
  • docs/content/docs/cua-driver/reference/cli-reference.mdx

📝 Walkthrough

Walkthrough

This PR adds a comprehensive "Explanation" documentation section about process attribution that clarifies how Windows session scoping and macOS TCC permissions affect cua-driver tool visibility, then integrates this explanation into existing guides through targeted cross-links.

Changes

Process Attribution Explanation and Integration

Layer / File(s) Summary
Explanation section core content and structure
docs/content/docs/cua-driver/explanation/meta.json, docs/content/docs/cua-driver/explanation/process-attribution.mdx
New documentation section covering Windows Session 0 daemon-proxy routing, macOS TCC bundle id + cdhash attribution, cua-driver doctor command behavior, a troubleshooting symptoms table, and related topic links.
Documentation structure and cross-link wiring
docs/content/docs/cua-driver/meta.json, docs/content/docs/cua-driver/guide/getting-started/installation.mdx, docs/content/docs/cua-driver/guide/getting-started/windows-ssh.mdx, docs/content/docs/cua-driver/reference/cli-reference.mdx
Top-level documentation metadata registers the new Explanation section, and existing guides (installation, Windows SSH, CLI reference) add directed links to the process-attribution explanation for deeper context on permissions and Session 0 behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • trycua/cua#1583: Introduces Windows SSH workflow documentation details that the new cross-link references.
  • trycua/cua#1368: Updates installation script to start the daemon first, aligning with the documented macOS TCC process attribution flow.
  • trycua/cua#1396: Addresses TCC prompt defaults and in-process fallback behavior that is now explained by the process-attribution documentation.

Poem

🐰 A new doc page hops into the fold,
explaining why Sessions and TCC take hold—
daemon-proxy routes, bundle ids and cdhash too,
now readers will know just what to do! 📚✨

🚥 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 pull request title clearly and concisely summarizes the main change: adding a documentation explainer page about process attribution on Windows (Session 0) and macOS (TCC).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/cua-driver-process-attribution-explainer

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

f-trycua added a commit that referenced this pull request May 20, 2026
…oses CUA-541) (#1596)

* docs(cua-driver): dedicated Linux install + run guide

Adds a Linux-specific getting-started page that covers what diverges
from the canonical macOS / Windows install — display server (X11 vs
Wayland vs XWayland), the AT-SPI prerequisite, autostart-via-systemd
(since `cua-driver autostart` is Windows-only today), and the headless
Xvfb workflow for CI.

Concrete behaviors documented (verified against the source):

  * Display-server probe in `libs/cua-driver-rs/crates/cua-driver/src/
    doctor.rs::append_platform_probes` (Linux branch) — Wayland-with-
    XWayland is the supported case; pure Wayland w/o XWayland is not
    today.
  * AT-SPI bus probe via `probe_at_spi_bus_via_gdbus` — required for
    accessibility-tree tools (`get_window_state`, indexed-element
    clicks). Per-distro install table (`at-spi2-core` on every distro,
    `gsettings` toggle for GNOME).
  * `cua-driver autostart` returns the documented `NOT_YET` error on
    Linux from `crates/cua-driver/src/autostart.rs` — the page points
    users at the two working alternatives: `install-local.sh
    --autostart` (which registers a systemd user unit) or a hand-rolled
    `~/.config/systemd/user/cua-driver.service` (full file content
    provided). Also mentions `loginctl enable-linger` for headless
    runners.
  * Headless workflow: `xvfb-run` recipe + standalone Xvfb + dbus-launch
    one-liner.
  * Distro notes for Ubuntu/Debian/Fedora/Arch/Alpine.
  * Cross-links to the existing PARITY.md per-tool Linux matrix, the
    new process-attribution explainer (#1594), the autostart concept
    page, and installation.mdx for the install one-liner.

Registers `linux` in `getting-started/meta.json` between `windows-ssh`
and `autostart` so the sidebar ordering is: install → quickstart →
windows-ssh → linux → autostart → … .

Closes CUA-538

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(cua-driver-rs): add kill_app tool for force-terminate by pid

Closes CUA-541. Adds a new `kill_app` MCP tool that force-terminates a
process by pid — equivalent to `taskkill /F /PID <pid>` on Windows,
`kill -9 <pid>` on macOS / Linux. Marked `destructive: true` so MCP
clients with permission gating prompt before invoking.

Use case from WINDOWS_CLAUDE_CODE_TEST_PLAN.md Test G live run today:
the cleanup step asked claude to close 3 leftover Calculator instances
via cua-driver tools, but the only available close path is `click` on
the X button (sends WM_CLOSE via PostMessage). UWP / WinUI3 apps
(Calculator, Photos, Settings, Win11 Notepad) treat WM_CLOSE as
"minimize to suspended state" rather than exit, leaving orphan
processes that survive every polite eviction attempt. `kill_app` is
the escalation: skip cooperative close, terminate the process
directly. Unsaved state is lost — tool docs explicitly recommend
trying the click-the-X path first.

Platform implementations:

  * Windows (`crates/platform-windows/src/tools/impl_.rs`):
    `OpenProcess(PROCESS_TERMINATE | PROCESS_SYNCHRONIZE)` +
    `TerminateProcess(h, 1)` + `WaitForSingleObject(h, 2000)`. The
    extra `PROCESS_SYNCHRONIZE` right + 2-second wait means the
    caller's follow-up `list_apps` reflects the change immediately;
    `WAIT_TIMEOUT` is treated as a soft success since the kill itself
    landed. Run on a `spawn_blocking` thread because Win32
    `WaitForSingleObject` is sync.

  * macOS (`crates/platform-macos/src/tools/kill_app.rs`, new file):
    `libc::kill(pid, SIGKILL)`. Synchronous; no spawn_blocking
    needed. Returns `EPERM` if the daemon can't signal the target
    (cross-user or root-owned), `ESRCH` if the pid doesn't exist —
    both surfaced via `std::io::Error::last_os_error()`.

  * Linux (`crates/platform-linux/src/tools/impl_.rs`):
    same `libc::kill(pid, SIGKILL)` as macOS. Adds `libc = "0.2"`
    to platform-linux/Cargo.toml since the crate didn't depend on
    libc directly before.

  * Stubs (`stubs.rs` in both platform crates): register
    `KillAppTool` for the cross-platform interface — non-target
    builds get the standard "not implemented for this platform"
    error.

Schema: single `pid: integer` argument. Bounds-checked at the tool
boundary (must be positive, must fit in i32/u32 depending on the
platform call signature).

Live tested locally on macOS — `cua-driver call kill_app '{"pid":<calc-pid>}'`
terminates the target cleanly. Windows verification pending in the
follow-up VM build + reinstall step.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(cua-driver-rs/kill_app): replace ambiguous .into() with .to_string()

Caught only on Windows since the windows-rs / bytes crate ecosystem
exposes more From<&str> impls than macOS / Linux. The macOS path
hit the same E0283 earlier in this branch; this lines up the other
two impls with the fix.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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