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
fix(ios): ask for a rating only right after the message that earned it
leepokai66d9c9891c95
diff --git a/apps/ios/Kit/Sources/CodyncKit/Review/ReviewInvitation.swift b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewInvitation.swiftindex f1b0af60..2104a42e 100644--- a/apps/ios/Kit/Sources/CodyncKit/Review/ReviewInvitation.swift+++ b/apps/ios/Kit/Sources/CodyncKit/Review/ReviewInvitation.swift@@ -14,6 +14,9 @@ public final class ReviewInvitation {private let capture: @MainActor (AnalyticsEvent) -> Voidprivate var history: ReviewHistorypublic private(set) var opportunity: UUID?+ private var opportunityDate = Date.distantPast+ /// With no view there to ask (a background shortcut), the token waits in memory: coming back to the app later must not ask.+ private static let opportunityLifetime: TimeInterval = 5init(defaults: UserDefaults = .standard,capture: @escaping @MainActor (AnalyticsEvent) -> Void = { Analytics.shared.capture($0) }) {@@ -28,23 +31,32 @@ public final class ReviewInvitation {} else { history = ReviewHistory() }}- /// A prompt reached the computer or its mailbox. One the app couldn't ask on (backgrounded) leaves the next prompt to ask.+ /// A prompt reached the computer or its mailbox.public func sent(version: String = AppVersion.current, now: Date = .now) {history.prompts += 1save()- if !defaults.bool(forKey: Self.offKey), history.eligible(at: now, version: version) { opportunity = UUID() }+ if !defaults.bool(forKey: Self.offKey), history.eligible(at: now, version: version) {+ opportunity = UUID()+ opportunityDate = now+ }}/// 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 opportunity == token else { return false }opportunity = nil+ guard now.timeIntervalSince(opportunityDate) <= Self.opportunityLifetime else { return false }history.recordRequest(at: now, version: version)save()capture(.reviewRequested(prompts: history.prompts))return true}+ /// The app couldn't ask on this one (backgrounded, or its view went away): only a later prompt asks.+ public func skip(_ token: UUID) {+ if opportunity == token { opportunity = nil }+ }+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/Tests/CodyncKitTests/ReviewInvitationTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/ReviewInvitationTests.swiftindex dbcda66e..2ec00808 100644--- a/apps/ios/Kit/Tests/CodyncKitTests/ReviewInvitationTests.swift+++ b/apps/ios/Kit/Tests/CodyncKitTests/ReviewInvitationTests.swift@@ -76,6 +76,37 @@ private func tracker(_ suite: String) -> ReviewInvitation {#expect(invitation.opportunity == nil)}+@MainActor+@Test func reviewSkippedRequestWaitsForTheNextPrompt() throws {+ let suite = UUID().uuidString+ defer { UserDefaults(suiteName: suite)!.removePersistentDomain(forName: suite) }+ let invitation = tracker(suite)+ for _ in 1...5 { invitation.sent(version: "2.29.0", now: reviewNow) }+ let skipped = try #require(invitation.opportunity)+ invitation.skip(skipped)+ #expect(invitation.opportunity == nil)+ #expect(!invitation.request(skipped, version: "2.29.0", now: reviewNow))+ invitation.sent(version: "2.29.0", now: reviewNow)+ let next = try #require(invitation.opportunity)+ invitation.skip(skipped)+ #expect(invitation.opportunity == next, "skipping an older one leaves the new one")+}++@MainActor+@Test func reviewStaleRequestWaitsForTheNextPrompt() throws {+ let suite = UUID().uuidString+ defer { UserDefaults(suiteName: suite)!.removePersistentDomain(forName: suite) }+ let invitation = tracker(suite)+ for _ in 1...5 { invitation.sent(version: "2.29.0", now: reviewNow) }+ let stale = try #require(invitation.opportunity)+ let later = reviewNow.addingTimeInterval(300)+ #expect(!invitation.request(stale, version: "2.29.0", now: later))+ #expect(invitation.opportunity == nil)+ invitation.sent(version: "2.29.0", now: later)+ let next = try #require(invitation.opportunity)+ #expect(invitation.request(next, version: "2.29.0", now: later.addingTimeInterval(1)))+}+@MainActor@Test func reviewRequestPersistsBeforeCallingStoreKitAndRespectsAnalyticsOptOut() throws {let suite = UUID().uuidStringdiff --git a/apps/ios/Views/ReviewInvitationModifier.swift b/apps/ios/Views/ReviewInvitationModifier.swiftindex 68d672d1..08e1d411 100644--- a/apps/ios/Views/ReviewInvitationModifier.swift+++ b/apps/ios/Views/ReviewInvitationModifier.swift@@ -16,6 +16,8 @@ private struct ReviewInvitationModifier: ViewModifier {func body(content: Content) -> some View {content.task(id: invitation.opportunity) {guard let token = invitation.opportunity else { return }+ // Every exit drops it, so a rebuilt root view (account switch, Start over) never asks without a new prompt.+ defer { invitation.skip(token) }do { try await Task.sleep(for: .seconds(1)) } catch { return }// The live state: an environment scenePhase here would still be the one this task began with.if UIApplication.shared.applicationState == .active, invitation.request(token) { requestReview() }diff --git a/docs/features/ios-review-invitation.md b/docs/features/ios-review-invitation.mdindex 3271013d..78a8e745 100644--- a/docs/features/ios-review-invitation.md+++ b/docs/features/ios-review-invitation.md@@ -11,7 +11,8 @@ It never requests on launch, pairing, sign-in, or foregrounding.or expires counts again when resent, and taking one back doesn't subtract, so the ask can come a prompt early.- At least 120 days between attempts, two attempts per rolling 365 days, one per version,and five more prompts since the previous attempt.-- A prompt sent while the app is in the background (a shortcut) doesn't ask; the next prompt does.+- A prompt sent while the app is in the background (a shortcut) doesn't ask, and neither does one the app can't ask on+ within five seconds; the next prompt does.- StoreKit may suppress the prompt, and never shows it in TestFlight. Persist an attempt beforecalling it regardless; there is no event claiming it appeared or that someone rated the app.