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(dev): sign a worktree's simulator or emulator into its sandbox account, and hold the Android rating invitation until Play

leepokai881c30f6e84a
diff --git a/apps/android/app/build.gradle.kts b/apps/android/app/build.gradle.kts
index 7615a255..66e43dba 100644
--- a/apps/android/app/build.gradle.kts
+++ b/apps/android/app/build.gradle.kts
@@ -174,9 +174,8 @@ dependencies {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.messaging)
implementation(libs.work)
- // What Google Play has for this app (the update notice) and its in-app review prompt.
+ // What Google Play has for this app (the update notice).
implementation(libs.play.app.update)
- implementation(libs.play.review)
implementation(libs.glance)
// Remote screen video and OpenAI Realtime voice, as the iPhone app's WebRTC.
implementation(libs.webrtc)
diff --git a/apps/android/app/proguard-rules.pro b/apps/android/app/proguard-rules.pro
index 1e98c00a..9b6c4cc2 100644
--- a/apps/android/app/proguard-rules.pro
+++ b/apps/android/app/proguard-rules.pro
@@ -19,6 +19,3 @@
-keep,allowoptimization class com.codync.android.** extends androidx.glance.appwidget.GlanceAppWidget {
public <init>();
}
-
-# play review-ktx references an annotation that ships only with Play services; it is never needed at runtime.
--dontwarn com.google.android.gms.common.annotation.NoNullnessRewrite
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt b/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt
index c95fa7aa..81764b69 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt
@@ -47,6 +47,11 @@ class AccountStore(application: Application) : AndroidViewModel(application) {
viewModelScope.launch {
withContext(Dispatchers.IO) { PushPreferences.splitSwitch(getApplication()) }
transitions.withLock { loadContext(null) }
+ launch {
+ try { NativeAccounts.signInForDevelopment(getApplication()) }
+ catch (cancelled: CancellationException) { throw cancelled }
+ catch (error: Exception) { mutableState.update { it.copy(error = "Couldn't sign in to the test account: ${error.message}") } }
+ }
NativeAccounts.observe(viewModelScope) { account ->
mutableState.update { it.copy(account = account) }
if (account.ready) transitions.withLock {
@@ -197,7 +202,6 @@ class AccountStore(application: Application) : AndroidViewModel(application) {
fun setForeground(active: Boolean) {
foreground = active
- ReviewPrompt.setActive(getApplication(), active)
PushDelivery.foreground = active || stores.value.any { it.state.value.voice != null }
for (store in stores.value) store.setForeground(active)
if (active && !state.value.loading) refreshCloud()
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt b/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt
index de92de81..619f9250 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt
@@ -62,19 +62,6 @@ internal sealed class AnalyticsEvent(val name: String) {
data class SettingChanged(val setting: PhoneSetting, val on: Boolean) : AnalyticsEvent("setting_changed") {
override val properties get() = mapOf("setting" to setting.json, "on" to JsonPrimitive(on))
}
- /** An eligible, viewed result was followed by returning to Bots (iOS `reviewOpportunity`). */
- data class ReviewOpportunity(val completed: Int) : AnalyticsEvent("review_opportunity") {
- override val properties get() = mapOf("completed_interactions" to JsonPrimitive(completed), "policy" to JsonPrimitive("v1"),
- "trigger" to JsonPrimitive("return_to_bots"))
- }
- data class ReviewCancelled(val reason: com.codync.android.core.ReviewCancellation) : AnalyticsEvent("review_cancelled") {
- override val properties get() = mapOf("reason" to JsonPrimitive(reason.wire), "policy" to JsonPrimitive("v1"))
- }
- /** The cooldown is used up and Google Play is about to be asked; not that a prompt showed. */
- data class ReviewRequested(val completed: Int) : AnalyticsEvent("review_requested") {
- override val properties get() = mapOf("completed_interactions" to JsonPrimitive(completed), "policy" to JsonPrimitive("v1"),
- "trigger" to JsonPrimitive("return_to_bots"))
- }
/** Rate on Google Play, in Settings (iOS `reviewLinkOpened`). */
data object ReviewLinkOpened : AnalyticsEvent("review_link_opened") {
override val properties get() = mapOf("source" to JsonPrimitive("settings"))
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt
index a1d55a14..475ef4b1 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt
@@ -90,7 +90,6 @@ fun AppStore.sendDraft(key: String, botId: String, text: String, replyTo: ReplyQ
mutableState.update { it.copy(drafts = it.drafts - key) }
persistDrafts()
onQueued()
- ReviewPrompt.sent(application, send.nonce)
action("send:" + send.nonce) { deliver(send) }
}
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt b/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
index 066def95..e05e29f3 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
@@ -98,10 +98,6 @@ import com.kyant.shapes.Capsule
val reply = { entry: Entry -> replyId = entry.id }
// The chat ignores Full conversation over it: it stays put underneath.
val chatState = state.copy(trace = false)
- // ponytail: "in sight" is the open chat with nothing over it, not its scroll position; add that if ratings come too early.
- ReviewReading("${state.contextId}/${state.computer.id}/${bot.id}", state.entries.filter { it.botId == bot.id },
- ready = details == null && viewing == null && peer == null && callLine == null && !state.trace && state.voice == null &&
- state.drafts[bot.id]?.let { it.text.isBlank() && it.files.isEmpty() } != false && state.settledForReview && bot.status == "idle")
GlassStage(Modifier.fillMaxSize().background(Palette.background), chrome = {
// Down to just above the header's bottom; the bottom one stops under Jump to latest.
ScrollEdge(Edge.Top, top + 84.dp)
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt b/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt
index 7cd91995..75a9b248 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt
@@ -29,9 +29,7 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.zIndex
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.platform.LocalContext
import com.codync.android.core.Bot
-import com.codync.android.core.ReviewCancellation
import com.codync.android.design.*
internal enum class AppTab { Bots, State, Settings }
@@ -47,12 +45,6 @@ internal enum class AppTab { Bots, State, Settings }
val open = states.firstOrNull { it.selectedBot != null }
// Opening a bot (notification, widget, link) always lands on the Bots tab.
if (open != null && tab != AppTab.Bots) onTab(AppTab.Bots)
- // Leaving a chat whose answer was read may invite a rating, once the roster has stayed clear (iOS `RootView`).
- val context = LocalContext.current
- ReviewOnReturn(open?.let { "${app.contextId}/${it.computer.id}/${it.selectedBot}" })
- ReviewInvitationEffect(covered || tab != AppTab.Bots || open != null || states.isEmpty() || states.any { state ->
- !state.settledForReview || state.bots.any { it.status in listOf("working", "needsInput", "error") }
- })
AnalyticsOnAppear(AnalyticsEvent.ScreenViewed(when (tab) {
AppTab.Bots -> AnalyticsScreen.Bots
AppTab.State -> AnalyticsScreen.State
@@ -84,10 +76,7 @@ internal enum class AppTab { Bots, State, Settings }
}
}
}) {
- // A touch on the roster turns down a waiting invitation, as on the iPhone.
- Box(Modifier.fillMaxSize().tabLayer(tab == AppTab.Bots).pointerInput(Unit) {
- awaitPointerEventScope { while (true) { awaitPointerEvent(PointerEventPass.Initial); ReviewPrompt.cancel(context, ReviewCancellation.Interaction) } }
- }) {
+ Box(Modifier.fillMaxSize().tabLayer(tab == AppTab.Bots)) {
// A chat's entry names its computer and bot; it keeps its state while sliding away.
var shown by remember { mutableStateOf<AppState?>(null) }
if (open != null) shown = open
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.kt b/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.kt
index 88fc2de2..2457fd45 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.kt
@@ -50,7 +50,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
-import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
@@ -116,9 +115,6 @@ private enum class Trailing { Interrupt, Stop, Call, Send }
// Dictation stops with its chat or draft (another chat, an artifact's box) and when the box goes.
val dictation = remember(draftKey) { Dictation(context, scope) }
DisposableEffect(dictation) { onDispose { dictation.stop() } }
- // Typing, files or dictation here hold off reading results and any rating invitation.
- var focused by remember { mutableStateOf(false) }
- ReviewInterruption(focused || files.isNotEmpty() || dictation.listening || dictation.transcribing)
val photos = rememberLauncherForActivityResult(ActivityResultContracts.PickMultipleVisualMedia(10)) { uris ->
if (uris.isNotEmpty()) store.importFiles(uris) { store.addDraftFiles(draftKey, it) }
}
@@ -219,7 +215,7 @@ private enum class Trailing { Interrupt, Stop, Call, Send }
if (ctrlEnter && trailing == Trailing.Send && canSend) send()
ctrlEnter
}
- BasicTextField(state = text, enabled = !queuing, modifier = Modifier.weight(1f).focusRequester(focus).onFocusChanged { focused = it.isFocused }.contentReceiver(receiver).then(sendKey).padding(vertical = 10.dp),
+ BasicTextField(state = text, enabled = !queuing, modifier = Modifier.weight(1f).focusRequester(focus).contentReceiver(receiver).then(sendKey).padding(vertical = 10.dp),
textStyle = Type.body.copy(color = Palette.text), cursorBrush = SolidColor(Palette.accent),
lineLimits = TextFieldLineLimits.MultiLine(maxHeightInLines = 8),
decorator = { input -> Box { if (text.text.isEmpty()) Text(placeholder, style = Type.body, color = Palette.tertiary, maxLines = 1, overflow = TextOverflow.Ellipsis); input() } })
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt b/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt
index 7ff0b029..b72a91b2 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt
@@ -1,6 +1,7 @@
package com.codync.android
import android.app.Activity
+import android.content.Context
import com.clerk.api.Clerk
import com.clerk.api.ClerkConfigurationOptions
import com.clerk.api.hostedauth.HostedAuthCancellationException
@@ -11,9 +12,13 @@ import com.clerk.api.sso.OAuthProvider
import com.clerk.api.sso.SSOCancellationException
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.withContext
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
+import java.io.File
import java.io.IOException
/** A sign-in that ended without an account, and why. */
@@ -65,6 +70,24 @@ object NativeAccounts {
}
}
+ /**
+ * A worktree's emulator signs into its sandbox's Clerk test account with a one-time token that
+ * `npm run phone-account` leaves through adb's run-as, as the desktop sandbox does: debug builds against Clerk's
+ * development instance only, and only while signed out.
+ */
+ suspend fun signInForDevelopment(context: Context) {
+ if (!BuildConfig.DEBUG || !BuildConfig.CLERK_PUBLISHABLE_KEY.startsWith("pk_test_")) return
+ val file = File(context.filesDir, "dev-sign-in-ticket")
+ val ticket = withContext(Dispatchers.IO) { file.takeIf(File::exists)?.readText()?.trim().also { file.delete() } }
+ if (ticket.isNullOrEmpty()) return
+ Clerk.isInitialized.first { it }
+ if (activeUserId() != null) return
+ when (val result = Clerk.auth.signInWithTicket(ticket)) {
+ is ClerkResult.Failure -> throw SignInError(SignInFailure.Error, result.errorMessage, result.throwable)
+ is ClerkResult.Success -> result.value.createdSessionId?.let { requireSuccess(Clerk.auth.setActive(it)) }
+ }
+ }
+
suspend fun hostedSignIn() {
val result = Clerk.auth.startHostedAuth()
if (result is ClerkResult.Failure) throw signInError(result)
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ReviewPrompt.kt b/apps/android/app/src/main/kotlin/com/codync/android/ReviewPrompt.kt
deleted file mode 100644
index 1f0c3b33..00000000
--- a/apps/android/app/src/main/kotlin/com/codync/android/ReviewPrompt.kt
+++ /dev/null
@@ -1,139 +0,0 @@
-package com.codync.android
-
-import android.app.Activity
-import android.content.Context
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.DisposableEffect
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.collectAsState
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.rememberCoroutineScope
-import androidx.compose.runtime.rememberUpdatedState
-import androidx.compose.runtime.setValue
-import androidx.compose.ui.platform.LocalContext
-import androidx.core.content.edit
-import com.codync.android.core.Entry
-import com.codync.android.core.LinkState
-import com.codync.android.core.ReviewCancellation
-import com.codync.android.core.ReviewHistory
-import com.codync.android.core.ReviewInvitation
-import com.codync.android.core.WireJson
-import com.google.android.play.core.review.ReviewManagerFactory
-import com.google.android.play.core.ktx.launchReview
-import com.google.android.play.core.ktx.requestReview
-import kotlinx.coroutines.CancellationException
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.asStateFlow
-
-/**
- * This phone's invitation to rate Codync on Google Play (iOS `ReviewInvitation.shared` and its roster modifier): kept in
- * the app's preferences, never sent to a computer. Google Play decides whether its prompt actually shows.
- */
-internal object ReviewPrompt {
- private const val KEY = "reviewInvitation.v1"
- private var invitation: ReviewInvitation? = null
- private val mutableOpportunity = MutableStateFlow<Long?>(null)
- val opportunity = mutableOpportunity.asStateFlow()
-
- private fun of(context: Context): ReviewInvitation = invitation ?: run {
- val prefs = context.applicationContext.getSharedPreferences("codync-review", Context.MODE_PRIVATE)
- val now = System.currentTimeMillis()
- val saved = prefs.getString(KEY, null)?.let { runCatching { WireJson.decodeFromString(ReviewHistory.serializer(), it) }.getOrNull() }
- ReviewInvitation(saved ?: ReviewHistory(firstUse = now), { history ->
- prefs.edit { putString(KEY, WireJson.encodeToString(ReviewHistory.serializer(), history)) }
- }) { event ->
- Analytics.capture(when (event) {
- is ReviewInvitation.Event.Opportunity -> AnalyticsEvent.ReviewOpportunity(event.completed)
- is ReviewInvitation.Event.Cancelled -> AnalyticsEvent.ReviewCancelled(event.reason)
- is ReviewInvitation.Event.Requested -> AnalyticsEvent.ReviewRequested(event.completed)
- })
- }.also { invitation = it }
- }
-
- private fun update(context: Context, change: ReviewInvitation.() -> Unit) {
- val shown = of(context)
- shown.change()
- mutableOpportunity.value = shown.opportunity
- }
-
- fun setActive(context: Context, active: Boolean) = update(context) { setActive(active, System.currentTimeMillis()) }
- fun sent(context: Context, nonce: String) = update(context) { sent(nonce, System.currentTimeMillis()) }
- fun viewed(context: Context, chat: String, entries: List<Entry>) = update(context) { viewed(chat, entries, System.currentTimeMillis()) }
- fun returned(context: Context, chat: String) = update(context) { returned(chat, APP_RELEASE, System.currentTimeMillis()) }
- fun cancel(context: Context, reason: ReviewCancellation) = update(context) { cancel(reason) }
- fun interrupt(context: Context, token: Any, active: Boolean) = update(context) { interrupt(token, active) }
-
- /** Uses up the opportunity (and this app's own cooldown) before Google Play is asked. */
- fun request(context: Context, token: Long): Boolean {
- var asked = false
- update(context) { asked = request(token, APP_RELEASE, System.currentTimeMillis()) }
- return asked
- }
-}
-
-/** A computer steady enough to read an answer on or to invite a rating over: connected, current, nothing else showing. */
-internal val AppState.settledForReview: Boolean
- get() = actualConnection is LinkState.Ready && mismatch == null && error == null && screenRequest == null
-
-/** Leaving [openChat] (the open chat's ID, null on the roster) may invite a rating; opening one turns a waiting invitation down. */
-@Composable internal fun ReviewOnReturn(openChat: String?) {
- val context = LocalContext.current
- var lastChat by remember { mutableStateOf<String?>(null) }
- LaunchedEffect(openChat) {
- if (openChat != null) ReviewPrompt.cancel(context, ReviewCancellation.Interaction)
- else lastChat?.let { ReviewPrompt.returned(context, it) }
- lastChat = openChat
- }
-}
-
-/** While [active] (the composer in use, files picked, dictation), reading a result doesn't count and no invitation shows. */
-@Composable internal fun ReviewInterruption(active: Boolean) {
- val context = LocalContext.current
- val token = remember { Any() }
- DisposableEffect(active) {
- ReviewPrompt.interrupt(context, token, active)
- onDispose { ReviewPrompt.interrupt(context, token, false) }
- }
-}
-
-/** A finished answer at the end of [chat] that stays in sight for 3 s, with nothing over it, counts as read. */
-@Composable internal fun ReviewReading(chat: String, entries: List<Entry>, ready: Boolean) {
- val context = LocalContext.current
- LaunchedEffect(chat, entries, ready) {
- if (!ready) return@LaunchedEffect
- delay(3_000)
- ReviewPrompt.viewed(context, chat, entries)
- }
-}
-
-/**
- * Back on the roster after reading an answer: once nothing has covered it for 2 s, Google Play's review prompt
- * ([blocked]: a chat, a sheet, an error, a computer that isn't settled cancels it).
- */
-@Composable internal fun ReviewInvitationEffect(blocked: Boolean) {
- val context = LocalContext.current
- val token by ReviewPrompt.opportunity.collectAsState()
- // `request` clears the opportunity, which restarts this effect, so Play's request runs outside it
- // and checks the screen again before it shows.
- val scope = rememberCoroutineScope()
- val covered by rememberUpdatedState(blocked)
- LaunchedEffect(token, blocked) {
- val opportunity = token ?: return@LaunchedEffect
- if (blocked) { ReviewPrompt.cancel(context, ReviewCancellation.Unavailable); return@LaunchedEffect }
- delay(2_000)
- val activity = context as? Activity ?: return@LaunchedEffect ReviewPrompt.cancel(context, ReviewCancellation.Unavailable)
- if (!ReviewPrompt.request(context, opportunity)) return@LaunchedEffect
- scope.launch {
- try {
- val manager = ReviewManagerFactory.create(context)
- val review = manager.requestReview()
- if (!covered) manager.launchReview(activity, review)
- } catch (cancelled: CancellationException) { throw cancelled }
- catch (error: Exception) { android.util.Log.i("Codync", "Review prompt unavailable: ${error.message}") }
- }
- }
-}
diff --git a/apps/android/core/src/main/kotlin/com/codync/android/core/Review.kt b/apps/android/core/src/main/kotlin/com/codync/android/core/Review.kt
deleted file mode 100644
index 74dd58b3..00000000
--- a/apps/android/core/src/main/kotlin/com/codync/android/core/Review.kt
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.codync.android.core
-
-import java.time.Instant
-import java.time.ZoneId
-import kotlinx.serialization.Serializable
-import kotlinx.serialization.json.booleanOrNull
-import kotlinx.serialization.json.jsonPrimitive
-
-// When to invite a rating (iOS `ReviewHistory`, `ReviewCompletion`, `ReviewInvitation`): after the person has used the
-// app for a while and just read a finished answer to their own message. Device-local; requests are attempts, never
-// evidence of a rating. Times are epoch milliseconds.
-
-private const val DAY = 86_400_000L
-
-/** The device-local policy's memory, saved as JSON. */
-@Serializable data class ReviewHistory(
- val firstUse: Long,
- val activeDays: Set<String> = emptySet(),
- val completed: Int = 0,
- val requests: List<Request> = emptyList(),
- val requestedVersions: Set<String> = emptySet(),
- /** Messages this phone sent (by client nonce) and when, waiting for their answer. */
- val sent: Map<String, Long> = emptyMap(),
-) {
- @Serializable data class Request(val date: Long, val version: String, val completed: Int)
-
- fun recordingActivity(now: Long, zone: ZoneId = ZoneId.systemDefault()): ReviewHistory {
- val day = Instant.ofEpochMilli(now).atZone(zone).toLocalDate()
- val days = activeDays + "${day.year}-${day.monthValue}-${day.dayOfMonth}"
- // Only the three-day milestone matters; keep a bounded set after reaching it.
- return copy(activeDays = if (days.size > 3) days.sorted().takeLast(3).toSet() else days)
- }
-
- /** A week since first use, three active days, five finished answers, once per version, twice a year, 120 days apart. */
- fun eligible(now: Long, version: String): Boolean {
- if (now - firstUse < 7 * DAY || activeDays.size < 3 || completed < 5 || version in requestedVersions ||
- requests.count { now - it.date < 365 * DAY } >= 2) return false
- val last = requests.lastOrNull() ?: return true
- return now - last.date >= 120 * DAY && completed - last.completed >= 5
- }
-
- fun recordingRequest(now: Long, version: String): ReviewHistory = copy(requestedVersions = requestedVersions + version,
- requests = requests.filter { now - it.date < 365 * DAY } + Request(now, version, completed))
-
- fun pruned(now: Long): ReviewHistory = copy(sent = sent.filterValues { now - it < 30 * DAY })
-}
-
-/** Which of this phone's messages a just-read final answer finished; only the host's turn and final flags count, never content. */
-object ReviewCompletion {
- fun match(entries: List<Entry>, sent: Map<String, Long>, now: Long): List<String>? {
- val chat = entries.filter { it.isChat && "call" !in it.data }
- val final = chat.lastOrNull() ?: return null
- if (final.kind != "agent" || final.data["final"]?.jsonPrimitive?.booleanOrNull != true || final.turn <= 0) return null
- val turn = entries.filter { it.turn == final.turn }
- // Non-successful completions and stops produce notices; be conservative about all notices.
- if (turn.any { it.kind == "notice" || it.status == "failed" || it.status == "cancelled" }) return null
- val nonces = turn.mapNotNull { entry ->
- val nonce = entry.clientNonce ?: return@mapNotNull null
- val at = sent[nonce] ?: return@mapNotNull null
- nonce.takeIf { entry.kind == "user" && entry.status == "sent" && "call" !in entry.data && "routineId" !in entry.data &&
- "from" !in entry.data && now - at < 30 * DAY }
- }
- return nonces.ifEmpty { null }
- }
-}
-
-/** Why an opportunity to invite a rating went away. */
-enum class ReviewCancellation(val wire: String) { Background("background"), Interaction("interaction"), Unavailable("unavailable") }
-
-/**
- * The invitation's state (iOS `ReviewInvitation`): a send, a finished answer read in its chat, then returning to the
- * roster makes an opportunity; the roster asks the store once it has stayed clear. [save] keeps the history, [events]
- * reports what happened (the analytics events).
- */
-class ReviewInvitation(initial: ReviewHistory, private val save: (ReviewHistory) -> Unit, private val events: (Event) -> Unit) {
- sealed interface Event {
- data class Opportunity(val completed: Int) : Event
- data class Cancelled(val reason: ReviewCancellation) : Event
- data class Requested(val completed: Int) : Event
- }
-
- var history: ReviewHistory = initial; private set
- private var activeSince: Long? = null
- private var viewedChat: String? = null
- /** The current opportunity's token; the roster waits on it. */
- var opportunity: Long? = null; private set
- private var tokens = 0L
- private val interruptions = mutableSetOf<Any>()
- val interrupted: Boolean get() = interruptions.isNotEmpty()
-
- fun interrupt(token: Any, active: Boolean) {
- if (active) { interruptions += token; cancel(ReviewCancellation.Unavailable) } else interruptions -= token
- }
-
- fun setActive(active: Boolean, now: Long) {
- if (active) { history = history.pruned(now); save(history); if (activeSince == null) activeSince = now }
- else { activeSince = null; viewedChat = null; cancel(ReviewCancellation.Background) }
- }
-
- fun sent(nonce: String, now: Long) {
- var next = history.pruned(now)
- if (next.sent.size >= 100) next.sent.minByOrNull { it.value }?.let { oldest -> next = next.copy(sent = next.sent - oldest.key) }
- history = next.copy(sent = next.sent + (nonce to now)).recordingActivity(now)
- viewedChat = null
- cancel(ReviewCancellation.Interaction)
- save(history)
- }
-
- /** An unobscured final answer at the bottom of [chat] stayed in sight. */
- fun viewed(chat: String, entries: List<Entry>, now: Long) {
- if (activeSince == null || interrupted) return
- val done = ReviewCompletion.match(entries, history.sent, now) ?: return
- history = history.copy(sent = history.sent - done.toSet(), completed = history.completed + 1).recordingActivity(now)
- viewedChat = chat
- save(history)
- }
-
- fun returned(from: String, version: String, now: Long) {
- val since = activeSince
- val viewed = viewedChat
- viewedChat = null
- if (interrupted || viewed != from || since == null || now - since < 60_000 || !history.eligible(now, version)) return
- opportunity = ++tokens
- events(Event.Opportunity(history.completed))
- }
-
- fun cancel(reason: ReviewCancellation) {
- if (opportunity == null) return
- opportunity = null
- events(Event.Cancelled(reason))
- }
-
- /** Saved before the store is asked: a request it doesn't show still uses up this app's own cooldown. */
- fun request(token: Long, version: String, now: Long): Boolean {
- val since = activeSince ?: return false
- if (interrupted || opportunity != token || now - since < 60_000 || !history.eligible(now, version)) return false
- opportunity = null
- history = history.recordingRequest(now, version)
- save(history)
- events(Event.Requested(history.completed))
- return true
- }
-}
diff --git a/apps/android/core/src/test/kotlin/com/codync/android/core/ReviewTest.kt b/apps/android/core/src/test/kotlin/com/codync/android/core/ReviewTest.kt
deleted file mode 100644
index 0bd5b73e..00000000
--- a/apps/android/core/src/test/kotlin/com/codync/android/core/ReviewTest.kt
+++ /dev/null
@@ -1,134 +0,0 @@
-package com.codync.android.core
-
-import kotlinx.serialization.json.buildJsonObject
-import kotlinx.serialization.json.put
-import org.junit.Assert.*
-import org.junit.Test
-
-class ReviewTest {
- private val day = 86_400_000L
-
- private fun user(nonce: String, turn: Long) = Entry("u$turn", turn, "b", turn, "user", turn,
- buildJsonObject { put("text", "do it"); put("clientNonce", nonce); put("status", "sent") })
- private fun answer(turn: Long) = Entry("a$turn", turn, "b", turn, "agent", turn, buildJsonObject { put("text", "done"); put("final", true) })
- /** A message from this phone that isn't the person asking: a call's, a routine's or another bot's. */
- private fun relayed(nonce: String, field: String) = Entry("r1", 1, "b", 1, "user", 1,
- buildJsonObject { put("text", "do it"); put("clientNonce", nonce); put("status", "sent"); put(field, "x") })
-
- /** An invitation with an opportunity waiting, made on day 10 as the person came back from "chat". */
- private fun waiting(events: MutableList<ReviewInvitation.Event>): Pair<ReviewInvitation, Long> {
- val invitation = ReviewInvitation(ReviewHistory(firstUse = 0, completed = 4, activeDays = setOf("a", "b", "c")), {}) { events += it }
- invitation.setActive(true, 10 * day)
- invitation.sent("n1", 10 * day)
- invitation.viewed("chat", listOf(user("n1", 1), answer(1)), 10 * day + 1_000)
- invitation.returned("chat", "2.34.0", 10 * day + 120_000)
- return invitation to requireNotNull(invitation.opportunity)
- }
-
- @Test fun `only a final answer to this phone's own message finishes it`() {
- val sent = mapOf("n1" to 0L)
- assertEquals(listOf("n1"), ReviewCompletion.match(listOf(user("n1", 1), answer(1)), sent, day))
- // Still working, or a notice in the turn (a stop, a failure).
- assertNull(ReviewCompletion.match(listOf(user("n1", 1)), sent, day))
- val notice = Entry("x", 2, "b", 2, "notice", 1, buildJsonObject { put("text", "Stopped.") })
- assertNull(ReviewCompletion.match(listOf(user("n1", 1), notice, answer(1)), sent, day))
- // Another device's message, or one sent over a month ago.
- assertNull(ReviewCompletion.match(listOf(user("n2", 1), answer(1)), sent, day))
- assertNull(ReviewCompletion.match(listOf(user("n1", 1), answer(1)), sent, 31 * day))
- }
-
- @Test fun `eligible after a week, three active days and five answers, once per version`() {
- var history = ReviewHistory(firstUse = 0, completed = 5)
- for (d in 0 until 3) history = history.recordingActivity(d * day + 1, java.time.ZoneOffset.UTC)
- assertFalse(history.eligible(6 * day, "2.34.0"))
- assertTrue(history.eligible(7 * day, "2.34.0"))
- history = history.recordingRequest(7 * day, "2.34.0")
- assertFalse(history.eligible(200 * day, "2.34.0"))
- // Another version needs 120 days and five more answers.
- assertFalse(history.eligible(100 * day, "2.35.0"))
- assertTrue(history.copy(completed = 10).eligible(130 * day, "2.35.0"))
- }
-
- @Test fun `returning from the chat whose answer was read makes one opportunity, and asking uses it`() {
- val events = mutableListOf<ReviewInvitation.Event>()
- var history = ReviewHistory(firstUse = 0, completed = 4, activeDays = setOf("a", "b", "c"))
- val invitation = ReviewInvitation(history, { history = it }) { events += it }
- val now = 10 * day
- invitation.setActive(true, now)
- invitation.sent("n1", now)
- invitation.viewed("chat", listOf(user("n1", 1), answer(1)), now + 1_000)
- invitation.returned("other", "2.34.0", now + 120_000)
- assertNull(invitation.opportunity)
- invitation.viewed("chat", listOf(user("n1", 1), answer(1)), now + 1_000)
- invitation.sent("n2", now + 2_000)
- invitation.viewed("chat", listOf(user("n2", 2), answer(2)), now + 3_000)
- invitation.returned("chat", "2.34.0", now + 120_000)
- val token = requireNotNull(invitation.opportunity)
- assertTrue(invitation.request(token, "2.34.0", now + 122_000))
- assertFalse(invitation.request(token, "2.34.0", now + 123_000))
- assertEquals(listOf(ReviewInvitation.Event.Opportunity(6), ReviewInvitation.Event.Requested(6)), events)
- assertEquals(setOf("2.34.0"), history.requestedVersions)
- }
-
- @Test fun `twice in a rolling year at most`() {
- val history = ReviewHistory(firstUse = 0, completed = 15, activeDays = setOf("a", "b", "c"),
- requests = listOf(ReviewHistory.Request(0, "2.30.0", 5), ReviewHistory.Request(130 * day, "2.31.0", 10)),
- requestedVersions = setOf("2.30.0", "2.31.0"))
- assertFalse(history.eligible(260 * day, "2.32.0"))
- assertTrue(history.eligible(366 * day, "2.32.0"))
- }
-
- @Test fun `leaving the app, a touch or something in use turns the opportunity down`() {
- val events = mutableListOf<ReviewInvitation.Event>()
- val (left, _) = waiting(events)
- left.setActive(false, 10 * day + 121_000)
- assertNull(left.opportunity)
- val (touched, _) = waiting(events)
- touched.cancel(ReviewCancellation.Interaction)
- val (busy, token) = waiting(events)
- busy.interrupt(Any(), true)
- assertFalse(busy.request(token, "2.34.0", 10 * day + 122_000))
- assertEquals(listOf(ReviewCancellation.Background, ReviewCancellation.Interaction, ReviewCancellation.Unavailable),
- events.filterIsInstance<ReviewInvitation.Event.Cancelled>().map { it.reason })
- // An answer read while something is in use doesn't count.
- busy.sent("n2", 10 * day + 130_000)
- busy.viewed("chat", listOf(user("n2", 2), answer(2)), 10 * day + 131_000)
- assertEquals(5, busy.history.completed)
- }
-
- @Test fun `a call's, a routine's or another bot's turn never counts`() {
- val sent = mapOf("n1" to 0L)
- for (field in listOf("call", "routineId", "from")) assertNull(field, ReviewCompletion.match(listOf(relayed("n1", field), answer(1)), sent, day))
- }
-
- @Test fun `sent messages are forgotten after a month and kept to a hundred`() {
- var history = ReviewHistory(firstUse = 0, sent = mapOf("old" to 0L, "recent" to 20 * day))
- val invitation = ReviewInvitation(history, { history = it }) { }
- invitation.setActive(true, 31 * day)
- assertEquals(setOf("recent"), history.sent.keys)
- for (i in 0 until 100) invitation.sent("n$i", 31 * day + i)
- assertEquals(100, history.sent.size)
- assertFalse("recent" in history.sent)
- }
-
- @Test fun `a turn with several messages counts once`() {
- var history = ReviewHistory(firstUse = 0)
- val invitation = ReviewInvitation(history, { history = it }) { }
- invitation.setActive(true, day)
- invitation.sent("n1", day)
- invitation.sent("n2", day + 1)
- val second = Entry("u1b", 2, "b", 2, "user", 1, buildJsonObject { put("text", "also"); put("clientNonce", "n2"); put("status", "sent") })
- invitation.viewed("chat", listOf(user("n1", 1), second, answer(1)), day + 1_000)
- assertEquals(1, history.completed)
- assertTrue(history.sent.isEmpty())
- }
-
- @Test fun `play version codes read back as versions and a newer one is reminded until dismissed`() {
- assertEquals("2.34.0", UpdateReminder.versionOf(2_034_000))
- assertEquals("2.34.12", UpdateReminder.versionOf(2_034_012))
- assertEquals("2.35.0", UpdateReminder.app("2.34.0", "2.35.0", null))
- assertNull(UpdateReminder.app("2.34.0", "2.35.0", "2.35.0"))
- assertNull(UpdateReminder.app("2.35.0", "2.35.0", null))
- assertNull(UpdateReminder.app("2.34.0", null, null))
- }
-}
diff --git a/apps/android/gradle/libs.versions.toml b/apps/android/gradle/libs.versions.toml
index 38eef972..5fc0125b 100644
--- a/apps/android/gradle/libs.versions.toml
+++ b/apps/android/gradle/libs.versions.toml
@@ -27,11 +27,9 @@ backdrop = "2.0.1"
kyant-shapes = "1.2.1"
webrtc = "125.6422.07"
play-app-update = "2.1.0"
-play-review = "2.0.2"
[libraries]
play-app-update = { module = "com.google.android.play:app-update-ktx", version.ref = "play-app-update" }
-play-review = { module = "com.google.android.play:review-ktx", version.ref = "play-review" }
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose" }
compose-ui = { module = "androidx.compose.ui:ui" }
compose-foundation = { module = "androidx.compose.foundation:foundation" }
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index fd689284..4cdc0c39 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -13,6 +13,7 @@
"main": "out/main/index.js",
"scripts": {
"dev": "node --experimental-strip-types --disable-warning=ExperimentalWarning --disable-warning=MODULE_TYPELESS_PACKAGE_JSON tools/dev.mjs",
+ "phone-account": "node --experimental-strip-types --disable-warning=ExperimentalWarning --disable-warning=MODULE_TYPELESS_PACKAGE_JSON tools/phone-account.mjs",
"build": "electron-vite build",
"build:demo": "vite build --config vite.demo.config.ts && mv ../../web/public/demo/desktop/index.html ../../web/public/demo/desktop.html",
"typecheck": "tsc --noEmit -p tsconfig.json",
diff --git a/apps/desktop/tools/dev.mjs b/apps/desktop/tools/dev.mjs
index 5df7eb2e..56c8b95d 100644
--- a/apps/desktop/tools/dev.mjs
+++ b/apps/desktop/tools/dev.mjs
@@ -174,7 +174,8 @@ async function sandbox() {
if (stopping) return
if (account) {
appEnv.CODYNC_DEV_SIGN_IN_TICKET = account.token
- console.log(` test account ${account.email}\n`)
+ console.log(` test account ${account.email}`)
+ console.log(` sign a phone into it npm run phone-account -- --ios <simulator udid> | --android <adb serial>${flags.name ? ` --name ${name}` : ''}\n`)
}
app = startApp(appEnv)
app.child.on('exit', (code) => stop(code ?? 0))
diff --git a/apps/desktop/tools/phone-account.mjs b/apps/desktop/tools/phone-account.mjs
new file mode 100644
index 00000000..4e37d64b
--- /dev/null
+++ b/apps/desktop/tools/phone-account.mjs
@@ -0,0 +1,46 @@
+// `npm run phone-account -- --ios <udid> | --android <serial> [--name <sandbox>]`: signs an iOS Simulator's or Android
+// emulator's Codync Dev into this worktree sandbox's Clerk test account, the one `npm run dev` signs the desktop app
+// into, so a phone and the sandbox share an account. The app trades the one-time token only while it is signed out
+// (iOS: the CODYNC_DEV_SIGN_IN_TICKET launch variable; Android: a file only adb's run-as can write). The main checkout's
+// Codync Dev keeps your own account: there this needs an explicit --name.
+import { spawnSync } from 'node:child_process'
+import { statSync } from 'node:fs'
+import { basename, dirname, join, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { parseArgs } from 'node:util'
+import { mintTicket } from './dev-account.mjs'
+import { sandboxName } from '../src/shared/dev-sandbox.ts'
+
+const root = resolve(dirname(fileURLToPath(import.meta.url)), '../../..')
+const { values: flags } = parseArgs({ options: { ios: { type: 'string' }, android: { type: 'string' }, name: { type: 'string' } } })
+const IOS_APP = 'com.pokai.Codync.ios.dev'
+const ANDROID_APP = 'com.pokai.Codync.android.dev'
+
+function fail(message) {
+ console.error(message)
+ process.exit(1)
+}
+
+function run(cmd, args, options = {}) {
+ const result = spawnSync(cmd, args, { encoding: 'utf8', ...options })
+ if (result.status !== 0) fail(`${cmd} ${args.join(' ')} failed: ${(result.stderr || result.stdout || '').trim()}`)
+}
+
+if (!flags.ios === !flags.android) fail('Pick one device: --ios <simulator udid> or --android <adb serial>.')
+if (statSync(join(root, '.git')).isDirectory() && !flags.name) {
+ fail("The main checkout's Codync Dev keeps your own account. Run this from a worktree, or name a sandbox with --name <name>.")
+}
+const name = sandboxName(flags.name ?? basename(root))
+const account = await mintTicket(name)
+if (!account) fail('No Clerk test key: set CODYNC_CLERK_SECRET_KEY in the main checkout\'s .env.development (see docs/guides/dev-app.md).')
+
+if (flags.ios) {
+ run('xcrun', ['simctl', 'launch', '--terminate-running-process', flags.ios, IOS_APP],
+ { env: { ...process.env, SIMCTL_CHILD_CODYNC_DEV_SIGN_IN_TICKET: account.token } })
+} else {
+ const adb = (...args) => ['-s', flags.android, ...args]
+ run('adb', adb('shell', 'run-as', ANDROID_APP, 'sh', '-c', "'mkdir -p files && cat > files/dev-sign-in-ticket'"), { input: account.token })
+ run('adb', adb('shell', 'am', 'force-stop', ANDROID_APP))
+ run('adb', adb('shell', 'am', 'start', '-n', `${ANDROID_APP}/com.codync.android.MainActivity`))
+}
+console.log(`Signing ${flags.ios ? 'the simulator' : 'the emulator'} into ${account.email} (sandbox ${name}).`)
diff --git a/apps/ios/App/AccountSession.swift b/apps/ios/App/AccountSession.swift
index c27f4e81..f02d7672 100644
--- a/apps/ios/App/AccountSession.swift
+++ b/apps/ios/App/AccountSession.swift
@@ -66,6 +66,23 @@ final class AccountSession {
telemetryEnabled: false,
redirectConfig: .init(redirectUrl: "\(scheme)://callback", callbackUrlScheme: scheme)
))
+ if key.hasPrefix("pk_test_"), let ticket = env["CODYNC_DEV_SIGN_IN_TICKET"], !ticket.isEmpty {
+ Task { await signInForDevelopment(ticket: ticket) }
+ }
+ }
+
+ /// A worktree's simulator signs into its sandbox's Clerk test account with a one-time token from
+ /// `npm run phone-account`, as the desktop sandbox does; only against Clerk's development instance, and only while signed out.
+ private func signInForDevelopment(ticket: String) async {
+ guard let clerk else { return }
+ for _ in 0..<200 where !clerk.isLoaded { try? await Task.sleep(for: .milliseconds(100)) }
+ guard clerk.isLoaded, !isSignedIn else { return }
+ do {
+ let signIn = try await clerk.auth.signInWithTicket(ticket)
+ if let session = signIn.createdSessionId { try await clerk.auth.setActive(sessionId: session) }
+ } catch {
+ errorMessage = "Couldn't sign in to the test account: \(error.localizedDescription)"
+ }
}
/// The signed-in session's JWT for the Codync cloud (Clerk caches it for a minute).
diff --git a/docs/features/ios-review-invitation.md b/docs/features/ios-review-invitation.md
index d2ed1944..16340965 100644
--- a/docs/features/ios-review-invitation.md
+++ b/docs/features/ios-review-invitation.md
@@ -44,11 +44,10 @@ is unavailable. Never treat a StoreKit attempt or a manual link tap as a submitt
## Platform scope
-The iPhone uses StoreKit. Since 2026-10-31 the Android app follows the same policy with Google Play's in-app
-review API (`core/Review.kt` for the policy, `ReviewPrompt.kt` for the hooks): a send from the composer, a
-finished answer read in its chat, returning to Bots, then two clear seconds before Play is asked. Play decides
-whether its dialog shows; Android's Settings has **Rate on Google Play** and **Report an issue**. Desktop
-Settings and help menu and terminal settings have no store review capability and keep their behavior.
+The iPhone uses StoreKit. The Android app has no invitation until it is on Google Play (the owner's call,
+2026-11-01): its Settings has **Rate on Google Play** and **Report an issue**, and the invitation comes with the
+Play release, through Play's in-app review API and this same policy. Desktop Settings and help menu and terminal
+settings have no store review capability and keep their behavior.
## Validation (2026-10-26)
diff --git a/docs/guides/dev-app.md b/docs/guides/dev-app.md
index eebdc4d1..3d88a47a 100644
--- a/docs/guides/dev-app.md
+++ b/docs/guides/dev-app.md
@@ -32,6 +32,8 @@ Flags go after `npm run dev --`: `--shared` takes the default Codync Dev from a
A sandbox starts past onboarding (welcome and computer-access setup, only where the window hasn't chosen yet); `--onboarding` clears those two settings once per start, so the flow comes back (a signed-in sandbox passes the welcome screen by itself and lands on computer-access setup). With `CODYNC_CLERK_SECRET_KEY` (the Clerk **development** instance's `sk_test_...` key) in the git-ignored `.env.development` at the main checkout's root (copy `.env.development.example`) (every worktree reads that one file) or the environment, it also signs in its own Clerk test account `sandbox-<name>[email protected]`: `tools/dev-account.mjs` finds or creates that user through the Backend API and mints a one-time sign-in token, which `account.ts` trades for a session (`ticket` strategy, unpackaged Dev runs only). The token is minted at every start and used only while the sandbox has no active session; the app also requires a `pk_test_` publishable key, and the key never reaches the host or the agents. Keys that aren't `sk_test_` are refused. Without a key a sandbox starts signed out; it never borrows Codync Dev's login.
+Phones follow the same rule. In the main checkout, a simulator's or emulator's Codync Dev keeps your own account. From a worktree, `npm run phone-account -- --ios <simulator udid>` or `-- --android <adb serial>` (in `apps/desktop`, beside `npm run dev`) signs it into the sandbox's test account, so the phone sees the sandbox computer in its account (run the sandbox with `--cloud`). It mints a one-time token with the same `tools/dev-account.mjs`. On iOS the token goes in through the `CODYNC_DEV_SIGN_IN_TICKET` launch variable (`AccountSession.swift`). On Android it goes into a file that only adb's `run-as` can write (`NativeAccounts.signInForDevelopment`, debug builds only). Both apps trade it only against Clerk's development instance, and only while signed out. In the main checkout the tool needs an explicit `--name`.
+
Still shared: macOS sees every unpackaged run as the same Electron app, so permissions and notifications are shared and a `codync-dev://` sign-in callback may reach another copy (test sign-in on the default Codync Dev); Codync Screen and computer use need the packaged `Codync Dev.app`; a global shortcut (the approval island's) goes to whichever app registered it first.
## Local secrets
diff --git a/docs/guides/environments-and-deployment.md b/docs/guides/environments-and-deployment.md
index aa3dedec..f35fdd62 100644
--- a/docs/guides/environments-and-deployment.md
+++ b/docs/guides/environments-and-deployment.md
@@ -86,9 +86,12 @@ The repository is public, so its whole history counts as published. Last scan: 2
| `0001_init.sql` | applied | applied | — |
| `0002_windows_computers.sql` | 2026-10-07 | 2026-10-07 | dev `00000b79-00000000-000050fc-e6cb8fa431592b1c3d7824f3cf64afb9`, main `0000041d-0000085c-000050fc-fda9fcdf91e3498c08fa7c332a989e24` |
| `0003_desktop_devices.sql` | 2026-10-07 | 2026-10-07 | dev `00000cb2-00000002-000050fd-8600044ac4775783e20c8ff9b4d5fa14`, main `00000420-000012d2-000050fd-12871b6db16548f336c1c9221d28c556` |
+| `0004_android_devices.sql` | 2026-11-01 | with the next `dev` → `main` merge | dev `00003428-00000000-00005115-cc5e0e1311eab7918b2c9470a0e71611` |
`0002` lets `computers.platform` be `windows` (Windows hosts register with `std::env::consts::OS`). SQLite can't change a CHECK, so it rebuilds `computers` together with `access_requests` and `grants`, the tables that reference it: dropping a referenced table while foreign keys are enforced would count every referencing row as a violation. Live schemas matched `0001` beforehand; row counts were unchanged afterwards (dev 24 computers, 8 grants, 14 access requests; main 101, 38, 48) with no orphaned rows. A signed `POST /v1/host/register` with `platform: "windows"` returned 200 on both (the probe rows were deleted). Main's Worker answered with the previous version for about 20 seconds after `deploy`.
+`0004` lets `devices.platform` be `android`, rebuilding `devices` with `grants` and `access_requests` the same way. Until it ran, every signed-in Android phone's `POST /v1/devices` failed with a CHECK constraint (`internal`), so it saw no account computers. On dev the live schema matched `0003` beforehand. Afterwards the row counts were unchanged (70 devices, 12 grants, 22 access requests, 232 computers), with no orphaned rows and a clean `foreign_key_check`. An Android emulator then registered, was approved and revoked through the account. Main still lacks it (`wrangler d1 migrations list codync --remote`).
+
The Worker accepting `windows` was deployed to both environments from the `windows` branch on 2026-10-07, ahead of its merge; its cloud code differed from `main` only in that platform list.
`0003` lets `devices.platform` be `linux` or `windows`. Accounts were built when only the iPhone and the SwiftUI Mac app signed in; the Electron app brought sign-in to Linux (and later Windows), whose device registration the cloud rejected (`400 Invalid platform`), so main held no Linux devices at all. It rebuilds `devices` with `access_requests` and `grants` the same way as `0002`. Row counts were unchanged (dev 14 devices, 8 grants, 14 access requests; main 128, 41, 53) with no orphaned rows; a `windows` device row inserted on dev was accepted and removed. The Worker accepting both platforms was deployed to dev and main the same day from the `device-platforms` branch, which differed from `main` only there. Windows apps up to 2.9.0 register as `linux`; later ones send `windows`.
diff --git a/docs/plans/android-app.md b/docs/plans/android-app.md
index 63a96778..2c270b4a 100644
--- a/docs/plans/android-app.md
+++ b/docs/plans/android-app.md
@@ -29,7 +29,7 @@ emulator against a real host; device acceptance is listed separately.
| Live updates | Android 16 Live updates (`ProgressStyle`), the status bar chip on Android 16 QPR1 (API 36.1) | Background updates need FCM in the deployment |
| Version check | `VersionMismatch.MIN_HOST`, the host's `minApp`, the update card in the roster and in place of the composer (Update Codync opens Google Play; greyed out while Play doesn't have the version yet), the newer-release reminder (`AppUpdates.kt`, Play's in-app update info) | Set `MIN_HOST` to the first release that ships Android support when it's cut |
| Remote screen | Ported: viewer from Computers, the chat header (watch a bot, then take over) and `codync-dev://screen`; WebRTC H.264, trackpad and direct touch, long-press drag, two-finger scroll, pinch zoom streaming the visible region, keyboard with IME and modifier keys, clipboard, displays, take over/hand back, Rotate, trickle ICE that keeps the video through a channel reconnect | Pinch, IME composition and a hardware keyboard on a device; TURN relay path and renewal |
-| Analytics | Ported: PostHog feature events with the Settings switch (and its sheet), crash reports sent on the next launch; Rate on Google Play, Report an issue and the rating invitation (Play in-app review, iOS policy) | — |
+| Analytics | Ported: PostHog feature events with the Settings switch (and its sheet), crash reports sent on the next launch; Rate on Google Play and Report an issue | The rating invitation, with the Play release |
| Packaging | Debug, R8 release signed with the Play upload key, `versionCode` from the version, Firebase (`codync-auth`) and private configuration, `Submit Android` to Google Play (internal testing since 2.24.0) | Production access (closed test), see [Before a Play release](#before-a-play-release) |
## Gates before merge into dev
@@ -44,7 +44,10 @@ emulator against a real host; device acceptance is listed separately.
Where the Android app still falls short, as of 2026-11-01. Everything else in the table above
was walked through on an emulator against a real host (several computers: two disposable hosts
-on one emulator, 2026-10-31). Push delivery was walked on 2026-11-01: a debug build with Firebase
+on one emulator, 2026-10-31). The account flows were walked on 2026-11-01 against the dev cloud, with the emulator
+signed into a worktree sandbox's test account (`npm run phone-account`, [Dev app isolation](../guides/dev-app.md#worktree-sandboxes)):
+the sandbox computer in the account, Ask for access approved on the computer, *Revoke this phone's access* (the cloud
+grant is revoked, the card goes back to *Ask for access*), and an older copy of the computer shown as such. Push delivery was walked on 2026-11-01: a debug build with Firebase
(`-PcodyncGoogleServicesFile=<google-services.json>`) on the Google APIs emulator, killed, got a bot's
*Task complete* alert through the dev relay and FCM (pushes wait while any phone, an iOS simulator
included, is connected to that computer).
@@ -53,13 +56,12 @@ included, is connected to that computer).
| What | Code | What it needs |
| --- | --- | --- |
-| Revoke this phone's access (also on Remove of a computer approved through the account); removing older copies of the computer from the account | `core/.../CloudClient.kt` (`revokeAccess`, `removeComputer`), `AccountStoreAccount.kt`, `ComputersView.kt` | A signed-in account on the emulator or a phone; only request tests cover it |
| Push on a phone running the Play build, and the background Live update refresh | `PushService.kt`, `AppStoreNotifications.kt` | A phone with the official build; alert delivery through FCM is verified on the emulator |
-| OpenAI Realtime, Gemini Live and Speech mode with a real key | `WebRtcPeer.kt`, `core/.../OpenAIRealtimeEngine.kt`, `GeminiLiveEngine.kt`, `CloudSpeechEngine.kt` | A provider key on the paired computer; the fallback to on-device voice is verified |
+| OpenAI Realtime and Speech mode with a real key | `WebRtcPeer.kt`, `core/.../OpenAIRealtimeEngine.kt`, `CloudSpeechEngine.kt` | A valid OpenAI key on the paired computer. Gemini Live was walked on 2026-11-01: the session reached Gemini's `setupComplete` and listened, on the key saved on Codync Dev. The OpenAI key saved on the production host was rejected (*Incorrect API key*), and the call fell back to on-device voice with its notice |
| Remote screen: Chinese IME composition, a hardware keyboard, the TURN relay path and its credential renewal | `ScreenKeys.kt`, `ScreenSession.kt`, `ScreenView.kt` | A computer it's safe to type into, and a signed-in host for the relay; viewing, trackpad and pinch zoom are verified |
| On-device voice with a live microphone | `PlatformSpeech.kt`, `LocalVoiceAudio.kt` | A phone; on the emulator the recognizer was fed the speech fixture |
| Camera QR pairing (focus and 1080p frames), launcher widget refresh, foldables, TalkBack end to end | `QrViewfinder.kt`, `CodyncWidgets.kt` | Physical devices; portrait lock with the rotating screen viewer, 130% text and TalkBack's Move up/down were checked on the emulator |
-| Google Play's review prompt, and update info from Play itself | `AppUpdates.kt`, `ReviewPrompt.kt` | An install from Google Play (a debug build gets neither); the review policy has unit tests, and `AppUpdatesTest` drives the update reminder and *Update Codync* through Play's `FakeAppUpdateManager` |
+| Update info from Google Play itself | `AppUpdates.kt` | An install from Google Play (a debug build gets none); `AppUpdatesTest` drives the update reminder and *Update Codync* through Play's `FakeAppUpdateManager` |
### Different from the iPhone on purpose or by platform
@@ -115,8 +117,9 @@ the Dynamic Island) with its feature graphic, per language.
- [ ] Move the default push relay URL into `apps/shared/Config/{dev,main}.plist` (iOS reads
them as `AccountConfig.plist`), so the Android build stops parsing the iOS kit's
`SharedStore.swift` and iPhone-only edits there stop counting as Android changes.
-- [x] *Rate on Google Play* and *Report an issue* in the Settings tab, and the rating invitation through
- Play's in-app review API ([review invitation](../features/ios-review-invitation.md)), since 2026-10-31.
+- [x] *Rate on Google Play* and *Report an issue* in the Settings tab, since 2026-10-31.
+- [ ] The rating invitation through Play's in-app review API, with the iPhone's policy
+ ([review invitation](../features/ios-review-invitation.md)): left out until the app is on Google Play.
- [ ] *Release to production* permission for `codync-play`, then `PLAY_TRACK=production`.
## Shared deployment
@@ -124,7 +127,9 @@ the Dynamic Island) with its feature graphic, per language.
The host accepts Android pairing (older hosts refuse it, and the app asks to update
Codync on the computer) and counts Android event streams as connected phones, so
pushes are held while one is open. The cloud accepts Android device records through
-the `0004_android_devices.sql` migration. The push Worker needs the matching Firebase
+the `0004_android_devices.sql` migration, applied to dev on 2026-11-01. Main gets it right after the next `dev` → `main`
+merge, together with that release's cloud deploy ([migration log](../guides/environments-and-deployment.md#migration-log)).
+Until then, signed-in Android phones can't register with the production account. The push Worker needs the matching Firebase
service account as an external secret; the client configuration contains no private key.
![Android roster](../screenshots/android-roster.png)
diff --git a/docs/reference/analytics-events.md b/docs/reference/analytics-events.md
index 7ca243bb..9fa48f3f 100644
--- a/docs/reference/analytics-events.md
+++ b/docs/reference/analytics-events.md
@@ -157,7 +157,7 @@ into its frame.
## Store review invitations (iPhone App Store, Android Google Play)
These events use the existing phone sender, identity, environment, version and analytics
-opt-out; Android sends the same events around Google Play's in-app review. No conversation content, message nonce, bot ID or review text is included.
+opt-out. Android sends only `review_link_opened` until it has the invitation. No conversation content, message nonce, bot ID or review text is included.
| Event | When | Properties |
| --- | --- | --- |