fix(ios): refuse scene-hosted remote content in bridge snapshots

Merged
DH
2mo ago
+119-34

Problem

On an iOS 26 simulator, a snapshot taken while a share extension is presented over its host app returns one node:

$ agent-device snapshot -i --session probe     # Photos, with a third-party share extension up
Snapshot: 1 nodes
Hint: sparse accessibility snapshot returned 1 node; ...
@e1 [other] "Photos"

The extension is scene-hosted. Its controls live in the extension's process and reach Photos' tree as one leaf, which the single-process host AX bridge cannot cross. From snapshot --raw (agent-device 0.21.22, iPhone 17 / iOS 26.5):

UIWindow › UITransitionView › UIDropShadowView › UIView ×4 › _UISceneHostingView › _UIScenePresentationView
  › AXRemoteElement  (NSObject, frame 0,0 402×874, no children)

decodeSnapshotBridgeTree already refuses this shape under a WebView (remote-content-boundary, #2484) so the route serves the XCTest runner. ADR 0004 left remote elements under any other host unclassified because "no capture has shown one". This is one.

Change

tree.ts also counts an AXRemoteElement leaf under a _UISceneHostingView as opaque remote content, with the same frame rules as the web case (zero-area or off-screen leaves are published; frameless ones refuse). The refusal, generation circuit and XCTest fallback are unchanged. Doc comments in tree.ts, types.ts, adapter.ts and ADR 0004 now name both hosts.

Verification

  • New tree.test.ts case built from the captured shape: fails without the change and passes with it. packages/platform-apple/src/snapshot-source: 109/109.

  • pnpm check:affected --run: all runnable checks passed. pnpm lint, pnpm typecheck, and format:check pass.

  • pnpm test:unit: 13,007 passed, 1 failed. The failure is scripts/__tests__/apple-ci-impact.test.ts ("a shallow PR merge still yields a known change set…"), which fails the same way on unmodified main on this machine.

  • Live, iOS 26.5 simulator, with the change applied to the 0.21.22 dist. The same screen now reads:

    Simulator AX snapshot unavailable (remote-content-boundary); used XCTest for this app generation.
    @e1 [application] "Photos"
    @e2 [other] "enshrine-0-View"
    @e3 [scroll-area] "LORELEI · SHARE SPIKE" [scrollable]
    @e5 [text] "Give this moment a title."
    @e7 [text-field] "A shared moment" [editable]
    @e8 [button] "Enshrine"
    @e9 [button] "Close"
    

    An @e2e-dev/mobile test that goes Photos → Share → extension → Enshrine, then asserts in the host app, passes using only locators. Before the change it failed at the first extension locator.

Not covered: a physical device (the bridge is simulator-only), Android, and Apple's own scene-hosted services (none captured).

🤖 Generated with Claude Code