A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Home: name the likely cause when the link is lost
Claudea638941aa9e1
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/AppModel.kt b/android/app/src/main/kotlin/com/coucou/android/app/AppModel.ktindex f860fb13..cb2c7b8b 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/AppModel.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/AppModel.kt@@ -462,6 +462,9 @@ class AppModel(private val context: Context) : LinkListener {// ── Keeping the link alive while the phone sleeps (docs/ANDROID_LINK.md, "Keeping the link alive") ──/** What happened to the link: when it was lost and why, and how often the screen had been off when it was. */+ /** Whether the phone is on Wi-Fi now, for the sentence that names why the link was lost. */+ val wifiUp: Boolean get() = netWatch.wifiUp+var health by mutableStateOf(LinkHealth(dropsWhileScreenOff = kv.getInt("link_drops_off", 0))); private set/** The screen was off at some point since the link last came up. */@Volatile private var screenWasOff = falsediff --git a/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.kt b/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.ktindex 8d4748e5..17850c95 100644--- a/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.kt+++ b/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.kt@@ -34,19 +34,25 @@ object LinkHealthText {}}- private fun why(reason: LostReason?) = when (reason) {+ /**+ * The most likely cause in plain words, from what the link layer knows: why the link ended and whether the phone is on Wi-Fi. The+ * phone cannot see the computer's side, so a cause it cannot know is a short list of what to look at, never a guess stated as fact.+ */+ fun why(reason: LostReason?, wifiUp: Boolean = true) = when (reason) {LostReason.SILENT -> "The computer stopped answering. This is usual after the phone slept."- LostReason.CLOSED -> "The computer closed the connection."- LostReason.NETWORK -> "The network dropped."+ LostReason.CLOSED -> "The computer closed the connection. Coucou may have been closed or restarted there."+ LostReason.NETWORK ->+ if (!wifiUp) "The phone is not on Wi-Fi. Join the network your computer is on, or use the internet link."+ else "The phone cannot reach the computer. Coucou may be closed there, its phone link may be off, or it is on another network."null -> ""}/** The two lines for Home while the link is down after having worked; null when there is nothing to say. */- fun lines(connected: Boolean, health: LinkHealth, nowMs: Long): Pair<String, String>? {+ fun lines(connected: Boolean, health: LinkHealth, nowMs: Long, wifiUp: Boolean = true): Pair<String, String>? {val at = health.lostAtMs ?: return nullif (connected) return nullval head = "Connection lost ${ago(nowMs - at)} ago, reconnecting" + if (health.attempts >= 3) " (${health.attempts} tries)" else ""- return head to why(health.reason)+ return head to why(health.reason, wifiUp)}}diff --git a/android/app/src/main/kotlin/com/coucou/android/ui/ConnectionHelp.kt b/android/app/src/main/kotlin/com/coucou/android/ui/ConnectionHelp.ktindex bb606d93..3485d1a8 100644--- a/android/app/src/main/kotlin/com/coucou/android/ui/ConnectionHelp.kt+++ b/android/app/src/main/kotlin/com/coucou/android/ui/ConnectionHelp.kt@@ -39,7 +39,7 @@ fun LinkHealthPanel(model: AppModel, onHelp: () -> Unit) {value = System.currentTimeMillis()}}- val lines = LinkHealthText.lines(model.linkState == LinkState.CONNECTED, model.health, now) ?: return+ val lines = LinkHealthText.lines(model.linkState == LinkState.CONNECTED, model.health, now, model.wifiUp) ?: returnval t = tokens()Panel {Column(Modifier.padding(Spacing.INSIDE.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {diff --git a/android/app/src/test/kotlin/com/coucou/android/link/LinkHealthTest.kt b/android/app/src/test/kotlin/com/coucou/android/link/LinkHealthTest.ktindex b7080480..ad0a7b61 100644--- a/android/app/src/test/kotlin/com/coucou/android/link/LinkHealthTest.kt+++ b/android/app/src/test/kotlin/com/coucou/android/link/LinkHealthTest.kt@@ -27,7 +27,19 @@ class LinkHealthTest {assertEquals("Connection lost 2 min ago, reconnecting", head)assertTrue(why.contains("phone slept"))assertTrue(LinkHealthText.lines(false, h.copy(reason = LostReason.CLOSED), 1_000_000)!!.second.contains("closed"))- assertTrue(LinkHealthText.lines(false, h.copy(reason = LostReason.NETWORK), 1_000_000)!!.second.contains("network"))+ assertTrue(LinkHealthText.lines(false, h.copy(reason = LostReason.NETWORK), 1_000_000)!!.second.contains("cannot reach the computer"))+ }++ @Test fun theCauseIsNamedFromWhatThePhoneKnows() {+ // Not on Wi-Fi: say that, not "the network dropped".+ assertTrue(LinkHealthText.why(LostReason.NETWORK, wifiUp = false).contains("not on Wi-Fi"))+ // On Wi-Fi but unreachable: the computer's side is a short list of what to look at.+ val reach = LinkHealthText.why(LostReason.NETWORK, wifiUp = true)+ assertTrue(reach.contains("closed there") && reach.contains("phone link may be off") && reach.contains("another network"))+ assertTrue(LinkHealthText.why(LostReason.CLOSED).contains("closed or restarted"))+ assertEquals("", LinkHealthText.why(null))+ assertFalse(LinkHealthText.why(LostReason.NETWORK, true).contains("dropped"))+ assertTrue(LinkHealthText.lines(false, LinkHealth().lost(0, LostReason.NETWORK, false), 0, wifiUp = false)!!.second.contains("not on Wi-Fi"))}@Test fun nothingIsSaidWhenConnectedOrWhenNothingWasLost() {