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.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(kit): remind about newer releases and wait for App Review
leepokai92c1d051f8ca
diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swiftindex bc5f7b85..97052d61 100644--- a/apps/ios/App/CodyncApp.swift+++ b/apps/ios/App/CodyncApp.swift@@ -9,9 +9,10 @@ import WidgetKitstruct CodyncApp: App {@UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate@State private var app = AppStore.shared+ /// What the App Store has: greys out an update it doesn't have yet, reminds of newer ones.+ @State private var updates = AppUpdates()@Environment(\.scenePhase) private var scenePhase@AppStorage("onboardingCompleted") private var onboardingCompleted = false- private static let appStorePage = URL(string: "https://apps.apple.com/app/id6760984418")!var body: some Scene {WindowGroup {@@ -21,7 +22,8 @@ struct CodyncApp: App {.environment(app.accounts).environment(app.account)// A computer needs a newer app: its App Store page has the Update button.- .environment(\.appUpdate, AppUpdateAction { UIApplication.shared.open(Self.appStorePage) })+ .environment(\.appUpdate, AppUpdateAction { UIApplication.shared.open(AppStoreRelease.page) })+ .environment(updates).tint(Palette.accent).codyncSheet(isPresented: Binding(get: { (onboardingCompleted || app.account.isSignedIn) && app.account.showSwitcher },@@ -43,7 +45,10 @@ struct CodyncApp: App {// app switcher, system prompts) comes and goes too often to drop the link.app.accounts.setActive(phase != .background)// Back in the app: a computer may have joined the account meanwhile.- if phase == .active { Task { await app.accounts.refreshCloud() } }+ if phase == .active {+ Task { await app.accounts.refreshCloud() }+ Task { await updates.refresh() }+ }}#if DEBUG.task {diff --git a/apps/ios/Views/BotListView.swift b/apps/ios/Views/BotListView.swiftindex e33424ef..ee73851d 100644--- a/apps/ios/Views/BotListView.swift+++ b/apps/ios/Views/BotListView.swift@@ -46,6 +46,12 @@ struct BotListView: View {let roster = accounts.roster.filter { shownIDs.contains($0.ref.computerId) }ScrollView {LazyVStack(spacing: 0) {+ // Newer releases (dismissible; everything still works): this app here, a computer's+ // host under its heading, or here when there's no heading.+ AppUpdateReminder()+ if !grouped {+ ForEach(shownStores, id: \.computer.id) { HostUpdateReminder(store: $0) }+ }if !grouped {// One computer: its update notice leads the list.ForEach(shownStores, id: \.computer.id) { updateCard($0) }@@ -65,6 +71,7 @@ struct BotListView: View {ComputerSection(store: store, empty: store.mismatch == nil && !roster.contains { $0.ref.computerId == id },targeted: dropTarget == id, move: move)updateCard(store)+ HostUpdateReminder(store: store)ForEach(roster.filter { $0.ref.computerId == id }) { row($0, store: store) }}.dropDestination(for: String.self) { ids, _ indiff --git a/apps/macos/Views/ChatWindow.swift b/apps/macos/Views/ChatWindow.swiftindex f744337e..18504461 100644--- a/apps/macos/Views/ChatWindow.swift+++ b/apps/macos/Views/ChatWindow.swift@@ -402,6 +402,7 @@ private struct ChatSplitView: View {@AppStorage("sidebarCompact") private var compact = false@AppStorage("desktopSidebarWidth") private var sidebarWidth = 296.0@State private var dragStartWidth: Double?+ @State private var appUpdates = AppUpdates()@Environment(\.accessibilityReduceMotion) private var reduceMotion/// Sheets hang from the window's title bar; sized from it so they never run past its bottom edge.@State private var windowSize = CGSize(width: 1100, height: 760)@@ -459,6 +460,8 @@ private struct ChatSplitView: View {ScrollView {LazyVStack(spacing: 2) {if !compact {+ // Other computers on older releases (this Mac's own host is the app's).+ UpdateReminders(stores: stores.filter { shownIDs.contains($0.computer.id) })ForEach(stores.filter { shownIDs.contains($0.computer.id) }, id: \.computer.id) { store inif let mismatch = store.mismatch {UpdateNeededCard(store: store, mismatch: mismatch)@@ -691,6 +694,8 @@ private struct ChatSplitView: View {.environment(\.appUpdate, updates.canCheckForUpdates || updates.hasStagedUpdate? AppUpdateAction { [updates] in updates.checkForUpdates() } : nil).environment(\.hostUpdate, HostUpdateAction(available: { [host] in $0 === host.store }) { [host] _ in host.restart() })+ // No App Store lookup here (Sparkle updates the Mac app); keeps reminder dismissals.+ .environment(appUpdates).codyncDialog("Start a new session?", isPresented: Binding(get: { newSessionBot != nil },set: { if !$0 { newSessionBot = nil } }diff --git a/kit/Sources/CodyncKit/Models/Compatibility.swift b/kit/Sources/CodyncKit/Models/Compatibility.swiftindex ff4fa2bc..ba5b1a7a 100644--- a/kit/Sources/CodyncKit/Models/Compatibility.swift+++ b/kit/Sources/CodyncKit/Models/Compatibility.swift@@ -60,3 +60,38 @@ public enum AppVersion {return v.lexicographicallyPrecedes(m)}}++/// The iPhone app in the App Store (iTunes lookup API).+public enum AppStoreRelease {+ public static let appID = "6760984418"+ public static let page = URL(string: "https://apps.apple.com/app/id\(appID)")!++ /// The version live in the App Store; nil when the lookup has no result.+ public static func latestVersion(session: URLSession = .shared) async throws -> String? {+ struct Lookup: Decodable {+ struct Result: Decodable { var version: String? }+ var results: [Result]+ }+ var request = URLRequest(url: URL(string: "https://itunes.apple.com/lookup?id=\(appID)")!)+ request.timeoutInterval = 10+ request.cachePolicy = .reloadIgnoringLocalCacheData+ let (data, response) = try await session.data(for: request)+ guard (response as? HTTPURLResponse)?.statusCode == 200 else { throw URLError(.badServerResponse) }+ return try JSONDecoder().decode(Lookup.self, from: data).results.first?.version+ }+}++/// Newer releases worth a (dismissible) reminder while everything still works together.+public enum UpdateReminder {+ /// The App Store has a newer app than this one, and it wasn't dismissed.+ public static func app(current: String, store: String?, dismissed: String?) -> String? {+ guard let store, AppVersion.isBelow(current, store), store != dismissed else { return nil }+ return store+ }++ /// This app is newer than the host, so that release exists for it; not dismissed for it.+ public static func host(app: String, host: String?, dismissed: String?) -> Bool {+ guard let host, AppVersion.isBelow(host, app) else { return false }+ return dismissed != app+ }+}diff --git a/kit/Sources/CodyncUI/Store/BotStore.swift b/kit/Sources/CodyncUI/Store/BotStore.swiftindex 1156ddd1..3180e277 100644--- a/kit/Sources/CodyncUI/Store/BotStore.swift+++ b/kit/Sources/CodyncUI/Store/BotStore.swift@@ -497,8 +497,9 @@ public final class BotStore {return}guard !Task.isCancelled, !retired else { return }- noteHostVersion(HostVersion(version: h.version, minApp: h.minApp))+ // hello first: whatever the version change shows (notices, reminders) reads it.hello = h+ noteHostVersion(HostVersion(version: h.version, minApp: h.minApp))if case .loopback = route {updateComputer { c inc.name = h.namediff --git a/kit/Sources/CodyncUI/UpdateNeededCard.swift b/kit/Sources/CodyncUI/UpdateNeededCard.swiftindex 1c635530..71b604b9 100644--- a/kit/Sources/CodyncUI/UpdateNeededCard.swift+++ b/kit/Sources/CodyncUI/UpdateNeededCard.swift@@ -35,6 +35,7 @@ public struct UpdateNeededCard: View {let mismatch: VersionMismatch@Environment(\.appUpdate) private var appUpdate@Environment(\.hostUpdate) private var hostUpdate+ @Environment(AppUpdates.self) private var appUpdates: AppUpdates?public init(store: BotStore, mismatch: VersionMismatch) {self.store = store@@ -56,6 +57,7 @@ public struct UpdateNeededCard: View {if let action {Button(action.title, action: action.run).buttonStyle(.primary)+ .disabled(inReview).padding(.top, 4)}}@@ -68,9 +70,17 @@ public struct UpdateNeededCard: View {var title: String { UpdateNeededText.title(mismatch, host: store.hostName) }var detail: String {- UpdateNeededText.detail(mismatch, host: store.hostName, hostVersion: store.hostVersion?.version,- // With a button here, instructions for that computer would only confuse.- os: store.hello?.os, instructions: action == nil)+ let text = UpdateNeededText.detail(mismatch, host: store.hostName, hostVersion: store.hostVersion?.version,+ // With a button here, instructions for that computer would only confuse.+ os: store.hello?.os, instructions: action == nil)+ return inReview ? "\(text) That version is still in App Store review; it'll be there soon." : text+ }++ /// The App Store doesn't have the app this computer needs yet. An unknown store version+ /// keeps the button: the App Store page itself shows what's there.+ private var inReview: Bool {+ guard case let .updateApp(minimum) = mismatch, let store = appUpdates?.store else { return false }+ return AppVersion.isBelow(store, minimum)}private var action: (title: String, run: () -> Void)? {@@ -112,3 +122,164 @@ public enum UpdateNeededText {}}}++/// What the App Store has, asked now and then (iPhone): the update notice greys out its button+/// while the needed version is in review, and a newer release gets a dismissible reminder.+@MainActor+@Observable+public final class AppUpdates {+ /// The version live in the App Store; nil until asked or when the lookup fails.+ public private(set) var store: String?+ @ObservationIgnored private var askedAt: Date?+ private var dismissedApp: String? = UserDefaults.standard.string(forKey: "dismissedAppUpdate")+ private var dismissedHosts: [String: String] =+ UserDefaults.standard.dictionary(forKey: "dismissedHostUpdates") as? [String: String] ?? [:]++ public init() {}++ /// Asks the App Store at most every few hours (foreground, launch).+ public func refresh() async {+ if let askedAt, Date().timeIntervalSince(askedAt) < 6 * 3600 { return }+ askedAt = Date()+ guard let version = try? await AppStoreRelease.latestVersion() else { return }+ if version != store { Motion.animate { store = version } }+ }++ /// A newer app release to remind about, unless dismissed.+ public var newerApp: String? {+ UpdateReminder.app(current: AppVersion.current, store: store, dismissed: dismissedApp)+ }++ public func dismissApp() {+ Motion.animate { dismissedApp = store }+ UserDefaults.standard.set(store, forKey: "dismissedAppUpdate")+ }++ /// The computer runs an older host than this app, so a newer one exists; not dismissed.+ public func hostBehind(_ store: BotStore) -> Bool {+ store.mismatch == nil && UpdateReminder.host(app: AppVersion.current, host: store.hostVersion?.version,+ dismissed: dismissedHosts[store.computer.id])+ }++ public func dismissHost(_ store: BotStore) {+ Motion.animate { dismissedHosts[store.computer.id] = AppVersion.current }+ UserDefaults.standard.set(dismissedHosts, forKey: "dismissedHostUpdates")+ }+}++/// A quiet, dismissible note that a newer release is out (everything still works).+public struct UpdateReminderCard: View {+ let title: String+ let detail: String+ let actionTitle: String?+ let action: () -> Void+ let dismiss: () -> Void++ public init(title: String, detail: String, actionTitle: String? = nil,+ action: @escaping () -> Void = {}, dismiss: @escaping () -> Void) {+ self.title = title+ self.detail = detail+ self.actionTitle = actionTitle+ self.action = action+ self.dismiss = dismiss+ }++ public var body: some View {+ HStack(alignment: .top, spacing: 12) {+ Image(systemName: "sparkles")+ .appFont(.title3)+ .foregroundStyle(Palette.secondary)+ .accessibilityHidden(true)+ VStack(alignment: .leading, spacing: 6) {+ Text(title).appFont(.subheadline.weight(.semibold)).foregroundStyle(Palette.text)+ Text(detail)+ .appFont(.footnote)+ .foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ if let actionTitle {+ Button(actionTitle, action: action)+ .buttonStyle(.secondary)+ .padding(.top, 4)+ }+ }+ Spacer(minLength: 0)+ IconButton("Dismiss", systemImage: "xmark", action: dismiss)+ .padding(.top, -6)+ .padding(.trailing, -6)+ }+ .padding(14)+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 16, style: .continuous))+ .accessibilityElement(children: .contain)+ }+}++/// The newer-release reminders for the shown computers (and, with `appUpdates`, this app).+public struct UpdateReminders: View {+ let stores: [BotStore]++ public init(stores: [BotStore]) { self.stores = stores }++ public var body: some View {+ // Empty when there's nothing newer: no space taken.+ VStack(spacing: 0) {+ AppUpdateReminder()+ ForEach(stores, id: \.computer.id) { HostUpdateReminder(store: $0) }+ }+ }+}++/// The App Store has a newer app (iPhone; needs `AppUpdates` in the environment).+public struct AppUpdateReminder: View {+ @Environment(AppUpdates.self) private var appUpdates: AppUpdates?+ @Environment(\.appUpdate) private var appUpdate++ public init() {}++ public var body: some View {+ if let appUpdates, let version = appUpdates.newerApp {+ UpdateReminderCard(title: "Codync \(version) is available",+ detail: "You have \(AppVersion.current).",+ actionTitle: appUpdate == nil ? nil : "Update",+ action: { appUpdate?() },+ dismiss: appUpdates.dismissApp)+ .padding(.vertical, 4)+ .transition(.opacity)+ }+ }+}++/// This computer runs an older host than this app.+public struct HostUpdateReminder: View {+ let store: BotStore+ @Environment(AppUpdates.self) private var appUpdates: AppUpdates?+ @Environment(\.hostUpdate) private var hostUpdate++ public init(store: BotStore) { self.store = store }++ public var body: some View {+ if let appUpdates, appUpdates.hostBehind(store) {+ let canUpdate = hostUpdate?.available(store) == true+ UpdateReminderCard(+ title: "Codync \(AppVersion.current) is available for \(store.hostName)",+ detail: UpdateReminderText.host(store, instructions: !canUpdate),+ actionTitle: canUpdate ? "Update" : nil,+ action: { hostUpdate?.action(store) },+ dismiss: { appUpdates.dismissHost(store) })+ .padding(.vertical, 4)+ .transition(.opacity)+ }+ }+}++enum UpdateReminderText {+ @MainActor static func host(_ store: BotStore, instructions: Bool) -> String {+ let runs = "It runs \(store.hostVersion?.version ?? "an older version")."+ guard instructions else { return runs }+ let how = switch store.hello?.os {+ case "macos": "Open Codync on that Mac and choose Check for Updates."+ case "linux": "Run codync-host update there, or use Check for updates in its Codync app."+ default: "Update Codync on that computer."+ }+ return "\(runs) \(how)"+ }+}diff --git a/kit/Tests/CodyncKitTests/CodyncKitTests.swift b/kit/Tests/CodyncKitTests/CodyncKitTests.swiftindex 4cb5e385..17be64ac 100644--- a/kit/Tests/CodyncKitTests/CodyncKitTests.swift+++ b/kit/Tests/CodyncKitTests/CodyncKitTests.swift@@ -109,3 +109,21 @@ import Testing#expect(VersionMismatch.check(app: "2.4.0", minHost: "2.3.0", hostVersion: "2.2.3", minApp: nil) == .updateHost(version: "2.2.3", minimum: "2.3.0"))#expect(VersionMismatch.check(app: "", minHost: "2.3.0", hostVersion: "2.6.0", minApp: "2.5.0") == nil)}++@Test func remindersShowOnlyNewerReleasesNotDismissed() {+ #expect(UpdateReminder.app(current: "2.4.0", store: "2.5.0", dismissed: nil) == "2.5.0")+ #expect(UpdateReminder.app(current: "2.4.0", store: "2.5.0", dismissed: "2.5.0") == nil)+ // Dismissing one release doesn't hide the next one.+ #expect(UpdateReminder.app(current: "2.4.0", store: "2.6.0", dismissed: "2.5.0") == "2.6.0")+ #expect(UpdateReminder.app(current: "2.5.0", store: "2.5.0", dismissed: nil) == nil)+ // A store that lags behind this build (TestFlight, review) or can't be read says nothing.+ #expect(UpdateReminder.app(current: "2.5.0", store: "2.4.0", dismissed: nil) == nil)+ #expect(UpdateReminder.app(current: "2.5.0", store: nil, dismissed: nil) == nil)+ #expect(UpdateReminder.app(current: "", store: "2.5.0", dismissed: nil) == nil)++ #expect(UpdateReminder.host(app: "2.5.0", host: "2.4.3", dismissed: nil))+ #expect(!UpdateReminder.host(app: "2.5.0", host: "2.4.3", dismissed: "2.5.0"))+ #expect(UpdateReminder.host(app: "2.6.0", host: "2.4.3", dismissed: "2.5.0"))+ #expect(!UpdateReminder.host(app: "2.5.0", host: "2.5.0", dismissed: nil))+ #expect(!UpdateReminder.host(app: "2.5.0", host: nil, dismissed: nil))+}