Files
Michał Pierzchała 942a310fb3 perf(selectors): collapse the double tree scan for disambiguate/fail-closed rows (#2009)
resolveSelectorChainWithPolicy ran listSelectorChainMatches (one full scan
per alternative) and then resolveSelectorChain (another full scan per
alternative) for the disambiguate/fail-closed rows readText/readUnique use —
the same defect class #1690 removed from replay's resolveRecordedTarget.

resolveSelectorChainDomain now tracks the first alternative that matched
anything (`firstMatch`) unconditionally, in the same pass that already
decides the winning resolution, so resolveSelectorChainWithPolicy needs only
one call for these rows. matchedNodes keeps naming the first alternative
that matched (not the winner) when they differ, preserving the existing
contract wait's landmark check and the ambiguous outcome rely on.

Also fixes analyzeSelectorMatches's lazy isVisible: it now builds the
viewport-root rect list once per alternative (via the newly extracted
collectViewportRects) alongside the existing lazily-built byIndex map,
instead of isNodeVisibleOnScreen re-deriving it on every ambiguous
candidate.

Closes #1970


Claude-Session: https://claude.ai/code/session_01YJoiggu7utUNDBmdzSBK2h

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-24 20:13:37 +02:00
..