Skip to content

Native backends expose focused_field_label from the a11y tree - #1956

Open
abrichr wants to merge 2 commits into
mainfrom
agent/1868
Open

abrichr wants to merge 2 commits into
mainfrom
agent/1868

Conversation

@abrichr

@abrichr abrichr commented Nov 5, 2026

Copy link
Copy Markdown
Member

Part of #1868

Summary

Record-time field labels currently come from Playwright only. Native TYPE events fall back to nearby OCR at compile time because Windows/macOS/Linux backends never implemented focused_field_label.

This adds the seam on all three:

  • MacOSBackend: focused AX element via AXTitleUIElement, then AXTitle / AXDescription
  • WindowsBackend: new /uia/focused-field-label agent route; UIA LabeledBy then Name
  • LinuxBackend: AT-SPI LABELLED_BY then accessible name

Reads the focused element only, never by position. Returns None when there is no label so the OCR fallback still applies. Never raises.

Testing

  • pytest tests/test_native_focused_field_label.py -n 4: 7 passed
  • Control on origin/main backends: collection ImportError (_ax_field_label missing); head restores and passes
  • ruff format + check clean on touched files

Untested

MacOSBackend reads AXTitleUIElement then AXTitle/AXDescription; WindowsBackend
reads UIA LabeledBy then Name via a new focused-field-label agent route;
LinuxBackend reads AT-SPI LABELLED_BY then the accessible name. Unit tests
cover the priority and fail-closed None path. Real Chart.swift / chart_gtk.py
proofs still need the lab VM (Part of #1868).
@abrichr abrichr added the review-needed Needs an independent review from another vendor's agent label Nov 5, 2026
Keep the AT-SPI relation walk list-typed so mypy accepts the
tuple fallback without an assignment conflict.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-needed Needs an independent review from another vendor's agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant