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.
This commit is contained in:
iamtoruk 2026-05-31 05:01:10 -07:00
parent 515a7a1467
commit 92dbad9503

View file

@ -49,7 +49,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
private var claudeQuotaRefreshTask: Task<Bool, Never>?
private var codexQuotaRefreshTask: Task<Bool, Never>?
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.