Fix menubar blocking system sleep and sync tab strip with detail view (#270)
Some checks are pending
CI / semgrep (push) Waiting to run

Drop .userInitiated from the process activity so macOS can enter
deep sleep while the menubar is running. The wake observer already
re-syncs on resume.

Run the all-provider and per-provider refreshes in parallel in the
loop tick so tab strip costs and the detail view update together
instead of the detail lagging behind by one CLI call.
This commit is contained in:
Resham Joshi 2026-05-08 01:32:12 -07:00 committed by GitHub
parent 04aeda71b6
commit e22cd158a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -59,8 +59,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
ProcessInfo.processInfo.automaticTerminationSupportEnabled = false
ProcessInfo.processInfo.disableSuddenTermination()
backgroundActivity = ProcessInfo.processInfo.beginActivity(
options: [.userInitiated, .automaticTerminationDisabled, .suddenTerminationDisabled],
reason: "CodeBurn menubar polls AI coding cost every 30 seconds while idle in the background."
options: [.automaticTerminationDisabled, .suddenTerminationDisabled],
reason: "CodeBurn menubar background refresh"
)
restorePersistedCurrency()
@ -271,9 +271,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
let sinceLast = Date().timeIntervalSince(self.lastRefreshTime)
if sinceLast >= 5 {
if self.store.selectedPeriod != .today || self.store.selectedProvider != .all {
await self.store.refreshQuietly(period: .today)
async let quiet: Void = self.store.refreshQuietly(period: .today)
async let main: Void = self.store.refresh(includeOptimize: false, force: true)
_ = await (quiet, main)
} else {
await self.store.refresh(includeOptimize: false, force: true)
}
await self.store.refresh(includeOptimize: false, force: true)
self.lastRefreshTime = Date()
self.refreshStatusButton()
}