feat: add batch computer action endpoint (POST /computer/batch)#144
Merged
feat: add batch computer action endpoint (POST /computer/batch)#144
Conversation
Adds a new endpoint that accepts an array of computer actions and executes them sequentially while holding a single input lock, avoiding per-action network round-trip latency. Includes a new "sleep" action type for configurable delays between actions. Refactors existing computer control handlers to extract core logic into private do* methods, enabling reuse from both individual endpoints and the batch endpoint. Introduces validationError/executionError sentinel types for clean 400/500 classification. Co-authored-by: Cursor <cursoragent@cursor.com>
Address bugbot review comments: - Validate duration_ms against bounds (0-30000ms) before sleeping - Use select with timer + ctx.Done instead of time.Sleep so the sleep is interrupted on context cancellation and doesn't hold inputMu indefinitely Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Remove the extra actionIndex parameter from doSleep so it matches the (ctx, body) signature of all other do* methods. Co-authored-by: Cursor <cursoragent@cursor.com>
masnwilliams
approved these changes
Feb 5, 2026
Contributor
masnwilliams
left a comment
There was a problem hiding this comment.
lgtm - clean refactoring to enable batch actions. the do* pattern is well-structured and error handling is solid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Summary
Adds a
POST /computer/batchendpoint that accepts an array of computer actions and executes them sequentially while holding a single input lock, eliminating per-action network round-trip latency.Key changes:
POST /computer/batch— accepts aBatchComputerActionRequestwith an orderedactionsarray. Supported action types:click_mouse,move_mouse,type_text,press_key,scroll,drag_mouse,set_cursor, and a newsleepaction (withduration_msfor configurable delays between actions)$ref), so there's nothing new for users to learn per-actioninputMulock acquisition; stops on first error and reports the failing action index in the error message (e.g."actions[2] (click_mouse): coordinates must be non-negative")do*methods (e.g.doClickMouse,doMoveMouse), making the public handlers thin wrappers. This avoids mutex re-entrancy issues and enables clean reuse from the batch handlervalidationError(→ 400) andexecutionError(→ 500) sentinel types withisValidationErr()helper for consistent HTTP status mapping in both individual and batch handlersTest plan
go test ./...)go vet ./...cleanTestValidationError,TestExecutionError,TestIsValidationErr_Nil)Made with Cursor
Note
Medium Risk
Touches multiple input-control handlers and changes how errors are classified and surfaced, so regressions could affect automation reliability and client-visible status codes. The new batch execution path also increases the impact of validation/execution bugs because it holds the input lock across a whole sequence.
Overview
Adds
POST /computer/batch, allowing clients to submit an ordered list of computer actions (mouse, keyboard, cursor, plus a boundedsleep) that are executed sequentially while holding the existinginputMulock; execution stops on the first failing action and returns an error message annotated with the action index/type.Refactors existing computer-control endpoints (
MoveMouse,ClickMouse,TypeText,PressKey,Scroll,DragMouse,SetCursor) to delegate to shareddo*helpers and introducesvalidationErrorvsexecutionErrorto consistently map failures to HTTP400vs500across both single-action and batch flows; updates generatedoapitypes/clients, Swagger spec, and adds unit tests for the new error classification helpers.Written by Cursor Bugbot for commit 8fdeda8. This will update automatically on new commits. Configure here.