Skip to content

feat(selectors): export listSelectorChainMatches from agent-device/selectors - #3192

Merged
thymikee merged 2 commits into
mainfrom
feat/selectors-export-list-chain-matches
Oct 4, 2026
Merged

thymikee merged 2 commits into
mainfrom
feat/selectors-export-list-chain-matches

Conversation

@thymikee

@thymikee thymikee commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #3180.

agent-device/selectors publishes listSelectorChainMatches, so a runner that must apply its own strictness gets the same matched-node domain the resolver decided over instead of reimplementing term matching (the tester-army/e2e copy has already drifted on hittable, visible, editable, text, role). The function existed internally; it now leaves through the published AST surface with a contract doc, and the doc plus the packed-package smoke check record the new symbol.

import { listSelectorChainMatches, parseSelectorChain } from 'agent-device/selectors';

const match = listSelectorChainMatches(snapshot.nodes, parseSelectorChain('label="Continue"'), {
  platform: 'ios',
});
// -> { selector, selectorIndex, matchedNodes: [e2, e4, e5] } in snapshot order, or null

One asymmetry is documented rather than smoothed over: the list reports the FIRST matching alternative — what findSelectorChainMatch names — while resolveSelectorChain under its default requireUnique: true can refuse that alternative and resolve from a later one.

6 files, +321/-12.

Validation

pnpm check:affected --run on f19ce5a81: all runnable checks passed, 633 files / 4727 tests. The public-entry test (src/sdk/selectors.test.ts, 8 tests) imports only src/sdk/selectors.ts; deleting the ast.ts export name makes all 8 fail, and each new pin was mutated in isolation to confirm it goes red alone (isNodeVisible's rect arm, post-filter requireRect, sorting by index).

Risk: none beyond widening a published subpath by one name. No device evidence needed — no runtime dispatch changed.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/sdk/selectors.test.ts
Comment thread website/docs/docs/client-api.md Outdated
Comment thread packages/selectors/src/internal/resolve.ts Outdated
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-04 06:16 UTC

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 4.95 MB 4.95 MB -4.0 kB
Package (unpacked) 4.95 MB 4.95 MB -4.0 kB
Package (download) 1.48 MB 1.48 MB -843 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.0 ms 25.9 ms -0.1 ms
CLI --help 82.5 ms 81.1 ms -1.3 ms

…ectors

A consumer that needs every node a selector chain matches — to apply its own
strictness — gets the same matched-node domain the resolver decided over
instead of reimplementing term matching. The function already existed
internally; it now leaves through the published AST surface with a
public-facing contract doc that names the one way it differs from
resolveSelectorChain: that function's default requireUnique refusal can walk
past the alternative this one reports.

The public-entry test pins the contract through the published module: several
matches from one alternative in snapshot-array order (with index order made to
disagree), first-alternative selection where find agrees and a
uniqueness-refusing resolve does not, requireRect removing candidates before
alternative selection, empty chain, and the term semantics the consumer copy
drifted on (hittable, text, role, editable, and both visibility arms).
The client-api.md subpath manifest and the packed-package selectors smoke
check are the two records that a published subpath symbol exists; both name the
new list entry so the exports surface cannot drift from the build. The doc also
states the two facts a strictness-applying consumer must not guess: the list is
null when nothing matches, and resolveSelectorChain can name a later
alternative than the one listed.
@thymikee
thymikee force-pushed the feat/selectors-export-list-chain-matches branch from f19ce5a to 733536d Compare October 3, 2026 20:45
@thymikee

thymikee commented Oct 3, 2026

Copy link
Copy Markdown
Member Author

This PR is ready at 733536d. The new listSelectorChainMatches export looks correct. All 21 checks pass, and there are no conflicts. Nothing else blocks merge. Not blocking, and you can take or leave these: scope the "same nodes the CLI matched" wording in the client API doc and the JSDoc, because the daemon also drops interaction-blocked nodes and sets requireRect per policy row, while the public function matches only over the nodes and requireRect the caller passes; revert or shorten the unrelated header comment edit in ast.ts and drop the ADR 0012 migration-step paragraph from the JSDoc; consider moving or dropping the "agent-device term semantics" test in src/sdk/selectors.test.ts, since match.test.ts and resolve.test.ts already cover it; export the return and options types next to SelectorChain only if a consumer asks; and refresh the file counts and validation sha in the PR body. I did not run the new public-entry tests, the mutation checks or the packed-package smoke test. Cubic and Copilot have not reviewed this head.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 3, 2026
@thymikee
thymikee merged commit 033e55d into main Oct 4, 2026
21 checks passed
@thymikee
thymikee deleted the feat/selectors-export-list-chain-matches branch October 4, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(selectors): export listSelectorChainMatches from agent-device/selectors

1 participant