Skip to content

ui touch: PlanTouch clamps the pinch/stretch half-distance to PinchCenterGapPx+2, so --distance 1 injects a 12 px spread and encode/decode is not round-trip safe #1259

Open

Description

@soarkit
Field Value
Labels (suggested) bug, cli, ui-automation
Reproduced on commit 52de26aa4539
Introduced by 93ed711ebf64 ("Add ui touch and ui pen commands (#600)") and e6b7b5f1190e ("Cooperative UI turns for concurrent winapp ui agents (#767)")

Summary

--distance is documented as the pixel finger spread for pinch/stretch, but PointerGesturePlanner computes
the half-distance as Math.Max(PinchCenterGapPx + 2, distance / 2). With PinchCenterGapPx = 10, distances
1–11 (and 13) all resolve to a half-distance of 6, i.e. a 12 px initial spread; 1 px is never produced and
the producer/consumer round trip is not identity.

Expected behavior

--distance N must produce an initial contact spread of N pixels (within the documented quantisation), so that the producer/consumer round trip is the identity (decode(encode(1)) == 1); a distance that cannot be honoured must be rejected with a clear validation error instead of being silently replaced.

Actual behavior

Real PointerGesturePlanner.PlanTouch (anchor (400,300), angle 0, 2 fingers):

--distance 1 -> pinch contacts start 12 px apart (end 8 px); stretch mirrors it (start 8, end 12)
distance sweep 1..20: 1..11 and 13 collapse to 12 px; 12,14,16,18,20 are honoured
encode_producer(1) -> decode_consumer -> 12 != 1

No warning or validation error is emitted for a distance that cannot be honoured.

Controls: a copy with only line 133 changed to Math.Max(1, distance / 2) gives a 2 px spread for the same
input (the residual ±half rounding is a separate, symmetric quantisation), and the second finding's drop-in
reproduction over 2 contacts / 4 points shows the injected first-waypoint spread changing from 12 px to 2 px
under the same patch.

Why it matters

A test that asks for a 1-pixel spread silently gets a 12-pixel one, which changes the gesture a UI test
performs — a pinch that should be a light touch becomes a wide one, and any assertion on the coordinates sees
numbers the caller never asked for.

Suggested fix

Either honour the requested distance (Math.max(1, distance / 2)), or reject values below the achievable floor
with a clear message (--distance must be >= <2*(PinchCenterGapPx+2)>), and document the floor.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions