From 0304be5281a41ba4b5f0b8da5c454070c1ff7c0e Mon Sep 17 00:00:00 2001 From: Bill Mill Date: Tue, 5 May 2026 08:37:20 -0400 Subject: [PATCH] feat: show file tree when showFileTree is false On startup, if the config option `showFileTree` is false, the panel is collapsed and it's a weird UI experience that it is focused despite being collapsed. Focus the diff panel on startup instead Also add a test --- pkg/ui/tui.go | 7 ++++++- pkg/ui/tui_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pkg/ui/tui.go b/pkg/ui/tui.go index feb7bda..ad44dd6 100644 --- a/pkg/ui/tui.go +++ b/pkg/ui/tui.go @@ -98,10 +98,15 @@ type mainModel struct { } func New(input string, cfg config.Config) mainModel { + initialPanel := FileTreePanel + if !cfg.UI.ShowFileTree { + initialPanel = DiffViewerPanel + } + m := mainModel{ input: input, isShowingFileTree: cfg.UI.ShowFileTree, - activePanel: FileTreePanel, + activePanel: initialPanel, config: cfg, iconStyle: cfg.UI.Icons, sideBySide: cfg.UI.SideBySide, diff --git a/pkg/ui/tui_test.go b/pkg/ui/tui_test.go index ab1fd42..8cea969 100644 --- a/pkg/ui/tui_test.go +++ b/pkg/ui/tui_test.go @@ -181,6 +181,30 @@ func TestSearchSidebarDragMotionIsIgnored(t *testing.T) { } } +func TestInitialActivePanelWhenFileTreeIsHidden(t *testing.T) { + zone.NewGlobal() + + cfg := config.DefaultConfig() + cfg.UI.ShowFileTree = false + + data, err := os.ReadFile("../../examples/multiple_files.txt") + if err != nil { + t.Fatal(err) + } + + m := New(string(data), cfg) + + if m.activePanel != DiffViewerPanel { + t.Fatalf( + "expected activePanel to be DiffViewerPanel when showFileTree is false, got %v", + m.activePanel, + ) + } + if m.isShowingFileTree { + t.Fatal("expected file tree to be hidden when showFileTree is false") + } +} + func newTestMainModel(t *testing.T) mainModel { t.Helper() zone.NewGlobal()