printing-the-semantics-tree

Diagnose failing Compose test finders by dumping the semantics tree with printToLog and printToString.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill printing-the-semantics-tree-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: printing-the-semantics-tree
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/printing-the-semantics-tree
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill printing-the-semantics-tree-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Jetpack Compose UI tests fail with "no node matched", "found N nodes", or confusing merged vs unmerged tree errors, and developers often respond with Thread.sleep, which never fixes a structural finder problem. This Skill teaches a deterministic diagnosis workflow: dump the actual semantics tree and read the framework's built-in hints. ## Core Features & Use Cases - Semantics tree dumping: Use printToLog(tag, maxDepth) and printToString(maxDepth) on onRoot() or any finder to see the real node hierarchy, including the full output grammar (bounds, sorted config, Actions, Unit-valued flags, MergeDescendants, ClearAndSetSemantics). - Merged vs unmerged diagnosis: Interpret the framework's "found in the unmerged tree" hint and fix finders by flipping useUnmergedTree = true, e.g. for an Icon collapsed into a Button. - Custom matcher support: Use fetchSemanticsNode / fetchSemanticsNodes with meaningful error messages for direct SemanticsNode introspection, and disambiguate "found N nodes" failures via dumps plus filterToOne / hasAnyAncestor. - Use Case: A test fails with "Expected exactly '1' node but could not find any node that satisfies: (TestTag = 'submit')". Add rule.onRoot(useUnmergedTree = true).printToLog("DEBUG"), read the logcat dump, discover the tag lives on a merged-away child, and fix the finder instead of adding sleep. ## Quick Start Ask the agent to debug the failing Compose test by dumping the semantics tree with rule.onRoot(useUnmergedTree = true).printToLog("DEBUG") and interpreting the output.

Frequently Asked Questions about printing-the-semantics-tree

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug onNodeWithTag not found in Compose tests?▼

Dump the semantics tree with rule.onRoot().printToLog("DEBUG") right after setContent, then inspect logcat for the actual node hierarchy. If the node is missing from the merged tree, retry with onRoot(useUnmergedTree = true) to see nodes collapsed by merging composables.

What does "found in the unmerged tree" mean in Compose testing?▼

It means your matcher found zero nodes in the merged tree but would have matched in the unmerged tree, typically because a parent like Button merges its descendants. The fix is to pass useUnmergedTree = true to the failing finder, as the error message itself suggests.

How do I fix "Expected exactly 1 node but found N nodes" errors?▼

Dump the matches with onAllNodesWithTag("tag").printToLog("DEBUG", maxDepth = Int.MAX_VALUE) to see each node's properties, then narrow the finder using filterToOne, hasAnyAncestor, or a more specific parent testTag. Collection finders default to maxDepth 0, so override it to see children.

Why is Thread.sleep a bad fix for Compose finder failures?▼

Finder failures are structural, not timing-related: the tag is wrong, the node is in the unmerged tree, or it was never composed. Thread.sleep desyncs from MainTestClock and never produces a missing node, so dump the semantics tree to find the real cause instead.

How do I access SemanticsNode directly for custom assertions?▼

Call fetchSemanticsNode(errorMessageOnFail = "...") on a single-node finder, or fetchSemanticsNodes(atLeastOneRootRequired = true) on a collection finder. These return the underlying SemanticsNode objects so you can read node.config entries like SemanticsProperties.Text or custom keys.

When should I not use semantics tree dumping for test failures?▼

Avoid it when the symptom is genuinely timing-related, such as unfinished animations or busy idling resources, which need synchronization skills instead. Also use a dedicated accessibility-checks approach when diagnosing accessibility violations rather than node lookup failures.