From ebb8d4f4ff06d7c04dfb143da1506b333b98daff Mon Sep 17 00:00:00 2001 From: Joe Julian Date: Sat, 11 Apr 2026 11:18:32 -0700 Subject: [PATCH] Hide synthetic vault root beside recycle bin --- internal/appui/main_test.go | 27 +++++++++++++++++++++++++++ internal/appui/recent_state.go | 11 +++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/internal/appui/main_test.go b/internal/appui/main_test.go index 8201ad8..93e1a7c 100644 --- a/internal/appui/main_test.go +++ b/internal/appui/main_test.go @@ -5136,6 +5136,33 @@ func TestUIAutoEntersSingleVaultRootGroupAndDisplaysSlashRoot(t *testing.T) { } } +func TestUIAutoEntersSingleVaultRootWhenRecycleBinAlsoExists(t *testing.T) { + t.Parallel() + + u := newUIWithModel("desktop", vault.Model{ + Entries: []vault.Entry{ + {ID: "vault-console", Title: "Vault Console", Path: []string{"keepass", "Crew", "Internet"}}, + }, + Groups: [][]string{ + {"keepass"}, + {"keepass", "Crew"}, + {"Recycle Bin"}, + }, + }) + + u.showEntriesSection() + + if got := u.currentPath; !slices.Equal(got, []string{"keepass"}) { + t.Fatalf("currentPath = %v, want [keepass]", got) + } + if got := u.displayPath(); len(got) != 0 { + t.Fatalf("displayPath() = %v, want root slash path", got) + } + if got := u.childGroups(); !slices.Equal(got, []string{"Crew"}) { + t.Fatalf("childGroups() = %v, want [Crew]", got) + } +} + func TestUIShowEntriesSectionRestoresHiddenRootAfterLeavingEntries(t *testing.T) { t.Parallel() diff --git a/internal/appui/recent_state.go b/internal/appui/recent_state.go index 3c1948f..1628349 100644 --- a/internal/appui/recent_state.go +++ b/internal/appui/recent_state.go @@ -1270,10 +1270,17 @@ func (u *ui) hiddenVaultRoot() string { return "" } groups := model.ChildGroups(nil) - if len(groups) != 1 { + roots := make([]string, 0, len(groups)) + for _, group := range groups { + if group == "Recycle Bin" { + continue + } + roots = append(roots, group) + } + if len(roots) != 1 { return "" } - return groups[0] + return roots[0] } func (u *ui) enterHiddenVaultRoot() {