Merge pull request #123 from getagentseal/fix/menubar-remove-prefetchall

fix(menubar): drop prefetchAll to keep Today label fresh
This commit is contained in:
Resham Joshi 2026-04-21 07:39:54 -07:00 committed by GitHub
commit d69aa344ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 17 deletions

View file

@ -89,15 +89,6 @@ final class AppStore {
}
}
/// Prefetch all periods so tab switching is instant. Skips any period already cached.
func prefetchAll() async {
for period in Period.allCases {
let key = PayloadCacheKey(period: period, provider: .all)
if cache[key] != nil { continue }
await refreshQuietly(period: period)
}
}
/// Background refresh for a period other than the visible one (e.g. keeping today fresh for the menubar badge).
/// Does not toggle isLoading, so the popover's loading overlay is unaffected.
/// Always uses the .all provider since the menubar badge shows total spend.

View file

@ -88,14 +88,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
}
}
// Prefetch the remaining periods in a detached task. This used to be awaited inside the
// refresh loop, but on large corpora the All Time / Month period can take 60+ seconds to
// parse and blocked Today's refresh for that whole window, so the status label drifted
// out of sync with the CLI until prefetchAll finally returned.
Task { @MainActor [weak self] in
guard let s = self else { return }
await s.store.prefetchAll()
}
// Period tabs are fetched lazily when the user first clicks them in the popover.
// An earlier version prefetched every period on launch to make tab switching instant,
// but on large session corpora that spawned four concurrent codeburn subprocesses
// competing with the main refresh loop for disk and parser time, and the status label
// drifted stale for minutes. A per-tab first-click cost of a few seconds is the better
// tradeoff on user machines that track thousands of sessions.
}
private func observeStore() {