Skip to content

refactor(macos): name computer-use executors for their scope - #124586

Merged
steipete merged 1 commit into
mainfrom
steipete/computer-use-naming-cleanup
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/computer-use-naming-cleanup

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Computer Use surface on macOS still carried v1/v2 naming from a migration
that finished long ago. The v1 wire contract is gone — there is one
ComputerActParamsSchema, one parseComputerActParamsJSON, and a typed
COMPUTER_CONTRACT_MISMATCH. What survived was naming that actively misdescribes
the 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
computer tool uses after a screenshot.

ComputerActionService.swift had also grown to 1,334 lines carrying four unrelated
responsibilities: the perform() router, the serializing execution queue, the
permission snapshot, and the entire screen-coordinate dispatch implementation.

Why This Change Was Made

Names now describe scope instead of version, and the file that owned four
responsibilities owns one.

  • ComputerActionService keeps its name and becomes the coordinator: it routes one
    request to the executor that owns it and owns what both share — the execution
    queue, the input-permission probe, and the ComputerActionError vocabulary.
  • ComputerScreenActionExecutor (new file) owns screen-coordinate execution:
    dispatch, typing, scroll, coordinate mapping and display-frame validation, the
    button-hold watchdog, and the raw CoreGraphics primitives.
  • ComputerActionServiceV2 becomes ComputerWindowActionExecutor, a peer named for
    window/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 and
    is byte-identical.
  • cua-computer: v2-actions.ts -> window-actions.ts, handleV2Act ->
    handleWindowAct (matching the sibling handleBrowserAct / handleRecordingAct
    convention), and the stale v1Params local inside handleDesktopAct -> desktopParams.

Deliberately untouched: computer.act:v1:<digest> in computer-tool-node.ts is a
dedupe 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.md is a historical campaign record where "v1" is correct
history, 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.act behavior and the same error codes. The benefit is for the next person
to 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:

  1. Git rename detection pairs the new file with its source:
    $ git diff --numstat --find-copies-harder -M origin/main...HEAD
    22  569  apps/macos/Sources/OpenClaw/{ComputerActionService.swift => ComputerScreenActionExecutor.swift}
    27   19  apps/macos/Sources/OpenClaw/{ComputerActionServiceV2.swift => ComputerWindowActionExecutor.swift}
    
  2. Direct region diff of the moved body against origin/main. Everything from
    // MARK: - Raw CoreGraphics primitives to end of file (raw click/drag/mouse-button
    plumbing, postTextGrapheme, ComputerMouseButton, ComputerModifiers) is
    byte-for-byte identical. The dispatch .. coordinate-mapping region diffs to
    exactly one mechanical substitution repeated at each site: the threaded
    lifecycleGeneration: UInt64 parameter became a checkExecutionAllowed: closure
    parameter, 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 reach
    typeText and releaseCurrentHeldButton.

Tests and checks (all local, macOS host):

Check Result
swift test --package-path apps/macos --parallel exit 0, 987 tests passed, 0 failures
pnpm test extensions/cua-computer src/plugins src/agents/tools 240/241 files pass; see note below
pnpm check:test-types clean
node scripts/run-oxlint.mjs extensions/cua-computer src/agents/tools exit 0
oxfmt --check on touched TS clean
swiftlint lint --config config/swiftlint.yml 0 violations in 335 files
swiftformat --lint apps/macos/Sources --config config/swiftformat 0/333 require formatting
pnpm check:import-cycles 0 runtime value cycles
check-deadcode-unused-files / check-deadcode-exports 0 entries
git diff --check clean
autoreview (codex, gpt-5.6-sol, high) autoreview clean: no accepted/actionable findings reported

Vitest note: src/plugins/plugin-lifecycle-lease.test.ts > reloads install records after waiting for another process fails on this host. It is pre-existing and
unrelated
— verified failing identically on a clean origin/main checkout. Its
waitForPath helper allows a fixed 2.5s (100 x 25ms) for a child spawned via
node --import tsx, which a loaded macOS host exceeds during cold tsx compile. Not
touched here; the timeout is flaky by construction and raising the count would mask
the cold-start cost.

Swift test hooks. Two #if DEBUG initializers on ComputerActionService
(mouseButtonEventPoster:, textGraphemePoster:) and three raw-primitive test hooks
collapsed into a single init(screen:) injection point, so tests that only exercise
coordinate execution now construct ComputerScreenActionExecutor directly instead of
reaching through the coordinator. Net effect is one seam instead of five.

LOC delta (git diff --numstat origin/main...HEAD):

  • Production: +882 / -825 = net +57
  • Tests: +73 / -69 = net +4

The +57 is entirely the cost of the second file existing: 6 import lines, the type
declaration, its perform entry point, the checkExecutionAllowed closure the
coordinator 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.

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

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos agents Agent runtime and tooling plugin: cua-computer size: XL maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 13:04
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 9:12 AM ET / 13:12 UTC.

ClawSweeper review

What this changes

The 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 readiness

⚠️ Ready for maintainer review - 2 items remain

Keep 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
Reviewed head: 163fecb2a5ba6aa4aa75b76f8351a44380d90ff1

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, coherent refactor with preserved authority boundaries and no actionable review findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored behavior-neutral refactor is not subject to the external-contributor real-behavior-proof gate; its PR body supplies focused Swift validation claims.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored behavior-neutral refactor is not subject to the external-contributor real-behavior-proof gate; its PR body supplies focused Swift validation claims.
Evidence reviewed 6 items Coordinator and owner boundary: The proposed coordinator retains queue ownership and routes window-scoped requests to the window executor; all other requests use the screen executor.
Screen-path lifecycle preservation: The extracted screen executor validates permissions and rechecks queue authority before and after dispatch, preserving the coordinator’s lifecycle fence.
Window-path authority preservation: The renamed window executor retains the existing pre/post-await authority checks around every dispatched operation.
Findings None None.
Security None None.

How this fits together

The 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
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and exact-head checks are still in progress, so merge readiness requires a current-base refresh and green exact-head CI.
  • Complete next step (P2) - No repair job is warranted; refresh the branch against current main and complete normal exact-head merge review.
Agent review details

Security

None.

PR surface

Source +6, Other +55. Total +61 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 3 38 32 +6
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 7 917 862 +55
Total 10 955 894 +61

Review metrics

Metric Value Why it matters
Production versus test LOC production +57, tests +4 Move-aware source counts show the macOS split adds 51 lines, with three additional plugin lines and a three-line idempotency-key contract comment; changed Swift tests grow by four lines.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Refresh against current main and merge after exact-head CI confirms that the behavior-neutral scope split remains clean.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

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

Labels

Label changes:

  • add P3: This is behavior-neutral internal maintainability work with no demonstrated operator-facing regression.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored behavior-neutral refactor is not subject to the external-contributor real-behavior-proof gate; its PR body supplies focused Swift validation claims.

Label justifications:

  • P3: This is behavior-neutral internal maintainability work with no demonstrated operator-facing regression.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored behavior-neutral refactor is not subject to the external-contributor real-behavior-proof gate; its PR body supplies focused Swift validation claims.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the original macOS computer-use feature and later lifecycle, cancellation, and permission hardening in the same owner module. (role: feature owner and recent area contributor; confidence: high; commits: f8dbd34ab8e8, 461772868da3, 3bec587d742f; files: apps/macos/Sources/OpenClaw/ComputerActionService.swift, apps/macos/Sources/OpenClaw/ComputerActionServiceV2.swift)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 243f51d into main Aug 16, 2026
257 checks passed
@steipete
steipete deleted the steipete/computer-use-naming-cleanup branch August 16, 2026 13:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: macos App: macos maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. plugin: cua-computer rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant