Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix: menu bar visibility + CloudKit sync cancellation issue

libokai949bc4a6df22
diff --git a/CodePulse-macOS/App/CodePulseApp.swift b/CodePulse-macOS/App/CodePulseApp.swift
index 37ebdae3..3dfae0fd 100644
--- a/CodePulse-macOS/App/CodePulseApp.swift
+++ b/CodePulse-macOS/App/CodePulseApp.swift
@@ -1,11 +1,16 @@
import SwiftUI
+import AppKit
import CodePulseShared
+import os
+
+private let logger = Logger(subsystem: "com.pokai.CodePulse", category: "App")
@main
struct CodePulseApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
+ // Menu bar only app — no windows
Settings { EmptyView() }
}
}
@@ -18,10 +23,19 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
var cloudKitSync: CloudKitSync!
func applicationDidFinishLaunching(_ notification: Notification) {
+ // Hide from Dock — must be called early
NSApp.setActivationPolicy(.accessory)
+
stateManager = SessionStateManager(scanner: scanner)
cloudKitSync = CloudKitSync(stateManager: stateManager)
menuBarController = MenuBarController(stateManager: stateManager)
scanner.start()
+
+ logger.info("CodePulse launched, menu bar active")
+ }
+
+ func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
+ // Don't quit when popover closes
+ false
}
}
diff --git a/CodePulse-macOS/Services/CloudKitSync.swift b/CodePulse-macOS/Services/CloudKitSync.swift
index ccf861d2..d6b0fd47 100644
--- a/CodePulse-macOS/Services/CloudKitSync.swift
+++ b/CodePulse-macOS/Services/CloudKitSync.swift
@@ -10,12 +10,12 @@ final class CloudKitSync {
private let stateManager: SessionStateManager
private var cancellables = Set<AnyCancellable>()
private var previousStates: [String: SessionState] = [:]
- private var syncTask: Task<Void, Never>?
+ private var isSyncing = false
init(stateManager: SessionStateManager) {
self.stateManager = stateManager
stateManager.$sessions
- .debounce(for: .seconds(2), scheduler: RunLoop.main)
+ .debounce(for: .seconds(5), scheduler: RunLoop.main)
.sink { [weak self] sessions in
self?.syncToCloud(sessions)
}
@@ -24,30 +24,32 @@ final class CloudKitSync {
}
private func syncToCloud(_ sessions: [SessionState]) {
- syncTask?.cancel()
- syncTask = Task {
+ // Don't start a new sync if one is already running (e.g. retrying)
+ guard !isSyncing else {
+ logger.debug("Sync skipped — already in progress")
+ return
+ }
+ isSyncing = true
+
+ Task {
+ defer { isSyncing = false }
+
var syncedCount = 0
for session in sessions {
- guard !Task.isCancelled else { return }
let previous = previousStates[session.sessionId]
+ guard session.updatedAt != previous?.updatedAt else { continue }
+
do {
- try await CloudKitManager.shared.saveIfChanged(session, previous: previous)
+ try await CloudKitManager.shared.save(session)
previousStates[session.sessionId] = session
syncedCount += 1
} catch {
- logger.error("CloudKit sync failed for session \(session.sessionId): \(error.localizedDescription)")
+ logger.error("Sync failed for \(session.sessionId): \(error.localizedDescription)")
+ // Don't block other sessions on one failure
}
}
if syncedCount > 0 {
- logger.debug("Synced \(syncedCount) sessions to CloudKit")
- }
- // Cleanup less frequently — only if we synced something
- if syncedCount > 0 {
- do {
- try await CloudKitManager.shared.deleteCompleted()
- } catch {
- logger.debug("CloudKit cleanup skipped: \(error.localizedDescription)")
- }
+ logger.info("Synced \(syncedCount) sessions to CloudKit")
}
}
}
diff --git a/CodePulse.xcodeproj/project.pbxproj b/CodePulse.xcodeproj/project.pbxproj
index 48275c5b..163232b4 100644
--- a/CodePulse.xcodeproj/project.pbxproj
+++ b/CodePulse.xcodeproj/project.pbxproj
@@ -69,7 +69,7 @@
3935CEE144EC8AFCA3AEAEA3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3B652652FD106495A82565C8 /* CodePulseLiveActivity.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.app-extension"; path = CodePulseLiveActivity.appex; sourceTree = BUILT_PRODUCTS_DIR; };
3BCD1168005B123A7F9ACB37 /* CodePulseLiveActivityBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodePulseLiveActivityBundle.swift; sourceTree = "<group>"; };
- 3EB0548BFADFAFC3616A8C4B /* CodePulse-iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; name = "CodePulse-iOS.app"; path = CodePulse.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 3EB0548BFADFAFC3616A8C4B /* CodePulse.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CodePulse.app; sourceTree = BUILT_PRODUCTS_DIR; };
42BAF66F7C50D732B7E69333 /* SessionScanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionScanner.swift; sourceTree = "<group>"; };
433D534BFD8D3D76B489B324 /* CodePulse-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "CodePulse-iOS.entitlements"; sourceTree = "<group>"; };
4A67A3CD19408484AB11BB73 /* CodePulseApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodePulseApp.swift; sourceTree = "<group>"; };
@@ -127,7 +127,7 @@
04721CC753DB3D170E2C8A15 /* Products */ = {
isa = PBXGroup;
children = (
- 3EB0548BFADFAFC3616A8C4B /* CodePulse-iOS.app */,
+ 3EB0548BFADFAFC3616A8C4B /* CodePulse.app */,
8B5EA7075E9DC97237EF2227 /* CodePulse.app */,
3B652652FD106495A82565C8 /* CodePulseLiveActivity.appex */,
);
@@ -298,7 +298,7 @@
C1CA2B270135307CC4E2724D /* CodePulseShared */,
);
productName = "CodePulse-iOS";
- productReference = 3EB0548BFADFAFC3616A8C4B /* CodePulse-iOS.app */;
+ productReference = 3EB0548BFADFAFC3616A8C4B /* CodePulse.app */;
productType = "com.apple.product-type.application";
};
AD1C1A5F9DF9E66175980B2F /* CodePulse */ = {
@@ -569,6 +569,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "CodePulse-iOS/App/CodePulse-iOS.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
+ DEVELOPMENT_TEAM = DEVELOPMENT_TEAM_REDACTED;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@@ -594,6 +595,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "CodePulse-iOS/App/CodePulse-iOS.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
+ DEVELOPMENT_TEAM = DEVELOPMENT_TEAM_REDACTED;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;