From db0501fca0e871feca8edda03c75daf9e3404ba1 Mon Sep 17 00:00:00 2001 From: Joe Julian Date: Fri, 3 Apr 2026 08:35:09 -0700 Subject: [PATCH] Keep parent breadcrumb on phone --- main.go | 5 +---- main_test.go | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 94e3d9a..2c28316 100644 --- a/main.go +++ b/main.go @@ -5364,7 +5364,7 @@ func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) { return indices }() } - if u.mode != "phone" || len(displayPath) <= 1 { + if u.mode != "phone" || len(displayPath) <= 2 { crumbs := append([]string{"/"}, append([]string{}, displayPath...)...) indices := make([]int, 0, len(crumbs)) indices = append(indices, 0) @@ -5373,9 +5373,6 @@ func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) { } return crumbs, indices } - if len(displayPath) == 2 { - return []string{"/", displayPath[len(displayPath)-1]}, []int{0, len(displayPath)} - } crumbs := []string{"/", "…", displayPath[len(displayPath)-1]} indices := []int{0, len(displayPath) - 1, len(displayPath)} return crumbs, indices diff --git a/main_test.go b/main_test.go index 4b911ca..6d2b025 100644 --- a/main_test.go +++ b/main_test.go @@ -5197,11 +5197,11 @@ func TestUIVisibleBreadcrumbsCompressesAggressivelyOnPhone(t *testing.T) { u := newUIWithModel("phone", vault.Model{}) gotCrumbs, gotIndices := u.visibleBreadcrumbs([]string{"Root", "Infrastructure"}) - if !slices.Equal(gotCrumbs, []string{"/", "Infrastructure"}) { - t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Infrastructure]", gotCrumbs) + if !slices.Equal(gotCrumbs, []string{"/", "Root", "Infrastructure"}) { + t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Root Infrastructure]", gotCrumbs) } - if !slices.Equal(gotIndices, []int{0, 2}) { - t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 2]", gotIndices) + if !slices.Equal(gotIndices, []int{0, 1, 2}) { + t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 1 2]", gotIndices) } gotCrumbs, gotIndices = u.visibleBreadcrumbs([]string{"Root", "Infrastructure", "SSH"}) @@ -5213,6 +5213,19 @@ func TestUIVisibleBreadcrumbsCompressesAggressivelyOnPhone(t *testing.T) { } } +func TestUIPhoneVisibleBreadcrumbsKeepParentForTwoSegmentPath(t *testing.T) { + t.Parallel() + + u := newUIWithModel("phone", vault.Model{}) + gotCrumbs, gotIndices := u.visibleBreadcrumbs([]string{"Crew", "Internet"}) + if !slices.Equal(gotCrumbs, []string{"/", "Crew", "Internet"}) { + t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Crew Internet]", gotCrumbs) + } + if !slices.Equal(gotIndices, []int{0, 1, 2}) { + t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 1 2]", gotIndices) + } +} + func TestUILocalLifecycleActionErrorsAreVisibleAndSpecific(t *testing.T) { t.Parallel()