Skip to content

native2: desktop_read scope walks the element's own subtree (#204) - #209

Merged
iamnbutler merged 4 commits into
mainfrom
fix-read-element
Oct 25, 2026
Merged

iamnbutler merged 4 commits into
mainfrom
fix-read-element

Conversation

@iamnbutler

Copy link
Copy Markdown
Contributor

Fixes #204

  • A scoped desktop_read walked the whole window (4000-element budget) and then cut out the scope's subtree, so on a busy page the budget or deadline could run out before or inside the scope, leaving only part of its text. It now walks from the scope element's live Accessibility reference held by the snapshot, so the whole budget goes to the subtree. Existing bounds stay (96 KB text, truncated/truncation with text_limit).
  • desktop_read has no top-level snapshot/element; those were silently ignored and the whole window came back, which is what the report saw. They're now read as scope; an element without a snapshot (or alongside scope) is refused with how to pass a scope. No schema change.

Checked on the dev app (native2) with a Safari page holding a 1148-character JSON <pre> in a table cell beside 300 filler rows: scope {snapshot, element: <cell>} and top-level snapshot+element both return the cell's full 1148 characters, traversing 4 elements; element alone is refused. swift build -c release and swift test pass.

@iamnbutler
iamnbutler force-pushed the fix-read-element branch 9 times, most recently from ebc20b2 to be12b9e Compare October 25, 2026 01:02
A scoped read walked the whole window and cut the scope out, so a busy window
could spend the 4000-element budget before the walk reached the scope. It now
walks from the snapshot's live reference. A top-level snapshot and element,
which the schema never had and were silently ignored, are read as the scope.

Why: native2/Sources/DesktopHost/TextRead.swift#fn textRead | a scoped text read walks from the snapshot element's AXUIElement, so element depths start at 0 there; the table read still walks the window because its row IDs map to snapshot IDs by depth
@iamnbutler
iamnbutler merged commit 9a88b58 into main Oct 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop_read with element returns the whole window, not that element's text

1 participant