Skip to content

fix(computer-use): settle macOS permission checks - #13025

Merged
Jinwoo-H merged 2 commits into
mainfrom
orca-computer-use-permission-issue
Aug 7, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
orca-computer-use-permission-issue

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Retry fresh-process Accessibility and Screen Recording trust checks while macOS TCC settles, preventing already-granted permissions from appearing denied.
  • Apply settled trust to permission status, setup UI, snapshot gates, and delayed AX window availability.
  • Warm Screen Recording trust with one cross-process capture probe, excluding Orca-owned windows so self-capture cannot produce a false grant.
  • Probe Accessibility and Screen Recording concurrently, and coalesce setup-window refreshes on a background queue so AppKit never waits on the bounded retry loops.
  • Show an immediate, honest checking state before rendering the settled permission result.

Fixes #9458.
Supersedes the combined intent of #10122 and #10373 while addressing the unresolved review findings on #10373.

Visual proof

The helper now renders while permission probes are still settling:

Pending permission check

It then renders the settled missing-permission state:

Settled permission result

Both screenshots use a temporary ad-hoc-signed helper with a unique bundle ID, giving it a deterministic ungranted TCC identity without resetting the developer's real Orca permissions.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — full repository suite not run locally; the complete native provider suite ran through pnpm verify:computer-native
  • pnpm build — full application build not run; pnpm build:computer-macos built and signed the universal helper successfully
  • pnpm verify:computer-native
  • 71 XCTest cases and 11 Swift Testing cases pass
  • Added deterministic regression tests for immediate grants, transient denials, bounded persistent denials, Screen Recording fallback ordering, cross-process capture selection, concurrent permission snapshots, refresh coalescing, and later refreshes
  • Repeated the four new concurrency/coalescing tests 20 times without a failure
  • Earlier grant-path stress reproduction: 100 concurrent helper executions returned both permissions granted in all 100 results
  • Live ungranted helper status completed in 2.35 seconds, versus the previous ~3.5-second sequential ceiling
  • Live pending UI was accessible and captured 0.95 seconds after launch while both permission checks were still settling
  • A one-second process sample showed the main thread in the NSApplication event loop while both retry sleeps ran on the new permission-status queues

AI Review Report

Reviewed the fresh-process TCC lifecycle, status/setup/runtime call sites, bounded wait behavior, genuine-denial path, refresh cadence, and Screen Recording fallback. The older Screen Recording PR could accept an Orca-owned window as proof of cross-app capture permission and did not test its fallback flow; this version excludes the current PID and adds direct fallback and selection tests. It also uses overflow-safe Thread.sleep instead of multiplying an unbounded interval for usleep.

The setup assistant can request a permission refresh every 350 ms while System Settings is visible. Those requests now coalesce behind one worker snapshot, preventing probe accumulation and repeated UI rebuilds. All window decisions consume the completed snapshot instead of calling TCC synchronously.

Cross-platform compatibility was checked explicitly. The implementation is confined to the macOS Swift provider and changes no shortcuts, paths, shell behavior, Electron IPC, remote wire formats, Linux behavior, or Windows behavior.

Security Audit

No new external input, command execution, dependency, authentication, secret, path, or IPC surface is introduced. Retry loops remain bounded and the already-granted path performs no sleep. The capture fallback selects one normal window owned by another process, checks only whether CoreGraphics returns an image, and does not serialize, retain, or publish its pixels. Orca-owned windows are excluded to prevent a false-positive permission result.

Permission results cross only in-process Swift queues as a two-boolean Sendable snapshot. A lock protects concurrent result writes, and the UI handler returns to the main actor before touching AppKit.

Notes

  • macOS can answer a freshly launched helper with preflight_unknown / do_not_cache before the stable TCC grant becomes visible in that PID.
  • A genuine denial can still add up to 1.5 seconds for Accessibility or 2 seconds for Screen Recording, but those checks now overlap. The setup window remains responsive and the CLI status ceiling is roughly 2 seconds instead of 3.5 seconds, excluding process launch overhead.
  • Runtime requests that need only one permission retain their existing bounded settling behavior.
  • The local helper is ad-hoc signed because this machine has no release signing identity. Universal build and signature verification passed; deterministic tests cover the transient TCC sequence independently of local signing identity.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds configurable permission polling with timeout, interval validation, injected sleep, probe attempts, and fallback settlement. Screen Recording checks can select a cross-process normal window and capture its image. Accessibility window lookup now retries before reporting denial. Snapshot creation, screenshot eligibility, permission UI, and status reporting use settling-aware checks. Tests cover polling, fallback behavior, window selection, retries, timeouts, and timing metrics.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Screen Recording fallback, cross-process window selection, and broader permission-status UI changes are not required by [#9458]. Link the supporting Screen Recording and UI issues, or move those changes into a separate pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation addresses Accessibility settlement races and adds regression coverage for the requirements in [#9458].
Title check ✅ Passed The title clearly and concisely describes the main change: settling macOS permission checks.
Description check ✅ Passed The description covers the change, visual proof, testing, AI review, security audit, and platform-specific notes with clear explanations for skipped commands.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@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.

🧹 Nitpick comments (1)
native/computer-use-macos/Tests/OrcaComputerUseMacOSTests/ScreenCaptureProbeWindowSelectionTests.swift (1)

6-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the first eligible window rule.

The selector contract returns the first eligible window. The current tests do not contain two eligible windows. Add a test that verifies the first eligible window ID is returned.

Proposed test
+    `@Test`("first eligible window is selected")
+    func selectsFirstEligibleWindow() {
+        let selected = ScreenCaptureProbeWindowSelection.firstCrossProcessNormalWindow(
+            ownPid: 42,
+            windows: [
+                .init(layer: 0, ownerPid: 84, windowId: 2),
+                .init(layer: 0, ownerPid: 126, windowId: 3)
+            ]
+        )
+
+        `#expect`(selected == 2)
+    }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8887e3f3-56db-4796-aff1-feb2bbd149aa

📥 Commits

Reviewing files that changed from the base of the PR and between 419151d and 5947912.

📒 Files selected for processing (6)
  • native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift
  • native/computer-use-macos/Sources/OrcaComputerUseMacOSCore/PermissionTrustSettling.swift
  • native/computer-use-macos/Sources/OrcaComputerUseMacOSCore/ScreenCaptureProbeWindowSelection.swift
  • native/computer-use-macos/Tests/OrcaComputerUseMacOSTests/PermissionTrustSettlingTests.swift
  • native/computer-use-macos/Tests/OrcaComputerUseMacOSTests/ScreenCapturePermissionSettlingTests.swift
  • native/computer-use-macos/Tests/OrcaComputerUseMacOSTests/ScreenCaptureProbeWindowSelectionTests.swift

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.

orca computer: Accessibility permission_denied persists despite granted TCC access (preflight-unknown race on fresh helper process)

1 participant