diff --git a/internal/tui/app.go b/internal/tui/app.go index 68c37f1..016c1e3 100644 --- a/internal/tui/app.go +++ b/internal/tui/app.go @@ -22,17 +22,19 @@ func Run(cfg *config.Config) error { } // scanReposCmd is a command that scans for repositories -func scanReposCmd(cfg *config.Config) tea.Cmd { +// If forceRefresh is true, bypass cache and scan fresh +func scanReposCmd(cfg *config.Config, forceRefresh bool) tea.Cmd { return func() tea.Msg { - // Try to load from cache first cacheStore := cache.NewFileStore() - cached, err := cacheStore.Load() - if err == nil && cacheStore.IsValid(cacheMaxAge) && cacheStore.IsSameRoots(cfg.Roots) { - // Use cached data but trigger background refresh - return scanCompleteMsg{ - repos: cached.Repos, - fromCache: true, + // Try to load from cache first (unless forcing refresh) + if !forceRefresh { + cached, err := cacheStore.Load() + if err == nil && cacheStore.IsValid(cacheMaxAge) && cacheStore.IsSameRoots(cfg.Roots) { + return scanCompleteMsg{ + repos: cached.Repos, + fromCache: true, + } } } diff --git a/internal/tui/model.go b/internal/tui/model.go index 2bb0dd1..4a71eee 100644 --- a/internal/tui/model.go +++ b/internal/tui/model.go @@ -153,7 +153,7 @@ func NewModel(cfg *config.Config) Model { // Init initializes the model func (m Model) Init() tea.Cmd { - return tea.Batch(m.spinner.Tick, scanReposCmd(m.cfg)) + return tea.Batch(m.spinner.Tick, scanReposCmd(m.cfg, false)) } // GetSelectedRepo returns the currently selected repo diff --git a/internal/tui/update.go b/internal/tui/update.go index 2a6b8e2..31b313b 100644 --- a/internal/tui/update.go +++ b/internal/tui/update.go @@ -110,7 +110,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } else { m.statusMsg = "" } - return m, scanReposCmd(m.cfg) + return m, scanReposCmd(m.cfg, true) case grassDataLoadedMsg: m.grassData = msg.data @@ -182,7 +182,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "r": m.state = StateLoading m.statusMsg = "Rescanning..." - return m, scanReposCmd(m.cfg) + return m, scanReposCmd(m.cfg, true) case "f": // Cycle through filter modes