Skip to content

Commit 79a50cb

Browse files
fix: rescan (r) now performs fresh scan instead of returning cached data (#13)
Added forceRefresh parameter to scanReposCmd(): - rescan (r) and workspace switch pass true to bypass cache - initial load passes false to keep fast cached startup Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0c00660 commit 79a50cb

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

internal/tui/app.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ func Run(cfg *config.Config) error {
2222
}
2323

2424
// scanReposCmd is a command that scans for repositories
25-
func scanReposCmd(cfg *config.Config) tea.Cmd {
25+
// If forceRefresh is true, bypass cache and scan fresh
26+
func scanReposCmd(cfg *config.Config, forceRefresh bool) tea.Cmd {
2627
return func() tea.Msg {
27-
// Try to load from cache first
2828
cacheStore := cache.NewFileStore()
29-
cached, err := cacheStore.Load()
3029

31-
if err == nil && cacheStore.IsValid(cacheMaxAge) && cacheStore.IsSameRoots(cfg.Roots) {
32-
// Use cached data but trigger background refresh
33-
return scanCompleteMsg{
34-
repos: cached.Repos,
35-
fromCache: true,
30+
// Try to load from cache first (unless forcing refresh)
31+
if !forceRefresh {
32+
cached, err := cacheStore.Load()
33+
if err == nil && cacheStore.IsValid(cacheMaxAge) && cacheStore.IsSameRoots(cfg.Roots) {
34+
return scanCompleteMsg{
35+
repos: cached.Repos,
36+
fromCache: true,
37+
}
3638
}
3739
}
3840

internal/tui/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func NewModel(cfg *config.Config) Model {
153153

154154
// Init initializes the model
155155
func (m Model) Init() tea.Cmd {
156-
return tea.Batch(m.spinner.Tick, scanReposCmd(m.cfg))
156+
return tea.Batch(m.spinner.Tick, scanReposCmd(m.cfg, false))
157157
}
158158

159159
// GetSelectedRepo returns the currently selected repo

internal/tui/update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
110110
} else {
111111
m.statusMsg = ""
112112
}
113-
return m, scanReposCmd(m.cfg)
113+
return m, scanReposCmd(m.cfg, true)
114114

115115
case grassDataLoadedMsg:
116116
m.grassData = msg.data
@@ -182,7 +182,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
182182
case "r":
183183
m.state = StateLoading
184184
m.statusMsg = "Rescanning..."
185-
return m, scanReposCmd(m.cfg)
185+
return m, scanReposCmd(m.cfg, true)
186186

187187
case "f":
188188
// Cycle through filter modes

0 commit comments

Comments
 (0)