fix(android): carry the heading flag and the role description on the snapshot node - #2915
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is covered end-to-end, with only minor test-coverage nits remaining.
Review effort: Lite
Findings: None
What changed in this PR
Adds Android accessibility heading and role-description metadata to snapshots, get attrs, and unchanged-snapshot comparisons.
Changes:
- Serializes and parses
headingandrole-description. - Propagates fields through Android and kernel snapshot nodes.
- Updates digests, documentation, changelog, and tests.
| File | Description |
|---|---|
website/docs/docs/snapshots.md |
Documents new snapshot metadata. |
src/daemon/response-views.ts |
Includes fields in selector digests. |
src/commands/capture/runtime/snapshot-unchanged.ts |
Compares fields for snapshot changes. |
src/__tests__/android-ui-hierarchy.test.ts |
Tests published Android snapshots. |
packages/platform-android/src/ui-hierarchy.ts |
Parses and normalizes metadata. |
packages/platform-android/src/ui-hierarchy-node.ts |
Adds hierarchy metadata fields. |
packages/platform-android/src/ui-hierarchy-builder.ts |
Publishes fields in snapshots. |
packages/platform-android/src/__tests__/ui-hierarchy-role-facts.test.ts |
Tests metadata propagation. |
packages/kernel/src/snapshot.ts |
Extends snapshot node types. |
CHANGELOG.md |
Records the fix. |
android/snapshot-helper/src/main/java/com/callstack/agentdevice/snapshothelper/AccessibilityTreeXml.java |
Serializes Android accessibility metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Reviewed at 4d6fb65. The change looks correct: #2913 edits the same comment block in The on-device run comes from the PR description; I did not repeat it. I could not confirm from repo sources that |
|
The extras key is androidx's |
…snapshot node React Native puts a header, a tab, a tab list, a radio group, a link, or a menu on a plain android.view.View and tells the accessibility tree what it is through two facts: the heading flag and the role description androidx stores in the node extras. The helper serialized neither, and the host reads only the helper's XML, so every one of them was a nameless View to an agent and to `get attrs`. The helper now writes `heading` when the node reports it (API 28 or later) and `role-description` when the app set one; the parser, the Android hierarchy node, and the published snapshot node carry them to `get attrs`, the unchanged-snapshot comparison, and the selector digest. The class stays the type, and snapshot text is unchanged: mapping a description to a role is the consumer's call.
4d6fb65 to
926d4f9
Compare
Summary
React Native puts a header, a tab, a tab list, a radio group, a link, or a menu on a plain
android.view.Viewand marks what it is through two facts: the heading flag and the role description androidx stores in the node extras. The helper serialized neither, and the host reads only its XML, so each was a namelessViewto an agent and toget attrs.The helper now writes
headingwhen the node reports it (API 28 or later) androle-descriptionwhen the app set one. The parser, the Android hierarchy node, and the published snapshot node carry them toget attrs, the unchanged-snapshot comparison, and the selector digest asheadingandroleDescription. The class stays thetypeand snapshot text is unchanged; mapping a localized description to a role is the consumer's call.10 files. No
HELPER_API_VERSIONbump, as withselected(#2515).Validation
Tested at 926d4f9 (rebased onto 86d719d).
pnpm check:affected --run --base 86d719dc3passed: format, lint, typecheck, layering, fallow, build, 853 test files, 6,671 tests.Rebuilt helper on an API 36 emulator, React Native app:
accessibilityRole="header"reportsheading: true;tablist,tab, andradiogroupviews reportTab List,Tab, andRadio Group; text views report neither key.Risk: a heading on API 23 to 27 still reports nothing, since the compat flag lives in an extras bit the helper does not read.