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: instant UI sync, duplicate Live Activity cleanup, working→idle/needsInput alerts

libokaieed40c46b766
diff --git a/Codync-iOS/Services/LiveActivityManager.swift b/Codync-iOS/Services/LiveActivityManager.swift
index b0e145da..e5f4b7be 100644
--- a/Codync-iOS/Services/LiveActivityManager.swift
+++ b/Codync-iOS/Services/LiveActivityManager.swift
@@ -17,6 +17,7 @@ final class LiveActivityManager: ObservableObject {
private var graceTimers: [String: Date] = [:]
private var activities: [String: Activity<CodyncAttributes>] = [:]
private var sessionsByID: [String: SessionState] = [:]
+ private var previousStatuses: [String: SessionStatus] = [:] // sessionId → last known status
private var lastPushedState: [String: CodyncAttributes.ContentState] = [:]
private var previousTasks: [String: String] = [:] // sessionId → last completed tool
private var secondPreviousTasks: [String: String] = [:] // sessionId → second-last tool
@@ -159,6 +160,28 @@ final class LiveActivityManager: ObservableObject {
logger.debug("updateSessions (\(self.mode.rawValue)) primary=\(self.userPrimarySessionId ?? "none") sessions=\(sessions.count)")
sessionsByID = Dictionary(sessions.map { ($0.sessionId, $0) }, uniquingKeysWith: { _, last in last })
+ // Notify when primary session transitions from working → idle/completed
+ if let primaryId = userPrimarySessionId {
+ let session = sessionsByID[primaryId]
+ let prevStatus = previousStatuses[primaryId]
+ #if DEBUG
+ logger.info("ALERT CHECK: primary=\(primaryId.suffix(8)) status=\(session?.status.rawValue ?? "nil") prev=\(prevStatus?.rawValue ?? "nil")")
+ #endif
+ if let session,
+ (session.status == .idle || session.status == .needsInput || session.status == .completed),
+ prevStatus == .working {
+ #if DEBUG
+ logger.info("ALERT SENDING local notification for \(session.projectName)")
+ #endif
+ sendCompletionNotification(session)
+ }
+ }
+
+ // Track statuses for next comparison
+ for session in sessions {
+ previousStatuses[session.sessionId] = session.status
+ }
+
switch mode {
case .individual: updateIndividual(sessions)
case .overall: updateOverall(sessions)
@@ -177,9 +200,6 @@ final class LiveActivityManager: ObservableObject {
return session.status == .completed
}
for sessionId in completedIds {
- if let session = sessionsByID[sessionId] {
- sendCompletionNotification(session)
- }
stopTracking(sessionId: sessionId)
pinnedSessionIds.remove(sessionId)
graceTimers.removeValue(forKey: sessionId)
@@ -241,6 +261,25 @@ final class LiveActivityManager: ObservableObject {
}
private func updateOverall(_ sessions: [SessionState]) {
+ // Recover orphaned Overall activity that iOS still manages but we lost reference to
+ // (e.g., after app termination + background relaunch)
+ if overallActivity == nil {
+ for activity in Activity<OverallAttributes>.activities
+ where activity.activityState == .active || activity.activityState == .stale {
+ overallActivity = activity
+ logger.info("Recovered orphaned Overall Live Activity")
+ break
+ }
+ }
+
+ // End any extra Overall activities beyond the one we're tracking
+ for activity in Activity<OverallAttributes>.activities
+ where activity.id != overallActivity?.id
+ && (activity.activityState == .active || activity.activityState == .stale) {
+ Task { await activity.end(nil, dismissalPolicy: .immediate) }
+ logger.info("Ended duplicate Overall Live Activity")
+ }
+
// Detect if iOS ended the activity (stale timeout, user dismissed, etc.)
if let activity = overallActivity,
activity.activityState == .ended || activity.activityState == .dismissed {
@@ -334,12 +373,9 @@ final class LiveActivityManager: ObservableObject {
overallTrackedIds.insert(session.sessionId)
}
- // Send completion notifications for newly completed sessions
+ // Clean up completed sessions from overall tracking
for session in sessions where session.status == .completed {
- if overallTrackedIds.contains(session.sessionId) {
- sendCompletionNotification(session)
- overallTrackedIds.remove(session.sessionId)
- }
+ overallTrackedIds.remove(session.sessionId)
}
}
@@ -375,6 +411,7 @@ final class LiveActivityManager: ObservableObject {
// 3. Safety clear all internal state
activities.removeAll()
trackedSessionIds.removeAll()
+ previousStatuses.removeAll()
previousTasks.removeAll()
secondPreviousTasks.removeAll()
graceTimers.removeAll()
diff --git a/Codync-iOS/Views/IOSRootView.swift b/Codync-iOS/Views/IOSRootView.swift
index e61597c3..eb732888 100644
--- a/Codync-iOS/Views/IOSRootView.swift
+++ b/Codync-iOS/Views/IOSRootView.swift
@@ -9,7 +9,6 @@ struct IOSRootView: View {
@AppStorage("codync_darkMode") private var storedDarkMode = true
@State private var isDarkMode = true
@State private var displayedSessions: [SessionState] = []
- @State private var reorderTimer: Timer?
@State private var showSplash = true
var body: some View {
@@ -40,6 +39,9 @@ struct IOSRootView: View {
liveActivityManager.userPrimarySessionId = primarySessionManager.primarySessionId
liveActivityManager.updateSessions(sessions)
primarySessionManager.autoSelect(from: sessions)
+ withAnimation(.spring(duration: 0.5, bounce: 0.1)) {
+ displayedSessions = sortSessions(sessions)
+ }
}
.onChange(of: primarySessionManager.primarySessionId) { _, newId in
liveActivityManager.userPrimarySessionId = newId
@@ -51,19 +53,6 @@ struct IOSRootView: View {
.task {
liveActivityManager.userPrimarySessionId = primarySessionManager.primarySessionId
displayedSessions = sortSessions(receiver.sessions)
- reorderTimer?.invalidate()
- reorderTimer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { _ in
- Task { @MainActor in
- let sorted = sortSessions(receiver.sessions)
- withAnimation(.spring(duration: 2.0, bounce: 0.1)) {
- displayedSessions = sorted
- }
- }
- }
- }
- .onDisappear {
- reorderTimer?.invalidate()
- reorderTimer = nil
}
}
diff --git a/Codync-iOS/Views/IOSSessionListView.swift b/Codync-iOS/Views/IOSSessionListView.swift
index 6e00044c..15b51232 100644
--- a/Codync-iOS/Views/IOSSessionListView.swift
+++ b/Codync-iOS/Views/IOSSessionListView.swift
@@ -79,15 +79,14 @@ struct IOSSessionListView: View {
if !didPromptPrimary,
!newSessions.isEmpty,
primarySessionManager.primarySessionId == nil {
+ didPromptPrimary = true
showPrimaryPrompt = true
}
}
.alert("Select a Primary Session", isPresented: $showPrimaryPrompt) {
- Button("OK") {
- didPromptPrimary = true
- }
+ Button("OK") {}
} message: {
- Text("Tap the circle on the right of a session to pin it as primary. Only the primary session will send completion notifications.")
+ Text("Tap the circle on the right of a session to pin it as primary. Only the primary session will send completion alerts.")
}
}
@@ -161,9 +160,7 @@ private struct SessionRowContent: View {
}
Spacer(minLength: 4)
if session.statusDescription == nil {
- Text(relativeTime(session.updatedAt))
- .font(.system(size: 12, design: .monospaced))
- .foregroundStyle(theme.tertiaryText)
+ timestampLabel
}
}
if let desc = session.statusDescription {
@@ -176,9 +173,7 @@ private struct SessionRowContent: View {
.transition(.push(from: .bottom))
.animation(.easeInOut(duration: 0.3), value: desc)
Spacer()
- Text(relativeTime(session.updatedAt))
- .font(.system(size: 12, design: .monospaced))
- .foregroundStyle(theme.tertiaryText)
+ timestampLabel
}
.clipped()
}
@@ -211,6 +206,12 @@ private struct SessionRowContent: View {
.animation(.spring(duration: 0.5, bounce: 0.15), value: depth)
}
+ private var timestampLabel: some View {
+ Text(relativeTime(session.updatedAt))
+ .font(.system(size: 12, design: .monospaced))
+ .foregroundStyle(theme.tertiaryText)
+ }
+
private var subtitleColor: Color {
guard session.status == .needsInput else { return theme.secondaryText }
return theme.waitingColor(for: session.waitingReason)
diff --git a/Codync-iOS/Views/SettingsView.swift b/Codync-iOS/Views/SettingsView.swift
index a95142d2..3a93205e 100644
--- a/Codync-iOS/Views/SettingsView.swift
+++ b/Codync-iOS/Views/SettingsView.swift
@@ -15,7 +15,7 @@ struct SettingsView: View {
Section {
subscriptionRow
} header: {
- Text("Subscription")
+ Text("Subscription").foregroundStyle(.secondary)
}
// MARK: - Appearance
@@ -25,7 +25,7 @@ struct SettingsView: View {
}
.tint(.primary)
} header: {
- Text("Appearance")
+ Text("Appearance").foregroundStyle(.secondary)
}
// MARK: - Notifications
@@ -45,7 +45,7 @@ struct SettingsView: View {
}
.tint(.primary)
} header: {
- Text("Notifications")
+ Text("Notifications").foregroundStyle(.secondary)
} footer: {
Text("Only the pinned primary session sends completion alerts.")
}
@@ -61,7 +61,7 @@ struct SettingsView: View {
}
.tint(.primary)
} header: {
- Text("Support")
+ Text("Support").foregroundStyle(.secondary)
}
// MARK: - About
@@ -80,9 +80,10 @@ struct SettingsView: View {
}
.tint(.secondary)
} header: {
- Text("About")
+ Text("About").foregroundStyle(.secondary)
}
}
+ .tint(.primary)
.navigationTitle("Settings")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
diff --git a/Codync-iOS/Views/TabRootView.swift b/Codync-iOS/Views/TabRootView.swift
index 756c17aa..791812f9 100644
--- a/Codync-iOS/Views/TabRootView.swift
+++ b/Codync-iOS/Views/TabRootView.swift
@@ -1,68 +1,39 @@
import SwiftUI
import CodyncShared
-enum AppTab: String, CaseIterable {
- case claudeCode
- case cowork
- case codex
-}
+// TODO: Re-enable TabView with Cowork and Codex tabs once those features are implemented.
+// enum AppTab: String, CaseIterable {
+// case claudeCode
+// case cowork
+// case codex
+// }
struct TabRootView: View {
let sessions: [SessionState]
@ObservedObject var liveActivityManager: LiveActivityManager
@ObservedObject var primarySessionManager: PrimarySessionManager
- @AppStorage("codync_selectedTab") private var selectedTab: String = AppTab.claudeCode.rawValue
- private let iconSize: CGFloat = 22
+ // private let iconSize: CGFloat = 22
var body: some View {
- TabView(selection: $selectedTab) {
- Tab(value: AppTab.claudeCode.rawValue) {
- NavigationStack {
- IOSSessionListView(
- sessions: sessions,
- liveActivityManager: liveActivityManager,
- primarySessionManager: primarySessionManager
- )
- }
- } label: {
- Image("ClaudeIcon")
- .resizable()
- .renderingMode(.template)
- .aspectRatio(contentMode: .fit)
- .frame(width: iconSize, height: iconSize)
- }
-
- Tab(value: AppTab.cowork.rawValue) {
- ComingSoonView(
- icon: "CoworkIcon",
- isSystemImage: false,
- title: "Cowork",
- description: "Monitor Claude Cowork sessions in real time"
- )
- } label: {
- Image("CoworkIcon")
- .resizable()
- .renderingMode(.template)
- .aspectRatio(contentMode: .fit)
- .frame(width: iconSize, height: iconSize)
- }
-
- Tab(value: AppTab.codex.rawValue) {
- ComingSoonView(
- icon: "CodexIcon",
- isSystemImage: false,
- title: "Codex",
- description: "Track OpenAI Codex jobs and costs"
- )
- } label: {
- Image("CodexIcon")
- .resizable()
- .renderingMode(.template)
- .aspectRatio(contentMode: .fit)
- .frame(width: iconSize, height: iconSize)
- }
+ // TODO: Restore TabView when Cowork / Codex tabs are ready.
+ // TabView(selection: $selectedTab) {
+ // Tab(value: AppTab.claudeCode.rawValue) { ... }
+ // Tab(value: AppTab.cowork.rawValue) {
+ // ComingSoonView(icon: "CoworkIcon", isSystemImage: false,
+ // title: "Cowork", description: "Monitor Claude Cowork sessions in real time")
+ // }
+ // Tab(value: AppTab.codex.rawValue) {
+ // ComingSoonView(icon: "CodexIcon", isSystemImage: false,
+ // title: "Codex", description: "Track OpenAI Codex jobs and costs")
+ // }
+ // }
+ NavigationStack {
+ IOSSessionListView(
+ sessions: sessions,
+ liveActivityManager: liveActivityManager,
+ primarySessionManager: primarySessionManager
+ )
}
- .tint(.primary)
}
}
diff --git a/Codync-macOS/Services/CloudKitSync.swift b/Codync-macOS/Services/CloudKitSync.swift
index 73e4bb7b..b582e741 100644
--- a/Codync-macOS/Services/CloudKitSync.swift
+++ b/Codync-macOS/Services/CloudKitSync.swift
@@ -105,13 +105,20 @@ final class CloudKitSync {
// Fetch primary session once — reused for alert + overall push
let primary = await CloudKitManager.shared.fetchPrimarySession()
- // Send completion alert only for primary session (Pro only)
- if let lockedPrimaryId = primary.sessionId, primary.locked {
- for session in toSave where session.status == .completed && session.sessionId == lockedPrimaryId {
- if previousStates[session.sessionId]?.status != .completed {
- await APNsPushService.shared.sendCompletionAlert(session: session)
- }
- }
+ // Send completion alert for the locked primary session
+ // Triggers on: working → idle (task finished) or working → completed (session ended)
+ #if DEBUG
+ let primarySession = toSave.first(where: { $0.sessionId == primary.sessionId })
+ let prevStatus = primary.sessionId.flatMap { previousStates[$0]?.status }
+ Self.log("ALERT CHECK: primaryId=\(primary.sessionId ?? "nil") locked=\(primary.locked) sessionStatus=\(primarySession?.status.rawValue ?? "not-in-toSave") prevStatus=\(prevStatus?.rawValue ?? "nil")")
+ #endif
+ if let lockedPrimaryId = primary.sessionId, primary.locked,
+ let session = toSave.first(where: { $0.sessionId == lockedPrimaryId && ($0.status == .idle || $0.status == .needsInput || $0.status == .completed) }),
+ previousStates[session.sessionId]?.status == .working {
+ #if DEBUG
+ Self.log("ALERT SENDING for \(session.projectName) (\(session.status.rawValue))")
+ #endif
+ await APNsPushService.shared.sendCompletionAlert(session: session)
}
let desc = toSave.map { "\($0.projectName):\($0.status.rawValue)" }.joined(separator: ", ")
diff --git a/metadata/screenshots/IMG_1746.png b/metadata/screenshots/IMG_1746.png
new file mode 100644
index 00000000..ef40d6ef
Binary files /dev/null and b/metadata/screenshots/IMG_1746.png differ