From db43f450bc61ed6795eb228a728804d6319fb4e7 Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 5 Sep 2026 22:31:17 +0530 Subject: [PATCH] refactor(hierarchy): name no screen for a tree Transitional calls a cross-fade ScreenName kept its own reading of the route markers and disagreed with Transitional on a marker repeated by a nested node: it named the screen on a step the runner was skipping as unsettled. One reading now. --- internal/hierarchy/hierarchy.go | 22 +++++++++------------- internal/hierarchy/hierarchy_test.go | 9 --------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/internal/hierarchy/hierarchy.go b/internal/hierarchy/hierarchy.go index b19b88e..7a7baf7 100644 --- a/internal/hierarchy/hierarchy.go +++ b/internal/hierarchy/hierarchy.go @@ -669,9 +669,7 @@ func (t *Tree) Transitional() bool { // 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. +// marks the route composable. A transitional tree names no screen. func (t *Tree) ScreenName() string { if t == nil || len(t.Elements) == 0 { return "" @@ -679,17 +677,15 @@ func (t *Tree) ScreenName() string { 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 + if t.Transitional() { + return "" } - return name + for _, element := range t.Elements { + if strings.HasSuffix(element.ResourceID, "Screen") { + return element.ResourceID + } + } + return "" } // Find returns the first element matching the selector, or nil. diff --git a/internal/hierarchy/hierarchy_test.go b/internal/hierarchy/hierarchy_test.go index d742bfc..3648fdc 100644 --- a/internal/hierarchy/hierarchy_test.go +++ b/internal/hierarchy/hierarchy_test.go @@ -1840,15 +1840,6 @@ func TestScreenNameNamesTheRouteTheTreeShows(t *testing.T) { ]}`, "HomeScreen", }, - { - "route marker repeated by a nested node", - `{"attributes": {"bounds": "[0,0,10,10]"}, "children": [ - {"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,10]"}, "children": [ - {"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,5]"}, "children": []} - ]} - ]}`, - "HomeScreen", - }, { "cross-fade names no screen", `{"attributes": {"bounds": "[0,0,10,10]"}, "children": [