Skip to content

feat(selectors): treat a bare tap target as visible text - #5271

Merged
thymikee merged 6 commits into
mainfrom
t3/bare-text-tap-targets
Nov 30, 2026
Merged

thymikee merged 6 commits into
mainfrom
t3/bare-text-tap-targets

Conversation

@thymikee

@thymikee thymikee commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

In Codex gpt-6-luna transcripts using agent-device 0.21.42–0.21.45, bare press Products or click Products cost an extra retry in 2 of 6 public runs and four local reproductions, about 3 seconds each. Agents retried with text=Products.

press, click, and longpress now translate one bare target argument into a quoted text selector. The prior refusal guided callers to that same selector. Ref, malformed selector, and trailing argument checks still apply. The existing selector path owns ambiguity and dispatch. The change preserves main’s fill grammar and error redaction.

Before / after

press General --settle previously returned INVALID_ARGS with a suggestion to use text="General". On the iPad (A16) simulator, the pre-rebase build at 63a80cfc68 switched Settings from Appearance to General:

Tapped text="General" (160, 277)
settled after 525ms: +15 -22 (~25 unchanged)
+ @e5~s633800 [cell] "General" [selected]
+ @e25~s633800 [navigation-bar] "General"

Validation

Oxlint passed on the two changed TypeScript files, and all 16 focused selector tests passed at 63e8ccf5e38c. All 44 focused selector and daemon tests passed at the prior head 49890486c1b2. The pre-rebase build and live check passed. The bare-text dispatch path was unchanged by the rebase. CI owns broader validation.

@thymikee
thymikee force-pushed the t3/bare-text-tap-targets branch from 63a80cf to e990cf7 Compare November 30, 2026 15:34
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.73 MB 6.73 MB +796 B
Package (unpacked) 6.73 MB 6.73 MB +796 B
Package (download) 2.05 MB 2.05 MB +263 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 24.1 ms 30.3 ms +6.1 ms
CLI --help 50.1 ms 56.7 ms +6.6 ms

@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

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

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread website/docs/docs/selectors.md Resolved
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 new finding on 4989048. The verdict and the full list are in the summary comment.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At 63e8ccf, the new text fallback accepts mistyped refs and malformed selectors that were refused before. Both need a fix before merge.

The text fallback never checks the ref grammar. The only earlier ref guard (/^e\d+$/) runs on the untrimmed argument. So press, click or longpress with e5-s12, e5~s12, e13,e14, e13,@e14, " @e5", " e5" or "e5 " now yields a text selector such as text="e5". A caller that drops the @ or adds a stray space now gets a capture and a selector miss, or taps an element whose text matches (an e5 square on a chess board, for example). The rule: if the trimmed argument, or any comma-separated member of it, is a ref by isRefToken (packages/kernel/src/snapshot.ts) or starts with @, it must never become text. Refuse it before the fallback, and add these inputs to the refusal test.

isBareTextTarget treats a null from detectUnknownSelectorKeyToken as proof of free text. That hint helper also returns null for an empty key or value, and the other guard needs a known key. So button=, foo=, button="" and =x become text selectors. So do visible || and || checked, because only an exact || is excluded. These now capture the screen and miss, or tap an element with that literal text, which contradicts the stated requirement and the PR description. The rule: an argument with selector syntax (= or ||) is either accepted by the selector parser or refused, and never becomes text. The existing refusal already suggests text="...". Please test both sides.

Could the single-argument tap branch classify the trimmed value once through the owning parsers? A value that tryParseSelectorChain accepts stays a selector. A value with = or ||, a leading @, any comma member that isRefToken accepts, or a finite number pair falls through to the existing refusal. Anything else is quoted as text. This would replace the isSelectorToken and detectUnknownSelectorKeyToken combination and cover both problems above plus the quoted boolean case below. The readers would still choose where the fallback applies, and nothing new would reach the daemon. First, a value import of the kernel snapshot module into interaction-positionals would need to stay within the CLI eager-closure budget.

Not blocking: these can be taken or left: add reader-level tests through readInputFromCli or interactionCliReaders for press, click and timed longpress with bare text, plus hover staying refused (no added test fails if allowBareText is removed from the readers); consider refusing a lone number for longpress, because an unset $REF in longpress $REF 800 now long-presses text 800 with the default duration (a forgotten y in press 300 likewise becomes text); add the visible-text form to the usage strings for click, press and longpress and the commands docs if it should be advertised there; and open a follow-up to refuse extra arguments after coordinates, which are already dropped before this change.

For a follow-up issue, not for this PR:

  • A quoted boolean-key expression such as visible checked or visible || checked is not recognized and becomes text, although parseSelectorChain accepts it and the docs say it keeps its selector meaning; a single argument the parser accepts should keep that meaning, with both inputs tested.
  • The shorthand docs and the three cliDetail strings should say that a label that looks like a ref, point or selector needs text=, for example longpress 'text="42"' 800, because longpress "42" 800 presses point (42,800), @username is read as a ref, and 10 20 or 2 + 2 = 4 are refused.

These earlier threads no longer apply at this head and can be resolved: boolean-key exception is now documented (the narrower multi-term case is in the follow-up list); press text now yields text="text" because refusal requires =; padded input is now trimmed before quoting (the padded ref-shaped inputs are the first problem above).

CI is green: lint/typecheck, coverage, integration, smoke, repo guards and Body rules pass, and a cancelled Body rules run was superseded by a passing one.

Not verified here: repository tests and lint were not run locally, and no live device run was done. Parser behavior was probed only with the head parser files and a stand-in error class, with the fallback switched off in place of the base code. The numeric longpress route and the ambiguity path were traced in code and not run against a daemon. The device evidence in the PR is from the pre-rebase commit 63a80cfc68 and covers only press.

A bare tap target becomes visible text only when it has no = or || the
selector parser rejected and no comma member that reads as a @ref.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 new finding on eb6a5c1. The verdict and the full list are in the summary comment.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of f412b6e

Since the review of eb6a5c1: 0 new · 0 still open · 1 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (15b6226ddcb3).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

No blocking code problems were found at f412b6e. Both problems from the earlier review are fixed: bare text fallback now refuses ref-shaped input, including padded values and comma members, and any unparsed input with = or ||. A single quoted 'e13 e14' still becomes text, which falls outside the earlier rule and does not block merge.

These threads no longer apply and can be resolved: two-number refusal is now documented in the selectors guide and help text; boolean-key exception is now documented in the selectors guide; bare text now yields text="text"; padded input is now trimmed before quoting.

CI is green: none of the 24 checks at this commit is failing or pending.

Not verified here: repository tests, lint and the bundle budget check were not run locally, so green CI is relied on for them. Parser behavior was probed only in memory with a stand-in error class, with no daemon or device run. The PR's device evidence comes from the pre-rebase commit 63a80cfc68 and covers only press; no new live run is needed because the latest changes only narrow CLI-side parsing.

Nothing from this review needs to change before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 30, 2026
@thymikee
thymikee merged commit 86bc60c into main Nov 30, 2026
24 checks passed
@thymikee
thymikee deleted the t3/bare-text-tap-targets branch November 30, 2026 19:02
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.

1 participant