From 92dbad9503a4e1798ff17aa68b0d0d307c276cbf Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Sun, 31 May 2026 05:01:10 -0700 Subject: [PATCH] refactor(menubar): remove dead distributed-notification listener Nothing posts com.codeburn.refresh since the launchd fetcher was dropped, so the listener and its heartbeat handler were vestigial. --- mac/Sources/CodeBurnMenubar/CodeBurnApp.swift | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift b/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift index cf33549a..d2686c45 100644 --- a/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift +++ b/mac/Sources/CodeBurnMenubar/CodeBurnApp.swift @@ -49,7 +49,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { private var claudeQuotaRefreshTask: Task? private var codexQuotaRefreshTask: Task? private var refreshLoopHeartbeatAt: Date = .distantPast - private var lastLaunchAgentHeartbeatAt: Date = .distantPast func applicationWillFinishLaunching(_ notification: Notification) { // Set accessory policy before the app's focus chain forms. On macOS Tahoe @@ -84,7 +83,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { observeStore() startRefreshLoop() setupWakeObservers() - setupDistributedNotificationListener() removeLegacyRefreshAgent() registerLoginItemIfNeeded() observeSubscriptionDisconnect() @@ -131,35 +129,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { } } - private func setupDistributedNotificationListener() { - DistributedNotificationCenter.default().addObserver( - forName: NSNotification.Name("com.codeburn.refresh"), - object: nil, - queue: .main - ) { [weak self] _ in - Task { @MainActor in - self?.handleLaunchAgentHeartbeat() - } - } - } - - private func handleLaunchAgentHeartbeat() { - let now = Date() - guard now.timeIntervalSince(lastLaunchAgentHeartbeatAt) >= refreshRateLimitSeconds else { return } - lastLaunchAgentHeartbeatAt = now - let loopAge = now.timeIntervalSince(refreshLoopHeartbeatAt) - guard refreshTimer == nil || loopAge > refreshLoopWatchdogSeconds else { - _ = store.clearStaleLoadingIfNeeded() - _ = clearStaleForceRefreshIfNeeded(now: now) - _ = clearStaleStatusPayloadRefreshIfNeeded(now: now) - return - } - if refreshTimer != nil { - NSLog("CodeBurn: refresh loop stale for %ds after launch agent - restarting", Int(loopAge)) - } - startRefreshLoop(forceQuotaOnStart: false) - } - private func prepareRefreshPipelineForSleep() { // Leave the timer running: the kernel pauses it during sleep, and tearing // it down stranded the loop whenever a wake notification was missed.