Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix(android): keep the push switch with each computer

leepokaic678b57f706b
diff --git a/apps/android/WhatsNew.md b/apps/android/WhatsNew.md
index e70c138f..821c6b59 100644
--- a/apps/android/WhatsNew.md
+++ b/apps/android/WhatsNew.md
@@ -11,12 +11,12 @@ else a generic "Bug fixes and improvements" line. Delete old sections.
### zh-Hant
- Agent、模型、推理強度與 Fast mode 整合成可收合的精簡設定;每個 Bot 可獨立保存推理強度,Default 也會顯示預設值。
-- 「設定」現在是「狀態」右邊的獨立分頁,只放這支手機自己的設定。電腦的擴充套件、語音、螢幕、推送通知與連線,都移到「管理電腦」裡那台電腦的卡片上。
+- 「設定」現在是「狀態」右邊的獨立分頁,只放這支手機自己的設定。電腦的擴充套件、語音、螢幕、推送通知與連線,都移到「管理電腦」裡那台電腦的卡片上;推送通知可以逐台電腦開關。
- 電腦卡片最下方的「Codync」會顯示那台電腦的版本;有新版時可以直接點「更新」。
- 電腦卡片多了網路按鈕(Beta):一台電腦可加入多個網路,列出各網路的電腦、是否在線、提供的 Bot、誰能傳訊息給這裡的 Bot,以及雲端助理是否開啟。Bot 設定多了「提供給網路」與「雲端助理可聯繫」開關。
### en-US
-- Agent, model, reasoning effort and Fast mode now share compact, expandable settings. Each bot keeps its own effort preference, with the default level shown.
-- Settings is now its own tab, next to State, with only this phone's own settings. Your computer's Extensions, Voice chat, Screen, Push notifications and Connection are on its card in Manage computers.
-- Codync at the bottom of the card shows the version your computer runs; when a newer one is out, tap Update.
-- A network button (beta) on each computer's card: a computer can be in several networks; see each one's computers, whether each answers, its bots, who may message the bots here, and cloud assistants. Bot settings add Offered to the network and Reachable by cloud assistants.
+- Agent, model, effort and Fast mode share compact settings; each bot keeps its own effort.
+- Settings is its own tab; each computer's Extensions, Voice chat, Screen, Push (now per computer) and Connection moved to its card in Manage computers.
+- The card shows your computer's Codync version, with Update when a newer one is out.
+- Network (beta) on the card lists your networks' computers and bots; bot settings add Offered to the network and Reachable by cloud assistants.
diff --git a/apps/android/app/src/androidTest/kotlin/com/codync/android/LiveRosterTest.kt b/apps/android/app/src/androidTest/kotlin/com/codync/android/LiveRosterTest.kt
index 9a53a025..8afcd263 100644
--- a/apps/android/app/src/androidTest/kotlin/com/codync/android/LiveRosterTest.kt
+++ b/apps/android/app/src/androidTest/kotlin/com/codync/android/LiveRosterTest.kt
@@ -87,7 +87,7 @@ class LiveRosterTest {
val bot = MirrorDatabase(context, local.directory, computer.id).use { it.snapshot().bots.first() }
val permitted = context.getSystemService(android.app.NotificationManager::class.java).areNotificationsEnabled()
assertTrue("Enable notifications in the phone's app settings before physical push acceptance", permitted)
- assertTrue("Enable bot notifications in Codync before push acceptance", PushPreferences.enabled(context))
+ assertTrue("Enable bot notifications in Codync before push acceptance", computer.notifications)
val destination = buildJsonObject {
put("fid", requireNotNull(PushPreferences.fid(context)))
put("pushKey", local.identity().pushKey)
diff --git a/apps/android/app/src/androidTest/kotlin/com/codync/android/PushTest.kt b/apps/android/app/src/androidTest/kotlin/com/codync/android/PushTest.kt
index ba297044..f58e08f7 100644
--- a/apps/android/app/src/androidTest/kotlin/com/codync/android/PushTest.kt
+++ b/apps/android/app/src/androidTest/kotlin/com/codync/android/PushTest.kt
@@ -26,7 +26,6 @@ class PushTest {
@Test fun sealedFallbackStaysGenericAndInactiveContextsCannotNotify() {
val previous = PushPreferences.activeUser(context)
- val previousEnabled = PushPreferences.enabled(context)
val previousVisible = PushDelivery.foreground
val user = "push-test-${UUID.randomUUID()}"
val local = LocalStore(context, user)
@@ -41,7 +40,7 @@ class PushTest {
if (permission) instrumentation.uiAutomation.grantRuntimePermission(context.packageName, Manifest.permission.POST_NOTIFICATIONS)
try {
local.saveComputers(listOf(computer)); local.identity()
- PushPreferences.active(context, user); PushPreferences.enabled(context, true); PushDelivery.foreground = false
+ PushPreferences.active(context, user); PushDelivery.foreground = false
val data = mapOf("kind" to "alert", "ctx" to local.referenceId, "computerId" to computer.id, "botId" to bot,
"sealed" to "invalid", "title" to "Never display unsealed private text", "body" to "private content")
PushService.receive(context, data + ("ctx" to "local"))
@@ -58,12 +57,12 @@ class PushTest {
PushService.receive(context, data)
assertTrue(manager.activeNotifications.none { it.tag == tag })
PushDelivery.foreground = false
- PushPreferences.enabled(context, false)
+ local.saveComputers(listOf(computer.copy(notifications = false)))
PushService.receive(context, data)
assertTrue(manager.activeNotifications.none { it.tag == tag })
} finally {
manager.cancel(tag, 1); local.erase()
- PushPreferences.active(context, previous); PushPreferences.enabled(context, previousEnabled); PushDelivery.foreground = previousVisible
+ PushPreferences.active(context, previous); PushDelivery.foreground = previousVisible
// Revoking this permission kills the test process on newer Android releases.
// These storage/identity tests run only on disposable emulator installations.
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt
index d40bcbfb..a33facee 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt
@@ -18,7 +18,6 @@ data class AppState(
val approvedAccess: Map<String, String> = emptyMap(),
/** The account computer an access request is running for: one at a time. */
val askingAccess: String? = null,
- val notifications: Boolean = true,
val tasks: Boolean = true,
val setupComplete: Boolean = false,
val loading: Boolean = true,
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt
index e313f86c..dc973886 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt
@@ -87,7 +87,7 @@ class AppStore(application: Application) : AndroidViewModel(application) {
val complete = withContext(Dispatchers.IO) { local.setupComplete() }
mutableState.update { AppState(contextId = local.referenceId, generation = it.generation + 1,
account = it.account, computers = computers, setupComplete = complete || computers.isNotEmpty() || userId != null) }
- mutableState.update { it.copy(notifications = PushPreferences.enabled(getApplication()), tasks = PushPreferences.tasks(getApplication())) }
+ mutableState.update { it.copy(tasks = PushPreferences.tasks(getApplication())) }
openMirror()
if (userId != null) configureCloud(userId)
mutableState.update { it.copy(loading = false) }
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreAccount.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreAccount.kt
index 06d544c9..2e511e94 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreAccount.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreAccount.kt
@@ -124,7 +124,8 @@ private suspend fun AppStore.askForAccess(target: CloudComputer, renew: Boolean)
}
/** Switch only after approval, retiring the old channel and its writers before replacing its mirror. */
-internal fun AppStore.useApprovedComputer(computer: Computer, requestId: String) {
+internal fun AppStore.useApprovedComputer(approved: Computer, requestId: String) {
+ val computer = approved.keepingDevicePicks(state.value.computers.firstOrNull { it.id == approved.id && it.signKey == approved.signKey })
// Approval is already confirmed by the cloud, even when switching must wait.
mutableState.update { it.copy(approvedAccess = it.approvedAccess + (computer.id to requestId)) }
val contextId = state.value.contextId
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt
index 9329713f..2ae7671f 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt
@@ -62,7 +62,7 @@ internal fun AppStore.pair(text: String, via: PairedVia) {
val identity = withContext(Dispatchers.IO) { local.identity() }
// Picked on this phone: re-pairing keeps them (iOS `AccountStore.pair`).
val paired = HostConnector.pair(pairing, identity, Build.MODEL.take(100))
- val computer = old?.let { paired.copy(color = it.color, route = it.route) } ?: paired
+ val computer = paired.keepingDevicePicks(old)
withContext(Dispatchers.IO) { local.saveComputers(listOf(computer)); local.completeSetup() }
mutableState.update { it.copy(computers = listOf(computer), setupComplete = true) }
Analytics.capture(AnalyticsEvent.ComputerPaired(via, computer.id))
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreNotifications.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreNotifications.kt
index c6163e5d..ad04fc0e 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreNotifications.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreNotifications.kt
@@ -16,9 +16,12 @@ fun AppStore.syncPush() = action("push") {
catch (error: CancellationException) { throw error }
catch (_: Exception) { PushDelivery.schedule(getApplication()) }
}
+/** Saved with the computer on this phone (iOS `AccountStore.setNotifications`). */
fun AppStore.notifications(enabled: Boolean) = action("notificationSettings") {
- PushPreferences.enabled(getApplication(), enabled)
- mutableState.update { it.copy(notifications = enabled) }
+ val computer = state.value.computers.firstOrNull() ?: return@action
+ val changed = computer.copy(notifications = enabled)
+ withContext(Dispatchers.IO) { local.saveComputers(listOf(changed)) }
+ mutableState.update { it.copy(computers = listOf(changed)) }
Analytics.capture(AnalyticsEvent.SettingChanged(PhoneSetting.Push, enabled))
if (!enabled) NotificationDisplay.cancel(getApplication(), 1)
syncPush(); PushDelivery.schedule(getApplication())
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ComputersView.kt b/apps/android/app/src/main/kotlin/com/codync/android/ComputersView.kt
index b18c7c46..e88fc208 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ComputersView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ComputersView.kt
@@ -114,7 +114,7 @@ private class ComputerActions(val extensions: () -> Unit, val screen: () -> Unit
/**
* The paired computer as the rows of its card: its connection and whether it's in the account, then
* Extensions, Voice chat (its keys live on the computer), Screen, whether it sends push alerts here
- * (the only computer this phone pairs, so the switch is the phone's), how it's reached, the Codync it runs
+ * (saved with the computer, so another account's computer keeps its own), how it's reached, the Codync it runs
* (and its update) and, for a stale pairing, Remove (iOS `ComputerRows`).
*/
private fun CardRows.computerRows(state: AppState, store: AppStore, inAccount: Boolean, actions: ComputerActions) {
@@ -126,7 +126,7 @@ private fun CardRows.computerRows(state: AppState, store: AppStore, inAccount: B
if (state.network?.shown == true) row { RowLabel("Network", NETWORK_ICON, chevron = true, modifier = Modifier.plainButton(action = actions.network)) }
}
if (BuildConfig.PUSH_CONFIGURED) row {
- CodyncSwitch(state.notifications, store::notifications, Modifier.fillMaxWidth()) {
+ CodyncSwitch(state.computers.first().notifications, store::notifications, Modifier.fillMaxWidth()) {
RowLabel("Push notifications", "bell", modifier = Modifier.weight(1f))
}
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/PushService.kt b/apps/android/app/src/main/kotlin/com/codync/android/PushService.kt
index 1579b757..80741cf0 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/PushService.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/PushService.kt
@@ -26,7 +26,6 @@ import kotlinx.serialization.json.*
object PushPreferences {
private fun prefs(context: Context) = context.getSharedPreferences("codync-push", Context.MODE_PRIVATE)
fun activeUser(context: Context): String? = prefs(context).getString("user", null)
- fun enabled(context: Context) = prefs(context).getBoolean("enabled", true)
fun tasks(context: Context) = prefs(context).getBoolean("tasks", true)
fun asked(context: Context) = prefs(context).getBoolean("asked", false)
fun markAsked(context: Context) { prefs(context).edit().putBoolean("asked", true).apply() }
@@ -35,7 +34,6 @@ object PushPreferences {
fun active(context: Context, user: String?) = synchronized(this) { prefs(context).edit().putString("user", user).putBoolean("retired", false).commit() }
fun retired(context: Context) = prefs(context).getBoolean("retired", false)
fun retire(context: Context) = synchronized(this) { prefs(context).edit().putBoolean("retired", true).commit() }
- fun enabled(context: Context, enabled: Boolean) { prefs(context).edit().putBoolean("enabled", enabled).commit() }
fun tasks(context: Context, enabled: Boolean) { prefs(context).edit().putBoolean("tasks", enabled).commit() }
fun reset(context: Context) {
val token = fid(context)
@@ -81,7 +79,7 @@ object PushDelivery {
feed.all().forEach { active.call("unregisterActivity", body("botId" to it.botId)) }
feed.clear()
}
- if (!PushPreferences.enabled(context) || !permitted) {
+ if (!computer.notifications || !permitted) {
active.call("unregisterDevice")
if (!permitted || !PushPreferences.tasks(context) || feed.all().none { !it.finished }) return
}
@@ -94,7 +92,7 @@ object PushDelivery {
}.addOnFailureListener { error -> continuation.resumeWith(Result.failure(error)) }
}
val identity = withContext(Dispatchers.IO) { local.identity() }
- if (PushPreferences.enabled(context)) {
+ if (computer.notifications) {
val ticket = PushRelay.ticket(BuildConfig.PUSH_RELAY_URL, token, local.referenceId, computer.id)
currentCoroutineContext().ensureActive()
active.call("registerDevice", buildJsonObject {
@@ -170,7 +168,7 @@ class PushService : FirebaseMessagingService() {
if (data["ctx"] != scope || data["kind"] !in setOf("alert", "task")) return
val local = LocalStore(context, user ?: "local")
val computerId = data["computerId"] ?: return
- if (local.computers().none { it.id == computerId }) return
+ val computer = local.computers().firstOrNull { it.id == computerId } ?: return
val botId = data["botId"]?.takeIf { it.matches(Regex("[A-Za-z0-9_-]{1,128}")) } ?: return
if (!context.getSystemService(NotificationManager::class.java).areNotificationsEnabled()) return
NotificationDisplay.channels(context)
@@ -180,7 +178,7 @@ class PushService : FirebaseMessagingService() {
NotificationDisplay.task(context, scope, computerId, watch)
return
}
- if (!PushPreferences.enabled(context) || PushDelivery.foreground) return
+ if (!computer.notifications || PushDelivery.foreground) return
var alert = PushAlert(title = context.getString(R.string.app_name), body = "A bot has an update.")
try {
if (local.hasIdentity()) {
diff --git a/apps/android/core/src/main/kotlin/com/codync/android/core/Computer.kt b/apps/android/core/src/main/kotlin/com/codync/android/core/Computer.kt
index cef22741..64e89a4e 100644
--- a/apps/android/core/src/main/kotlin/com/codync/android/core/Computer.kt
+++ b/apps/android/core/src/main/kotlin/com/codync/android/core/Computer.kt
@@ -14,7 +14,13 @@ data class Computer(
val route: ConnectionRoute = ConnectionRoute.Automatic,
/** The badge color picked on this phone (an `AvatarPalette` id). */
val color: String? = null,
+ /** Whether this computer sends push alerts to this phone, switched on its card. */
+ val notifications: Boolean = true,
) {
+ /** Keeps what this phone picked (color, route, push) over a newer copy from pairing or the account (iOS `keepDevicePicks`). */
+ fun keepingDevicePicks(previous: Computer?): Computer =
+ previous?.let { copy(color = it.color, route = it.route, notifications = it.notifications) } ?: this
+
fun validate() {
require(RelayCrypto.computerId(signKey.decodeBase64Url(32)) == id) { "This computer's identity changed. Pair it again." }
boxKey?.decodeBase64Url(32)
diff --git a/apps/android/core/src/test/kotlin/com/codync/android/core/PairingTest.kt b/apps/android/core/src/test/kotlin/com/codync/android/core/PairingTest.kt
index 5c2b694f..5ff3be29 100644
--- a/apps/android/core/src/test/kotlin/com/codync/android/core/PairingTest.kt
+++ b/apps/android/core/src/test/kotlin/com/codync/android/core/PairingTest.kt
@@ -25,6 +25,15 @@ class PairingTest {
assertEquals(fixture.getValue("pairing").let { it as kotlinx.serialization.json.JsonObject }.text("offerId"), pairing.offerId)
}
+ @Test fun `pairing again keeps the color route and push switch picked on this phone`() {
+ val paired = Pairing.parse(link(), "codync").computer
+ val picked = paired.copy(name = "Old name", color = "mint", route = ConnectionRoute.DirectOnly, notifications = false)
+ val kept = paired.keepingDevicePicks(picked)
+ assertEquals(Triple("mint", ConnectionRoute.DirectOnly, false), Triple(kept.color, kept.route, kept.notifications))
+ assertEquals(params["name"], kept.name)
+ assertEquals(paired, paired.keepingDevicePicks(null))
+ }
+
@Test fun `Codync Dev and Codync only accept their own pairing links`() {
val dev = link().replace("codync://", "codync-dev://")
assertEquals(params["id"], Pairing.parse(dev, "codync-dev").computer.id)