feat(mcp): include resolved element bounds in tap_on and run_flow responses#3123
feat(mcp): include resolved element bounds in tap_on and run_flow responses#3123sinano1107 wants to merge 8 commits intomobile-dev-inc:mainfrom
Conversation
…ponses Add CommandResult and FlowResult data classes to Orchestra so that element metadata (bounds, center) captured during command execution is propagated back to MCP tool callers. Changes: - Orchestra.runFlow() now returns FlowResult (success + commandResults) instead of a bare Boolean. Internal command handlers are unchanged; an accumulator (_commandResults) captures element info from tapOnElement and swipeCommand without touching the 40+ other handlers. - TapOnTool: response includes "bounds" [x1,y1,x2,y2] and "center" [cx,cy]. - RunFlowTool: response includes "command_results" array with per-command bounds / start_point / end_point when available. - RunFlowFilesTool, MaestroCommandRunner, TestSuiteInteractor: updated to use FlowResult.success (backward-compatible one-liner changes). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace CommandResult.element (UiElement) with CommandResult.bounds (Bounds) since callers only access bounds - Extract bounds/center/start_point/end_point JSON serialization into CommandResultSerializer.kt (addBoundsTo extension function) - Fix TapOnTool hardcoded success=true to use flowResult.success - Skip accumulating empty CommandResult for direction-only and relative-coordinate swipes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
runFlow() now returns FlowResult instead of Boolean. Update assertions to use .success property. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code reviewFound 1 issue:
Same issue in 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
- Use Bounds.center() in CommandResultSerializer instead of manual center calculation, for consistency with the rest of the codebase - Remove unnecessary same-package imports of addBoundsTo in TapOnTool.kt and RunFlowTool.kt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Can you elaborate on the value and motivation for this change? |
|
I'm building a system that records iOS Simulator interactions (via Maestro MCP) and composites tap/swipe indicators onto the recorded video using Remotion. To place the indicators accurately, I need the resolved element coordinates from each Currently, Maestro resolves the element internally but discards the coordinates before returning the MCP response. The only alternative is calling This change surfaces coordinates that Maestro already computes, with no impact on existing behavior. |
|
Oooh, neat idea I think there might be other applications folks find for this too. Just need to check that this doesn't "cross-pollenate" too heavily. Will review properly once I'm back at my desk on Tuesday 👍 |
Summary
CommandResultandFlowResultdata classes toOrchestraso that element metadata (bounds, center) captured during command execution is propagated back to MCP tool callers.Orchestra.runFlow()now returnsFlowResult(success + commandResults) instead of a bareBoolean. Internal command handlers are unchanged; an accumulator captures element info fromtapOnElementandswipeCommandwithout touching the 40+ other handlers.tap_onresponse now includes"bounds": [x1,y1,x2,y2]and"center": [cx,cy]run_flowresponse now includes a"command_results"array with per-command bounds / start_point / end_point when availableMotivation
When building automation that records tap/swipe coordinates (e.g. for video overlay generation), the resolved element bounds are needed but currently discarded inside Orchestra. This change surfaces them through the existing MCP tool responses without altering Orchestra's internal command execution logic.
Changes
Orchestra.ktCommandResult/FlowResultdata classes,_commandResultsaccumulator,runFlow()returnsFlowResultCommandResultSerializer.ktaddBoundsTo()extension for JSON serializationTapOnTool.ktRunFlowTool.ktRunFlowFilesTool.ktflowResult.successMaestroCommandRunner.kt.successaccessor (backward-compatible)TestSuiteInteractor.kt.successaccessor (backward-compatible)Test plan
maestro-orchestra:testpassesmaestro-cli:testpassestap_onreturns correct bounds/center on iOS simulator (Settings app)run_flowwith tap + swipe returns command_results with tap bounds🤖 Generated with Claude Code