Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions libs/cua-driver-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions libs/cua-driver-rs/crates/platform-macos/src/permissions/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ impl PermissionsStatus {
}

/// Read the live TCC status for both required grants. Cheap to call
/// repeatedly — `AXIsProcessTrusted` is a quick C function and the
/// screen recording probe falls back to the window-enumeration heuristic
/// when `CGPreflightScreenCaptureAccess` reports false.
/// repeatedly — both probes are quick C-level calls into the system
/// TCC daemon.
///
/// Mirrors Swift `Permissions.currentStatus()`. Difference: Swift uses
/// `SCShareableContent.excludingDesktopWindows` (ScreenCaptureKit) for
/// the screen recording probe, which is unavailable from Rust without
/// large bindings — same caveat documented in `check_permissions.rs`.
/// large bindings. `CGPreflightScreenCaptureAccess` is Apple's
/// documented preflight API for the same grant and is accurate on
/// macOS 11+.
Comment on lines 30 to +35

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 | 🟠 Major | ⚖️ Poor tradeoff

🧩 Analysis chain

🌐 Web query:

What is the minimum macOS version that supports CGPreflightScreenCaptureAccess API?

💡 Result:

The CGPreflightScreenCaptureAccess API was introduced in macOS 11.0 [1]. It is used to check whether an application has permission to capture the screen [1]. As of May 2026, Apple recommends that developers transition to the ScreenCaptureKit framework for screen recording functionality [2].

Citations:


🏁 Script executed:

find . -name "Cargo.toml" -o -name ".github" -type d -o -name "*.yml" -path "*/.github/*" | head -20

Repository: trycua/cua

Length of output: 824


🏁 Script executed:

rg "macos|rust-version|minimum" -i $(find . -name "Cargo.toml" | head -5) -A 2

Repository: trycua/cua

Length of output: 899


🏁 Script executed:

cat -n libs/cua-driver-rs/crates/platform-macos/Cargo.toml

Repository: trycua/cua

Length of output: 2048


🏁 Script executed:

rg "macos|deployment|target" .github/workflows/*.yml | grep -i macos | head -20

Repository: trycua/cua

Length of output: 1583


🏁 Script executed:

sed -n '48,67p' libs/cua-driver-rs/crates/platform-macos/src/permissions/status.rs

Repository: trycua/cua

Length of output: 1101


Add macOS version check or update minimum version requirement.

CGPreflightScreenCaptureAccess is only available on macOS 11.0+, but your project's Cargo.toml includes features for older macOS versions (e.g., "elcapitan" for 10.11, "highsierra" for 10.13). The current implementation will fail to link on macOS 10.15 and earlier.

Either:

  1. Drop support for older macOS and update minimum version to 11.0, or
  2. Add a version gate or fallback for older versions
🤖 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-rs/crates/platform-macos/src/permissions/status.rs` around
lines 30 - 35, The CGPreflightScreenCaptureAccess call in
libs/cua-driver-rs/crates/platform-macos/src/permissions/status.rs is only
available on macOS 11+, but the crate still exposes older macOS feature flags
(e.g., "elcapitan", "highsierra") causing link failures; either update the
crate's supported macOS minimum to 11.0 by removing/adjusting those older
feature flags in Cargo.toml and any platform feature gating, or add a version
gate/fallback in permissions/status.rs so calls to
CGPreflightScreenCaptureAccess are only compiled/linked for macOS >= 11.0 (and
provide an alternative code path for older macOS targets); refer to the
CGPreflightScreenCaptureAccess symbol and the permissions/status.rs module when
making the change.

pub fn current_status() -> PermissionsStatus {
PermissionsStatus {
accessibility: accessibility_granted(),
Expand All @@ -44,18 +45,25 @@ pub fn accessibility_granted() -> bool {
unsafe { crate::ax::bindings::AXIsProcessTrusted() }
}

/// Best-effort screen recording probe. Uses `CGPreflightScreenCaptureAccess`
/// then falls back to the window-enumeration heuristic for parity with
/// the existing `check_permissions` tool — see that file for rationale.
/// Live Screen Recording grant state — `CGPreflightScreenCaptureAccess()`.
///
/// This is the only probe. Earlier versions fell back to
/// `!all_windows().is_empty()` when preflight returned false, on the
/// theory that `CGWindowListCopyWindowInfo` returning real windows
/// implied the grant was active. That theory is wrong:
/// `CGWindowListCopyWindowInfo` returns window IDs and bounds for **any**
/// process without requiring the Screen Recording grant — only window
/// titles are gated. The fallback therefore returned `true` on any
/// populated desktop regardless of grant state, which (a) made
/// `check_permissions` report a false positive after `tccutil reset
/// ScreenCapture com.trycua.driver`, and (b) short-circuited the
/// startup permissions gate's prompt for users who had never granted SR.
pub fn screen_recording_granted() -> bool {
#[link(name = "CoreGraphics", kind = "framework")]
extern "C" {
fn CGPreflightScreenCaptureAccess() -> bool;
}
if unsafe { CGPreflightScreenCaptureAccess() } {
return true;
}
!crate::windows::all_windows().is_empty()
unsafe { CGPreflightScreenCaptureAccess() }
}

/// Raise the Accessibility TCC prompt if not yet granted. No-op when
Expand Down
Loading