Skip to content

fix(emulator): iOS ax via plain-JSON serve-sim helper (supersedes #10007) - #10029

Merged
AmethystLiang merged 8 commits into
mainfrom
ios-emulator-ax-correct-fix
Jul 23, 2026
Merged

AmethystLiang merged 8 commits into
mainfrom
ios-emulator-ax-correct-fix

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes orca emulator ax actually work on iOS, and fixes the accompanying
docs/CLI so they describe the real output shape.

Two implementations of iOS ax existed. #10007 (merged) modeled the
serve-sim helper /ax endpoint as a Server-Sent Events stream and read
it with a streaming parser — but the helper Orca runs (serve-sim --detach)
serves /ax as a plain one-shot HTTP GET returning a JSON array of raw
AX nodes. So #10007 reads nothing and fails with
stream ended without an accessibility tree event. #9924 (@5Hyeons) used
the correct plain-JSON net.fetch model. This PR supersedes #10007 by
reverting it and landing #9924, then adds the missing pieces.

Verified against [email protected] + a live iPhone simulator: the helper
/ax returns Content-Type: application/json, a finite Content-Length,
one shot (not a stream), a JSON array of raw AX nodes (AXLabel, AXValue,
AXUniqueId, enabled, type, role_description, absolute-pixel frame,
nested children), and HTTP 503 while accessibility is momentarily
unavailable. The SSE /ax only exists in serve-sim internal middleware Orca
does not run.

What's in this PR

  1. Revert Enable accessibility tree (ax) command on iOS emulator sessions #10007 (wrong SSE model). Removes serve-sim-ax-tree.ts, its
    test, and the fetchAccessibilityTree DI seam.
  2. Re-apply fix(emulator): expose iOS accessibility tree #9924 (@5Hyeons) — the correct base. Plain-JSON one-shot
    net.fetch of the helper /ax (serve-sim-accessibility-tree.ts), with
    503 → retry hint and clean EmulatorError mapping. Original commits are
    preserved with 5Hyeons' authorship.
  3. Coordinate normalization (new). serve-sim reports frames in absolute
    pixels, but tap/gesture take normalized 0..1. New
    serve-sim-ax-normalization.ts normalizes the raw node tree to 0..1 over
    the device screen (first root's frame, mirroring serve-sim's own
    normalizeAxTree), keeping label/role/type/enabled/value + nested
    children — so agents can feed ax output straight back into input commands.
  4. Heal missing axUrl (new). fix(emulator): expose iOS accessibility tree #9924 only derived /ax at parse time, so
    sessions already registered without an axUrl 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.
  5. Docs + CLI accuracy. Both skill guides and the CLI summary now state
    ax works on both backends (Android uiautomator, iOS serve-sim), and
    describe the real iOS output — a raw AX node tree with frames
    normalized to 0..1 — not the "screen + elements" shape Enable accessibility tree (ax) command on iOS emulator sessions #10007 wrongly
    described. Bundled skill guides regenerated.

Credit

Base implementation by @5Hyeons in #9924 (fix/ios-emulator-ax);
their commits are preserved here. This PR builds on that with normalization,
the heal-fallback, docs, and tests.

Verification

  • npx vitest run src/main/emulator → 221 passed
  • npx tsc --noEmit -p config/tsconfig.node.json → clean
  • npx oxlint + npx oxfmt -c .oxfmtrc.json on changed files → clean
  • generate-bundled-skill-guides.mjs --check → clean

New/updated tests cover plain-JSON fetch + normalization, 503 retry hint,
non-array/unparseable/network-failure paths, the guarded axUrl derivation,
and the bridge heal-fallback.

STA-2338.

Made with Orca 🐋

AmethystLiang and others added 5 commits July 22, 2026 17:49
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.
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.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3b6aa100-efd7-481a-a37b-24c0905333a1

📥 Commits

Reviewing files that changed from the base of the PR and between 111f3e3 and fad13ae.

📒 Files selected for processing (6)
  • skill-guides/orca-emulator.md
  • src/cli/bundled-skill-guides.ts
  • src/main/emulator/emulator-bridge.test.ts
  • src/main/emulator/emulator-bridge.ts
  • src/main/emulator/serve-sim-ax-normalization.test.ts
  • src/main/emulator/serve-sim-ax-normalization.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • skill-guides/orca-emulator.md
  • src/main/emulator/serve-sim-ax-normalization.ts
  • src/main/emulator/emulator-bridge.ts
  • src/main/emulator/emulator-bridge.test.ts

📝 Walkthrough

Walkthrough

The emulator accessibility flow now fetches raw serve-sim AX JSON directly, validates and normalizes nodes and frames, and maps request failures to emulator errors. Session parsing derives /ax only from MJPEG stream URLs. The bridge validates iOS session identity, repairs missing AX endpoints, and passes optional URLs to backends. Tests cover normalization, fetching, endpoint derivation, routing, and failure cases. CLI summaries and skill guides describe Android uiautomator trees and normalized iOS AX node trees.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and verification, but omits required Screenshots, AI Review Report, Security Audit, and Notes sections from the template. Add the missing template sections: Screenshots, Testing checklist, AI Review Report with cross-platform checks, Security Audit, and Notes, or state 'No visual change' where applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing iOS AX via the plain-JSON serve-sim helper and superseding the older SSE approach.
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.

CI verify failed because generated skill artifacts were stale after version/skill revision bumps.
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).
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.
@AmethystLiang
AmethystLiang merged commit 4a9affd into main Jul 23, 2026
19 checks passed
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
…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.

2 participants