feat(gesture): pinch an element by ref or selector

Merged
TH
5d ago
+269-58

Summary

gesture pinch now takes an element in place of x/y: gesture pinch <scale> <@ref|selector> on the CLI and element on the MCP gesture tool. The element is resolved like a drag target and the pinch centers on its touch point. Refs pass drag's ref-frame admission. A recorded .ad line stores the selector, and an unresolved ref is refused at save time. element on other gesture kinds is refused.

Unknown pinch and zoom commands now suggest gesture pinch <scale> <@ref|selector>.

Reason: a pinch without coordinates lands at the screen center and misses an off-center image. Agents tried gesture pinch 2 @e17 first, then had to compute coordinates.

Before / after

Test app, iPhone 17 Pro simulator, off-center gesture image:

CallBaseHead
gesture pinch 1.5scale 1.00 (missed)same
gesture pinch 1.5 @e17gesture origin requires both x and y coordinatesscale 1.39
pinch 2 @e17Unknown command: pinch.`…Did you mean gesture pinch <@ref

Sonnet pinch task, 4 runs per arm, all passed: CLI median 8 → 4 turns, $0.031 → $0.016. MCP median 11.5 → 6.5 turns, $0.076 → $0.044.

Validation

  • Device at 435f4bf: pinch by ref (1.00 → 1.39), selector (→ 1.92), and MCP element (→ 1.39). The saved script recorded gesture "pinch" 1.5 "id=\"gesture-target-image\"", and replaying it on a fresh app pinched (→ 1.39).
  • Head 724715b: typecheck, lint, Fallow audit, and the touched suites pass.
  • Follow-up: drag-style replay target evidence for pinch elements.

🤖 Generated with Claude Code