Repository navigation
feat: report truncated mobile trees as warnings - #141
Merged
Merged
Conversation
pnarayanaswamy
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the mm CLI v2 effort (P1-38, core part). The device-mcp part is device-mcp#59, released in device-mcp 0.9.0.
Problem
The idb accessibility read stops at a size bound. On the 2026-10-28 run, iOS wallet home was 51 levels deep, so some visible controls were not in the tree. device-mcp reports this as
SnapshotResult.warnings, but core reads onlyhierarchyand drops it. The agent sees a tree with no sign that it is incomplete, and concludes that the element is not on screen.Solution
The mobile driver keeps the snapshot warnings and adds advice for the codes it knows. The tools and the observation copy them to the top level of their output.
flowchart TD A["backend.snapshot()"] --> B{"SnapshotResult.warnings<br/>non-empty?"} B -->|no| C["tree and testIds as before<br/>(no warnings key)"] B -->|yes| D["withAdvice: add what to do<br/>for a known code"] D --> E["AccessibilityTree.warnings /<br/>ScreenCapture.warnings"] E --> F["describe_screen and<br/>accessibility_snapshot: result.warnings"] E --> G["observation.warnings<br/>(kept in diff observations)"] classDef new fill:#fff3cd,stroke:#d39e00 class B,D,E,F,G newYellow boxes are new.
What the agent sees
mm describe-screenon a truncated iOS tree (message fromWARNING_ADVICE, details from device-mcp):warnings, or an empty arraywarningskey anywhere. Output is unchanged.ax-tree-truncated(...)warnings: ["ax-tree-truncated(...): the tree hit the device read limit, …"]ax-tree-fallback(...)(device-mcp#67, not released)warnings: ["ax-tree-fallback(...): the full read failed, …"]: confirm the screen with a control that is present, tap a missing element by coordinateswarnings: ["<code>(...)"], passed through without adviceclick(or any call) with an observationobservations.warnings, also in adiffobservationwarningssource.Decisions for reviewers
^0.10.0, which reports the truncation from idb's owntruncatedflag.mm screenshotandmm tap-coordinates--root(P1-39) is not on mobile.--testid, refs andscroll-to-elementsearch the same snapshot as the tree, so they do not find an element that is missing from it.string[]keeps the shape ofSnapshotResult.warnings.warningsplaced first in the outputReview guide
Read the files in this order:
src/platform/types.tsAccessibilityTreetype;ScreenCaptureextends it.src/platform/mobile-platform-driver.ts#snapshotAppkeepswarnings;WARNING_ADVICEandwithAdvice.src/tools/discovery-tools.tsdescribe_screenandaccessibility_snapshotaddwarningsonly when present.src/server/create-server.ts,observation-compaction.tssnapshotMobile,collectObservationanddiffObservationcarrywarnings.*.test.tsSKILL.md,README.mdTesting
yarn build,yarn lintandCI=1 yarn testpass (76 files, 2975 tests). Coverage: statements 98.13, branches 95.54, functions 97.53, lines 98.23 (floors 97 / 94 / 96 / 97).mobile-platform-driver.test.ts: the exact messages forax-tree-truncatedandax-tree-fallback; advice on each warning when both are present; an unknown code passes through; nowarningskey for an absent or empty array (captureScreenandgetAccessibilityTree).discovery-tools.test.ts: both tools return the driver warnings, and no key without them.create-server.test.ts(realMobilePlatformDriver, fake backend): the warning reachesdescribe_screen,accessibility_snapshotand aclickobservation, also adiffobservation. Nowarningstext in any of the three bodies without warnings.Live, iOS sim (iPhone 17 Pro, dev client, Metro 8085, this branch via yalc, consumer device-mcp 0.10.0):
describe-screenandaccessibility-snapshot: nowarningskey. idb read: depth 34, 67 nodes,truncated: false.warningskey. The fullaxbridgeread fails ("did not respond to an accessibility request"), and device-mcp 0.10.0 falls back to the flataxread (depth 2, 45 nodes) without a warning.On the current app build, wallet home is 64 levels deep. iOS rejects the full read beyond about 62 levels, so device-mcp falls back to the flat read. device-mcp#67 adds the
ax-tree-fallbackwarning for that case. The truncation warning is covered by the unit and HTTP tests above, not by a live read.Docs changed
SKILL.md: thewarningsarray, an example, and what to do (screenshot, thentap-coordinates).README.md: the response shape, the observation fields, and where device warnings appear.