Keep parent breadcrumb on phone

This commit is contained in:
Joe Julian
2026-04-03 08:35:09 -07:00
parent 48dfe604cf
commit da53696435
2 changed files with 18 additions and 8 deletions
+1 -4
View File
@@ -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
+17 -4
View File
@@ -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{"Joe", "Internet"})
if !slices.Equal(gotCrumbs, []string{"/", "Joe", "Internet"}) {
t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Joe 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()