Skip to content

refactor: converge Maestro gesture handling#624

Merged
thymikee merged 2 commits into
mainfrom
refactor/maestro-scroll-swipe-convergence
May 30, 2026
Merged

refactor: converge Maestro gesture handling#624
thymikee merged 2 commits into
mainfrom
refactor/maestro-scroll-swipe-convergence

Conversation

@thymikee

Copy link
Copy Markdown
Member

Summary

Reuse shared gesture geometry for Maestro directional and percentage swipes, including percent point projection and viewport-based finger swipe planning.
Preserve Android horizontal Maestro content-lane behavior and keep target-relative swipe.label/from distance policy local to Maestro.
Touched files: 6.
Known gaps: target-relative Maestro swipes still keep Maestro-specific element-rect distance semantics because they intentionally differ from viewport scroll planning.

Validation

Focused Maestro/core gesture unit tests passed for runtime swipes, target swipes, percentage taps, and shared scroll/swipe planning.
Provider-backed Android Maestro replay guard passed for fresh selector snapshots and horizontal content-lane swipes.
Typecheck and formatting passed; unrelated formatter churn was restored.

@thymikee thymikee left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — converge Maestro gesture handling

I traced the directional endpoints through the new shared planner and the Maestro-visible geometry is preserved, which is the thing that matters for compat:

  • buildSwipeGesturePlan('up')buildScrollGesturePlan('down', amount 0.6) → start (centerX, centerY+half), end (centerX, centerY−half). On an 800px frame that's y 640→160 — identical to the old point(50,80)→point(50,20). left/right line up the same way (320↔80 on a 400px frame), and the Android horizontal content-lane override stays at 65%. So the convergence doesn't move finger paths. Good.
  • pointFromPercent without a margin keeps tapPointPercent unclamped (the 125% / −10% test), preserving the existing off-screen behavior.

Two cleanups, both minor:

  1. clampGestureCoordinate(value, minY, maxY + minY) is hard to read. You're passing maxY + minY as the size arg purely so that size − marginPx === maxY. It's correct but a reader will misparse it as a bug. A small clampToRange(value, min, max) helper (or even a comment) at the swipeCoordinatesFromTarget call sites would be clearer than overloading the margin-based clamp.

  2. clampGestureCoordinate no longer rounds (the old clampCoordinate did Math.round). It's safe today because every caller feeds pre-rounded integers (pointInsideRect center + Math.round'd swipeDistance, and pointFromPercent rounds before clamping). But the contract is now "integer in / integer out, fractional in / fractional out," and a future caller passing a fractional value would leak a non-integer coordinate to adb input swipe. Either round inside clampGestureCoordinate or document the integer-input expectation.

Neither blocks merge — the geometry is the important part and it checks out.


Generated by Claude Code

@thymikee thymikee merged commit 10fc86f into main May 30, 2026
17 checks passed
@thymikee thymikee deleted the refactor/maestro-scroll-swipe-convergence branch May 30, 2026 13:44
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-05-30 13:45 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant