Repository navigation
refactor(macos): name computer-use executors for their scope - #124586
Conversation
The computer.act v1 wire contract is gone, but the naming that survived it still described a version split instead of the real one: screen-coordinate execution versus window/element-scoped execution. Both are live rungs of the same ladder. - Extract the screen-coordinate half of the 1334-line ComputerActionService into ComputerScreenActionExecutor (dispatch, typing, scroll, coordinate mapping, button-hold watchdog, raw CoreGraphics primitives). Moved code is unchanged apart from threading the queue authority check as a parameter instead of reaching back into the queue. - ComputerActionService keeps its name and becomes the coordinator that owns the execution queue, the permission probe, and the shared error vocabulary. - Rename ComputerActionServiceV2 to ComputerWindowActionExecutor, isV2Request to isWindowScopedRequest, isComputerActV2Only to isWindowScopedOnly, and ComputerActionError.invalidV2Request to .invalidRequest. The emitted COMPUTER_INVALID_REQUEST: prefix is unchanged. - cua-computer: v2-actions.ts becomes window-actions.ts, handleV2Act becomes handleWindowAct, and the stale v1Params local in handleDesktopAct becomes desktopParams. - Note at the computer.act idempotency key that its v1 prefix versions the key composition, not the wire contract. Behavior-neutral: no logic edits, no new branches, no changed error strings.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 9:12 AM ET / 13:12 UTC. ClawSweeper reviewWhat this changesThe PR extracts macOS screen-coordinate computer actions into a dedicated executor and renames window/element execution and CUA plugin symbols from version-based to scope-based terms. Merge readinessKeep open: current main still contains the version-oriented split, while this maintainer-authored refactor cleanly makes the screen and window scopes explicit without a concrete behavior regression found. Priority: P3 Review scores
Verification
How this fits togetherThe agent’s computer tool sends a computer-action request to a paired macOS node. The node coordinator serializes it and routes either screen-coordinate input to CoreGraphics/Peekaboo or window and element work to the accessibility executor, then returns the action result. flowchart LR
A[Agent computer tool] --> B[Node action request]
B --> C[macOS action coordinator]
C --> D[Screen-coordinate executor]
C --> E[Window and element executor]
D --> F[Native input events]
E --> G[Accessibility actions]
F --> H[Action result]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +6, Other +55. Total +61 across 10 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Refresh against current main and merge after exact-head CI confirms that the behavior-neutral scope split remains clean. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor, assessed through source equivalence, preserved callers, and existing owner-boundary tests rather than a bug reproduction. Is this the best way to solve the issue? Yes: splitting by execution scope aligns the implementation with the documented coordinate versus window/element model while retaining one coordinator and the existing queue authority boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7ed321de30ef. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…w#124586) The computer.act v1 wire contract is gone, but the naming that survived it still described a version split instead of the real one: screen-coordinate execution versus window/element-scoped execution. Both are live rungs of the same ladder. - Extract the screen-coordinate half of the 1334-line ComputerActionService into ComputerScreenActionExecutor (dispatch, typing, scroll, coordinate mapping, button-hold watchdog, raw CoreGraphics primitives). Moved code is unchanged apart from threading the queue authority check as a parameter instead of reaching back into the queue. - ComputerActionService keeps its name and becomes the coordinator that owns the execution queue, the permission probe, and the shared error vocabulary. - Rename ComputerActionServiceV2 to ComputerWindowActionExecutor, isV2Request to isWindowScopedRequest, isComputerActV2Only to isWindowScopedOnly, and ComputerActionError.invalidV2Request to .invalidRequest. The emitted COMPUTER_INVALID_REQUEST: prefix is unchanged. - cua-computer: v2-actions.ts becomes window-actions.ts, handleV2Act becomes handleWindowAct, and the stale v1Params local in handleDesktopAct becomes desktopParams. - Note at the computer.act idempotency key that its v1 prefix versions the key composition, not the wire contract. Behavior-neutral: no logic edits, no new branches, no changed error strings.
What Problem This Solves
The Computer Use surface on macOS still carried
v1/v2naming from a migrationthat finished long ago. The v1 wire contract is gone — there is one
ComputerActParamsSchema, oneparseComputerActParamsJSON, and a typedCOMPUTER_CONTRACT_MISMATCH. What survived was naming that actively misdescribesthe real split.
The real split is screen-coordinate execution vs window/element-scoped
execution. Both are first-class rungs of the same ladder (
docs/nodes/computer-use.md:"Coordinate actions bind to a node-issued reference frame; capable providers can
also address windows and elements"). Calling the window path "V2" and the
coordinate path "v1" tells the next reader that one is legacy and the other is the
replacement, which is false — coordinate actions are live and are what the
computertool uses after a screenshot.ComputerActionService.swifthad also grown to 1,334 lines carrying four unrelatedresponsibilities: the
perform()router, the serializing execution queue, thepermission snapshot, and the entire screen-coordinate
dispatchimplementation.Why This Change Was Made
Names now describe scope instead of version, and the file that owned four
responsibilities owns one.
ComputerActionServicekeeps its name and becomes the coordinator: it routes onerequest to the executor that owns it and owns what both share — the execution
queue, the input-permission probe, and the
ComputerActionErrorvocabulary.ComputerScreenActionExecutor(new file) owns screen-coordinate execution:dispatch, typing, scroll, coordinate mapping and display-frame validation, thebutton-hold watchdog, and the raw CoreGraphics primitives.
ComputerActionServiceV2becomesComputerWindowActionExecutor, a peer named forwindow/element-scoped execution. Its doc comment described migration history
("the additive computer.act v2 surface without changing the v1 coordinate path")
and now describes the screen-vs-window split and the reference-lifecycle invariant.
isV2Request->isWindowScopedRequest,isComputerActV2Only->isWindowScopedOnly,ComputerActionError.invalidV2Request->.invalidRequest.The emitted
COMPUTER_INVALID_REQUEST:prefix is the closed code on the wire andis byte-identical.
v2-actions.ts->window-actions.ts,handleV2Act->handleWindowAct(matching the siblinghandleBrowserAct/handleRecordingActconvention), and the stale
v1Paramslocal insidehandleDesktopAct->desktopParams.Deliberately untouched:
computer.act:v1:<digest>incomputer-tool-node.tsis adedupe key-format namespace, not the wire contract; it keeps its string and
gains a comment saying so. Wire values (
semantic_v2,dom_refs_v1,openclaw:computer-resource:v1:,cua:v2:/peekaboo:v2:ref prefixes,COMPUTER_USE_V2_ACTION_NAMES) are contract values and are unchanged.docs/plan/computer-use.mdis a historical campaign record where "v1" is correcthistory, and is not touched.
User Impact
None. This is behavior-neutral: no logic edits, no new branches, no changed error
strings, no changed wire values. Operators and models see exactly the same
computer.actbehavior and the same error codes. The benefit is for the next personto read this code: file and symbol names now say which execution scope they own.
Evidence
Behavior neutrality proof. The extraction is a move, verified two ways:
origin/main. Everything from// MARK: - Raw CoreGraphics primitivesto end of file (raw click/drag/mouse-buttonplumbing,
postTextGrapheme,ComputerMouseButton,ComputerModifiers) isbyte-for-byte identical. The
dispatch.. coordinate-mapping region diffs toexactly one mechanical substitution repeated at each site: the threaded
lifecycleGeneration: UInt64parameter became acheckExecutionAllowed:closureparameter, so
try self.executionQueue.checkExecutionAllowed(lifecycleGeneration:)became
try checkExecutionAllowed(). Same checks, same order, same call sites —this mirrors the closure the window executor already receives. The only other
deltas are two
private-> internal access widenings so the coordinator can reachtypeTextandreleaseCurrentHeldButton.Tests and checks (all local, macOS host):
swift test --package-path apps/macos --parallelpnpm test extensions/cua-computer src/plugins src/agents/toolspnpm check:test-typesnode scripts/run-oxlint.mjs extensions/cua-computer src/agents/toolsoxfmt --checkon touched TSswiftlint lint --config config/swiftlint.ymlswiftformat --lint apps/macos/Sources --config config/swiftformatpnpm check:import-cyclescheck-deadcode-unused-files/check-deadcode-exportsgit diff --checkgpt-5.6-sol, high)autoreview clean: no accepted/actionable findings reportedVitest note:
src/plugins/plugin-lifecycle-lease.test.ts > reloads install records after waiting for another processfails on this host. It is pre-existing andunrelated — verified failing identically on a clean
origin/maincheckout. ItswaitForPathhelper allows a fixed 2.5s (100 x 25ms) for a child spawned vianode --import tsx, which a loaded macOS host exceeds during cold tsx compile. Nottouched here; the timeout is flaky by construction and raising the count would mask
the cold-start cost.
Swift test hooks. Two
#if DEBUGinitializers onComputerActionService(
mouseButtonEventPoster:,textGraphemePoster:) and three raw-primitive test hookscollapsed into a single
init(screen:)injection point, so tests that only exercisecoordinate execution now construct
ComputerScreenActionExecutordirectly instead ofreaching through the coordinator. Net effect is one seam instead of five.
LOC delta (
git diff --numstat origin/main...HEAD):The +57 is entirely the cost of the second file existing: 6 import lines, the type
declaration, its
performentry point, thecheckExecutionAllowedclosure thecoordinator now builds once, and the doc comments this PR was asked to add or correct.
Total Swift lines across the three files went 2,328 -> 2,379 while the largest file
dropped from 1,334 to 598. No new branches, no new logic.