From c72443b3c69247e6b444453107dcf5fe0a4a5db8 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Sat, 10 Jan 2026 01:36:17 -0500 Subject: [PATCH] Keep history tab selection and add clear all --- internal/ui/mainmenu.go | 25 ++++++++++++++++++++++++- main.go | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/internal/ui/mainmenu.go b/internal/ui/mainmenu.go index 35e02d1..8766677 100644 --- a/internal/ui/mainmenu.go +++ b/internal/ui/mainmenu.go @@ -207,6 +207,9 @@ func BuildHistorySidebar( activeJobs []HistoryEntry, onEntryClick func(HistoryEntry), onEntryDelete func(HistoryEntry), + onClearAll func(), + selectedTab int, + onTabChanged func(int), titleColor, bgColor, textColor color.Color, ) fyne.CanvasObject { // Filter by status @@ -231,14 +234,34 @@ func BuildHistorySidebar( container.NewTabItem("Failed", container.NewVScroll(failedList)), ) tabs.SetTabLocation(container.TabLocationTop) + if selectedTab >= 0 && selectedTab < len(tabs.Items) { + tabs.SelectIndex(selectedTab) + } + tabs.OnSelected = func(item *container.TabItem) { + if onTabChanged == nil { + return + } + for idx, tab := range tabs.Items { + if tab == item { + onTabChanged(idx) + return + } + } + } // Header title := canvas.NewText("HISTORY", titleColor) title.TextStyle = fyne.TextStyle{Monospace: true, Bold: true} title.TextSize = 18 + clearBtn := widget.NewButton("Clear All", func() { + if onClearAll != nil { + onClearAll() + } + }) + clearBtn.Importance = widget.LowImportance header := container.NewVBox( - container.NewCenter(title), + container.NewBorder(nil, nil, title, clearBtn, nil), widget.NewSeparator(), ) diff --git a/main.go b/main.go index 07cb1d4..bb5e22f 100644 --- a/main.go +++ b/main.go @@ -1145,6 +1145,7 @@ type appState struct { // History sidebar state historyEntries []ui.HistoryEntry sidebarVisible bool + historyTabIdx int // Author module state authorFile *videoSource @@ -1436,6 +1437,10 @@ func (s *appState) deleteHistoryEntry(entry ui.HistoryEntry) { _ = s.jobQueue.Remove(entry.ID) } + if entry.LogPath != "" { + _ = os.Remove(entry.LogPath) + } + // Remove entry from history var updated []ui.HistoryEntry for _, e := range s.historyEntries { @@ -1455,6 +1460,20 @@ func (s *appState) deleteHistoryEntry(entry ui.HistoryEntry) { s.refreshMainMenuThrottled() } +func (s *appState) clearHistoryEntries() { + for _, entry := range s.historyEntries { + if entry.LogPath != "" { + _ = os.Remove(entry.LogPath) + } + } + s.historyEntries = nil + cfg := historyConfig{Entries: s.historyEntries} + if err := saveHistoryConfig(cfg); err != nil { + logging.Debug(logging.CatUI, "failed to save history after clear: %v", err) + } + s.refreshMainMenuThrottled() +} + func (s *appState) stopPreview() { if s.anim != nil { s.anim.Stop() @@ -1941,6 +1960,11 @@ func (s *appState) showMainMenu() { activeJobs, s.showHistoryDetails, s.deleteHistoryEntry, + s.clearHistoryEntries, + s.historyTabIdx, + func(idx int) { + s.historyTabIdx = idx + }, titleColor, utils.MustHex("#1A1F2E"), textColor,