Skip to content

find <q> get text / get attrs still take the first of several matches (follow-up to #1625) #4685

Open

Description

@xiatiandeairen

Purpose

#1625 made mutating find reject ambiguous matches and noted: "the read-only engine path (get text/get attrs) keeps first-match semantics — reads don't mutate, so it is flagged rather than changed here." This issue is that follow-up.

The first-match read returns a value without any warning, while get on the same tree refuses. Observed on 0.21.39, on an iOS 27.2 simulator with two rows labelled "dup":

$ agent-device get text 'label="dup"' --session c39
Error (AMBIGUOUS_MATCH): Selector matched 2 elements: label="dup". Not dispatched. …
$ agent-device find "dup" get text --session c39
dup                                            # exit 0, no warning

With rows "Speakers (4)" and "Nov 10 · 4 speakers", find "speakers" get text returns Speakers (4) and exits 0. An agent that reads a value through find cannot tell that it read one of several elements.

In resolution-policy.ts, find's read-only actions use readAny (first-match, "presence is the question"). That fits exists and wait. get text and get attrs read a value, though, and get attrs is fail-closed ("must never guess") when it runs as get. --first and --last are documented as "pick the first/last match when ambiguous", which reads as an explicit opt-in.

Required behavior

Completion conditions

  • find "dup" get text on a tree with two "dup" labels fails with AMBIGUOUS_MATCH and lists both candidates. With --first it returns the first one.
  • find "dup" exists still passes.
  • The help for find and the resolution-policy comments describe the new contract.

Environment: agent-device 0.21.39, macOS 27.2, Xcode 27.2, Node 26.13.1, iOS 27.2 simulator.

Activity

  1. added
    bug
    on Nov 19, 2026
  2. added a commit that references this issue on Nov 19, 2026
    c9da502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions