Repository navigation
fix(computer-use): settle macOS permission checks - #13025
Conversation
📝 WalkthroughWalkthroughThe 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)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
native/computer-use-macos/Tests/OrcaComputerUseMacOSTests/ScreenCaptureProbeWindowSelectionTests.swift (1)
6-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTest 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
📒 Files selected for processing (6)
native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swiftnative/computer-use-macos/Sources/OrcaComputerUseMacOSCore/PermissionTrustSettling.swiftnative/computer-use-macos/Sources/OrcaComputerUseMacOSCore/ScreenCaptureProbeWindowSelection.swiftnative/computer-use-macos/Tests/OrcaComputerUseMacOSTests/PermissionTrustSettlingTests.swiftnative/computer-use-macos/Tests/OrcaComputerUseMacOSTests/ScreenCapturePermissionSettlingTests.swiftnative/computer-use-macos/Tests/OrcaComputerUseMacOSTests/ScreenCaptureProbeWindowSelectionTests.swift
Summary
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:
It then renders the settled missing-permission state:
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 lintpnpm typecheckpnpm test— full repository suite not run locally; the complete native provider suite ran throughpnpm verify:computer-nativepnpm build— full application build not run;pnpm build:computer-macosbuilt and signed the universal helper successfullypnpm verify:computer-nativeNSApplicationevent loop while both retry sleeps ran on the new permission-status queuesAI 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.sleepinstead of multiplying an unbounded interval forusleep.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
Sendablesnapshot. A lock protects concurrent result writes, and the UI handler returns to the main actor before touching AppKit.Notes
preflight_unknown/do_not_cachebefore the stable TCC grant becomes visible in that PID.