feat(flow): regex matching via matches in assertions and selectors#503
Open
j-piasecki wants to merge 1 commit into
Open
feat(flow): regex matching via matches in assertions and selectors#503j-piasecki wants to merge 1 commit into
j-piasecki wants to merge 1 commit into
Conversation
## What
- Add `matches` as a case-sensitive JavaScript regex comparator for `await` and `assert` text conditions.
- Support `{ text: { matches: ... } }` in every flow selector slot, combined with `id` and `role`.
- Preserve regex matchers through parsing, YAML serialization, recording summaries, and run reports.
## Correctness
- Prevent empty-matchable patterns from matching unlabeled nodes or empty assertion text.
- Reject unknown raw `await-ui-element` selector keys instead of silently dropping constraints.
- Reject selector combinations YAML cannot round-trip without changing their semantics.
- Document native label aggregation accurately and keep action ranking consistent.
## Maintenance
- Share selector-field and regex-syntax validation across both matcher parse paths.
- Compile selector regexes once per tree walk and full-match regexes once per ranking pass.
- Make comparator serialization exhaustive, extract the duplicated flow test harness, and scope slow-test timeouts narrowly.
## Verification
- Full tool-server suite: 2,588 tests across 263 files.
- Source and test typechecks, ESLint, Prettier, and skill-copy validation pass.
latekvo
approved these changes
Jul 14, 2026
Comment on lines
+39
to
+41
| `text` also takes a **regex matcher map** — `{ text: { matches: '^Order #\d+$' } }`, in any selector slot — for dynamic text no literal can pin. It tests each node's native **own** label/value, excluding only adapter-hoisted `subtreeText`. On iOS, an accessible container's native label may already aggregate descendant text, so a wrapper and its leaf can both match. Matching is unanchored and **case-sensitive** like the `text` condition's `matches`, and an invalid pattern fails at parse. Quote the pattern in single quotes (they keep backslashes). So `assert: { visible: { text: { matches: '^Taps: \d+$' } } }` asserts a counter is on screen with no locator at all, and `tap: { text: { matches: '^Order #\d+$' } }` taps a dynamic row — though a stable `id` is still the more robust action target. | ||
|
|
||
| Selectors resolve against the **full native hierarchy** (iOS: the UIView tree; Android: the complete accessibility hierarchy including not-important views) — strictly more than `describe` or the raw `await-ui-element` tool see (both use the trimmed tree), with complete `testID`/`resource-id` coverage. So an `id` selector works even when `describe` collapses or omits the element — don't fall back to coordinate taps just because a testID isn't visible in `describe` output. And when several elements match — including wrappers whose native text aggregates descendant content — the action directives (`tap`, `type`, `scroll-to`) pick the **most specific** match: an exact text/identifier match beats a substring hit (for a regex matcher, a pattern consuming the element's whole text counts as exact), then the smallest frame wins. |
Member
There was a problem hiding this comment.
Just to be clear, my comment from #497 DOES NOT apply to this text block, as flow files should always prefer by-label taps over coord taps. Just wanted to clear this out :)
Comment on lines
+39
to
+41
| `text` also takes a **regex matcher map** — `{ text: { matches: '^Order #\d+$' } }`, in any selector slot — for dynamic text no literal can pin. It tests each node's native **own** label/value, excluding only adapter-hoisted `subtreeText`. On iOS, an accessible container's native label may already aggregate descendant text, so a wrapper and its leaf can both match. Matching is unanchored and **case-sensitive** like the `text` condition's `matches`, and an invalid pattern fails at parse. Quote the pattern in single quotes (they keep backslashes). So `assert: { visible: { text: { matches: '^Taps: \d+$' } } }` asserts a counter is on screen with no locator at all, and `tap: { text: { matches: '^Order #\d+$' } }` taps a dynamic row — though a stable `id` is still the more robust action target. | ||
|
|
||
| Selectors resolve against the **full native hierarchy** (iOS: the UIView tree; Android: the complete accessibility hierarchy including not-important views) — strictly more than `describe` or the raw `await-ui-element` tool see (both use the trimmed tree), with complete `testID`/`resource-id` coverage. So an `id` selector works even when `describe` collapses or omits the element — don't fall back to coordinate taps just because a testID isn't visible in `describe` output. And when several elements match — including wrappers whose native text aggregates descendant content — the action directives (`tap`, `type`, `scroll-to`) pick the **most specific** match: an exact text/identifier match beats a substring hit (for a regex matcher, a pattern consuming the element's whole text counts as exact), then the smallest frame wins. |
Member
There was a problem hiding this comment.
This text looks bloated to me but this isn't a core skill so it's not a huge deal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
matchesas a case-sensitive JavaScript regex comparator forawaitandasserttext conditions.{ text: { matches: ... } }in every flow selector slot, combined withidandrole.Correctness
await-ui-elementselector keys instead of silently dropping constraints.Maintenance
Verification