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
TalkBack: every tapped Widget area speaks one sentence, with a guard for the rest
Claude48cafce6d18f
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.ktindex c2a8c65e..5a5078f8 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.kt@@ -8,6 +8,7 @@ import android.util.SizeFimport android.view.Viewimport android.widget.RemoteViewsimport com.coucou.android.R+import com.coucou.android.core.WidgetSpokenimport com.coucou.android.core.Glanceimport com.coucou.android.core.WidgetToneimport com.coucou.android.core.look@@ -61,7 +62,7 @@ class GlanceWidget : AppWidgetProvider() {val mood = g.mood()v.setImageViewBitmap(R.id.glance_mochi, MochiBitmap.of(mood, WidgetHub.px(context, 64), glow = true, tone = tone))- v.setContentDescription(R.id.glance_mochi, context.getString(R.string.widget_mochi_description, mood.key))+ v.setContentDescription(R.id.glance_mochi, context.getString(R.string.widget_mochi_description, WidgetSpoken.mood(mood)))v.setViewVisibility(R.id.glance_offline, if (g.connected) View.GONE else View.VISIBLE)v.setTextViewText(R.id.glance_headline, g.headline)@@ -93,6 +94,7 @@ class GlanceWidget : AppWidgetProvider() {v.setTextViewText(r.text, line.text)}+ v.setContentDescription(R.id.widget_root, listOf(g.headline, g.detail).filter { it.isNotBlank() }.joinToString(". "))v.setOnClickPendingIntent(R.id.widget_root, WidgetHub.openApp(context, WidgetHub.CODE_GLANCE))return v}diff --git a/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.ktindex 5d09c8cf..e8303c1c 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.kt@@ -8,6 +8,7 @@ import android.view.Viewimport android.widget.RemoteViewsimport com.coucou.android.Rimport com.coucou.android.core.WidgetContent+import com.coucou.android.core.WidgetSpoken/*** The List widget: the headline with a badge, then one row per agent of at least 48dp (a bar in its own colour, Mochi's@@ -41,6 +42,7 @@ class ListWidget : AppWidgetProvider() {val v = RemoteViews(context.packageName, R.layout.widget_list)WidgetHub.paint(v, R.id.list_root, R.id.list_tint, c.look)v.setOnClickPendingIntent(R.id.list_root, WidgetHub.openApp(context, WidgetHub.CODE_LIST_HEADER))+ v.setContentDescription(R.id.list_root, WidgetSpoken.list(c))if (c.tiles.isEmpty()) {// The empty state fills the card: Mochi asleep (or calm) with his glow, the headline and one clear line.@@ -48,7 +50,7 @@ class ListWidget : AppWidgetProvider() {v.setViewVisibility(R.id.list_rows, View.GONE)v.setViewVisibility(R.id.list_empty, View.VISIBLE)v.setImageViewBitmap(R.id.list_empty_face, MochiBitmap.of(c.mood, WidgetHub.px(context, 96), glow = true, tone = c.look))- v.setContentDescription(R.id.list_empty_face, context.getString(R.string.widget_mochi_description, c.mood.key))+ v.setContentDescription(R.id.list_empty_face, context.getString(R.string.widget_mochi_description, WidgetSpoken.mood(c.mood)))v.setImageViewResource(R.id.list_empty_icon, if (c.connected) R.drawable.widget_dot else R.drawable.ic_widget_offline)v.setInt(R.id.list_empty_icon, "setColorFilter", c.look.argb)v.setTextViewText(R.id.list_empty_title, c.headline)@@ -87,6 +89,7 @@ class ListWidget : AppWidgetProvider() {v.setTextViewText(r.name, tile.name)v.setTextViewText(r.state, tile.stateWord)v.setInt(r.dot, "setColorFilter", tile.tone.argb)+ v.setContentDescription(r.row, WidgetSpoken.tile(tile))v.setOnClickPendingIntent(r.row, WidgetHub.openSession(context, WidgetHub.CODE_LIST_ROW + i, tile.pillId))}return vdiff --git a/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.ktindex 68e0f8bb..fc20f3ba 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt@@ -12,6 +12,7 @@ import com.coucou.android.core.LaunchScreenimport com.coucou.android.core.UsageRingimport com.coucou.android.core.UsageSideimport com.coucou.android.core.WidgetContent+import com.coucou.android.core.WidgetSpokenimport com.coucou.android.core.WidgetTone/**@@ -92,6 +93,7 @@ class MochiBigWidget : AppWidgetProvider() {} else {v.setViewVisibility(R.id.big_badge, View.GONE)}+ v.setContentDescription(R.id.big_root, WidgetSpoken.top(c))v.setOnClickPendingIntent(R.id.big_root,if (top != null) WidgetHub.openSession(context, WidgetHub.CODE_BIG, top.pillId) else WidgetHub.openApp(context, WidgetHub.CODE_BIG),@@ -123,6 +125,13 @@ class MochiBigWidget : AppWidgetProvider() {val second = rows.getOrNull(1)?.takeIf { !small }if (second != null) bindRow(v, context, second, BigRow(R.id.big_usage_b, R.id.big_usage_b_label, R.id.big_usage_b_pct, R.id.big_usage_b_pct_big, R.id.big_usage_b_note, R.id.big_usage_b_bar))else v.setViewVisibility(R.id.big_usage_b, View.GONE)+ // The whole usage side, in one sentence per plan (a near-limit row says so, and when it resets).+ v.setContentDescription(+ R.id.big_right,+ listOfNotNull(rows[0], second).joinToString(". ") { r ->+ listOfNotNull(context.getString(R.string.widget_ring_cd, r.plan, r.shown), r.note).joinToString(", ")+ },+ )v.setOnClickPendingIntent(R.id.big_right, WidgetHub.openApp(context, WidgetHub.CODE_BIG_USAGE_APP))}UsageSide.OFF, UsageSide.NOT_CONNECTED -> {@@ -132,10 +141,12 @@ class MochiBigWidget : AppWidgetProvider() {if (c.usageSide == UsageSide.NOT_CONNECTED) {v.setTextViewText(R.id.big_off_title, context.getString(R.string.widget_big_not_connected))v.setTextViewText(R.id.big_off_line, c.emptyLine.orEmpty())+ v.setContentDescription(R.id.big_right, "${context.getString(R.string.widget_big_not_connected)}. ${c.emptyLine.orEmpty()}")v.setOnClickPendingIntent(R.id.big_right, WidgetHub.openApp(context, WidgetHub.CODE_BIG_USAGE_APP))} else {v.setTextViewText(R.id.big_off_title, context.getString(R.string.widget_big_usage_off))v.setTextViewText(R.id.big_off_line, context.getString(R.string.widget_big_usage_off_line))+ v.setContentDescription(R.id.big_right, "${context.getString(R.string.widget_big_usage_off)}. ${context.getString(R.string.widget_big_usage_off_line)}")v.setOnClickPendingIntent(R.id.big_right, WidgetHub.openScreen(context, WidgetHub.CODE_BIG_USAGE_SETTINGS, LaunchScreen.SETTINGS))}}diff --git a/android/app/src/main/kotlin/com/coucou/android/app/MoodWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/MoodWidget.ktindex e7a3fd90..17a3aa47 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/MoodWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/MoodWidget.kt@@ -7,6 +7,7 @@ import android.view.Viewimport android.widget.RemoteViewsimport com.coucou.android.Rimport com.coucou.android.core.WidgetContent+import com.coucou.android.core.WidgetSpoken/*** The Mochi Mood widget: only Mochi's face in the current state, with his glow. Drawn by [WidgetHub] when something changes@@ -24,6 +25,7 @@ class MoodWidget : AppWidgetProvider() {v.setContentDescription(R.id.mood_face, context.getString(R.string.widget_mochi_description, (c.top?.stateWord ?: c.headline).lowercase()))v.setViewVisibility(R.id.mood_offline, if (c.connected) View.GONE else View.VISIBLE)val top = c.top+ v.setContentDescription(R.id.mood_root, WidgetSpoken.top(c))v.setOnClickPendingIntent(R.id.mood_root,if (top != null) WidgetHub.openSession(context, WidgetHub.CODE_MOOD, top.pillId) else WidgetHub.openApp(context, WidgetHub.CODE_MOOD),diff --git a/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.ktindex 8c60821e..c796b837 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.kt@@ -9,6 +9,7 @@ import android.view.Viewimport android.widget.RemoteViewsimport com.coucou.android.Rimport com.coucou.android.core.WidgetContent+import com.coucou.android.core.WidgetSpoken/*** The Solo widget: Mochi with a glow in the state's colour, the name of the most urgent agent with a dot and one state@@ -36,6 +37,8 @@ class SoloWidget : AppWidgetProvider() {v.setImageViewBitmap(R.id.solo_mochi, MochiBitmap.of(c.mood, WidgetHub.px(context, if (large) 150 else if (small) 72 else 104), glow = true, tone = c.look))val word = top?.stateWord ?: c.headlinev.setContentDescription(R.id.solo_mochi, context.getString(R.string.widget_mochi_description, word.lowercase()))+ // The tapped card says who and what, in one sentence.+ v.setContentDescription(R.id.solo_root, WidgetSpoken.top(c))if (top != null) {v.setViewVisibility(R.id.solo_name_row, View.VISIBLE)diff --git a/android/app/src/main/kotlin/com/coucou/android/app/TodayWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/TodayWidget.ktindex 0a11d93e..24e5136f 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/TodayWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/TodayWidget.kt@@ -7,6 +7,7 @@ import android.content.Intentimport android.widget.RemoteViewsimport com.coucou.android.Rimport com.coucou.android.core.WidgetContent+import com.coucou.android.core.WidgetSpoken/*** The Today widget: how many agent tasks finished today. The count is kept on this phone only ([TodayStore]) and starts@@ -36,7 +37,7 @@ class TodayWidget : AppWidgetProvider() {val v = RemoteViews(context.packageName, R.layout.widget_today)WidgetHub.paint(v, R.id.today_root, R.id.today_tint, c.todayLook)v.setImageViewBitmap(R.id.today_face, MochiBitmap.of(c.todayMood, WidgetHub.px(context, 72), glow = true, tone = c.todayLook))- v.setContentDescription(R.id.today_face, context.getString(R.string.widget_mochi_description, c.todayMood.key))+ v.setContentDescription(R.id.today_face, context.getString(R.string.widget_mochi_description, WidgetSpoken.mood(c.todayMood)))v.setTextViewText(R.id.today_count, c.today.toString())v.setContentDescription(R.id.today_root, context.getString(R.string.widget_today_cd, c.today))v.setOnClickPendingIntent(R.id.today_root, WidgetHub.openApp(context, WidgetHub.CODE_TODAY))diff --git a/android/app/src/main/kotlin/com/coucou/android/app/WaitingAlertWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/WaitingAlertWidget.ktindex f2a409c0..f4a19502 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/WaitingAlertWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/WaitingAlertWidget.kt@@ -7,6 +7,7 @@ import android.view.Viewimport android.widget.RemoteViewsimport com.coucou.android.Rimport com.coucou.android.core.WidgetContent+import com.coucou.android.core.WidgetSpoken/*** The Waiting Alert widget: calm when nothing waits for you; a bright orange "N waiting", an orange border and an anxious@@ -22,7 +23,7 @@ class WaitingAlertWidget : AppWidgetProvider() {val v = RemoteViews(context.packageName, R.layout.widget_alert)WidgetHub.paint(v, R.id.alert_root, R.id.alert_tint, c.look)v.setImageViewBitmap(R.id.alert_face, MochiBitmap.of(c.mood, WidgetHub.px(context, 84), glow = true, tone = c.look))- v.setContentDescription(R.id.alert_face, context.getString(R.string.widget_mochi_description, c.mood.key))+ v.setContentDescription(R.id.alert_face, context.getString(R.string.widget_mochi_description, WidgetSpoken.mood(c.mood)))v.setViewVisibility(R.id.alert_offline, if (c.connected) View.GONE else View.VISIBLE)val waiting = c.waiting > 0v.setViewVisibility(R.id.alert_count, if (waiting) View.VISIBLE else View.GONE)@@ -30,6 +31,7 @@ class WaitingAlertWidget : AppWidgetProvider() {v.setTextViewText(if (waiting) R.id.alert_count else R.id.alert_calm, c.alertLine)v.setTextViewText(R.id.alert_sub, c.alertSub)if (waiting) v.setContentDescription(R.id.alert_count, context.getString(R.string.widget_badge_description, c.waiting))+ v.setContentDescription(R.id.alert_root, WidgetSpoken.alert(c))v.setOnClickPendingIntent(R.id.alert_root, WidgetHub.openApp(context, WidgetHub.CODE_ALERT))return v}diff --git a/android/app/src/main/kotlin/com/coucou/android/core/WidgetSpoken.kt b/android/app/src/main/kotlin/com/coucou/android/core/WidgetSpoken.ktnew file mode 100644index 00000000..481768e7--- /dev/null+++ b/android/app/src/main/kotlin/com/coucou/android/core/WidgetSpoken.kt@@ -0,0 +1,39 @@+package com.coucou.android.core++import com.coucou.android.mochi.BotState++/**+ * What TalkBack says for a Widget: whole sentences for the parts that are tapped, built from the same words the Widget shows (agent+ * names, state words, counts), so the spoken text can never say more than the screen does. Pure.+ */+object WidgetSpoken {+ /** Mochi's mood in plain words ("waiting for you"), not the engine's key ("approval"). */+ fun mood(state: BotState): String = when (state) {+ BotState.IDLE -> "calm"+ BotState.WORKING -> "working"+ BotState.THINKING -> "thinking"+ BotState.SEARCHING -> "searching"+ BotState.APPROVAL -> "waiting for you"+ BotState.QUESTION -> "has a question"+ BotState.ERROR -> "in trouble"+ BotState.FINISHED -> "happy"+ BotState.RATELIMIT -> "at a limit"+ BotState.SLEEPING -> "asleep"+ BotState.DIZZY -> "dizzy"+ }++ /** One agent: "Claude Code, waiting for your approval". */+ fun tile(t: WidgetTile): String = SpokenLabels.agent(t.name, t.stateWord, null)++ /** The tapped card of Solo and Mood: the top agent, or the headline when there is none; with what waits for you. */+ fun top(c: WidgetContent): String {+ val base = c.top?.let { tile(it) } ?: SpokenLabels.agent(c.headline, c.emptyLine.orEmpty(), null)+ return if (c.waiting > 0 && c.top != null) "$base. ${c.waiting} waiting for you" else base+ }++ /** Waiting Alert: "1 waiting. Claude Code", "All calm. Nothing needs you", "Not connected. Waiting for your PC". */+ fun alert(c: WidgetContent): String = "${c.alertLine}. ${c.alertSub}"++ /** The header of the list. */+ fun list(c: WidgetContent): String = if (c.waiting > 0) "${c.headline}. ${c.waiting} waiting for you" else c.headline+}diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetAccessibilityTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetAccessibilityTest.ktnew file mode 100644index 00000000..3e4b3b74--- /dev/null+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetAccessibilityTest.kt@@ -0,0 +1,72 @@+package com.coucou.android++import java.io.File+import javax.xml.parsers.DocumentBuilderFactory+import org.junit.Assert.assertEquals+import org.junit.Assert.assertFalse+import org.junit.Assert.assertTrue+import org.junit.Test+import org.w3c.dom.Element++/** TalkBack: no Widget has a picture or a tapped area that is silent, and no spoken text is a raw engine key. */+class WidgetAccessibilityTest {+ private val main = "src/main/"+ private val ns = "http://schemas.android.com/apk/res/android"+ private val widgets = listOf(+ "SoloWidget", "ListWidget", "MochiBigWidget", "StatusPillWidget", "WaitingAlertWidget", "UsageRingWidget", "TodayWidget", "MoodWidget", "GlanceWidget",+ )++ private fun layouts() = File(main + "res/layout").listFiles { f -> f.name.startsWith("widget_") && !f.name.startsWith("widget_preview_") }!!.sortedBy { it.name }++ private fun elements(f: File): List<Element> {+ val doc = DocumentBuilderFactory.newInstance().apply { isNamespaceAware = true }.newDocumentBuilder().parse(f)+ val all = doc.getElementsByTagName("*")+ return (0 until all.length).map { all.item(it) as Element }+ }++ @Test fun everyPictureInAWidgetLayoutIsDescribedOrSilent() {+ for (f in layouts()) for (e in elements(f)) {+ if (e.tagName != "ImageView") continue+ val described = e.getAttributeNS(ns, "contentDescription").isNotEmpty()+ val silent = e.getAttributeNS(ns, "importantForAccessibility") == "no"+ assertTrue("${f.name} ${e.getAttributeNS(ns, "id")} is neither described nor marked unimportant", described || silent)+ }+ }++ @Test fun everyTappedAreaIsDescribedByLayoutOrCode() {+ for (name in widgets) {+ val src = File(main + "kotlin/com/coucou/android/app/$name.kt").readText()+ val layoutText = layouts().joinToString("\n") { it.readText() }+ // Areas named in the code; those in a loop (the buttons) are described in the layout, which the first test covers.+ val tapped = Regex("""setOnClickPendingIntent\(\s*R\.id\.(\w+),""").findAll(src).map { it.groupValues[1] }.toSet()+ for (id in tapped) {+ val byCode = src.contains("setContentDescription(R.id.$id,") || src.contains("setContentDescription($id,")+ val byLayout = layouts().any { f ->+ elements(f).any { e -> e.getAttributeNS(ns, "id") == "@+id/$id" && e.getAttributeNS(ns, "contentDescription").isNotEmpty() }+ }+ assertTrue("$name taps $id without a spoken description", byCode || byLayout)+ }+ }+ }++ @Test fun theRoundButtonsOfThePillSpeakTheirAction() {+ val pill = elements(File(main + "res/layout/widget_pill.xml")).filter { it.getAttributeNS(ns, "id").startsWith("@+id/pill_btn") }+ assertTrue(pill.size >= 4)+ for (e in pill) assertTrue(e.getAttributeNS(ns, "id"), e.getAttributeNS(ns, "contentDescription").startsWith("@string/widget_btn_"))+ }++ @Test fun spokenTextIsWordsNotEngineKeys() {+ for (name in widgets) {+ val src = File(main + "kotlin/com/coucou/android/app/$name.kt").readText()+ assertFalse("$name speaks a raw key", Regex("""widget_mochi_description,\s*[\w.]*mood\.key""").containsMatchIn(src))+ assertFalse("$name speaks a raw key", Regex("""widget_mochi_description,\s*[\w.]*Mood\.key""").containsMatchIn(src))+ }+ }++ @Test fun theTappedCardsSpeakOneSentence() {+ for (name in listOf("SoloWidget", "ListWidget", "WaitingAlertWidget", "MoodWidget")) {+ assertTrue(name, File(main + "kotlin/com/coucou/android/app/$name.kt").readText().contains("WidgetSpoken."))+ }+ assertEquals(1, Regex("WidgetSpoken\\.alert").findAll(File(main + "kotlin/com/coucou/android/app/WaitingAlertWidget.kt").readText()).count())+ }+}diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetSpokenTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetSpokenTest.ktnew file mode 100644index 00000000..676de05f--- /dev/null+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetSpokenTest.kt@@ -0,0 +1,55 @@+package com.coucou.android++import com.coucou.android.core.WidgetData+import com.coucou.android.core.WidgetSample+import com.coucou.android.core.WidgetSpoken+import com.coucou.android.mochi.BotState+import org.junit.Assert.assertEquals+import org.junit.Assert.assertFalse+import org.junit.Assert.assertTrue+import org.junit.Test++class WidgetSpokenTest {+ private fun sample(s: WidgetSample) = WidgetData.sample(s, 1_000_000L)++ @Test fun everyMoodHasWordsNotAKey() {+ for (s in BotState.values()) {+ val w = WidgetSpoken.mood(s)+ assertTrue(s.toString(), w.isNotBlank())+ }+ assertEquals("waiting for you", WidgetSpoken.mood(BotState.APPROVAL))+ assertFalse("the engine key is not a word", WidgetSpoken.mood(BotState.APPROVAL) == BotState.APPROVAL.key)+ }++ @Test fun aWaitingAgentIsSaidWithItsStateAndTheCount() {+ val c = sample(WidgetSample.WAITING)+ assertEquals("Claude Code, waiting for your approval. 1 waiting for you", WidgetSpoken.top(c))+ assertEquals("1 waiting. Claude Code", WidgetSpoken.alert(c))+ assertTrue(WidgetSpoken.list(c).endsWith("1 waiting for you"))+ }++ @Test fun aWorkingAgentIsJustItsState() {+ val c = sample(WidgetSample.WORKING)+ assertEquals("Claude Code, working", WidgetSpoken.top(c))+ assertEquals(WidgetSpoken.tile(c.top!!), WidgetSpoken.top(c))+ assertEquals(c.headline, WidgetSpoken.list(c))+ }++ @Test fun theEmptyAndDisconnectedStatesAreSpokenToo() {+ val off = sample(WidgetSample.DISCONNECTED)+ assertEquals("Not connected. Waiting for your PC", WidgetSpoken.alert(off))+ assertTrue(WidgetSpoken.top(off).startsWith(off.headline))+ assertTrue(WidgetSpoken.top(sample(WidgetSample.EMPTY)).isNotBlank())+ assertEquals("All calm. Nothing needs you", WidgetSpoken.alert(sample(WidgetSample.EMPTY)))+ }++ @Test fun nothingSpokenIsMoreThanTheWidgetShows() {+ // Names, state words and counts only: a sentence never carries a command or a file.+ for (s in WidgetSample.values()) {+ val c = sample(s)+ for (text in listOf(WidgetSpoken.top(c), WidgetSpoken.alert(c), WidgetSpoken.list(c)) + c.tiles.map { WidgetSpoken.tile(it) }) {+ for (word in listOf("command", "path", "statusText", ".kt")) assertFalse("$s: $text", text.contains(word, ignoreCase = true))+ }+ }+ }+}