You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 191c351
Browse filesBrowse the repository at this point in the historyBrowse files
fix(daemon): require discriminating overlap for a post-gesture baseline match
PR review on #1563 (P1): interactionSurfaceMatchesBaseline returned true
whenever ANY shared entry was frozen, including the application/window
viewport root, whose rect is invariant under any gesture. In the exact
scope-drift case this PR supports, a broad pre-gesture baseline and a
narrow post-gesture selector capture can share only that root after a
real, successful scroll — the boolean predicate called that a baseline
match and extended the interaction to the 3.5s stale-read cap on zero
real evidence.
Fix: replace the boolean with classifyBaselineSurfaceEvidence, a
subset-tolerant classifier reusing this module's existing
InteractionSurfaceChange vocabulary ('changed' | 'unchanged' |
'ambiguous') instead of a bespoke boolean or an Application-only special
case. An entry only counts as evidence when it is `discriminating` —
excludes the viewport root (minimal local equivalent of
snapshot-occlusion.ts's isViewportRoot) and keyboard chrome (minimal
local equivalent of snapshot-chrome.ts's keyboard-container check), both
computed once at signature-build time since the flat signature-entry
representation has no ref/parentIndex to reuse those modules' full
ancestor-walk classifiers directly. Zero discriminating overlap is now
'ambiguous' (insufficient evidence) rather than a match, and
decidePostGestureStabilityVerdict falls through 'ambiguous' to 'trust' —
the safe default, same as 'changed'.
Tests: the reviewer's exact shape (signatures sharing only the
Application root, with the real content swapped) at three layers —
classifyBaselineSurfaceEvidence directly, decidePostGestureStabilityVerdict,
and the full capturePostGestureStabilizedResult async loop (proving no
cap-tax: settles in 2 capture attempts, not 3.5s). Also: root+one real
element both frozen still matches (guards against over-excluding), and
keyboard chrome excluded from discriminating overlap. All prior tests
kept green unchanged.
Counterfactual: reverted to the old boolean predicate and reran — 5
tests went red, including the async regression test, which didn't just
fail an assertion but timed out after 5s because the boolean predicate
extended the interaction to the 3.5s distrust cap the test's 1s timer
advance never covered — exactly the "extends to cap" failure mode the
review predicted. Restored, 37/37 green.
_Generated by Claude Code_
// --- #1563 review regression: root-only overlap must NOT read as evidence ---
134
+
135
+
test('classifyBaselineSurfaceEvidence is ambiguous (NOT unchanged) when a real scroll leaves only the application root shared — the reviewer-caught false-distrust shape',()=>{
136
+
// baseline = {Application, Pickup@y=500}; current = {Application,
137
+
// OtherButton@...} — a genuine, successful scroll replaced every real
138
+
// element in view, so the only entry the two signatures still share is the
139
+
// always-present, always-identical viewport root. A boolean "any shared
140
+
// entry frozen" predicate calls this a baseline match (the root always
141
+
// "matches") and would extend the interaction to the 3.5s stale-read
142
+
// deadline on zero real evidence — exactly the bug this test pins.
test('classifyBaselineSurfaceEvidence still reports unchanged when the root AND a real discriminating element both match (guards against over-excluding)',()=>{
196
+
// Root-sharing alone is not disqualifying — it just cannot be the ONLY
197
+
// evidence. Once a real, frozen discriminating element is also shared
198
+
// (the ordinary "genuinely stuck" case), the verdict must still be
199
+
// 'unchanged', not swing to 'ambiguous' just because the root is present.
// capturePostGestureStabilizedResult: the async loop wired to the pure
214
264
// decision above. Fake timers keep these instant despite the real 200ms poll
@@ -400,6 +450,44 @@ test('capturePostGestureStabilizedResult catches a frozen target even when the b
400
450
assert.equal(settled,0);
401
451
});
402
452
453
+
test('capturePostGestureStabilizedResult trusts immediately (no cap tax) when a real scroll leaves only the application root shared — #1563 review regression',async()=>{
454
+
// The reviewer's exact false-distrust shape end to end: the baseline is
455
+
// Application + Pickup; every post-gesture read is Application + a
456
+
// DIFFERENT button (Delivery) — a genuine, successful scroll that swapped
457
+
// every real element. A boolean "any shared entry frozen" predicate would
458
+
// call the shared, always-identical Application root a baseline match and
459
+
// extend this to the 3.5s stale-read cap on zero real evidence.
460
+
vi.useFakeTimers();
461
+
constsession=makeSession('ios');
462
+
session.snapshot=pickupSnapshot(500);
463
+
markPostGestureStabilization(session,'scroll');
464
+
465
+
constcapture=vi.fn(async()=>deliverySnapshot(120));// consistent from the first read: quiet immediately
0 commit comments