feat(hierarchy): name the route a native tree shows

The screen name was web-only: the Chrome driver stamps sanderling-screen on
the root and nothing else does, so every Android and iOS step recorded and
logged an empty screen. The route marker the tree already carries (the
resource id ending in Screen, the same one Transitional counts) names it.
This commit is contained in:
pj committed 2026-08-19 18:37:51 +05:30
1 parent 9b4ff5f247
commit be8a7e0194
2 files changed
+79

No files matched your search

+25
View File
@@ -667,6 +667,31 @@ func (t *Tree) Transitional() bool {
return false
}
// ScreenName names the route this tree shows: the driver-set screen when the
// platform reports one (web), otherwise the resource id ending in "Screen" that
// marks the route composable. A tree carrying two different route ids is a
// cross-fade in flight and names no screen, which is the same reading
// Transitional gives it.
func (t *Tree) ScreenName() string {
if t == nil || len(t.Elements) == 0 {
return ""
}
if screen := t.Elements[0].Screen; screen != "" {
return screen
}
name := ""
for _, element := range t.Elements {
if !strings.HasSuffix(element.ResourceID, "Screen") {
continue
}
if name != "" && name != element.ResourceID {
return ""
}
name = element.ResourceID
}
return name
}
// Find returns the first element matching the selector, or nil.
func (t *Tree) Find(selector string) *Element {
node := t.FindNode(selector)