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(apps): keep the pairing check code whole, and let Android debug builds use a local cloud

leepokai883a998aa8d1
diff --git a/apps/android/app/src/main/AndroidManifest.xml b/apps/android/app/src/main/AndroidManifest.xml
index eab6a096..49bbe80f 100644
--- a/apps/android/app/src/main/AndroidManifest.xml
+++ b/apps/android/app/src/main/AndroidManifest.xml
@@ -21,6 +21,7 @@
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<application
+ android:name=".CodyncApplication"
android:enableOnBackInvokedCallback="true"
android:allowBackup="false"
android:fullBackupContent="false"
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/CodyncApplication.kt b/apps/android/app/src/main/kotlin/com/codync/android/CodyncApplication.kt
new file mode 100644
index 00000000..7e5dc279
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/CodyncApplication.kt
@@ -0,0 +1,12 @@
+package com.codync.android
+
+import android.app.Application
+import com.codync.android.core.LocalCloud
+
+/** Runs first in every process (activities, push, widgets): a debug build may use a cloud on the developer's machine. */
+class CodyncApplication : Application() {
+ override fun onCreate() {
+ super.onCreate()
+ LocalCloud.allowed = BuildConfig.DEBUG
+ }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt b/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt
index c4d9a945..25d74ea6 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt
@@ -95,7 +95,8 @@ internal fun pairingLine(pasted: String, scheme: String): String =
pairingLine(runCatching { Pairing.parse(pasted, scheme).computer.cloud }.getOrNull())
/** What the pairing page shows while it pairs: the code a computer in no account shows when it asks, as `123 456`. */
-internal fun pairingCheckLine(code: String): String = "If the computer asks, check it shows ${code.take(3)} ${code.drop(3)}."
+/** The code's halves keep together on one line (a no-break space). */
+internal fun pairingCheckLine(code: String): String = "If the computer asks, check it shows ${code.take(3)}\u00A0${code.drop(3)}."
/** A sentence to translate, and the counts that fill its `%d`s in order. */
internal data class Phrase(val template: String, val counts: List<Int> = emptyList()) {
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/PairingView.kt b/apps/android/app/src/main/kotlin/com/codync/android/PairingView.kt
index a14238af..5bd8f50e 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/PairingView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/PairingView.kt
@@ -226,7 +226,7 @@ private enum class ComputerOS { Mac, Linux }
Box(Modifier.fillMaxWidth().aspectRatio(1f).clip(RoundedRectangle(24.dp))) {
key(attempt) { QrViewfinder({ pair(it) }, Modifier.fillMaxSize()) { message -> if (message != null) error = message } }
val dim by animateFloatAsState(if (state.pairing) 1f else 0f, Motion.fade(), label = "Pairing")
- if (dim > 0f) Column(Modifier.fillMaxSize().graphicsLayer { alpha = dim }.background(Palette.background.copy(alpha = 0.7f))
+ if (dim > 0f) Column(Modifier.fillMaxSize().graphicsLayer { alpha = dim }.background(Palette.background)
.padding(24.dp), Arrangement.spacedBy(16.dp, Alignment.CenterVertically), Alignment.CenterHorizontally) {
Spinner(28.dp)
// A computer in no account asks its user first: the same code on both says it's this phone.
diff --git a/apps/android/app/src/test/kotlin/com/codync/android/PairingCopyTest.kt b/apps/android/app/src/test/kotlin/com/codync/android/PairingCopyTest.kt
index f28670a1..dc516fe1 100644
--- a/apps/android/app/src/test/kotlin/com/codync/android/PairingCopyTest.kt
+++ b/apps/android/app/src/test/kotlin/com/codync/android/PairingCopyTest.kt
@@ -24,8 +24,8 @@ class PairingCopyTest {
@Test fun `the pairing check reads as two groups of three and fills the shared phrase`() {
val line = pairingCheckLine("855066")
- assertEquals("If the computer asks, check it shows 855 066.", line)
+ assertEquals("If the computer asks, check it shows 855\u00A0066.", line)
val table = mapOf("If the computer asks, check it shows {code}." to "如果電腦問你,確認它顯示 {code}。")
- assertEquals("如果電腦問你,確認它顯示 855 066。", translate(line, AppLanguage.ZhHant, systemIsChinese = false, table))
+ assertEquals("如果電腦問你,確認它顯示 855\u00A0066。", translate(line, AppLanguage.ZhHant, systemIsChinese = false, table))
}
}
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 8fc6ff01..906a1622 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
@@ -46,8 +46,14 @@ internal fun isDirectUrl(value: String): Boolean {
return url.username.isEmpty() && url.password.isEmpty() && url.fragment == null
}
+/** Debug builds set this: plain http to this machine also counts as a cloud (a local Wrangler), as in the iPhone's debug build. */
+object LocalCloud {
+ @Volatile var allowed = false
+}
+
internal fun isCloudUrl(value: String): Boolean {
val url = value.toHttpUrlOrNull() ?: return false
- return url.isHttps && url.username.isEmpty() && url.password.isEmpty() && url.query == null && url.fragment == null
+ val local = LocalCloud.allowed && url.scheme == "http" && url.host in setOf("127.0.0.1", "localhost")
+ return (url.isHttps || local) && url.username.isEmpty() && url.password.isEmpty() && url.query == null && url.fragment == null
}
diff --git a/apps/android/core/src/test/kotlin/com/codync/android/core/LocalCloudTest.kt b/apps/android/core/src/test/kotlin/com/codync/android/core/LocalCloudTest.kt
new file mode 100644
index 00000000..a240bcb2
--- /dev/null
+++ b/apps/android/core/src/test/kotlin/com/codync/android/core/LocalCloudTest.kt
@@ -0,0 +1,20 @@
+package com.codync.android.core
+
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class LocalCloudTest {
+ @Test fun `plain http counts as a cloud only on this machine and only in debug builds`() {
+ try {
+ assertFalse(isCloudUrl("http://127.0.0.1:8787"))
+ LocalCloud.allowed = true
+ assertTrue(isCloudUrl("http://127.0.0.1:8787"))
+ assertTrue(isCloudUrl("http://localhost:8787"))
+ assertFalse("never another machine", isCloudUrl("http://example.test"))
+ assertTrue(isCloudUrl("https://dev-api.codync.dev"))
+ } finally {
+ LocalCloud.allowed = false
+ }
+ }
+}
diff --git a/apps/ios/Views/PairingView.swift b/apps/ios/Views/PairingView.swift
index 3a460116..b79278a8 100644
--- a/apps/ios/Views/PairingView.swift
+++ b/apps/ios/Views/PairingView.swift
@@ -312,20 +312,18 @@ private struct ScanPage: View {
Image(systemName: "qrcode.viewfinder").font(.system(size: 44, weight: .light))
Text(L10n.tr("Camera not available. Paste the link below.")).font(.footnote)
}
- // The pairing progress takes its place.
- .opacity(pairing ? 0 : 1)
.foregroundStyle(Palette.tertiary)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Palette.surface)
}
if pairing {
- Palette.background.opacity(0.7)
+ Palette.background
VStack(spacing: 16) {
Spinner(size: 28)
// A computer in no account asks its user first, showing the same code.
if let code = app.accounts.pairingCheck {
Text(L10n.tr("If the computer asks, check it shows {code}.")
- .replacingOccurrences(of: "{code}", with: "\(code.prefix(3)) \(code.suffix(3))"))
+ .replacingOccurrences(of: "{code}", with: "\(code.prefix(3))\u{00A0}\(code.suffix(3))"))
.font(.subheadline.monospacedDigit())
.foregroundStyle(Palette.text)
.multilineTextAlignment(.center)
diff --git a/docs/guides/cloudflare-testing.md b/docs/guides/cloudflare-testing.md
index 9839cec3..cdcfc7b4 100644
--- a/docs/guides/cloudflare-testing.md
+++ b/docs/guides/cloudflare-testing.md
@@ -53,6 +53,21 @@ The integration runner starts an isolated Wrangler service and real host with te
This runner does not validate a deployed Worker, actual Google consent, APNs or iOS background behavior. Cloud CI runs unit/type checks; run this integration command explicitly for the complete local scenario.
+### Real phones against a local cloud
+
+To walk a cloud change on the iPhone and Android apps before it is deployed (for example the device certificates and short pairing codes of 2.36.0), run Wrangler so it trusts the dev Clerk instance's tokens, and point a host and the debug apps at it. Debug builds of both apps accept plain `http` to `127.0.0.1`/`localhost` as a cloud.
+
+```sh
+cd cloud && npx wrangler d1 migrations apply codync-local --env local --local
+curl -s https://sunny-mollusk-8651.clerk.accounts.dev/.well-known/jwks.json # → CLERK_JWT_KEY as PEM
+npx wrangler dev --env local --port 8787 --var CLERK_ISSUER:https://sunny-mollusk-8651.clerk.accounts.dev \
+ --var "CLERK_JWT_KEY:$PEM" --var "DEVICE_CERT_KEY:$JWK" # a throwaway Ed25519 JWK
+CODYNC_HOME=$TMP CODYNC_CLOUD_URL=http://127.0.0.1:8787 CODYNC_DEVICE_CERT_KEY=$PUB codync-host serve --port 19391
+```
+
+- iPhone: launch with `SIMCTL_CHILD_CODYNC_CLOUD_URL=http://127.0.0.1:8787` (also while running `npm run phone-account`).
+- Android: build with `-PcodyncCloudUrl=http://127.0.0.1:8787` plus the dev `codyncClerkPublishableKey` and `codyncPushRelayUrl` (the three go together), and `adb reverse tcp:8787 tcp:8787`.
+
## Troubleshooting
- **Direct works, relay fails:** compare cloud URLs, cloud enablement, registration status and host logs.