Skip to content

feat(install): add --experimental-rust flag to opt into cua-driver-rs backend (#1534) - #1538

Merged
f-trycua merged 2 commits into
mainfrom
feat/cua-driver-experimental-rust-flag-1534
May 17, 2026
Merged

feat(install): add --experimental-rust flag to opt into cua-driver-rs backend (#1534)#1538
f-trycua merged 2 commits into
mainfrom
feat/cua-driver-experimental-rust-flag-1534

Conversation

@f-trycua

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

Copy link
Copy Markdown
Collaborator

Summary

  • Adds --experimental-rust (and explicit alias --backend=rust) to libs/cua-driver/scripts/install.sh. When set, the Swift install path is skipped entirely and the script execs into libs/cua-driver-rs/scripts/install.sh with --bin-dir / --no-modify-path (and anything after --) forwarded verbatim.
  • Flag works at any argv position; --backend=swift is accepted as an explicit no-op; --backend=<other> exits 2 with a clear error. Default behavior (no flag) is unchanged — the Swift binary is still what curl ... | bash installs.
  • Delegation uses the on-disk libs/cua-driver-rs/scripts/install.sh when this script runs from a checked-out tree, otherwise curls the canonical raw.githubusercontent.com URL — the latter is what end users hit when they run via the documented one-liner.
  • Docs: new "Try the Rust backend (experimental)" callout in installation.mdx covering the install command, separate /Applications/CuaDriverRs.app bundle (com.trycua.cuadriverrs), TCC + telemetry isolation, and the "switch back" recipe. Root README.md gets a one-line pointer next to the existing install line.

Closes #1534.

Why not just edit the default

The cua-driver-rs port is approaching feature parity with the Swift binary but isn't there yet on macOS — we want a soak period where opt-in users surface remaining edge cases before we flip the switch. This PR adds the opt-in flag only; default install behavior is intentionally untouched and Hermes' upstream installer reference stays on Swift until GA.

Test plan

Syntax check (passes locally on macOS bash 3.2):

bash -n libs/cua-driver/scripts/install.sh
bash -n libs/cua-driver-rs/scripts/install.sh

Flag-parsing smoke test (stub Rust installer that prints its argv):

--- Test 1: --experimental-rust alone ---
RUST_STUB_INVOKED args=
--- Test 2: --backend=rust alone ---
RUST_STUB_INVOKED args=
--- Test 3: --experimental-rust with --no-modify-path ---
RUST_STUB_INVOKED args=--no-modify-path
--- Test 4: --no-modify-path then --experimental-rust (flag at end) ---
RUST_STUB_INVOKED args=--no-modify-path
--- Test 5: --experimental-rust with --bin-dir /tmp/foo ---
RUST_STUB_INVOKED args=--bin-dir /tmp/foo
--- Test 6: --experimental-rust -- --rust-only-flag --other ---
RUST_STUB_INVOKED args=--rust-only-flag --other
--- Test 7: --backend=swift (no-op, continues to swift install) ---
==> latest release: cua-driver-v0.1.9
==> downloading https://github.com/trycua/cua/releases/download/cua-driver-v0.1.9/cua-driver-0.1.9-darwin-arm64.tar.gz
--- Test 8: --backend=unknown ---
error: unknown backend unknown; supported: swift, rust   (exit 2)

End-to-end acceptance (run on a fresh macOS install before merge):

  • Default — installs Swift binary
    curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh | bash
  • Experimental — delegates to Rust installer
    curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh | bash -s -- --experimental-rust
  • Both bundles present after running each in turn (ls /Applications/CuaDriver*.app); each --version reports independently.
  • rm -rf /Applications/CuaDriverRs.app + re-running the default installer restores the Swift symlink.

Note: the curl | bash paths above only work after this PR lands on main, since the experimental flag has to ship in the canonical installer URL before users can pass it.

Summary by CodeRabbit

  • New Features

    • Added experimental Rust backend option for Cua Driver, accessible via --experimental-rust flag during installation. Runs independently alongside the existing Swift version.
  • Documentation

    • Updated installation guide with comprehensive instructions for trying the experimental Rust backend, including setup and rollback procedures.
    • Updated README with information about the experimental Rust backend option.

Review Change Stack

… backend (#1534)

Wire `--experimental-rust` (and the explicit alias `--backend=rust`) into
the canonical Swift installer so early adopters can swap to the cross-
platform Rust port without us flipping the default for everyone. When
set, the Swift install path is skipped entirely and execution is handed
off to `libs/cua-driver-rs/scripts/install.sh` with `--bin-dir` /
`--no-modify-path` (and anything after `--`) forwarded verbatim. The
two bundles use distinct bundle ids so they coexist on the same machine
with independent TCC grants and telemetry IDs — flipping back is just
`rm -rf /Applications/CuaDriverRs.app` + re-running the installer
without the flag.

Closes #1534

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

vercel Bot commented May 17, 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 Preview May 17, 2026 9:50am

Request Review

@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b1ad1397-783a-4058-abd6-35ef44456a9d

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
📝 Walkthrough

Walkthrough

The PR adds an --experimental-rust installation flag to the cua-driver installer, enabling early adopters to opt into the experimental Rust backend. The install.sh script parses the flag and delegates to the Rust installer while preserving the Swift path as default. Documentation is updated to guide users through the opt-in flow and explain coexistence mechanics.

Changes

Experimental Rust Backend Opt-in

Layer / File(s) Summary
Install script: flag parsing and Rust delegation
libs/cua-driver/scripts/install.sh
install.sh now recognizes --experimental-rust and --backend=rust flags via two-pass argument parsing, delegates to the Rust installer when detected, forwards unrecognized arguments, and prefers a local on-disk script or downloads it via curl. Updated usage comment documents the delegation behavior.
User documentation: README and installation guide
README.md, docs/content/docs/cua-driver/guide/getting-started/installation.mdx
README adds a brief note about the -- --experimental-rust flag. Installation guide includes a new "Try the Rust backend (experimental)" section explaining opt-in, installation location, coexistence with Swift (separate bundle id and telemetry), symlink behavior, and how to switch back.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

  • trycua/cua#1532: Adds telemetry install-event ping in the cua-driver-rs install flow that this PR delegates into.
  • trycua/cua#1530: Covers Rust backend packaging and TCC auto-relaunch behavior that aligns with the install delegation target.

Poem

🐰 A flag to try before we leap,
The Rust port's tested, bugs run deep.
Swift stays safe, the Rust takes flight—
Both living side-by-side, quite right! 🚀

🚥 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 clearly and specifically describes the main change: adding an --experimental-rust flag to enable opt-in installation of the cua-driver-rs backend.
Linked Issues check ✅ Passed All coding objectives from issue #1534 are met: --experimental-rust flag implementation with --backend=rust alias, delegation to cua-driver-rs installer, documentation updates in installation.mdx and README.md, and default Swift behavior preserved.
Out of Scope Changes check ✅ Passed All changes are directly within scope: install.sh flag implementation, documentation for experimental Rust backend, and README pointer. No unrelated modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 feat/cua-driver-experimental-rust-flag-1534

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/cua-driver/scripts/install.sh`:
- Line 76: The command-line parsing for the --bin-dir case reads $2 unguarded
which can trigger an unbound-variable error; update the --bin-dir branch that
sets BIN_DIR and appends to FORWARDED_ARGS to first verify a following value
exists and is not another option (e.g., check that "$2" is non-empty and does
not start with '-') and if missing print a clear error/usage message and exit
non-zero, otherwise assign BIN_DIR="$2", append both args to FORWARDED_ARGS and
shift 2 as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9521cbb0-d109-4aef-8e3c-40fa16abbe07

📥 Commits

Reviewing files that changed from the base of the PR and between 943f779 and a1850b1.

📒 Files selected for processing (3)
  • README.md
  • docs/content/docs/cua-driver/guide/getting-started/installation.mdx
  • libs/cua-driver/scripts/install.sh

Comment thread libs/cua-driver/scripts/install.sh Outdated
printf 'error: unknown backend %q; supported: swift, rust\n' "${1#*=}" >&2
exit 2
;;
--bin-dir) BIN_DIR="$2"; FORWARDED_ARGS+=("$1" "$2"); shift 2 ;;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the current branch dereferences $2 without an arity guard.
rg -n -C2 -- '--bin-dir\)\s+BIN_DIR="\$2"' libs/cua-driver/scripts/install.sh
rg -n -- 'requires a path value|\$# -lt 2' libs/cua-driver/scripts/install.sh

Repository: trycua/cua

Length of output: 347


🏁 Script executed:

#!/bin/bash
# 1. Check for set -euo pipefail at the script start
head -20 libs/cua-driver/scripts/install.sh

# 2. View broader context around line 76 (lines 60-85)
sed -n '60,85p' libs/cua-driver/scripts/install.sh

# 3. Check if other flag arguments have similar guards
rg -n '\$\(# -' libs/cua-driver/scripts/install.sh | head -10

Repository: trycua/cua

Length of output: 2310


🏁 Script executed:

#!/bin/bash
# Check for set -euo pipefail anywhere in the script
grep -n 'set -[eux]' libs/cua-driver/scripts/install.sh

# View the complete section after the case statement to see what happens next
sed -n '80,120p' libs/cua-driver/scripts/install.sh

# Check total line count
wc -l libs/cua-driver/scripts/install.sh

Repository: trycua/cua

Length of output: 2324


Add a missing-value guard for --bin-dir.

Line 76 reads $2 unconditionally; with set -u, --bin-dir without a value crashes with an unhelpful unbound-variable error instead of a user-friendly message.

Suggested fix
-        --bin-dir)           BIN_DIR="$2"; FORWARDED_ARGS+=("$1" "$2"); shift 2 ;;
+        --bin-dir)
+            if [[ $# -lt 2 ]]; then
+                printf 'error: --bin-dir requires a path value\n' >&2
+                exit 2
+            fi
+            BIN_DIR="$2"; FORWARDED_ARGS+=("$1" "$2"); shift 2
+            ;;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--bin-dir) BIN_DIR="$2"; FORWARDED_ARGS+=("$1" "$2"); shift 2 ;;
--bin-dir)
if [[ $# -lt 2 ]]; then
printf 'error: --bin-dir requires a path value\n' >&2
exit 2
fi
BIN_DIR="$2"; FORWARDED_ARGS+=("$1" "$2"); shift 2
;;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/cua-driver/scripts/install.sh` at line 76, The command-line parsing for
the --bin-dir case reads $2 unguarded which can trigger an unbound-variable
error; update the --bin-dir branch that sets BIN_DIR and appends to
FORWARDED_ARGS to first verify a following value exists and is not another
option (e.g., check that "$2" is non-empty and does not start with '-') and if
missing print a clear error/usage message and exit non-zero, otherwise assign
BIN_DIR="$2", append both args to FORWARDED_ARGS and shift 2 as before.

@f-trycua

Copy link
Copy Markdown
Collaborator Author

Pushed fix for the --bin-dir unguarded-arg finding. bash -n clean.

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.

cua-driver: add --experimental-rust install flag to opt into cua-driver-rs backend

1 participant