From 14cec4283d6ce90260cca20010fcfc0d591574af Mon Sep 17 00:00:00 2001 From: Tyler Koenig Date: Wed, 1 Jul 2026 21:02:45 -0400 Subject: [PATCH] feat(tui): persist bottom panel preference across restarts Save bottom_panel pref (logs/maint/none) to store on toggle. Restore on startup via InitialModel, same pattern as detail_open. --- internal/tui/data.go | 15 +++++++++++++++ internal/tui/tui.go | 12 +++++++++++- internal/tui/update.go | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/internal/tui/data.go b/internal/tui/data.go index 8e6249b..c9d4a8e 100644 --- a/internal/tui/data.go +++ b/internal/tui/data.go @@ -50,6 +50,21 @@ func writeCmd(op string, fn func() error) tea.Cmd { } } +func (m *Model) saveBottomPanelPref() tea.Cmd { + v := "logs" + switch m.bottomPanel { + case bottomNone: + v = "none" + case bottomMaint: + v = "maint" + } + st := m.store + ctx := m.ctx + return writeCmd("Save bottom panel preference", func() error { + return st.SetPreference(ctx, "bottom_panel", v) + }) +} + func sortSitesForDisplay(allSites []models.Site, collapsed map[int]bool, sortCol int, sortAsc bool) []models.Site { var groups, ungrouped []models.Site children := make(map[int][]models.Site) diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 0af7ea7..c8a7203 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -243,6 +243,16 @@ func InitialModel(ctx context.Context, isAdmin bool, s store.Store, eng *monitor detailPref, _ := s.GetPreference(ctx, "detail_open") + bp := bottomLogs + if bpPref, _ := s.GetPreference(ctx, "bottom_panel"); bpPref != "" { + switch bpPref { + case "none": + bp = bottomNone + case "maint": + bp = bottomMaint + } + } + return Model{ ctx: ctx, state: stateDashboard, @@ -257,7 +267,7 @@ func InitialModel(ctx context.Context, isAdmin bool, s store.Store, eng *monitor theme: theme, themeIndex: themeIdx, st: newStyles(theme), - bottomPanel: bottomLogs, + bottomPanel: bp, detailOpen: detailPref == "true", demoMode: os.Getenv("UPTOP_DEMO") == "1", version: version, diff --git a/internal/tui/update.go b/internal/tui/update.go index 0d47f04..16b464f 100644 --- a/internal/tui/update.go +++ b/internal/tui/update.go @@ -662,6 +662,7 @@ func (m *Model) handleDashboardKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { m.focusedPanel = panelMaint } m.recalcLayout() + return m, m.saveBottomPanelPref() case "l": if m.bottomPanel == bottomLogs { m.bottomPanel = bottomNone @@ -671,6 +672,7 @@ func (m *Model) handleDashboardKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { m.focusedPanel = panelLogs } m.recalcLayout() + return m, m.saveBottomPanelPref() case "up", "k": if m.focusedPanel == panelDetail && m.detailOpen { m.detailScrollOffset--