mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-04-28 06:59:37 +00:00
Merge pull request #123 from getagentseal/fix/menubar-remove-prefetchall
fix(menubar): drop prefetchAll to keep Today label fresh
This commit is contained in:
commit
d69aa344ab
2 changed files with 6 additions and 17 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue