From e22cd158a86f1b021d6dbadfadfb32b7b851d471 Mon Sep 17 00:00:00 2001 From: Resham Joshi <65915470+iamtoruk@users.noreply.github.com> Date: Fri, 8 May 2026 01:32:12 -0700 Subject: [PATCH] Fix menubar blocking system sleep and sync tab strip with detail view (#270) 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. --- mac/Sources/CodeBurnMenubar/CodeBurnApp.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift b/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift index b4d596e..f0e1737 100644 --- a/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift +++ b/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift @@ -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() }