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.

feat(ios): invite ratings after completed conversations

leepokai1e0d15a12880
diff --git a/apps/Codync.xcodeproj/project.pbxproj b/apps/Codync.xcodeproj/project.pbxproj
index 990b0967..3a11fd37 100644
--- a/apps/Codync.xcodeproj/project.pbxproj
+++ b/apps/Codync.xcodeproj/project.pbxproj
@@ -67,6 +67,7 @@
BCB60463C96AF5725EC4A2C7 /* CodyncBot-hex-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D827E43025A592B41CB68EFD /* CodyncBot-hex-Tint.ttf */; };
BF77DD7946621D8818EDAB9B /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A87B0091DAF0E4807D62017 /* SettingsView.swift */; };
C7ED489193AC0934515D2E85 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D0DE72EEAEC947C1D3CA237F /* PrivacyInfo.xcprivacy */; };
+ CF8160C37D98BD7C1472CF49 /* ReviewInvitationModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1B021A5F4CCAA3D180C2CB /* ReviewInvitationModifier.swift */; };
E0D116BF893B81AEC0D2135A /* BotShortcuts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 300202AE0BDAB4961D1E4423 /* BotShortcuts.swift */; };
E695251CFD06AC6F4E3396B7 /* OpenBotIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C4EB0DBA2F08CD7C0E25E30 /* OpenBotIntent.swift */; };
E78E3B5FAFEB79F31AAC104D /* CodyncBot-teardrop-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C8F46BD8301E7E2C83C35111 /* CodyncBot-teardrop-Tint.ttf */; };
@@ -158,6 +159,7 @@
B274A0195CB3B2409EA4C194 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
B6E13F8EA6C7B0DA4D899FEE /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
B97102DEC6029268332DF901 /* AccessRequestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessRequestView.swift; sourceTree = "<group>"; };
+ BB1B021A5F4CCAA3D180C2CB /* ReviewInvitationModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewInvitationModifier.swift; sourceTree = "<group>"; };
C3BB9F034194450254CE14EC /* CodyncBot-wedge-Tint.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-wedge-Tint.ttf"; sourceTree = "<group>"; };
C484135603CEF437C27BE67B /* CodyncBot-blob-Ink.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-blob-Ink.ttf"; sourceTree = "<group>"; };
C518FF3FFD22C3A114B6D1B8 /* AppStore+Shortcuts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppStore+Shortcuts.swift"; sourceTree = "<group>"; };
@@ -307,6 +309,7 @@
73D324231A9BCE79C84C0403 /* LanguageSettings.swift */,
6FC76D28AB02DF1427D530ED /* LaunchSplash.swift */,
ECD0B4EA4BBA2BB2826C4362 /* PairingView.swift */,
+ BB1B021A5F4CCAA3D180C2CB /* ReviewInvitationModifier.swift */,
B6E13F8EA6C7B0DA4D899FEE /* RootView.swift */,
0A87B0091DAF0E4807D62017 /* SettingsView.swift */,
9AD0BD16672E128A4F26272B /* SignInButtons.swift */,
@@ -696,6 +699,7 @@
E695251CFD06AC6F4E3396B7 /* OpenBotIntent.swift in Sources */,
719EABCBBAC0A973D729363A /* PairingView.swift in Sources */,
89CA3972915769DBA315876F /* Push.swift in Sources */,
+ CF8160C37D98BD7C1472CF49 /* ReviewInvitationModifier.swift in Sources */,
0631979397E0D6822747E03A /* RootView.swift in Sources */,
BF77DD7946621D8818EDAB9B /* SettingsView.swift in Sources */,
76E77CC8A2B7C74213512FAB /* SignInButtons.swift in Sources */,
diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swift
index 43b1337e..4be13936 100644
--- a/apps/ios/App/CodyncApp.swift
+++ b/apps/ios/App/CodyncApp.swift
@@ -68,6 +68,7 @@ struct CodyncApp: App {
}
.onOpenURL { url in app.open(url) }
.onChange(of: scenePhase, initial: true) { _, phase in
+ ReviewInvitation.shared.setActive(phase == .active)
switch phase {
case .active: Analytics.shared.becameActive()
case .background: BackgroundTime.run("Analytics") { await Analytics.shared.enteredBackground() }
diff --git a/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift b/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift
index bfbaeb56..1413a495 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift
@@ -25,6 +25,12 @@ public enum AnalyticsEvent: Equatable, Sendable {
/// never), reconnects, the first phase stuck too long, why it failed.
case voiceCallQuality(VoiceEngine, readyMs: Int?, reconnects: Int, stuck: VoiceStuck, failure: VoiceFailure)
case screenViewed(Screen)
+ case reviewOpportunity(completed: Int)
+ case reviewCancelled(ReviewCancellation)
+ case reviewRequested(completed: Int)
+ case reviewLinkOpened
+
+ public enum ReviewCancellation: String, Sendable { case background, interaction, unavailable }
public enum Notifications: String, Sendable { case allowed, denied, notAsked = "not_asked" }
public enum OnboardingStep: String, Sendable { case welcome, install, scan }
@@ -36,7 +42,7 @@ public enum AnalyticsEvent: Equatable, Sendable {
public enum PromptSource: String, Sendable { case settings, widgets }
public enum Setting: String, Sendable { case push, liveActivities = "live_activities" }
public enum Link: String, Sendable {
- case github, appStore = "app_store", demo, tailscale, privacy, installCommand = "install_command"
+ case github, issues, appStore = "app_store", demo, tailscale, privacy, installCommand = "install_command"
}
public enum VoiceEngine: String, Sendable { case onDevice = "on_device", openai, gemini, cloud }
public enum VoiceStuck: String, Sendable { case none, connecting, reconnecting, speaking }
@@ -110,6 +116,10 @@ public enum AnalyticsEvent: Equatable, Sendable {
case .voiceCallStarted: "voice_call_started"
case .voiceCallQuality: "voice_call_quality"
case .screenViewed: "screen_viewed"
+ case .reviewOpportunity: "review_opportunity"
+ case .reviewCancelled: "review_cancelled"
+ case .reviewRequested: "review_requested"
+ case .reviewLinkOpened: "review_link_opened"
}
}
@@ -139,6 +149,10 @@ public enum AnalyticsEvent: Equatable, Sendable {
"stuck": .string(stuck.rawValue), "failure": .string(failure.rawValue)]
p["ready_ms"] = readyMs.map(Analytics.Value.int)
return p
+ case let .reviewOpportunity(completed), let .reviewRequested(completed):
+ return ["completed_interactions": .int(completed), "policy": .string("v1"), "trigger": .string("return_to_bots")]
+ case let .reviewCancelled(reason): return ["reason": .string(reason.rawValue), "policy": .string("v1")]
+ case .reviewLinkOpened: return ["source": .string("settings")]
case let .screenViewed(screen): return ["screen": .string(screen.rawValue)]
}
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/Compatibility.swift b/apps/ios/Kit/Sources/CodyncKit/Models/Compatibility.swift
index c319bf93..7b722451 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Models/Compatibility.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Models/Compatibility.swift
@@ -66,6 +66,8 @@ public enum AppStoreRelease {
public static let appID = "6760984418"
public static let page = URL(string: "https://apps.apple.com/app/id\(appID)")!
+ public static let reviewPage = URL(string: "https://apps.apple.com/app/id\(appID)?action=write-review")!
+
/// 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 {
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
index b57789b4..c1532b78 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
@@ -1237,5 +1237,6 @@
"Codync {version} is currently the newest version available.": "Codync {version} ist die neueste verfügbare Version.",
"Install it first.": "Installiere es zuerst.",
"Not set up on {name} yet.": "Auf {name} noch nicht eingerichtet.",
- "Downloads {name} on {host} if it needs to, then checks its sign-in.": "Lädt {name} bei Bedarf auf {host} herunter und prüft dann die Anmeldung."
+ "Downloads {name} on {host} if it needs to, then checks its sign-in.": "Lädt {name} bei Bedarf auf {host} herunter und prüft dann die Anmeldung.",
+ "Rate on the App Store": "Im App Store bewerten"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
index 45064a08..5d540799 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
@@ -1237,5 +1237,6 @@
"Codync {version} is currently the newest version available.": "Codync {version} es la versión más reciente disponible.",
"Install it first.": "Instálalo primero.",
"Not set up on {name} yet.": "Aún no está configurado en {name}.",
- "Downloads {name} on {host} if it needs to, then checks its sign-in.": "Descarga {name} en {host} si hace falta y luego comprueba su inicio de sesión."
+ "Downloads {name} on {host} if it needs to, then checks its sign-in.": "Descarga {name} en {host} si hace falta y luego comprueba su inicio de sesión.",
+ "Rate on the App Store": "Valorar en el App Store"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
index e82e7416..1e6c02aa 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
@@ -1237,5 +1237,6 @@
"Codync {version} is currently the newest version available.": "Codync {version} est la version la plus récente disponible.",
"Install it first.": "Installez-le d'abord.",
"Not set up on {name} yet.": "Pas encore configuré sur {name}.",
- "Downloads {name} on {host} if it needs to, then checks its sign-in.": "Télécharge {name} sur {host} si besoin, puis vérifie sa connexion."
+ "Downloads {name} on {host} if it needs to, then checks its sign-in.": "Télécharge {name} sur {host} si besoin, puis vérifie sa connexion.",
+ "Rate on the App Store": "Noter sur l’App Store"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
index 748a44c8..359a63f2 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
@@ -1237,5 +1237,6 @@
"Codync {version} is currently the newest version available.": "Codync {version} は現在入手できる最新バージョンです。",
"Install it first.": "先にインストールしてください。",
"Not set up on {name} yet.": "{name} ではまだセットアップされていません。",
- "Downloads {name} on {host} if it needs to, then checks its sign-in.": "必要なら {host} に {name} をダウンロードし、サインイン状態を確認します。"
+ "Downloads {name} on {host} if it needs to, then checks its sign-in.": "必要なら {host} に {name} をダウンロードし、サインイン状態を確認します。",
+ "Rate on the App Store": "App Store で評価"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
index 713772e5..8e7bc719 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
@@ -1237,5 +1237,6 @@
"Codync {version} is currently the newest version available.": "Codync {version}은(는) 현재 사용 가능한 최신 버전입니다.",
"Install it first.": "먼저 설치하세요.",
"Not set up on {name} yet.": "{name}에 아직 설정되지 않았습니다.",
- "Downloads {name} on {host} if it needs to, then checks its sign-in.": "필요하면 {host}에 {name}을(를) 내려받은 뒤 로그인 상태를 확인합니다."
+ "Downloads {name} on {host} if it needs to, then checks its sign-in.": "필요하면 {host}에 {name}을(를) 내려받은 뒤 로그인 상태를 확인합니다.",
+ "Rate on the App Store": "App Store에서 평가하기"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
index 0a5776e2..0193d145 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
@@ -1237,5 +1237,6 @@
"Codync {version} is currently the newest version available.": "Codync {version} 是目前最新的版本。",
"Install it first.": "请先安装。",
"Not set up on {name} yet.": "还没在 {name} 上设置。",
- "Downloads {name} on {host} if it needs to, then checks its sign-in.": "需要的话会在 {host} 上下载 {name},再检查登录状态。"
+ "Downloads {name} on {host} if it needs to, then checks its sign-in.": "需要的话会在 {host} 上下载 {name},再检查登录状态。",
+ "Rate on the App Store": "在 App Store 评分"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
index 73ee26a7..8791369b 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
@@ -1237,5 +1237,6 @@
"Codync {version} is currently the newest version available.": "Codync {version} 是目前最新的版本。",
"Install it first.": "請先安裝。",
"Not set up on {name} yet.": "還沒在 {name} 上設定。",
- "Downloads {name} on {host} if it needs to, then checks its sign-in.": "需要的話會在 {host} 上下載 {name},再檢查登入狀態。"
+ "Downloads {name} on {host} if it needs to, then checks its sign-in.": "需要的話會在 {host} 上下載 {name},再檢查登入狀態。",
+ "Rate on the App Store": "在 App Store 評分"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Review/ReviewCompletion.swift b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewCompletion.swift
new file mode 100644
index 00000000..a408a174
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewCompletion.swift
@@ -0,0 +1,20 @@
+import Foundation
+
+/// Uses host-owned turn IDs/final flags; never infers satisfaction from message content.
+enum ReviewCompletion {
+ static func match(entries: [Entry], sent: [String: Date], now: Date) -> [String]? {
+ let chat = entries.filter { $0.isChat && $0.data.call == nil }
+ guard let final = chat.last, final.kind == "agent", final.data.final == true, final.turn > 0 else { return nil }
+ let turn = entries.filter { $0.turn == final.turn }
+ // Non-successful completions and stops produce notices; be conservative about all notices.
+ guard !turn.contains(where: { $0.kind == "notice" || $0.data.status == "failed" || $0.data.status == "cancelled" }) else { return nil }
+ let nonces = turn.compactMap { entry -> String? in
+ guard entry.kind == "user", entry.data.status == "sent", entry.data.call == nil,
+ entry.data.routineId == nil, entry.data.from == nil,
+ let nonce = entry.data.clientNonce, let date = sent[nonce],
+ now.timeIntervalSince(date) < 30 * ReviewHistory.day else { return nil }
+ return nonce
+ }
+ return nonces.isEmpty ? nil : nonces
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Review/ReviewHistory.swift b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewHistory.swift
new file mode 100644
index 00000000..8a539da4
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewHistory.swift
@@ -0,0 +1,40 @@
+import Foundation
+
+/// Device-local StoreKit policy. Requests are attempts, never evidence of a rating.
+struct ReviewHistory: Codable {
+ struct Request: Codable {
+ let date: Date
+ let version: String
+ let completed: Int
+ }
+
+ static let day: TimeInterval = 86_400
+ var firstUse: Date
+ var activeDays: Set<String> = []
+ var completed = 0
+ var requests: [Request] = []
+ var requestedVersions: Set<String> = []
+ var sent: [String: Date] = [:]
+
+ mutating func recordActivity(at now: Date) {
+ let parts = Calendar.current.dateComponents([.year, .month, .day], from: now)
+ activeDays.insert("\(parts.year ?? 0)-\(parts.month ?? 0)-\(parts.day ?? 0)")
+ // Only the three-day milestone matters; retain a bounded set after reaching it.
+ if activeDays.count > 3 { activeDays = Set(activeDays.sorted().suffix(3)) }
+ }
+
+ func eligible(at now: Date, version: String) -> Bool {
+ guard now.timeIntervalSince(firstUse) >= 7 * Self.day,
+ activeDays.count >= 3, completed >= 5,
+ !requestedVersions.contains(version),
+ requests.filter({ now.timeIntervalSince($0.date) < 365 * Self.day }).count < 2 else { return false }
+ guard let last = requests.last else { return true }
+ return now.timeIntervalSince(last.date) >= 120 * Self.day && completed - last.completed >= 5
+ }
+
+ mutating func recordRequest(at now: Date, version: String) {
+ requestedVersions.insert(version)
+ requests.removeAll { now.timeIntervalSince($0.date) >= 365 * Self.day }
+ requests.append(Request(date: now, version: version, completed: completed))
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Review/ReviewInvitation.swift b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewInvitation.swift
new file mode 100644
index 00000000..24ca8312
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewInvitation.swift
@@ -0,0 +1,110 @@
+import Foundation
+import Observation
+import os
+
+/// The iPhone's StoreKit invitation state; never sent to the host or shared with widgets.
+@MainActor @Observable
+public final class ReviewInvitation {
+ public static let shared = ReviewInvitation()
+ static let storageKey = "reviewInvitation.v1"
+ private static let log = Logger(subsystem: "com.pokai.Codync", category: "ReviewInvitation")
+ private let defaults: UserDefaults
+ private let capture: @MainActor (AnalyticsEvent) -> Void
+ private var history: ReviewHistory
+ private var activeSince: Date?
+ private var viewedChat: String?
+ public private(set) var opportunity: UUID?
+ private var interruptions: Set<UUID> = []
+ public var isInterrupted: Bool { !interruptions.isEmpty }
+
+ init(defaults: UserDefaults = .standard, now: Date = .now,
+ capture: @escaping @MainActor (AnalyticsEvent) -> Void = { Analytics.shared.capture($0) }) {
+ self.defaults = defaults
+ self.capture = capture
+ if let data = defaults.data(forKey: Self.storageKey) {
+ do { history = try JSONDecoder().decode(ReviewHistory.self, from: data) }
+ catch {
+ Self.log.error("Cannot read review history: \(error.localizedDescription)")
+ history = ReviewHistory(firstUse: now)
+ }
+ } else { history = ReviewHistory(firstUse: now) }
+ prune(at: now)
+ save()
+ }
+
+ public func setInterrupted(_ token: UUID, active: Bool) {
+ if active {
+ interruptions.insert(token)
+ cancel(.unavailable)
+ } else { interruptions.remove(token) }
+ }
+
+ public func setActive(_ active: Bool, now: Date = .now) {
+ if active {
+ prune(at: now)
+ save()
+ if activeSince == nil { activeSince = now }
+ } else {
+ activeSince = nil
+ viewedChat = nil
+ cancel(.background)
+ }
+ }
+
+ public func sent(_ nonce: String, now: Date = .now) {
+ prune(at: now)
+ if history.sent.count >= 100, let oldest = history.sent.min(by: { $0.value < $1.value })?.key {
+ history.sent[oldest] = nil
+ }
+ history.sent[nonce] = now
+ history.recordActivity(at: now)
+ viewedChat = nil
+ cancel(.interaction)
+ save()
+ }
+
+ /// Called only after an unobscured final answer at the bottom of the chat stayed visible.
+ public func viewed(chat: String, entries: [Entry], now: Date = .now) {
+ guard activeSince != nil, !isInterrupted,
+ let result = ReviewCompletion.match(entries: entries, sent: history.sent, now: now) else { return }
+ for nonce in result { history.sent[nonce] = nil }
+ history.completed += 1
+ history.recordActivity(at: now)
+ viewedChat = chat
+ save()
+ }
+
+ public func returned(from chat: String, version: String = AppVersion.current, now: Date = .now) {
+ defer { viewedChat = nil }
+ guard !isInterrupted, viewedChat == chat, let activeSince, now.timeIntervalSince(activeSince) >= 60,
+ history.eligible(at: now, version: version) else { return }
+ opportunity = UUID()
+ capture(.reviewOpportunity(completed: history.completed))
+ }
+
+ public func cancel(_ reason: AnalyticsEvent.ReviewCancellation) {
+ guard opportunity != nil else { return }
+ opportunity = nil
+ capture(.reviewCancelled(reason))
+ }
+
+ /// Persist before StoreKit: an undisplayed request still consumes our own cooldown.
+ public func request(_ token: UUID, version: String = AppVersion.current, now: Date = .now) -> Bool {
+ guard !isInterrupted, opportunity == token, let activeSince, now.timeIntervalSince(activeSince) >= 60,
+ history.eligible(at: now, version: version) else { return false }
+ opportunity = nil
+ history.recordRequest(at: now, version: version)
+ save()
+ capture(.reviewRequested(completed: history.completed))
+ return true
+ }
+
+ private func prune(at now: Date) {
+ history.sent = history.sent.filter { now.timeIntervalSince($0.value) < 30 * ReviewHistory.day }
+ }
+
+ private func save() {
+ do { defaults.set(try JSONEncoder().encode(history), forKey: Self.storageKey) }
+ catch { Self.log.error("Cannot save review history: \(error.localizedDescription)") }
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Chrome.swift b/apps/ios/Kit/Sources/CodyncUI/Chrome.swift
index d30b2fca..0014b1a6 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Chrome.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Chrome.swift
@@ -166,16 +166,19 @@ public extension View {
/// Content titles itself with `ModalHeader` and closes with `\.dismissModal`.
func codyncSheet<Sheet: View>(isPresented: Binding<Bool>, @ViewBuilder content: @escaping () -> Sheet) -> some View {
modifier(CodyncSheet(isPresented: isPresented, sheet: content))
+ .reviewInterruption(active: isPresented.wrappedValue)
}
func codyncSheet<Item: Identifiable, Sheet: View>(item: Binding<Item?>, @ViewBuilder content: @escaping (Item) -> Sheet) -> some View {
modifier(CodyncItemSheet(item: item, sheet: content))
+ .reviewInterruption(active: item.wrappedValue != nil)
}
/// Presents a full-window layer the content draws itself (dialogs, the remote screen), fading in and out.
/// `close` animates it away.
func codyncOverlay<Layer: View>(isPresented: Binding<Bool>, @ViewBuilder content: @escaping (_ close: @escaping () -> Void) -> Layer) -> some View {
modifier(CodyncOverlay(isPresented: isPresented, layer: content))
+ .reviewInterruption(active: isPresented.wrappedValue)
}
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Dialog.swift b/apps/ios/Kit/Sources/CodyncUI/Dialog.swift
index 2430876b..96c31e83 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Dialog.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Dialog.swift
@@ -27,6 +27,7 @@ public extension View {
actions: @escaping () -> [DialogAction]) -> some View {
modifier(CodyncDialog(title: title, message: message, cancel: cancel, inPlace: inPlace,
isPresented: isPresented, actions: actions))
+ .reviewInterruption(active: isPresented.wrappedValue)
}
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/ReviewInterruption.swift b/apps/ios/Kit/Sources/CodyncUI/ReviewInterruption.swift
new file mode 100644
index 00000000..20f3a837
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncUI/ReviewInterruption.swift
@@ -0,0 +1,21 @@
+import CodyncKit
+import SwiftUI
+
+extension View {
+ /// Shared presentations and editing suspend the continuous result-reading timer.
+ func reviewInterruption(active: Bool) -> some View {
+ modifier(ReviewInterruption(active: active))
+ }
+}
+
+private struct ReviewInterruption: ViewModifier {
+ let active: Bool
+ @State private var token = UUID()
+
+ func body(content: Content) -> some View {
+ content
+ .onAppear { ReviewInvitation.shared.setInterrupted(token, active: active) }
+ .onChange(of: active) { _, active in ReviewInvitation.shared.setInterrupted(token, active: active) }
+ .onDisappear { ReviewInvitation.shared.setInterrupted(token, active: false) }
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift
index 924992cd..f371adfd 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift
@@ -72,6 +72,7 @@ extension BotStore {
pasted: [String] = [], call: String? = nil) -> Task<SendProgress, Never>? {
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty || !files.isEmpty, !retired else { return nil }
+ if call == nil { ReviewInvitation.shared.sent(nonce) }
var data = EntryData(text: trimmed, status: "sending", clientNonce: nonce)
data.call = call
// Shown at once; the computer's own quote replaces it.
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
index b8cd964d..9172df52 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
@@ -143,6 +143,8 @@ struct Composer: View {
append(picked.map(\.file))
return true
}
+ .reviewInterruption(active: focused || pickingFiles || pickingPhotos || !files.isEmpty
+ || dictation.listening || dictation.transcribing)
.fileImporter(isPresented: $pickingFiles, allowedContentTypes: [.item], allowsMultipleSelection: true) { result in
if case .success(let urls) = result { add(urls) }
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ReviewReading.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ReviewReading.swift
new file mode 100644
index 00000000..0db681ee
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ReviewReading.swift
@@ -0,0 +1,32 @@
+import CodyncKit
+import SwiftUI
+
+extension View {
+ func reviewReading(botId: String, unobscured: Bool) -> some View {
+ modifier(ReviewReading(botId: botId, unobscured: unobscured))
+ }
+}
+
+private struct ReviewReading: ViewModifier {
+ let botId: String
+ let unobscured: Bool
+ @Environment(BotStore.self) private var model
+ @Environment(\.scenePhase) private var phase
+
+ private struct Reading: Equatable {
+ let entries: [Entry]
+ let ready: Bool
+ }
+
+ func body(content: Content) -> some View {
+ let reading = Reading(entries: model.chat(botId), ready: unobscured && !ReviewInvitation.shared.isInterrupted && phase == .active
+ && model.connection == .online && model.mismatch == nil && model.lastError == nil
+ && model.screenRequest == nil && model.bots[botId]?.status == "idle")
+ content.task(id: reading) {
+ guard reading.ready else { return }
+ do { try await Task.sleep(for: .seconds(3)) } catch { return }
+ guard !Task.isCancelled else { return }
+ ReviewInvitation.shared.viewed(chat: "\(model.storage.id)/\(model.computer.id)/\(botId)", entries: reading.entries)
+ }
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift
index f77d74a7..25d23d26 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift
@@ -65,6 +65,9 @@ public struct ThreadView: View {
var conversation: some View {
chrome(chat)
.readingConversation(botId)
+ .reviewReading(botId: botId, unobscured: following && !calling && !showTrace && botChat == nil
+ && openArtifact == nil && openCall == nil && details == nil && !editingGroup
+ && model.composerDraft(for: botId).isEmpty && model.fileDownloads.export == nil)
.onChange(of: model.voiceCallRequest, initial: true) { _, _ in
if model.takeVoiceCallRequest(for: botId) { startShortcutCall() }
}
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/ReviewInvitationTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/ReviewInvitationTests.swift
new file mode 100644
index 00000000..c632d00b
--- /dev/null
+++ b/apps/ios/Kit/Tests/CodyncKitTests/ReviewInvitationTests.swift
@@ -0,0 +1,214 @@
+import Foundation
+import Testing
+@testable import CodyncKit
+
+private let reviewNow = Date(timeIntervalSince1970: 1_800_000_000)
+
+private func eligibleHistory() -> ReviewHistory {
+ ReviewHistory(firstUse: reviewNow.addingTimeInterval(-8 * ReviewHistory.day),
+ activeDays: ["2026-1-1", "2026-1-2", "2026-1-3"], completed: 5)
+}
+
+@Test func reviewRequiresAgeActiveDaysAndCompletedInteractions() {
+ let now = reviewNow
+ var history = eligibleHistory()
+ #expect(history.eligible(at: now, version: "2.29.0"))
+ history.firstUse = now.addingTimeInterval(-7 * ReviewHistory.day + 1)
+ #expect(!history.eligible(at: now, version: "2.29.0"))
+ history.firstUse = now.addingTimeInterval(-7 * ReviewHistory.day)
+ #expect(history.eligible(at: now, version: "2.29.0"))
+ history.activeDays.remove("2026-1-3")
+ #expect(!history.eligible(at: now, version: "2.29.0"))
+ history = eligibleHistory()
+ history.completed = 4
+ #expect(!history.eligible(at: now, version: "2.29.0"))
+}
+
+@Test func reviewCooldownSurvivesVersionsAndRequiresNewUse() {
+ var history = eligibleHistory()
+ history.recordRequest(at: reviewNow, version: "2.29.0")
+ history.completed += 5
+ #expect(!history.eligible(at: reviewNow.addingTimeInterval(120 * ReviewHistory.day - 1), version: "2.30.0"))
+ let later = reviewNow.addingTimeInterval(120 * ReviewHistory.day)
+ #expect(!history.eligible(at: later, version: "2.29.0"))
+ #expect(history.eligible(at: later, version: "2.30.0"))
+ history.completed -= 1
+ #expect(!history.eligible(at: later, version: "2.30.0"))
+}
+
+@Test func reviewAllowsAtMostTwoRequestsInRollingYear() {
+ var history = eligibleHistory()
+ history.recordRequest(at: reviewNow, version: "2.29.0")
+ history.completed += 5
+ history.recordRequest(at: reviewNow.addingTimeInterval(120 * ReviewHistory.day), version: "2.30.0")
+ history.completed += 5
+ #expect(!history.eligible(at: reviewNow.addingTimeInterval(364 * ReviewHistory.day), version: "2.31.0"))
+ #expect(history.eligible(at: reviewNow.addingTimeInterval(365 * ReviewHistory.day), version: "2.31.0"))
+}
+
+private func reviewEntries(nonce: String = "local-send", turn: Int64 = 1) -> [Entry] {
+ var final = EntryData(text: "Done")
+ final.final = true
+ return [
+ Entry(id: "u", seq: 1, botId: "b", rev: 1, kind: "user", turn: turn,
+ data: EntryData(text: "Hello", status: "sent", clientNonce: nonce), createdAt: 1, updatedAt: 1),
+ Entry(id: "a", seq: 2, botId: "b", rev: 2, kind: "agent", turn: turn, data: final, createdAt: 2, updatedAt: 2),
+ ]
+}
+
+@Test func reviewIgnoresHistoricalOtherDeviceAndExpiredSends() {
+ let entries = reviewEntries()
+ #expect(ReviewCompletion.match(entries: entries, sent: [:], now: reviewNow) == nil)
+ #expect(ReviewCompletion.match(entries: entries, sent: ["another-device": reviewNow], now: reviewNow) == nil)
+ #expect(ReviewCompletion.match(entries: entries, sent: ["local-send": reviewNow.addingTimeInterval(-30 * ReviewHistory.day)], now: reviewNow) == nil)
+ #expect(ReviewCompletion.match(entries: entries, sent: ["local-send": reviewNow], now: reviewNow) == ["local-send"])
+}
+
+@Test func reviewIgnoresPartialFailedCancelledAndRoutineTurns() {
+ let sent = ["local-send": reviewNow]
+ var entries = reviewEntries()
+ entries[1].data.final = false
+ #expect(ReviewCompletion.match(entries: entries, sent: sent, now: reviewNow) == nil)
+ for status in ["failed", "cancelled", "queued"] {
+ entries = reviewEntries()
+ entries[0].data.status = status
+ #expect(ReviewCompletion.match(entries: entries, sent: sent, now: reviewNow) == nil)
+ }
+ entries = reviewEntries()
+ entries[0].data.routineId = "routine"
+ #expect(ReviewCompletion.match(entries: entries, sent: sent, now: reviewNow) == nil)
+ entries = reviewEntries()
+ var notice = entries[1]
+ notice.id = "stop"; notice.kind = "notice"; notice.data = EntryData(text: "Stopped.")
+ entries.append(notice)
+ #expect(ReviewCompletion.match(entries: entries, sent: sent, now: reviewNow) == nil)
+}
+
+@MainActor
+@Test func reviewCountsTurnOnceAcrossReplaysAndRelaunch() throws {
+ let suite = UUID().uuidString
+ let defaults = UserDefaults(suiteName: suite)!
+ defer { defaults.removePersistentDomain(forName: suite) }
+ let tracker = ReviewInvitation(defaults: defaults, now: reviewNow, capture: { _ in })
+ tracker.setActive(true, now: reviewNow)
+ tracker.sent("local-send", now: reviewNow)
+ tracker.viewed(chat: "c/b", entries: reviewEntries(), now: reviewNow)
+ tracker.viewed(chat: "c/b", entries: reviewEntries(), now: reviewNow)
+ let relaunched = ReviewInvitation(defaults: defaults, now: reviewNow, capture: { _ in })
+ relaunched.setActive(true, now: reviewNow)
+ relaunched.viewed(chat: "c/b", entries: reviewEntries(), now: reviewNow)
+ let history = try JSONDecoder().decode(ReviewHistory.self, from: #require(defaults.data(forKey: ReviewInvitation.storageKey)))
+ #expect(history.completed == 1)
+}
+
+@MainActor
+@Test func reviewOnlyRequestsAfterReturnAndCancelsOnBackground() throws {
+ let suite = UUID().uuidString
+ let defaults = UserDefaults(suiteName: suite)!
+ defer { defaults.removePersistentDomain(forName: suite) }
+ try defaults.set(JSONEncoder().encode(eligibleHistory()), forKey: ReviewInvitation.storageKey)
+ var events: [AnalyticsEvent] = []
+ let tracker = ReviewInvitation(defaults: defaults, now: reviewNow, capture: { events.append($0) })
+ tracker.setActive(true, now: reviewNow)
+ tracker.sent("local-send", now: reviewNow)
+ tracker.viewed(chat: "c/b", entries: reviewEntries(), now: reviewNow)
+ #expect(tracker.opportunity == nil)
+ tracker.returned(from: "c/b", version: "2.29.0", now: reviewNow.addingTimeInterval(59))
+ #expect(tracker.opportunity == nil)
+ tracker.sent("next", now: reviewNow)
+ tracker.viewed(chat: "c/b", entries: reviewEntries(nonce: "next", turn: 2), now: reviewNow)
+ tracker.returned(from: "c/b", version: "2.29.0", now: reviewNow.addingTimeInterval(60))
+ let token = try #require(tracker.opportunity)
+ tracker.setActive(false)
+ #expect(!tracker.request(token, version: "2.29.0", now: reviewNow.addingTimeInterval(62)))
+ #expect(events.last == .reviewCancelled(.background))
+ tracker.setActive(true, now: reviewNow.addingTimeInterval(100))
+ #expect(tracker.opportunity == nil)
+}
+
+@MainActor
+@Test func reviewRequestPersistsBeforeCallingStoreKitAndRespectsAnalyticsOptOut() throws {
+ let suite = UUID().uuidString
+ let defaults = UserDefaults(suiteName: suite)!
+ defer { defaults.removePersistentDomain(forName: suite) }
+ defaults.set(false, forKey: Analytics.enabledKey)
+ let analytics = Analytics(defaults: defaults, upload: { _ in true })
+ try defaults.set(JSONEncoder().encode(eligibleHistory()), forKey: ReviewInvitation.storageKey)
+ let tracker = ReviewInvitation(defaults: defaults, now: reviewNow, capture: { analytics.capture($0) })
+ tracker.setActive(true, now: reviewNow)
+ tracker.sent("local-send", now: reviewNow)
+ tracker.viewed(chat: "c/b", entries: reviewEntries(), now: reviewNow)
+ tracker.returned(from: "c/b", version: "2.29.0", now: reviewNow.addingTimeInterval(60))
+ let token = try #require(tracker.opportunity)
+ #expect(tracker.request(token, version: "2.29.0", now: reviewNow.addingTimeInterval(62)))
+ #expect(!tracker.request(token, version: "2.29.0", now: reviewNow.addingTimeInterval(63)))
+ let history = try JSONDecoder().decode(ReviewHistory.self, from: #require(defaults.data(forKey: ReviewInvitation.storageKey)))
+ #expect(history.requests.count == 1)
+ #expect(!history.eligible(at: reviewNow.addingTimeInterval(63), version: "2.30.0"))
+ #expect(analytics.pending.isEmpty)
+}
+
+@Test func reviewAnalyticsContainsOnlyCountsAndFixedNames() {
+ #expect(AnalyticsEvent.reviewRequested(completed: 8).name == "review_requested")
+ #expect(AnalyticsEvent.reviewRequested(completed: 8).properties == [
+ "completed_interactions": .int(8), "policy": .string("v1"), "trigger": .string("return_to_bots"),
+ ])
+ #expect(AnalyticsEvent.reviewCancelled(.interaction).properties["reason"] == .string("interaction"))
+ #expect(AnalyticsEvent.reviewLinkOpened.properties == ["source": .string("settings")])
+}
+
+@MainActor
+@Test func reviewDoesNotCountResultsBehindNestedPresentations() throws {
+ let suite = UUID().uuidString
+ let defaults = UserDefaults(suiteName: suite)!
+ defer { defaults.removePersistentDomain(forName: suite) }
+ let tracker = ReviewInvitation(defaults: defaults, now: reviewNow, capture: { _ in })
+ tracker.setActive(true, now: reviewNow)
+ tracker.sent("local-send", now: reviewNow)
+ let sheet = UUID(), picker = UUID()
+ tracker.setInterrupted(sheet, active: true)
+ tracker.setInterrupted(picker, active: true)
+ tracker.setInterrupted(sheet, active: false)
+ tracker.viewed(chat: "c/b", entries: reviewEntries(), now: reviewNow)
+ var history = try JSONDecoder().decode(ReviewHistory.self, from: #require(defaults.data(forKey: ReviewInvitation.storageKey)))
+ #expect(history.completed == 0)
+ #expect(history.sent["local-send"] != nil)
+ tracker.setInterrupted(picker, active: false)
+ tracker.viewed(chat: "c/b", entries: reviewEntries(), now: reviewNow)
+ history = try JSONDecoder().decode(ReviewHistory.self, from: #require(defaults.data(forKey: ReviewInvitation.storageKey)))
+ #expect(history.completed == 1)
+}
+
+@MainActor
+@Test func reviewRemovesExpiredNoncesOnNextLaunch() throws {
+ let suite = UUID().uuidString
+ let defaults = UserDefaults(suiteName: suite)!
+ defer { defaults.removePersistentDomain(forName: suite) }
+ var history = eligibleHistory()
+ history.sent = ["old": reviewNow.addingTimeInterval(-30 * ReviewHistory.day), "recent": reviewNow]
+ try defaults.set(JSONEncoder().encode(history), forKey: ReviewInvitation.storageKey)
+ _ = ReviewInvitation(defaults: defaults, now: reviewNow, capture: { _ in })
+ let saved = try JSONDecoder().decode(ReviewHistory.self, from: #require(defaults.data(forKey: ReviewInvitation.storageKey)))
+ #expect(saved.sent == ["recent": reviewNow])
+}
+
+@Test func reviewCountsSeveralMessagesInOneTurnTogetherAndExcludesCalls() {
+ var entries = reviewEntries()
+ var second = entries[0]
+ second.id = "u2"; second.seq = 2; second.data.clientNonce = "second"
+ entries.insert(second, at: 1)
+ #expect(ReviewCompletion.match(entries: entries, sent: ["local-send": reviewNow, "second": reviewNow], now: reviewNow) == ["local-send", "second"])
+ entries = reviewEntries()
+ entries[0].data.call = "voice"
+ #expect(ReviewCompletion.match(entries: entries, sent: ["local-send": reviewNow], now: reviewNow) == nil)
+}
+
+@Test func reviewRemembersVersionsAfterOldAttemptsExpire() {
+ var history = eligibleHistory()
+ history.recordRequest(at: reviewNow, version: "2.29.0")
+ history.completed += 5
+ let nextYear = reviewNow.addingTimeInterval(366 * ReviewHistory.day)
+ history.recordRequest(at: nextYear, version: "2.30.0")
+ history.completed += 5
+ #expect(!history.eligible(at: nextYear.addingTimeInterval(120 * ReviewHistory.day), version: "2.29.0"))
+}
diff --git a/apps/ios/Views/BotListView.swift b/apps/ios/Views/BotListView.swift
index d09f5d34..9cd5dfd2 100644
--- a/apps/ios/Views/BotListView.swift
+++ b/apps/ios/Views/BotListView.swift
@@ -106,6 +106,8 @@ struct BotListView: View {
.listRowSeparator(.hidden)
.listRowBackground(Color.clear)
}
+ .reviewInvitation(blocked: creating != nil || editing != nil || editingGroup != nil
+ || confirmDelete != nil || confirmNewSession != nil || lifted != nil)
.listStyle(.plain)
.scrollContentBackground(.hidden)
.environment(\.defaultMinListRowHeight, 0)
diff --git a/apps/ios/Views/ReviewInvitationModifier.swift b/apps/ios/Views/ReviewInvitationModifier.swift
new file mode 100644
index 00000000..0b479041
--- /dev/null
+++ b/apps/ios/Views/ReviewInvitationModifier.swift
@@ -0,0 +1,56 @@
+import CodyncKit
+import CodyncUI
+import StoreKit
+import SwiftUI
+
+extension View {
+ func reviewInvitation(blocked: Bool) -> some View {
+ modifier(ReviewInvitationModifier(blocked: blocked))
+ }
+}
+
+/// Only the returned-to roster can present StoreKit; navigation/overlays cancel its one-shot delay.
+private struct ReviewInvitationModifier: ViewModifier {
+ let blocked: Bool
+ @Environment(AppStore.self) private var app
+ @Environment(AccountStore.self) private var accounts
+ @Environment(\.scenePhase) private var phase
+ @Environment(\.requestReview) private var requestReview
+ private let invitation = ReviewInvitation.shared
+
+ private var unavailable: Bool {
+ blocked || invitation.isInterrupted || phase != .active || app.tab != .bots || accounts.selection != nil
+ || app.showComputers || app.showUsage || app.marketplace != nil || app.account.showSwitcher
+ || accounts.lastError != nil || accounts.computers.isEmpty
+ || accounts.computers.contains { computer in
+ guard let store = accounts.store(for: computer.id) else { return true }
+ return store.connection != .online || store.mismatch != nil || store.lastError != nil
+ || store.screenRequest != nil || store.bots.values.contains { $0.isWorking || $0.status == "error" }
+ }
+ }
+
+ func body(content: Content) -> some View {
+ content
+ .task(id: invitation.opportunity) {
+ guard let token = invitation.opportunity else { return }
+ guard !unavailable else { invitation.cancel(.unavailable); return }
+ do { try await Task.sleep(for: .seconds(2)) } catch { return }
+ guard !Task.isCancelled, !unavailable, presentationIsClear else {
+ invitation.cancel(.unavailable)
+ return
+ }
+ if invitation.request(token) { requestReview() }
+ }
+ .onChange(of: unavailable) { _, blocked in if blocked { invitation.cancel(.unavailable) } }
+ .onDisappear { invitation.cancel(.interaction) }
+ .simultaneousGesture(DragGesture(minimumDistance: 0).onChanged { _ in invitation.cancel(.interaction) })
+ }
+
+ private var presentationIsClear: Bool {
+ guard let scene = UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene })
+ .first(where: { $0.activationState == .foregroundActive }),
+ let window = scene.windows.first(where: \.isKeyWindow),
+ let root = window.rootViewController else { return false }
+ return root.presentedViewController == nil
+ }
+}
diff --git a/apps/ios/Views/RootView.swift b/apps/ios/Views/RootView.swift
index 306edc82..10e6ba05 100644
--- a/apps/ios/Views/RootView.swift
+++ b/apps/ios/Views/RootView.swift
@@ -85,7 +85,14 @@ struct RootView: View {
.tint(Palette.text)
.tracked(.screenViewed(app.tab == .bots ? .bots : .state))
// Opening a bot (notification, widget, link) always lands on the Bots tab.
- .onChange(of: accounts.selection) { _, ref in if ref != nil { app.tab = .bots } }
+ .onChange(of: accounts.selection) { old, ref in
+ if ref != nil {
+ app.tab = .bots
+ ReviewInvitation.shared.cancel(.interaction)
+ } else if let old {
+ ReviewInvitation.shared.returned(from: "\(accounts.storage.id)/\(old.computerId)/\(old.botId)")
+ }
+ }
}
/// Once per setup (Start over begins a new one): the first computer reached, or Skip.
diff --git a/apps/ios/Views/SettingsView.swift b/apps/ios/Views/SettingsView.swift
index 0e088501..24c7df80 100644
--- a/apps/ios/Views/SettingsView.swift
+++ b/apps/ios/Views/SettingsView.swift
@@ -117,6 +117,22 @@ struct SettingsView: View {
}
CardSection {
+ Button {
+ Analytics.shared.capture(.reviewLinkOpened)
+ openURL(AppStoreRelease.reviewPage)
+ } label: {
+ Text(L10n.tr("Rate on the App Store"))
+ }
+ .buttonStyle(.plain)
+ .foregroundStyle(Palette.text)
+ Button {
+ Analytics.shared.capture(.linkOpened(.issues))
+ openURL(URL(string: "https://github.com/leepokai/Codync/issues")!)
+ } label: {
+ Text(L10n.tr("Report an issue"))
+ }
+ .buttonStyle(.plain)
+ .foregroundStyle(Palette.text)
ValueRow("App version", value: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")
Button {
Analytics.shared.capture(.linkOpened(.github))
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index 642d45ad..408477f1 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -6,58 +6,10 @@ any left). tools/asc-submit.py reads the released version's section;
a version without one gets a generic "Bug fixes and improvements" line. Delete old sections.
-->
-## 2.28.0
+## 2.29.0
### zh-Hant
-- 主助理的頭像右下角新增金色星星;點一下詳細頁的星星,即可了解它如何追蹤目標、協調 bots 與定時關心進度。
-- 你的電腦連成一個網路後(在電腦上執行 codync-host network),Bot 可以請其他電腦上的 Bot 幫忙;聊天裡會寫出對方 Bot 和它在哪台電腦。
-- 可以把 Codync 加進 ChatGPT 或 Claude 當聯結器,從那裡請你的 Bot 做事;Bot 的聊天會顯示「Message from Cloud assistant」。
+- 評分邀請只會在你使用一段時間、看完 Bot 的成果並回到列表後出現,不會在開啟 App 時打擾你。也可以隨時從設定前往 App Store 評分。
### en-US
-- Your lead agent now has a gold star on its avatar. Tap the larger star in its details to learn how it follows your goals, coordinates bots, and checks in.
-- Once your computers share a network (codync-host network on each), a bot can ask a bot on another computer; the chat names that bot and its computer.
-- Add Codync to ChatGPT or Claude as a connector to give your bots tasks from there; the bot's chat shows Message from Cloud assistant.
-
-## 2.27.0
-
-### zh-Hant
-- 此版本起需要 iOS 26 或更新版本。
-- 修正送出文字、清空或替換聊天草稿時可能閃退的問題。
-- 擴充套件的列表改回往下捲動,不再分頁;聯結器捲到底會自動從 MCP Registry 載入更多。
-- 點聯結器或智慧體只會打開詳情,要按「Add」或「Set up」才會加入或下載。
-- 用量也會顯示這台電腦上其他 agent 的額度,包括 oh-my-pi、Amp、Kiro、Kimi、Antigravity、OpenCode、Mistral Vibe 和 Junie。Cursor 會用本機已登入的帳號向 cursor.com 查詢用量。
-
-### en-US
-- This version requires iOS 26 or later.
-- Fixed a possible crash when sending text or clearing or replacing a chat draft.
-- Extensions lists scroll again instead of paging; connectors load more from the MCP Registry as you reach the end.
-- Tapping a connector or agent only opens its details; nothing is added or downloaded until you press Add or Set up.
-- Usage limits now include the other agents installed on your computer: oh-my-pi, Amp, Kiro, Kimi, Antigravity, OpenCode, Mistral Vibe and Junie. Cursor asks cursor.com with the sign-in saved on that computer.
-
-## 2.26.2
-
-### zh-Hant
-- Bot 傳來的圖片會直接顯示在聊天裡,點一下可以放大看,不用先下載。
-- 電腦上的 Codync 版本太舊時,更新提示多了「Update now」按鈕,直接從手機叫那台電腦更新。
-- 擴充套件一次顯示一個分類:智慧體、聯結器或技能,每個列表都分頁。點列表兩側的圓形按鈕或左右滑動就能翻頁,下方可選每頁 6、10、20 或 50 筆,並顯示目前在第幾頁。
-- 聯結器翻到還沒載入的頁面時,會從 MCP Registry 接著載入。
-- 「憑證」移到上方電腦名稱旁;「自定義聯結器」和「自己的技能」放在各自分類的列表上方。
-- 電腦使用自建中繼時,設定和連線狀態會顯示該中繼的地址,不再一律寫成 Cloudflare。
-- 可以建立使用 WorkBuddy 的 Bot:Codync 會使用 WorkBuddy 桌面 App 內附的 CLI,並在聊天裡請你登入。
-
-### en-US
-- Images a bot sends now show right in the chat; tap one to see it full size, no download needed.
-- When a computer's Codync is too old for this app, Update now on the notice updates that computer from your phone.
-- Extensions shows one section at a time: Agents, Connectors or Skills, each in pages. Tap the round buttons beside the list or swipe left or right to turn the page; under it, pick 6, 10, 20 or 50 per page and see which page you're on.
-- Connectors keep loading from the MCP Registry as you page past what's loaded.
-- Credentials sits beside the computer's name at the top, and Custom connector and Your own skill sit above their lists.
-- When a computer uses a private relay, Settings and connection status show that relay's address instead of always saying Cloudflare.
-- Create bots that run WorkBuddy: Codync uses the CLI inside the WorkBuddy desktop app and asks you to sign in from the chat.
-
-## 2.26.1
-
-### zh-Hant
-- 在背景從即時動態或鎖定畫面掛斷通話時,聊天裡也會留下這通電話的紀錄,回到 App 不再顯示連不上電腦。
-
-### en-US
-- A call you end from its Live Activity or the Lock Screen, with the app in the background, still leaves its line in the chat, and coming back no longer says your computer can't be reached.
+- Rating invitations wait until you have used Codync for a while, viewed a bot's result, and returned to the list. You can also rate Codync anytime from Settings.
diff --git a/docs/features/ios-review-invitation.md b/docs/features/ios-review-invitation.md
new file mode 100644
index 00000000..650744be
--- /dev/null
+++ b/docs/features/ios-review-invitation.md
@@ -0,0 +1,66 @@
+# iPhone rating invitations
+
+The iPhone asks StoreKit for a review at a natural pause: after a locally sent bot interaction
+finishes, its final result stays visible at the bottom of the conversation for three seconds,
+and the person returns to Bots. It waits two more seconds with no interaction. It never
+requests on launch, pairing, sign-in, or foregrounding. These are conservative initial
+thresholds, not measured conversion optima.
+
+## Eligibility and cancellation
+
+- At least seven elapsed days since this feature first ran, activity on three different local
+ calendar dates, and five completed, viewed interactions.
+- At least 60 seconds continuously active before returning to Bots.
+- At least 120 days between attempts, two attempts per rolling 365 days, one per version,
+ and five additional completed/viewed interactions since the previous attempt.
+- Navigation, touching the list, backgrounding, sheets, errors, incompatible versions,
+ disconnected computers, running agents, or pending approvals cancel the opportunity.
+ Cancellation does not consume the cooldown; it needs a new completed/viewed interaction.
+- StoreKit may suppress the prompt. Persist an attempt before calling it regardless; there
+ is no event claiming it appeared or that someone rated the app.
+
+The device retains first-use time, three activity-day markers, counts, request history, and
+up to 100 locally generated message nonces, valid for 30 days. Expired nonces are removed
+on the next launch, foreground transition, or send. This is device-only StoreKit
+presentation policy, using the host's existing turn IDs, statuses, and final-message flags.
+No host API or compatibility minimum changes. Pending sends survive a relaunch; presentation
+opportunities do not. Successful turns with notices are conservatively excluded, as are
+voice calls, routine results, historical messages without a locally recorded send, failures,
+and cancellations. Multiple messages in one turn count once. Reading means the result was
+visible, not that the user approved it; no sentiment analysis or rating pre-screen is used.
+
+Settings offers **Rate on the App Store** to everyone, opening Apple's write-review page,
+and an independent **Report an issue** link to GitHub. Neither is gated on satisfaction.
+Only StoreKit's own prompt appears automatically. All seven existing translations include
+the settings label.
+
+## Analytics
+
+Use the existing iPhone PostHog client and opt-out switch. See the event contract in
+[analytics events](../reference/analytics-events.md). Compare `review_opportunity` to
+`review_requested`, grouped by `app_version`, and inspect cancellation reasons. For any
+rating-count trend use aggregate App Store Connect reports; individual review conversion
+is unavailable. Never treat a StoreKit attempt or a manual link tap as a submitted rating.
+
+## Platform scope
+
+This feature is specific to the iPhone App Store build. Android's Settings, desktop Settings
+and help menu, and terminal settings were inspected: they have no Apple StoreKit review
+capability. They retain their existing behavior; Google Play review invitations would need
+a separate store-specific implementation. Desktop package and host versions change only
+for the repository's synchronized release version.
+
+## Validation (2026-10-26)
+
+- iOS package: 286 tests passed, including 13 invitation regression tests; iOS Dev simulator
+ build passed. The three-reviewer pass confirmed and fixed obscured reading, expired nonce
+ cleanup, and the missing independent issue-report link.
+- Device Hub on a dedicated iOS 26.5 simulator: fresh launch had no rating prompt; version
+ 2.29.0 Settings exposed Rate on the App Store and Report an issue. UI testing was narrowed
+ to this smoke check at the owner's request. An eligible StoreKit display and live PostHog
+ ingestion were not verified; request semantics and analytics opt-out have unit coverage.
+- Desktop: typecheck and 258 tests passed. User documentation: 18 pages and 88 links passed.
+- Version-only host checks: formatting and Clippy passed; the broad suite progressed through
+ many suites but timed out at `stop_ends_a_turn_whose_agent_ignores_the_cancel` after the
+ hook's 300-second limit. Host source is unchanged. Android checks were not run; the owner
+ explicitly excluded Android review invitations because the app is not published yet.
diff --git a/docs/reference/analytics-events.md b/docs/reference/analytics-events.md
index 91338c9b..8c773f84 100644
--- a/docs/reference/analytics-events.md
+++ b/docs/reference/analytics-events.md
@@ -148,3 +148,21 @@ without it PostHog drops these events): `$pageview`, `download_clicked` (`platfo
`link_opened` (`link`). One document-level click listener in `web/app/analytics.tsx` reads each
link's `href`, so a new link is counted without code; the film counts as `demo` when focus moves
into its frame.
+
+## iPhone App Store review invitations
+
+These events use the existing iPhone sender, identity, environment, version and analytics
+opt-out. No conversation content, message nonce, bot ID or review text is included.
+
+| Event | When | Properties |
+| --- | --- | --- |
+| `review_opportunity` | An eligible, viewed result is followed by returning to Bots | `completed_interactions` (count), `policy: v1`, `trigger: return_to_bots` |
+| `review_cancelled` | An opportunity is abandoned before StoreKit | `reason: background / interaction / unavailable`, `policy: v1` |
+| `review_requested` | The persisted cooldown is consumed and StoreKit is about to be called | `completed_interactions` (count), `policy: v1`, `trigger: return_to_bots` |
+| `review_link_opened` | The person taps Rate on the App Store in Settings | `source: settings` |
+
+`review_requested` does not mean the system displayed a prompt or the person submitted a
+rating. StoreKit does not provide those outcomes. The [invitation policy](../features/ios-review-invitation.md)
+describes timing, exclusions, and cooldowns.
+
+The iPhone also reports `link_opened` with `link: issues` for its independent **Report an issue** action.
diff --git a/web/content/docs/privacy.mdx b/web/content/docs/privacy.mdx
index 9946d3ad..7b39423c 100644
--- a/web/content/docs/privacy.mdx
+++ b/web/content/docs/privacy.mdx
@@ -84,3 +84,16 @@ The info button next to the switch (**About usage analytics…** in the terminal
## Removing your data
Delete a bot to remove its conversation. To remove everything from a computer, see "Uninstalling" in [Updates](/docs/updates). On the iPhone, **Start over** in **Computers & settings** signs out and forgets every computer; your computers keep their bots and chats. Deleting the iPhone app removes its cache.
+
+## iPhone rating invitations
+
+Codync may invite you to rate it after you have used it on several days, viewed a bot's
+completed result, and returned to the bot list. It does not ask when you open the app.
+Invitations are at least 120 days apart, with at most two requests in a year. Apple decides
+whether to show its rating window. You can also choose **Rate on the App Store** in
+**Computers & settings** at any time. **Report an issue** opens a separate feedback link,
+regardless of whether you choose to rate the app.
+
+The timing history stays on your iPhone. If **Share usage analytics** is on, Codync records
+invitation opportunities, cancellation reasons, requests, and taps on the rating link, with
+interaction counts. It does not send conversation content or know whether you rated it.