Skip to content

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.

Android Widgets: guards for the picker previews, and the README

Claude0e071a4c1903
diff --git a/android/README.md b/android/README.md
index 09016cbf..59380293 100644
--- a/android/README.md
+++ b/android/README.md
@@ -58,16 +58,16 @@ The desktop side is in `windows/src-tauri/src/phone_link`; the protocol is `docs
- **Away from home Wi-Fi** (optional): through your own Cloudflare relay, end-to-end encrypted; the direct link is always tried first.
- **Keeping the link alive with the screen off**: an alarm every few minutes checks that the computer still answers and reconnects if not (Doze allows nothing more); Home says when and why the link was lost; Settings > Computer > *Can't connect?* checks the network, address, discovery, certificate, pairing code and relay; a calm hint suggests the battery setting ("Unrestricted", with the Samsung steps) only if it would help. Details and limits: `docs/ANDROID_LINK.md`, "Keeping the link alive".
- **Widget, quick-settings tile, ongoing notification**: agent names and state words only. Updated when something changes, never on a timer.
-- **Widgets**: nine to pick from on the home screen, all on one card (24dp corners, a thin border, dark by default and light when the system is in day mode) with a gradient and a glow in the colour of the state: orange while something waits for you, blue while an agent works, green when it is done, muted when nothing runs or the computer is not there.
+- **Widgets**: nine to pick from on the home screen, all on one card (24dp corners, a thin border, dark by default and light when the system is in day mode) with a gradient and a glow in the colour of the state: orange while something waits for you, blue while an agent works, green when it is done, muted when nothing runs or the computer is not there. In the Widget picker each one shows a large, realistic preview with sample data (Android 12 and later; Android 11 shows a still picture of the card with Mochi), its name and a one-line description. The previews are static: vector Mochi faces in `res/drawable/preview_*`, layouts in `res/layout/widget_preview_*`.
- *Coucou for Android*: the summary (unchanged).
- - *Coucou Solo* (2x2): Mochi in the state of your most urgent agent, its name and a state word.
- - *Coucou List* (4x3): one row of at least 48dp per agent (Mochi's face, name, state word, dot), up to five, with a badge for what waits for you; with no agent, a centred empty state ("Waiting for your computer" / "No agents running").
- - *Coucou Mochi Big* (4x4): a large Mochi with a speech bubble such as "Claude Code is working" (a name and a state, never a command or a file).
- - *Coucou Status Pill* (4x1): one slim line with a dot, the agent's name and its state.
- - *Coucou Waiting Alert* (2x2): calm when nothing waits, a bright orange "N waiting" when something does. A tap opens the app and the sheet rises by itself.
- - *Coucou Usage Ring* (2x2): a ring for your Claude or Codex plan usage; "Turn on plan usage in the app" when it is off.
- - *Coucou Today* (2x2): agent tasks finished today, counted on this phone only and started again at local midnight.
- - *Coucou Mochi Mood* (1x1): just his face.
+ - *Mochi at a glance* (Solo, 2x2): Mochi in the state of your most urgent agent, its name and a state word.
+ - *All your agents* (List, 4x3): one row of at least 48dp per agent (Mochi's face, name, state word, dot), up to five, with a badge for what waits for you; with no agent, a centred empty state ("Waiting for your computer" / "No agents running").
+ - *Mochi, big* (4x4): a large Mochi with a speech bubble such as "Claude Code is working" (a name and a state, never a command or a file).
+ - *One-line status* (Status Pill, 4x1): one slim line with a dot, the agent's name and its state.
+ - *Approvals waiting* (Waiting Alert, 2x2): calm when nothing waits, a bright orange "N waiting" when something does. A tap opens the app and the sheet rises by itself.
+ - *Plan usage* (Usage Ring, 2x2): a ring for your Claude or Codex plan usage; "Turn on plan usage in the app" when it is off.
+ - *Finished today* (Today, 2x2): agent tasks finished today, counted on this phone only and started again at local midnight.
+ - *Mochi's mood* (Mood, 1x1): just his face.
A tap on Solo, Mochi Big, Status Pill, Mochi Mood or a List row opens that agent in the app. A request is still decided in the app, behind the fingerprint, never from a Widget. Widgets show agent names, state words and colours only, are redrawn when something changes (`updatePeriodMillis` stays 0) and a redraw that would look the same is skipped. On Android 12 and later they adapt to their size (small, medium, large). Code: `core/WidgetData.kt` (pure, tested), `app/WidgetHub.kt`, one class per Widget in `app/`, `app/MochiBitmap.kt`, `app/RingBitmap.kt`.
- **Looking at every state without a computer** (debug builds only): `adb shell am broadcast -n com.coucou.android/.app.WidgetPreviewReceiver -a com.coucou.android.debug.WIDGET_STATE --es state <disconnected|empty|working|waiting|done|live>`; `live` goes back to the real state. The receiver is in `app/src/debug` and does not exist in a release build.
diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetPreviewTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetPreviewTest.kt
new file mode 100644
index 00000000..5409ef68
--- /dev/null
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetPreviewTest.kt
@@ -0,0 +1,229 @@
+package com.coucou.android
+
+import com.coucou.android.core.WidgetTone
+import java.io.File
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+/**
+ * What the Widget picker shows: every provider has a preview that exists, looks like the Widget with sample data, is static
+ * (no ids, no runtime bitmap, nothing from the app) and has a short name and a one-line description.
+ */
+class WidgetPreviewTest {
+ private val res = "src/main/res/"
+ private fun read(path: String) = File(path).readText()
+ private val strings: Map<String, String> =
+ Regex("""<string name="(\w+)">(.*?)</string>""").findAll(read(res + "values/strings.xml")).associate { it.groupValues[1] to it.groupValues[2].replace("\\'", "'") }
+
+ /** Provider XML name to the name of its preview. */
+ private val providers = listOf("solo", "list", "big", "pill", "alert", "ring", "today", "mood")
+ private fun info(name: String) = read("${res}xml/coucou_${name}_widget_info.xml")
+ private fun attr(xml: String, name: String) = Regex("""android:$name="([^"]*)"""").find(xml)?.groupValues?.get(1)
+ private fun preview(name: String) = read("${res}layout/widget_preview_$name.xml")
+ private val previewFiles get() = File(res + "layout").listFiles()!!.filter { it.name.startsWith("widget_preview_") }
+
+ // ── Every provider points at a preview that exists ─────────────────────────────────────────────
+
+ @Test fun everyProviderHasAPreviewLayoutAndAPreviewImageThatExist() {
+ for (n in providers) {
+ val xml = info(n)
+ assertEquals("$n previewLayout", "@layout/widget_preview_$n", attr(xml, "previewLayout"))
+ assertEquals("$n previewImage", "@drawable/widget_preview_image_$n", attr(xml, "previewImage"))
+ assertTrue(File("${res}layout/widget_preview_$n.xml").exists())
+ assertTrue(File("${res}drawable/widget_preview_image_$n.xml").exists())
+ assertTrue("$n: the initial layout exists", File("${res}layout/" + attr(xml, "initialLayout")!!.removePrefix("@layout/") + ".xml").exists())
+ // previewLayout is Android 12 and later; the app starts at Android 11, so lint is told it is deliberate.
+ assertTrue("$n", xml.contains("""tools:targetApi="31""""))
+ }
+ assertEquals("one preview layout per provider, no stray ones", providers.map { "widget_preview_$it.xml" }.sorted(), previewFiles.map { it.name }.sorted())
+ }
+
+ @Test fun theFirstWidgetKeepsItsProviderAsItWas() {
+ assertFalse(info("solo").isEmpty())
+ val first = read(res + "xml/coucou_widget_info.xml")
+ assertFalse(first.contains("preview"))
+ assertTrue(first.contains("""android:initialLayout="@layout/widget_glance""""))
+ }
+
+ // ── Names and descriptions ─────────────────────────────────────────────────────────────────────
+
+ @Test fun everyLabelAndDescriptionIsShortClearAndOneLine() {
+ val manifest = read("src/main/AndroidManifest.xml")
+ val labels = mutableSetOf<String>()
+ for (n in providers) {
+ val desc = attr(info(n), "description")!!.removePrefix("@string/")
+ val label = Regex("""android:name="\.app\.\w+"\s+android:exported="true"\s+android:label="@string/(\w+)"[^>]*>\s*<intent-filter>(?:(?!</receiver>).)*?coucou_${n}_widget_info""", RegexOption.DOT_MATCHES_ALL)
+ .find(manifest)?.groupValues?.get(1)
+ assertNotNull("$n has no label in the manifest", label)
+ val l = strings.getValue(label!!)
+ val d = strings.getValue(desc)
+ assertTrue("$n label is empty", l.isNotBlank())
+ assertTrue("$n description is empty", d.isNotBlank())
+ assertTrue("$n label '$l' is long", l.length <= 24)
+ assertTrue("$n description '$d' is long", d.length <= 60)
+ assertFalse("$n description spans lines", d.contains("\n") || d.contains("\\n"))
+ assertTrue("$n description should end with a full stop", d.endsWith("."))
+ assertFalse("$n label is the description", l == d)
+ assertTrue("$n label says Coucou although the picker already shows the app", !l.startsWith("Coucou"))
+ labels += l
+ }
+ assertEquals("two Widgets with the same name", providers.size, labels.size)
+ }
+
+ @Test fun theNamesAreTheOnesInTheBrief() {
+ val expected = mapOf(
+ "widget_solo_label" to "Mochi at a glance", "widget_list_label" to "All your agents", "widget_big_label" to "Mochi, big",
+ "widget_pill_label" to "One-line status", "widget_alert_label" to "Approvals waiting", "widget_ring_label" to "Plan usage",
+ "widget_today_label" to "Finished today", "widget_mood_label" to "Mochi's mood",
+ )
+ for ((k, v) in expected) assertEquals(k, v, strings[k])
+ }
+
+ // ── The preview layouts are static, self-contained and clean ───────────────────────────────────
+
+ @Test fun aPreviewHasNoIdAndNothingFromTheAppAtRuntime() {
+ for (f in previewFiles) {
+ val xml = f.readText()
+ // An id is how the app finds a view to update: a preview has none, so nothing can be pushed into it.
+ assertFalse("${f.name} has an id", Regex("""android:id=|@\+id/|@id/""").containsMatchIn(xml))
+ for (tag in listOf("<include", "<merge", "<ViewStub", "<fragment", "<ListView", "<GridView")) assertFalse("${f.name} uses $tag", xml.contains(tag))
+ // The root fills the cell the provider asks for, so the picker neither squashes nor crops it.
+ val root = xml.substringAfter("<FrameLayout").substringBefore(">")
+ assertTrue(f.name, root.contains("""android:layout_width="match_parent"""") && root.contains("""android:layout_height="match_parent""""))
+ }
+ }
+
+ @Test fun aPreviewSaysNoCommandNoStepAndNoFile() {
+ for (f in previewFiles) {
+ val xml = f.readText()
+ val text = xml + "\n" + Regex("""@string/(\w+)""").findAll(xml).joinToString("\n") { strings.getValue(it.groupValues[1]) }
+ for (word in listOf("statusText", "steps", ".command", "files")) assertFalse("${f.name} says $word", text.contains(word))
+ }
+ }
+
+ @Test fun aPreviewOnlyUsesVectorsAndTheSharedResources() {
+ val allowed = setOf("FrameLayout", "LinearLayout", "TextView", "ImageView")
+ for (f in previewFiles) {
+ val xml = f.readText()
+ for (tag in Regex("""<(\w+)[\s>]""").findAll(xml).map { it.groupValues[1] }) assertTrue("${f.name}: <$tag>", tag in allowed)
+ // Every drawable it names is an XML drawable (vector, shape or layer list), never a bitmap.
+ for (d in Regex("""@drawable/(\w+)""").findAll(xml).map { it.groupValues[1] }.toSet()) {
+ assertTrue("${f.name}: @drawable/$d is not an XML drawable", File("${res}drawable/$d.xml").exists())
+ }
+ // The shared card and tone colours, not literals; the only literal colour is the dark text on the orange badge.
+ assertFalse(f.name, Regex("""android:textColor="#(?!FF1C1C1E)""").containsMatchIn(xml))
+ assertTrue(f.name, xml.contains("@drawable/widget_card"))
+ assertTrue(f.name, xml.contains("@drawable/widget_tint_"))
+ // Every image is described or hidden from accessibility (a still picture of a sample).
+ for (img in Regex("""<ImageView[^>]*>""").findAll(xml)) assertTrue("${f.name}: $img", img.value.contains("importantForAccessibility=\"no\"") || img.value.contains("contentDescription"))
+ }
+ }
+
+ @Test fun theSampleDataIsTheOneInTheBrief() {
+ fun text(n: String) = Regex("""@string/(\w+)""").findAll(preview(n)).map { strings.getValue(it.groupValues[1]) }.toList()
+ assertEquals(listOf("Claude Code", "Waiting for your approval", "1"), text("solo").filter { it in setOf("Claude Code", "Waiting for your approval", "1") })
+ val list = text("list")
+ assertEquals("Waiting for you", list.first())
+ assertEquals(listOf("Waiting for you", "1", "Claude Code", "Waiting for your approval", "Codex", "Working", "Gemini CLI", "Finished"), list)
+ assertEquals(3, Regex("""android:minHeight="@dimen/widget_row_min"""").findAll(preview("list")).count())
+ assertTrue(text("big").contains("Claude Code is working"))
+ assertEquals(listOf("Claude Code", "Working"), text("pill"))
+ assertEquals(listOf("2 waiting", "Claude Code"), text("alert"))
+ assertEquals(listOf("70%", "Claude · 5 h"), text("ring"))
+ assertTrue(text("today").containsAll(listOf("5", "done today")))
+ assertTrue("the Mood preview shows only a face", text("mood").isEmpty())
+ // The tones of the samples: waiting orange, working blue, finished green.
+ assertTrue(preview("solo").contains("widget_tone_attention") && preview("solo").contains("preview_mochi_waiting"))
+ assertTrue(preview("pill").contains("widget_tone_working"))
+ assertTrue(preview("alert").contains("widget_card_attention"))
+ assertTrue(preview("big").contains("preview_mochi_working"))
+ assertTrue(preview("mood").contains("preview_mochi_done") && preview("today").contains("preview_mochi_done"))
+ assertTrue(preview("list").let { it.contains("preview_face_waiting") && it.contains("preview_face_working") && it.contains("preview_face_done") })
+ assertTrue(preview("ring").contains("preview_ring_70"))
+ }
+
+ @Test fun theBadgeAndTheAlertAreOrange() {
+ for (n in listOf("solo", "list")) assertTrue(n, preview(n).contains("@drawable/widget_badge_bg"))
+ assertTrue(File(res + "drawable/widget_badge_bg.xml").readText().contains("#FFFF9F0A"))
+ assertTrue(preview("alert").contains("""android:textColor="@color/widget_tone_attention""""))
+ }
+
+ // ── The vector Mochi ───────────────────────────────────────────────────────────────────────────
+
+ private val states = mapOf("working" to WidgetTone.WORKING, "waiting" to WidgetTone.ATTENTION, "done" to WidgetTone.DONE, "idle" to WidgetTone.MUTED)
+ private fun hex(t: WidgetTone) = t.argb.toUInt().toString(16).uppercase().padStart(8, '0').substring(2)
+
+ @Test fun everyStateHasAVectorFaceAGlowAndTheLayeredMochi() {
+ for ((state, tone) in states) {
+ val face = read("${res}drawable/preview_face_$state.xml")
+ val glow = read("${res}drawable/preview_glow_$state.xml")
+ val mochi = read("${res}drawable/preview_mochi_$state.xml")
+ assertTrue(state, face.contains("<vector") && glow.contains("<vector"))
+ // The glow is in the state's colour and fades to nothing, and sits behind the face.
+ assertTrue("$state glow colour", glow.contains(hex(tone)))
+ assertTrue("$state glow fades out", glow.contains("""android:type="radial"""") && Regex("""android:color="#00${hex(tone)}"""").containsMatchIn(glow))
+ assertTrue(mochi.indexOf("preview_glow_$state") in 0 until mochi.indexOf("preview_face_$state"))
+ // The body, its light gradient, the pink cheeks and two dark eyes.
+ assertTrue(face.contains("#EDEDEF") && face.contains("#C4C5CA"))
+ assertTrue(face.contains("#59FF7896"))
+ assertTrue(state, Regex("""#1A1412""").findAll(face).count() >= 2)
+ for (d in listOf(face, glow)) {
+ assertTrue(d.contains("""android:viewportWidth="120"""") && d.contains("""android:viewportHeight="120""""))
+ }
+ }
+ }
+
+ @Test fun theBadgesAreTheOnesOfTheStates() {
+ assertTrue("blue dots bubble", read(res + "drawable/preview_face_working.xml").let { it.contains("#3B9EFF") && Regex("""#FFFFFF" android:pathData="M25.5""").containsMatchIn(it) })
+ assertTrue("orange bang", read(res + "drawable/preview_face_waiting.xml").let { it.contains("#F5A524\" android:pathData=\"M25.7") && it.contains("#FFFFFF") })
+ assertTrue("green check", read(res + "drawable/preview_face_done.xml").let { it.contains("#34D499") && it.contains("""android:strokeColor="#FFFFFF"""") })
+ assertFalse("calm: no badge", read(res + "drawable/preview_face_idle.xml").contains("""android:fillColor="#000000""""))
+ }
+
+ @Test fun theRingIsAnArcAtSeventyPercentInTheMediumTone() {
+ val ring = read(res + "drawable/preview_ring_70.xml")
+ assertTrue(ring.contains("""android:strokeLineCap="round""""))
+ assertTrue(ring.contains("#" + hex(WidgetTone.ATTENTION)))
+ // 70 % of the circle from the top, clockwise: it ends at 252 degrees (x = 50 + 44 sin, y = 50 - 44 cos).
+ val end = Regex("""M50,6 A44,44 0 1 1 (?!50,)([\d.]+),([\d.]+)""").find(ring)!!.groupValues
+ assertEquals(50 + 44 * Math.sin(Math.toRadians(252.0)), end[1].toDouble(), 0.1)
+ assertEquals(50 - 44 * Math.cos(Math.toRadians(252.0)), end[2].toDouble(), 0.1)
+ }
+
+ @Test fun nothingInThePreviewsIsABitmap() {
+ for (dir in File(res).listFiles()!!.filter { it.name.startsWith("drawable") || it.name.startsWith("mipmap") }) {
+ for (f in dir.listFiles()!!.filter { it.name.startsWith("preview_") || it.name.startsWith("widget_preview_") }) {
+ assertEquals("${f.path} is not an XML drawable", "xml", f.extension)
+ }
+ }
+ }
+
+ @Test fun theFallbackImageIsTheCardWithMochiInIt() {
+ for (n in providers) {
+ val d = read("${res}drawable/widget_preview_image_$n.xml")
+ assertTrue(n, d.contains("<layer-list"))
+ assertTrue(n, d.contains("@drawable/widget_card"))
+ assertTrue(n, d.contains("@drawable/widget_tint_"))
+ assertTrue(n, d.contains("@drawable/preview_"))
+ }
+ }
+
+ // ── The initial layout is never a blank box ────────────────────────────────────────────────────
+
+ @Test fun everyInitialLayoutShowsMochiOrAFaceAndAShortLineUntilTheFirstUpdate() {
+ val real = mapOf("solo" to "solo", "list" to "list", "big" to "big", "pill" to "pill", "alert" to "alert", "ring" to "ring", "today" to "today", "mood" to "mood")
+ for ((n, layout) in real) {
+ val xml = read("${res}layout/widget_$layout.xml")
+ assertTrue("$n has no starting face", xml.contains("@drawable/preview_mochi_idle") || xml.contains("@drawable/preview_face_idle") || n == "pill")
+ if (n != "mood") assertTrue("$n has no starting line", xml.contains("@string/widget_initial_"))
+ }
+ assertEquals("Coucou", strings["widget_initial_title"])
+ assertEquals("Waiting for your agents", strings["widget_initial_line"])
+ // The List starts on its empty state, not on empty rows.
+ val list = read(res + "layout/widget_list.xml")
+ assertTrue(Regex("""@\+id/list_header"[^>]*android:visibility="gone"""", RegexOption.DOT_MATCHES_ALL).containsMatchIn(list.substringBefore("@+id/list_status")))
+ }
+}
diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
index 5666498b..2b3b5c0f 100644
--- a/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
@@ -233,7 +233,9 @@ class WidgetSurfacesTest {
for (layout in File("src/main/res/layout").listFiles()!!.filter { it.name.startsWith("widget_") && it.name != "widget_glance.xml" }) {
val xml = layout.readText()
assertTrue(layout.name, xml.contains("@drawable/widget_card"))
- assertTrue(layout.name, xml.contains("@drawable/widget_tint_muted"))
+ // A real layout starts muted and is repainted by WidgetHub; a preview is already in the tone of its sample.
+ if (layout.name.startsWith("widget_preview_")) assertTrue(layout.name, xml.contains("@drawable/widget_tint_"))
+ else assertTrue(layout.name, xml.contains("@drawable/widget_tint_muted"))
for (tag in Regex("""<(\w+)[\s>]""").findAll(xml).map { it.groupValues[1] }) assertTrue("${layout.name}: <$tag> in a RemoteViews layout", tag in allowed)
// Colours come from the shared resources (so the light variant follows the system), not from a literal.
assertFalse(layout.name, Regex("""android:textColor="#(?!FF1C1C1E)""").containsMatchIn(xml))
@@ -244,8 +246,11 @@ class WidgetSurfacesTest {
val strings = File("../i18n/app-strings.json").readText()
val texts = listOf(strings, File("../README.md").readText(), File("../../docs/android.html").readText()).joinToString("\n")
assertFalse(texts.contains("Wedge", ignoreCase = true))
- for (w in listOf("Coucou Mochi Big", "Coucou Status Pill", "Coucou Waiting Alert", "Coucou Usage Ring", "Coucou Today", "Coucou Mochi Mood", "Coucou Solo", "Coucou List")) {
+ // The picker names: short, and the same ones in the README.
+ val readme = File("../README.md").readText()
+ for (w in listOf("Mochi at a glance", "All your agents", "Mochi, big", "One-line status", "Approvals waiting", "Plan usage", "Finished today", "Mochi's mood")) {
assertTrue(w, strings.contains(w))
+ assertTrue("$w is not in the README", readme.contains(w))
}
}
}