feat: add batch computer action endpoint (POST /computer/batch) #144
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.