Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(desktop): add opt-in Cua Driver computer use #5533

Closedf-trycua(GitHub profile, opens in a new tab)wants to merge 237 commits intot3code/codex-turn-mapping fromrefs/pull/5533/headopened View on GitHub

Problem

T3 Code does not currently expose an opt-in path for Codex agents to use the packaged Cua Driver integration. The original contribution in #4354 contains the intended implementation, but its branch history diverged from t3code/codex-turn-mapping, producing conflicts and an inflated 241-commit, 821-file comparison.

This PR rebuilds that contribution on the current target branch, preserves Zane Chee's authorship, and updates the host topology to match Cua Driver's macOS permission contract.

Solution

  • Add a desktop-only, opt-in Computer use setting (disabled by default).
  • Package checksum-pinned Cua Driver 0.12.2 binaries for macOS, Linux, and Windows desktop artifacts.
  • Start and supervise the embedded daemon directly from Electron main, after app.whenReady() and the macOS permission preflight.
  • Pass the SDK-generated MCP command, args, and environment to the local Node backend through the typed bootstrap envelope. The backend installs only the proxy configuration; it never starts a second desktop daemon.
  • Keep WSL and inherited development environment variables from recreating the old backend-owned topology.
  • Preserve existing Codex mcp_servers.cua-driver configuration as authoritative, including definitions supplied through appended launch args.
  • Preserve configured/appended/managed argument boundaries by tokenizing each source independently.
  • If the Electron-owned daemon exits unexpectedly, clear its descriptor and restart the local backend so Codex cannot retain dead-socket MCP arguments.
  • Stop backend processes before stopping the Electron-owned daemon.

The resulting ownership tree is:

T3 Code (Electron, owns macOS permissions)
├─ cua-driver serve
└─ T3 Code backend
   └─ Codex
      └─ cua-driver mcp --socket <private>

The reusable host/target contract is documented in trycua/cua#2982.

Validation

  • Focused desktop lifecycle/backend tests: 31 passed (DesktopCuaDriver, DesktopBackendConfiguration, DesktopAppErrors)
  • Full desktop test suite: 455 passed
  • Focused Cua/bootstrap/precedence server tests: 28 passed
  • Expanded Codex provider, adapter, and text-generation regression tests: 131 passed
  • Targeted typechecks passed for @t3tools/desktop, t3, and @t3tools/contracts
  • Changed TypeScript files pass targeted lint and formatting checks
  • pnpm build:desktop passed (web, server, and Electron main/preload bundles); the exact final server head also passed vp pack
  • Unsigned macOS arm64 packaging passed; verified the executable at Contents/Resources/cua-driver, the unpacked native Node binding, and both SDK JS entry points in app.asar
  • git diff --check passes

Screenshots

Enabled:

Computer use enabled

Disabled:

Computer use disabled


Note

High Risk Touches macOS accessibility/screen-recording permissions, native embedded daemons, Codex MCP configuration, and backend restart on driver failure—security- and reliability-sensitive desktop startup paths.

Overview Introduces opt-in computer use (default off) for the desktop app: a new Computer use setting in General settings, gated on desktopBridge, with restart required after toggling.

Electron owns the embedded @trycua/cua-driver daemon when enableCua is on—macOS permission preflight, graceful failure dialogs, shutdown ordering (backends stop before the driver), and restart of the local primary backend if the daemon exits so Codex does not keep stale MCP launch args. The typed bootstrap envelope gains optional cuaDriverMcp; only the local primary backend receives it (not WSL), and inherited T3CODE_CUA_DRIVER_* env vars are stripped from backend children to avoid a second daemon.

Server startup installs either desktop-supplied MCP config (proxy only) or a server-private embedded driver when T3CODE_CUA_DRIVER_PATH is set. Codex launch-arg resolution now returns tokenized argv, merges append/CUA env overrides, and defers managed Cua injection when config.toml or launch args already define mcp_servers.cua-driver. Codex adapter sessions read live process env for integration args.

Desktop builds download and stage checksum-pinned Cua Driver 0.12.2 binaries per OS/arch into prod-resources/cua-driver as an extra resource.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1e262919716fac4a6a321a1c235a47829ff7b439. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add opt-in computer use (CUA) driver to desktop app

  • Adds an enableCua client setting (default false) exposed in General Settings; when enabled, the desktop app downloads, verifies (SHA-256), extracts, and stages the @trycua/cua-driver binary during build and starts it at runtime.
  • Introduces DesktopCuaDriver service (DesktopCuaDriver.ts) that manages the driver lifecycle: resolves the binary path, checks macOS permissions, starts the embedded host, exposes an MCP descriptor, and monitors for unexpected exits.
  • The server runtime (serverRuntimeStartup.ts) picks up the MCP descriptor from bootstrap and conditionally injects CUA launch args into Codex via T3CODE_CODEX_CUA_LAUNCH_ARGS, skipping injection if the user has already configured a CUA driver in their config.toml.
  • If the driver exits unexpectedly while the app is running, the desktop backend is automatically restarted without CUA; macOS permission failures and module load errors surface as blocking dialogs.
  • Risk: the driver binary is downloaded and cached at build time per platform/arch; checksum mismatches abort the build. At runtime, the extra startup phase (permission checks, process spawn) runs before keybindings init and logs warnings on failure rather than aborting startup.
Macroscope summarized 1e26291.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: e4c79c38-5273-4714-b35e-c8dd87658338

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.
    2. Reviewed the new Cua driver Effect code (apps/desktop/src/cua/CuaDriverServerEnvironment.ts, apps/server/src/cua/CuaDriverEmbedded.ts) and the touched call sites against the Effect service conventions. Error classes use Schema.TaggedErrorClass with structural attributes and real cause, failures are recovered with Effect.catchTags, and imports use effect/* namespaces — no Layer.succeed, ManagedRuntime.make, or runPromise misuse was introduced. One convention issue: the new startup handlers stringify the underlying defect into the log payload instead of passing it through as cause.

      Posted via Macroscope — Effect Service Conventions
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      app/DesktopApp.ts:321

      Same here: String(error.cause) flattens the defect into the log annotations. Consider typing continueWithoutCua's context as Readonly<Record<string, unknown>> and logging cause: error.cause so the underlying failure (and its stack) is preserved rather than an opaque string.

      No longer relevant as of 997b37d8c510125f22c78016a38c94fc7191ea19

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e8d5b0258ce7b16ef5f0c9b822ccddb873e6de36. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. Approvability

      Verdict: Needs human review

      This PR introduces a substantial new feature (opt-in computer use via Cua Driver) with new services, external process management, permission handling, UI controls, and build infrastructure for bundling native binaries across platforms. New capabilities of this scope require human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      Closing this PR after an automated pass over open pull requests. Outside computer-use integration changes 881 files and adds a separate product capability.

    7. juliusmarminge reopened this

    8. juliusmarminge closed this

    9. github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched

    10. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

Sign in to join this conversation.