Skip to content

Enable accessibility tree (ax) command on iOS emulator sessions - #10007

Merged
AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-2338-bug-ios-emulator-ax-command-is-disabled-despite-serve-sim
Jul 23, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-2338-bug-ios-emulator-ax-command-is-disabled-despite-serve-sim

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Enable the orca emulator ax command for iOS simulator sessions by implementing support for serve-sim's /ax HTTP endpoint. Previously, the ax capability was marked as Android-only; this change allows agents and users to query the accessibility tree on iOS via the active session's serve-sim helper.

Changes

  • Backend capability: Mark accessibilityTree as supported on iOS (previously Android-only).
  • Session state: Extend EmulatorSessionInfo to track the /ax endpoint URL, either explicitly provided by serve-sim or derived from the stream endpoint.
  • iOS implementation: Fetch the accessibility tree from the active session's /ax endpoint via a new fetchServeSimAccessibilityTree function.
  • Bridge routing: Route ax requests through the bridge's accessibilityTree() method to pass the session endpoint URL to the backend; derive /ax from /stream.mjpeg URLs when explicit axUrl is not available.
  • Documentation: Update skill guides to clarify that ax works on both iOS and Android with backend-specific output (serve-sim AX snapshot on iOS, uiautomator tree on Android).

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — new test suites added for fetchServeSimAccessibilityTree, bridge routing, and iOS backend ax support.
  • pnpm build
  • Added high-quality tests covering: SSE stream parsing, settle-window behavior for stale cache detection, connection failures, timeout handling, stream drops, and unparseable responses.

AI Review Report

Reviewed implementation for correctness:

  • SSE streaming with settle window correctly handles cached trees replayed by serve-sim and waits for fresh updates.
  • Proper error mapping: connection failures → emulator_no_active, HTTP errors → emulator_error, unparseable events → emulator_helper_failed.
  • Fallback derivation of /ax endpoint from /stream.mjpeg URLs ensures compatibility with sessions registered without explicit axUrl.
  • Abort signal and timeout handling prevent hangs on stalled streams.
  • All platforms (iOS/Android): backends receive the endpoint URL parameter for iOS; Android backends safely ignore it.

Security Audit

Notes

  • The ax command now returns serve-sim's native accessibility snapshot format on iOS (screen dimensions + element tree) vs. Android's uiautomator dump format.
  • Requires an active emulator session (enforced; returns emulator_no_active if missing).
  • Cross-platform: Android backend continues to use adb uiautomator; iOS backend uses serve-sim's /ax endpoint.

Fetch the accessibility tree from serve-sim's /ax endpoint, which requires an
active session but provides the same UI snapshot capability as Android's
uiautomator output. Derive the endpoint from the stream URL when not explicitly
provided by the helper, and route through the bridge to pass session context to
the backend.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bb5bbd80-79f9-4747-8b9e-1b39af5e5c36

📥 Commits

Reviewing files that changed from the base of the PR and between f36a37f and d5b474f.

📒 Files selected for processing (3)
  • src/main/emulator/backends/android-emulator-backend.test.ts
  • src/main/emulator/emulator-bridge.test.ts
  • src/main/emulator/serve-sim-detached-session.test.ts

📝 Walkthrough

Walkthrough

The emulator accessibility-tree command now supports iOS serve-sim AX snapshots in addition to Android uiautomator output. Session parsing derives AX endpoints from MJPEG stream URLs, while the bridge resolves and routes endpoints to the iOS backend. A new SSE fetcher handles streamed trees, settling, timeouts, and errors. Runtime command routing, backend contracts, tests, CLI metadata, and skill documentation were updated accordingly.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: enabling the ax command on iOS emulator sessions.
Description check ✅ Passed The description matches the template well; the only notable gap is the explicit macOS/Linux/Windows compatibility confirmation in the AI Review Report.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Tests verify accessibility tree routes through EmulatorBridge,
Android backend ignores iOS-specific ax URLs, and ax endpoints
are derived from serve-sim stream URLs.
@AmethystLiang
AmethystLiang merged commit 43ae014 into main Jul 23, 2026
5 of 6 checks passed
AmethystLiang added a commit that referenced this pull request Jul 23, 2026
) (#10029)

* Revert "Enable accessibility tree (`ax`) command on iOS emulator sessions (#10007)"

This reverts commit 43ae014.

* fix(emulator): expose iOS accessibility tree

* fix(emulator): support device-only iOS AX

* fix(emulator): normalize iOS ax to 0..1 and heal missing axUrl

serve-sim's helper /ax reports element frames in absolute pixels, but
tap/gesture take normalized 0..1 coords. Normalize the raw AX node tree
into a compact nested shape whose frames are 0..1 over the device screen
(first root's frame), mirroring serve-sim's own normalizeAxTree, so agents
can feed ax output straight back into input commands.

Also heal sessions that were registered without an axUrl: #9924 only
derived /ax at parse time, so already-active sessions had no endpoint.
The bridge now derives it from the session's mjpeg stream URL, guarded to
the /stream.mjpeg suffix so a non-mjpeg URL never fabricates a bogus /ax.

* docs(emulator): mark ax working on iOS with correct raw-AX-tree shape

Both skill guides and the CLI summary described iOS ax as unsupported (or,
via the reverted #10007, as a normalized "screen + elements" shape that
never matched the endpoint). ax works on both backends: Android via
uiautomator, iOS via the serve-sim helper. Document the real iOS output —
a raw AX node tree (labels, roles, nested children) with frames normalized
to 0..1 — and regenerate the bundled skill guides.

* chore(skills): regenerate skill bundle manifests

CI verify failed because generated skill artifacts were stale after version/skill revision bumps.

* fix(emulator): read ax from explicit device without active session

Fall back to udid-keyed session lookup when a worktree has no active emulator,
allowing `--device` targeting to work the same way for ax as it does for tap/type.
Also clarify in docs that AX frames are normalized 0..1 with top-left origin,
and show how to tap an element at its frame center (x+width/2, y+height/2).

* fix(emulator): cap iOS AX tree at 500 nodes

Unbounded accessibility trees can flood agent output. Enforce a 500-node limit (matching serve-sim's snapshot cap) and mark truncated parents so consumers know the tree was cut.

---------

Co-authored-by: 5Hyeons <[email protected]>
gal064 pushed a commit to gal064/orca that referenced this pull request Jul 25, 2026
…blyai#10007) (stablyai#10029)

* Revert "Enable accessibility tree (`ax`) command on iOS emulator sessions (stablyai#10007)"

This reverts commit 43ae014.

* fix(emulator): expose iOS accessibility tree

* fix(emulator): support device-only iOS AX

* fix(emulator): normalize iOS ax to 0..1 and heal missing axUrl

serve-sim's helper /ax reports element frames in absolute pixels, but
tap/gesture take normalized 0..1 coords. Normalize the raw AX node tree
into a compact nested shape whose frames are 0..1 over the device screen
(first root's frame), mirroring serve-sim's own normalizeAxTree, so agents
can feed ax output straight back into input commands.

Also heal sessions that were registered without an axUrl: stablyai#9924 only
derived /ax at parse time, so already-active sessions had no endpoint.
The bridge now derives it from the session's mjpeg stream URL, guarded to
the /stream.mjpeg suffix so a non-mjpeg URL never fabricates a bogus /ax.

* docs(emulator): mark ax working on iOS with correct raw-AX-tree shape

Both skill guides and the CLI summary described iOS ax as unsupported (or,
via the reverted stablyai#10007, as a normalized "screen + elements" shape that
never matched the endpoint). ax works on both backends: Android via
uiautomator, iOS via the serve-sim helper. Document the real iOS output —
a raw AX node tree (labels, roles, nested children) with frames normalized
to 0..1 — and regenerate the bundled skill guides.

* chore(skills): regenerate skill bundle manifests

CI verify failed because generated skill artifacts were stale after version/skill revision bumps.

* fix(emulator): read ax from explicit device without active session

Fall back to udid-keyed session lookup when a worktree has no active emulator,
allowing `--device` targeting to work the same way for ax as it does for tap/type.
Also clarify in docs that AX frames are normalized 0..1 with top-left origin,
and show how to tap an element at its frame center (x+width/2, y+height/2).

* fix(emulator): cap iOS AX tree at 500 nodes

Unbounded accessibility trees can flood agent output. Enforce a 500-node limit (matching serve-sim's snapshot cap) and mark truncated parents so consumers know the tree was cut.

---------

Co-authored-by: 5Hyeons <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ablyai#10007)

* Enable accessibility tree (`ax`) command on iOS emulator sessions

Fetch the accessibility tree from serve-sim's /ax endpoint, which requires an
active session but provides the same UI snapshot capability as Android's
uiautomator output. Derive the endpoint from the stream URL when not explicitly
provided by the helper, and route through the bridge to pass session context to
the backend.

* Add ax command routing and backend integration tests

Tests verify accessibility tree routes through EmulatorBridge,
Android backend ignores iOS-specific ax URLs, and ax endpoints
are derived from serve-sim stream URLs.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…blyai#10007) (stablyai#10029)

* Revert "Enable accessibility tree (`ax`) command on iOS emulator sessions (stablyai#10007)"

This reverts commit 9011129.

* fix(emulator): expose iOS accessibility tree

* fix(emulator): support device-only iOS AX

* fix(emulator): normalize iOS ax to 0..1 and heal missing axUrl

serve-sim's helper /ax reports element frames in absolute pixels, but
tap/gesture take normalized 0..1 coords. Normalize the raw AX node tree
into a compact nested shape whose frames are 0..1 over the device screen
(first root's frame), mirroring serve-sim's own normalizeAxTree, so agents
can feed ax output straight back into input commands.

Also heal sessions that were registered without an axUrl: stablyai#9924 only
derived /ax at parse time, so already-active sessions had no endpoint.
The bridge now derives it from the session's mjpeg stream URL, guarded to
the /stream.mjpeg suffix so a non-mjpeg URL never fabricates a bogus /ax.

* docs(emulator): mark ax working on iOS with correct raw-AX-tree shape

Both skill guides and the CLI summary described iOS ax as unsupported (or,
via the reverted stablyai#10007, as a normalized "screen + elements" shape that
never matched the endpoint). ax works on both backends: Android via
uiautomator, iOS via the serve-sim helper. Document the real iOS output —
a raw AX node tree (labels, roles, nested children) with frames normalized
to 0..1 — and regenerate the bundled skill guides.

* chore(skills): regenerate skill bundle manifests

CI verify failed because generated skill artifacts were stale after version/skill revision bumps.

* fix(emulator): read ax from explicit device without active session

Fall back to udid-keyed session lookup when a worktree has no active emulator,
allowing `--device` targeting to work the same way for ax as it does for tap/type.
Also clarify in docs that AX frames are normalized 0..1 with top-left origin,
and show how to tap an element at its frame center (x+width/2, y+height/2).

* fix(emulator): cap iOS AX tree at 500 nodes

Unbounded accessibility trees can flood agent output. Enforce a 500-node limit (matching serve-sim's snapshot cap) and mark truncated parents so consumers know the tree was cut.

---------

Co-authored-by: 5Hyeons <[email protected]>
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.

1 participant