@@ -103,6 +103,13 @@ async function readMovingTargetGate(
103103 * `nodeRectByIdentity` then answers fail-closed — absent, ambiguous and unmeasurable all read as
104104 * "not shown at rest" — because a guard whose failure mode is a refused tap must never grant rest
105105 * on a guess.
106+ *
107+ * The claim is an inference from one tree, not stability evidence: an animation that has not moved
108+ * the control yet reads here exactly as a finished transition does, and no observation available at
109+ * this instant separates them. The tier that carries evidence is `resolveAtRestTarget`, which spends
110+ * two fresh observations and requires them to agree on a position and a surface. This one buys the
111+ * case it can decide for free — the previous transition already finished, which is what the large
112+ * majority of presses inside the window are — and sends everything else to be measured.
106113 */
107114function baselineShowsTargetAtRest (
108115 baseline : MovingTargetBaseline ,
@@ -150,27 +157,53 @@ async function resolveAtRestTarget(
150157 const first = await reObserveTarget ( runtime , options , params ) ;
151158 if ( ! first . measured ) throw motionRefusal ( resolved , undefined , now ( runtime ) - waitedFrom ) ;
152159 await sleep ( runtime , MOVING_TARGET_GATE_SAMPLE_GAP_MS ) ;
153- const second = await reObserveTarget ( runtime , options , params ) ;
160+ const second = onSameSurface ( first , await reObserveTarget ( runtime , options , params ) ) ;
154161 if ( second . measured && movingTargetRectsStable ( first . rect , second . rect ) ) return second . resolved ;
155162 throw motionRefusal ( resolved , second . rect , now ( runtime ) - waitedFrom ) ;
156163}
157164
165+ /**
166+ * Rest is one position on one surface, which is why the screening refuses to compare positions
167+ * across surfaces at all (#2438). A look taken on another presentation — a system sheet arriving
168+ * during the sample gap can carry the same control at the same rect — therefore measures nothing
169+ * about where this target came to rest, and is demoted to the shape that already means that: it
170+ * cannot certify agreement, and no position from it is reported as somewhere the target moved to.
171+ */
172+ function onSameSurface (
173+ first : MovingTargetObservation & { measured : true } ,
174+ next : MovingTargetObservation ,
175+ ) : MovingTargetObservation {
176+ return next . measured && next . surfaceBundleId === first . surfaceBundleId
177+ ? next
178+ : { measured : false , rect : undefined , resolved : next . resolved } ;
179+ }
180+
158181/** One look at the target: what it resolved to, and whether that look measured a position. */
159182type MovingTargetObservation = MovingTargetMeasurement & {
160183 resolved : ResolvedInteractionTarget ;
161184} ;
162185
163186/** Whether a look produced a position of its own, or nothing to compare against. */
164187type MovingTargetMeasurement =
165- /** The position this observation's own capture reported for the target. */
166- | { measured : true ; rect : Rect }
188+ /** The position this observation's own capture reported for the target, on that capture's surface . */
189+ | MovingTargetMeasured
167190 /**
168191 * No position of its own. Two of these would "agree" trivially — rest certified by a
169192 * non-measurement, the one outcome the gate must never produce — so the first of them ends the
170193 * recheck, and a refusal reports no `movedToRect` rather than a stale one.
171194 */
172195 | { measured : false ; rect : undefined } ;
173196
197+ /**
198+ * A look that measured the target: where it put it, and on which surface. The surface rides along
199+ * because a rect is only comparable to one measured on the same presentation (#2438).
200+ */
201+ type MovingTargetMeasured = {
202+ measured : true ;
203+ rect : Rect ;
204+ surfaceBundleId : string | undefined ;
205+ } ;
206+
174207/**
175208 * One observation of the same target, asked as the original question rather than a narrower one.
176209 *
@@ -190,8 +223,11 @@ async function reObserveTarget(
190223 if ( options . target . kind !== 'ref' ) {
191224 const resolved = await resolveInteractionTarget ( runtime , options , params ) ;
192225 const rect = resolvedRect ( resolved ) ;
226+ // A selector resolution measured its target on the surface it resolved against, which it
227+ // publishes as `preAction` along with the tree.
228+ const surfaceBundleId = resolved . preAction ?. surfaceBundleId ;
193229 return rect
194- ? { measured : true , resolved, rect }
230+ ? { measured : true , resolved, rect, surfaceBundleId }
195231 : { measured : false , resolved, rect : undefined } ;
196232 }
197233 const { snapshot } = await captureInteractionSnapshot ( runtime , options , true ) ;
@@ -226,7 +262,9 @@ function measureRefObservation(
226262 captured !== undefined &&
227263 movingTargetRectsStable ( captured . rect , rect ) &&
228264 localIdentitiesEqual ( readNodeLocalIdentity ( captured ) , readNodeLocalIdentity ( dispatchedNode ) ) ;
229- return measured ? { measured : true , rect } : { measured : false , rect : undefined } ;
265+ return measured
266+ ? { measured : true , rect, surfaceBundleId : snapshot . iosSystemSurfaceBundleId }
267+ : { measured : false , rect : undefined } ;
230268}
231269
232270function resolvedRect ( resolved : ResolvedInteractionTarget ) : Rect | undefined {
0 commit comments