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 buttons and the restyled Widgets, and the README

Claudee179544f1e10
diff --git a/android/README.md b/android/README.md
index 59380293..8761c7af 100644
--- a/android/README.md
+++ b/android/README.md
@@ -59,17 +59,17 @@ The desktop side is in `windows/src-tauri/src/phone_link`; the protocol is `docs
- **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. 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).
+ - *Agents summary* (3x2, the first Widget, same receiver as before): its text and counts are unchanged, now on the shared card with a small Mochi in the state of your most urgent agent, a headline with a badge for what waits for you and up to three short lines with a state dot each. A tap anywhere opens the app; it has no buttons.
- *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.
+ - *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), the status line and rounded buttons under it: Home, Chat, Settings, Recent, the top agent and Pair again (tinted orange while something waits). Smaller, one row of four, then none.
+ - *One-line status* (Status Pill, 4x1): one slim line with a dot, the agent's name and its state word, and four round buttons that open Home, Chat, Settings and Recent decisions. Narrower, the state word goes first, then the name; the text never runs under the buttons.
- *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`.
+ The buttons only open a screen of the app, from a closed list (`core/LaunchScreen.kt`) through the non-exported `LaunchActivity`; none approves, denies or sends anything, and `MainActivity` still reads no intent extra. 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.
- Mochi and his 11 outfits, sounds, wardrobe (Settings), a tap on Mochi slaps him, a long press pets him.
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt
index 6812fb50..5a84a665 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
@@ -22,9 +22,9 @@ class MochiBigWidget : AppWidgetProvider() {
WidgetHub.refresh(context, manager, ids) { c, w -> views(c, w) }
companion object {
- // Height in dp, so that Mochi keeps at least 40% of the card: under 270 no buttons, from 270 one row of four, from 380 two rows.
- private val MEDIUM_AT = SizeF(0f, 270f)
- private val LARGE_AT = SizeF(0f, 380f)
+ // Height in dp, so that Mochi keeps at least 40% of the card: under 290 no buttons, from 290 one row of four, from 400 two rows.
+ private val MEDIUM_AT = SizeF(0f, 290f)
+ private val LARGE_AT = SizeF(0f, 400f)
private class Tile(val view: Int, val screen: LaunchScreen?)
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/StatusPillWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/StatusPillWidget.kt
index c7bd8ad1..88f53dc5 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/StatusPillWidget.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/StatusPillWidget.kt
@@ -15,16 +15,16 @@ import com.coucou.android.core.WidgetContent
* word; on the right four round buttons (Home, Chat, Settings, Recent) that open that screen of the app. Narrower, the state
* word goes first, then the name; the buttons never move and the text never runs under them. Drawn by [WidgetHub] when
* something changes (updatePeriodMillis = 0). A tap on the text opens the top agent, or the app. It only opens things: no
- * button approves, denies or sends anything.
+ * button changes anything.
*/
class StatusPillWidget : AppWidgetProvider() {
override fun onUpdate(context: Context, manager: AppWidgetManager, ids: IntArray) =
WidgetHub.refresh(context, manager, ids) { c, w -> views(c, w) }
companion object {
- // Width in dp: under 260 only the dot is left of the buttons, from 260 the name, from 330 the state word too.
- private val MEDIUM_AT = SizeF(260f, 0f)
- private val LARGE_AT = SizeF(330f, 0f)
+ // Width in dp: under 290 only the dot is left of the buttons, from 290 the name, from 360 the state word too.
+ private val MEDIUM_AT = SizeF(290f, 0f)
+ private val LARGE_AT = SizeF(360f, 0f)
private class Button(val view: Int, val screen: LaunchScreen)
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt b/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt
index 49fb3b58..59da9a8c 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt
@@ -139,7 +139,7 @@ object WidgetHub {
/**
* Opens one screen of the closed [LaunchScreen] list, for a button. Through LaunchActivity like [openSession]: explicit
- * component, immutable, one [code] of its own per button, and only the key of the screen travels. Nothing is approved.
+ * component, immutable, one [code] of its own per button, and only the key of the screen travels. Nothing is changed.
*/
fun openScreen(context: Context, code: Int, screen: LaunchScreen): PendingIntent {
val open = Intent(context, LaunchActivity::class.java)
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/LaunchScreen.kt b/android/app/src/main/kotlin/com/coucou/android/core/LaunchScreen.kt
index 210556bb..72603fb3 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/LaunchScreen.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/LaunchScreen.kt
@@ -4,7 +4,7 @@ package com.coucou.android.core
* The screens a Widget button may open: a closed list, never a free string. A button carries the [key] of one of these to
* LaunchActivity (ours, not exported), which turns it into a [LaunchScreen] with [parse] and hands it to the app inside
* the process ([PendingLaunch]). Anything that is not in the list is rejected, so a button can only ever open a screen; none
- * approves, denies or sends anything.
+ * changes or sends anything.
*/
enum class LaunchScreen(val key: String, val screen: Screen) {
HOME("home", Screen.HOME),
diff --git a/android/app/src/test/kotlin/com/coucou/android/LaunchScreenTest.kt b/android/app/src/test/kotlin/com/coucou/android/LaunchScreenTest.kt
new file mode 100644
index 00000000..dbbf6397
--- /dev/null
+++ b/android/app/src/test/kotlin/com/coucou/android/LaunchScreenTest.kt
@@ -0,0 +1,63 @@
+package com.coucou.android
+
+import com.coucou.android.core.LaunchScreen
+import com.coucou.android.core.Nav
+import com.coucou.android.core.Screen
+import java.io.File
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+/** The closed list of screens a Widget button may open: nothing else can be asked for. */
+class LaunchScreenTest {
+ @Test fun theListIsExactlyTheFiveScreensOfTheBrief() {
+ assertEquals(listOf("home", "chat", "settings", "recent", "pair"), LaunchScreen.values().map { it.key })
+ assertEquals(listOf(LaunchScreen.HOME, LaunchScreen.CHAT, LaunchScreen.SETTINGS, LaunchScreen.RECENT, LaunchScreen.PAIR), LaunchScreen.values().toList())
+ assertEquals("a key is used once", 5, LaunchScreen.values().map { it.key }.toSet().size)
+ }
+
+ @Test fun everyValueParsesBackFromItsOwnKey() {
+ for (s in LaunchScreen.values()) assertEquals(s, LaunchScreen.parse(s.key))
+ }
+
+ @Test fun anythingElseIsRejected() {
+ val bad = listOf(
+ null, "", " ", "HOME", "Home", " home", "home ", "ho me", "home\n", "session", "history", "scan", "diagnostics", "licences", "wardrobe",
+ "approve", "allow", "deny", "send", "unpair", "SESSION", "../home", "home;chat", "0", "-1", "HOME,CHAT", "com.coucou.android.MainActivity",
+ )
+ for (k in bad) assertNull("'$k' must not open anything", LaunchScreen.parse(k))
+ // The enum name is not the key: only the key is accepted.
+ for (s in LaunchScreen.values()) assertNull(s.name, LaunchScreen.parse(s.name).takeIf { it != s })
+ }
+
+ @Test fun everyValueIsAScreenThatExistsInTheApp() {
+ for (s in LaunchScreen.values()) assertTrue(s.name, s.screen in Screen.values())
+ // The three tabs of the bottom bar.
+ assertEquals(Nav.screenOf(com.coucou.android.core.Tab.HOME), LaunchScreen.HOME.screen)
+ assertEquals(Nav.screenOf(com.coucou.android.core.Tab.CHAT), LaunchScreen.CHAT.screen)
+ assertEquals(Nav.screenOf(com.coucou.android.core.Tab.SETTINGS), LaunchScreen.SETTINGS.screen)
+ // "Recent" is the full list of your own decisions, one level under Settings; "Pair again" is the pairing scan.
+ assertEquals(Screen.HISTORY, LaunchScreen.RECENT.screen)
+ assertEquals(Screen.SCAN, LaunchScreen.PAIR.screen)
+ assertEquals(Screen.SETTINGS, Nav.back(Screen.HISTORY))
+ assertEquals(Screen.HOME, Nav.back(Screen.SCAN))
+ // No screen that needs a session or a request in hand is on the list.
+ assertFalse(LaunchScreen.values().any { it.screen == Screen.SESSION })
+ }
+
+ @Test fun onlyTheKeyTravelsAndOnlyTheNonExportedActivityParsesIt() {
+ val main = "src/main/kotlin/com/coucou/android/"
+ val launch = File(main + "app/LaunchActivity.kt").readText()
+ assertTrue(launch.contains("LaunchScreen.parse(intent.getStringExtra(EXTRA_SCREEN))"))
+ val hub = File(main + "app/WidgetHub.kt").readText()
+ // A button is built from a LaunchScreen value, never from a free string.
+ assertTrue(hub.contains("fun openScreen(context: Context, code: Int, screen: LaunchScreen): PendingIntent"))
+ assertTrue(hub.contains(".putExtra(LaunchActivity.EXTRA_SCREEN, screen.key)"))
+ assertFalse(File(main + "MainActivity.kt").readText().contains("EXTRA_SCREEN"))
+ assertFalse(File(main + "MainActivity.kt").readText().contains("LaunchScreen.parse"))
+ val manifest = File("src/main/AndroidManifest.xml").readText()
+ assertTrue(manifest.substringAfter(""".app.LaunchActivity"""").substringBefore("/>").contains("""android:exported="false""""))
+ }
+}
diff --git a/android/app/src/test/kotlin/com/coucou/android/PendingLaunchTest.kt b/android/app/src/test/kotlin/com/coucou/android/PendingLaunchTest.kt
index ae007ff7..d6694035 100644
--- a/android/app/src/test/kotlin/com/coucou/android/PendingLaunchTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/PendingLaunchTest.kt
@@ -1,5 +1,6 @@
package com.coucou.android
+import com.coucou.android.core.LaunchScreen
import com.coucou.android.core.PendingLaunch
import java.io.File
import org.junit.Assert.assertEquals
@@ -121,4 +122,62 @@ class PendingLaunchTest {
.filter { it.readText().contains("launch.requestSession(") }.map { it.name }.toList()
assertEquals(listOf("LaunchActivity.kt"), callers)
}
+
+ // ── The screen slot (a Widget button) ───────────────────────────────────────────────────────────
+
+ @Test fun aWidgetButtonAsksForAScreenOnce() {
+ launch.requestScreen(LaunchScreen.CHAT)
+ assertEquals(LaunchScreen.CHAT, launch.takeScreen())
+ assertNull("only once, and the slot is cleared", launch.takeScreen())
+ }
+
+ @Test fun nothingAskedMeansNoScreen() = assertNull(launch.takeScreen())
+
+ @Test fun aStaleScreenRequestIsDropped() {
+ launch.requestScreen(LaunchScreen.SETTINGS)
+ now += PendingLaunch.TTL_MS + 1
+ assertNull(launch.takeScreen())
+ launch.requestScreen(LaunchScreen.RECENT)
+ now += PendingLaunch.TTL_MS
+ assertEquals(LaunchScreen.RECENT, launch.takeScreen())
+ }
+
+ @Test fun aNewerScreenRequestReplacesTheOlderOneAndNullClearsIt() {
+ launch.requestScreen(LaunchScreen.HOME)
+ launch.requestScreen(LaunchScreen.PAIR)
+ assertEquals(LaunchScreen.PAIR, launch.takeScreen())
+ launch.requestScreen(LaunchScreen.HOME)
+ launch.requestScreen(null)
+ assertNull(launch.takeScreen())
+ }
+
+ @Test fun theThreeSlotsNeverMeet() {
+ launch.request("fp-1", allow = true)
+ launch.requestSession("agent_codex")
+ launch.requestScreen(LaunchScreen.CHAT)
+ assertEquals(LaunchScreen.CHAT, launch.takeScreen())
+ assertNull("a screen never turns into a session", launch.takeScreen())
+ assertEquals("agent_codex", launch.takeSession())
+ assertEquals("the Allow is still there, untouched", PendingLaunch.Request("fp-1", true), launch.take())
+ launch.requestScreen(LaunchScreen.HOME)
+ assertNull("a screen is never an Allow", launch.take())
+ assertNull("nor a session", launch.takeSession())
+ assertEquals(LaunchScreen.HOME, launch.takeScreen())
+ }
+
+ @Test fun theScreenSlotOnlyHoldsAValueOfTheClosedList() {
+ val src = File("src/main/kotlin/com/coucou/android/core/PendingLaunch.kt").readText()
+ assertTrue(src.contains("fun requestScreen(which: LaunchScreen?)"))
+ assertTrue(src.contains("fun takeScreen(): LaunchScreen?"))
+ assertTrue(src.contains("private var screen: LaunchScreen?"))
+ }
+
+ @Test fun theExportedActivityOnlyAsksTheModelForTheScreenToOpen() {
+ val src = File(main + "MainActivity.kt").readText()
+ assertTrue(src.contains("model.launch.takeScreen()"))
+ for (bad in listOf("EXTRA_SCREEN", "getStringExtra", "getExtras", "intent.extras", "hasExtra")) assertFalse("MainActivity reads $bad", src.contains(bad))
+ val callers = File(main).walkTopDown().filter { it.extension == "kt" }
+ .filter { it.readText().contains("launch.requestScreen(") }.map { it.name }.toList()
+ assertEquals(listOf("LaunchActivity.kt"), callers)
+ }
}
diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetButtonsTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetButtonsTest.kt
new file mode 100644
index 00000000..6ac1529b
--- /dev/null
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetButtonsTest.kt
@@ -0,0 +1,167 @@
+package com.coucou.android
+
+import com.coucou.android.core.LaunchScreen
+import java.io.File
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+/**
+ * The buttons of the Status Pill and Mochi Big, and the room they take. A button only opens a screen of the app (or the top agent):
+ * none approves, denies or sends anything, and each has its own request code, a name and a content description.
+ */
+class WidgetButtonsTest {
+ private val main = "src/main/kotlin/com/coucou/android/"
+ 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] }
+ private val dimens: Map<String, Double> =
+ Regex("""<dimen name="(\w+)">([\d.]+)(?:dp|sp)</dimen>""").findAll(read(res + "values/dimens.xml")).associate { it.groupValues[1] to it.groupValues[2].toDouble() }
+
+ // ── The icons ────────────────────────────────────────────────────────────────────────────────────
+
+ private val icons = listOf("home", "chat", "settings", "recent", "session", "pair")
+
+ @Test fun sixOutlineIconsWithOneStrokeWeight() {
+ for (i in icons) {
+ val xml = read("${res}drawable/ic_widget_$i.xml")
+ assertTrue(i, xml.contains("<vector") && xml.contains("""android:width="24dp"""") && xml.contains("""android:viewportWidth="24""""))
+ val widths = Regex("""android:strokeWidth="([\d.]+)"""").findAll(xml).map { it.groupValues[1] }.toSet()
+ assertEquals("$i: one stroke weight", setOf("2"), widths)
+ assertTrue("$i: in the Widgets' text colour, so the light variant follows", xml.contains("""android:strokeColor="@color/widget_text""""))
+ assertFalse("$i: an outline, not a fill", xml.contains("android:fillColor"))
+ assertTrue(i, xml.contains("""android:strokeLineCap="round""""))
+ }
+ }
+
+ @Test fun theButtonsAreLighterCirclesAndRoundedTilesInBothModes() {
+ val dark = read(res + "values/colors.xml")
+ val light = read(res + "values-notnight/colors.xml")
+ assertTrue(dark.contains("""<color name="widget_button">#1FFFFFFF</color>"""))
+ assertTrue(light.contains("""<color name="widget_button">#14000000</color>"""))
+ assertTrue(read(res + "drawable/widget_button_bg.xml").contains("""android:shape="oval""""))
+ assertEquals(16.0, dimens.getValue("widget_tile_radius"), 0.0)
+ assertTrue(read(res + "drawable/widget_tile_bg.xml").contains("@dimen/widget_tile_radius"))
+ // Tinted orange while something waits.
+ val waiting = read(res + "drawable/widget_tile_bg_attention.xml")
+ assertTrue(waiting.contains("@color/widget_tint_attention") && waiting.contains("@color/widget_tone_attention"))
+ assertTrue("round buttons of 36 to 40dp", dimens.getValue("widget_button") in 36.0..40.0)
+ }
+
+ @Test fun everyButtonHasAShortLabelAndADescription() {
+ for (k in listOf("home", "chat", "settings", "recent", "session", "pair")) {
+ val label = strings.getValue("widget_btn_$k")
+ val cd = strings.getValue("widget_btn_${k}_cd")
+ assertTrue("$k label '$label'", label.isNotBlank() && label.length <= 12)
+ assertTrue("$k description '$cd'", cd.isNotBlank() && cd.length <= 40)
+ }
+ }
+
+ // ── The Status Pill ─────────────────────────────────────────────────────────────────────────────
+
+ @Test fun theStatusPillHasFourRoundButtonsThatOpenTheFourScreens() {
+ val layout = read(res + "layout/widget_pill.xml")
+ val ids = Regex("""@\+id/(pill_btn_\w+)""").findAll(layout).map { it.groupValues[1] }.toList()
+ assertEquals(listOf("pill_btn_home", "pill_btn_chat", "pill_btn_settings", "pill_btn_recent"), ids)
+ for (b in Regex("""<ImageView[^>]*pill_btn_[^>]*>""").findAll(layout)) {
+ val tag = b.value
+ assertTrue(tag, tag.contains("""android:layout_width="@dimen/widget_button"""") && tag.contains("""android:layout_height="@dimen/widget_button""""))
+ assertTrue(tag, tag.contains("@drawable/widget_button_bg") && tag.contains("android:contentDescription=\"@string/widget_btn_"))
+ }
+ val src = read(main + "app/StatusPillWidget.kt")
+ val pairs = Regex("""Button\(R\.id\.(pill_btn_\w+), LaunchScreen\.(\w+)\)""").findAll(src).map { it.groupValues[1] to it.groupValues[2] }.toList()
+ assertEquals(listOf("pill_btn_home" to "HOME", "pill_btn_chat" to "CHAT", "pill_btn_settings" to "SETTINGS", "pill_btn_recent" to "RECENT"), pairs)
+ assertTrue(src.contains("WidgetHub.openScreen(context, WidgetHub.CODE_PILL_BUTTON + i, b.screen)"))
+ assertFalse("the pill opens no session from a button", src.contains("openSession(context, WidgetHub.CODE_PILL_BUTTON"))
+ }
+
+ @Test fun theStatusPillKeepsTheTextOffTheButtons() {
+ val layout = read(res + "layout/widget_pill.xml")
+ // The text group is the weighted child, so the buttons (wrap) are measured first and never move.
+ assertTrue(layout.contains("""android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_vertical""""))
+ assertEquals("every text on the pill is one line, ellipsized", 2, Regex("""android:maxLines="1"""").findAll(layout).count())
+ // Width budget in dp: padding 16 + 8, four buttons of 36 with 6 between.
+ val buttons = 4 * dimens.getValue("widget_button") + 4 * 6 + 16 + 8
+ val src = read(main + "app/StatusPillWidget.kt")
+ val medium = Regex("""MEDIUM_AT = SizeF\((\d+)f""").find(src)!!.groupValues[1].toInt()
+ val large = Regex("""LARGE_AT = SizeF\((\d+)f""").find(src)!!.groupValues[1].toInt()
+ val minResize = Regex("""android:minResizeWidth="(\d+)dp"""").find(read(res + "xml/coucou_pill_widget_info.xml"))!!.groupValues[1].toInt()
+ assertTrue("the buttons alone fit the narrowest the Widget can be", buttons <= minResize)
+ assertTrue("from $medium dp the name has room (dot + about 80dp)", medium - buttons >= 90)
+ assertTrue("from $large dp the state word has room too", large - buttons >= 90 + 50)
+ assertTrue("narrower the pill hides the state word first: $medium < $large", medium < large)
+ // Under the medium width only the dot is left of the buttons; the state word goes first, then the name.
+ assertTrue(src.contains("R.id.pill_name, if (size == WidgetHub.Size.SMALL) View.GONE"))
+ assertTrue(src.contains("R.id.pill_state, if (size == WidgetHub.Size.LARGE) View.VISIBLE else View.GONE"))
+ }
+
+ // ── Mochi Big ───────────────────────────────────────────────────────────────────────────────────
+
+ @Test fun mochiBigHasSixTilesAndEachOpensOneThing() {
+ val layout = read(res + "layout/widget_big.xml")
+ val ids = Regex("""@\+id/(big_tile_\w+)""").findAll(layout).map { it.groupValues[1] }.toList()
+ assertEquals(listOf("big_tile_home", "big_tile_chat", "big_tile_settings", "big_tile_recent", "big_tile_session", "big_tile_pair"), ids)
+ // Icon above a 12sp label, on a rounded tile.
+ assertEquals(6, Regex("""@drawable/widget_tile_bg"""").findAll(layout).count())
+ assertEquals(6, Regex("""android:textSize="@dimen/widget_text_secondary"[^>]*/>""").findAll(layout.substringAfter("big_buttons").substringBefore("big_badge")).count())
+ assertEquals(12.0, dimens.getValue("widget_text_secondary"), 0.0)
+ val src = read(main + "app/MochiBigWidget.kt")
+ val tiles = Regex("""Tile\(R\.id\.(big_tile_\w+), (LaunchScreen\.\w+|null)\)""").findAll(src).map { it.groupValues[1] to it.groupValues[2] }.toList()
+ assertEquals(
+ listOf(
+ "big_tile_home" to "LaunchScreen.HOME", "big_tile_chat" to "LaunchScreen.CHAT", "big_tile_settings" to "LaunchScreen.SETTINGS",
+ "big_tile_recent" to "LaunchScreen.RECENT", "big_tile_session" to "null", "big_tile_pair" to "LaunchScreen.PAIR",
+ ),
+ tiles,
+ )
+ // The top agent goes through the session slot; everything else through the screen slot; each tile has its own code.
+ assertTrue(src.contains("WidgetHub.openSession(context, WidgetHub.CODE_BIG_BUTTON + i, top.pillId)"))
+ assertTrue(src.contains("WidgetHub.openScreen(context, WidgetHub.CODE_BIG_BUTTON + i, t.screen)"))
+ assertTrue(src.contains("R.drawable.widget_tile_bg_attention"))
+ }
+
+ @Test fun theBigOnesButtonsGoFromTwoRowsToOneRowToNone() {
+ val layout = read(res + "layout/widget_big.xml")
+ assertEquals("a row of four then a row of two", 2, Regex("""@\+id/big_buttons_[ab]""").findAll(layout).count())
+ assertEquals(4, Regex("""@\+id/big_tile_(home|chat|settings|recent)"""").findAll(layout).count())
+ val src = read(main + "app/MochiBigWidget.kt")
+ assertTrue(src.contains("R.id.big_buttons, if (small) View.GONE else View.VISIBLE"))
+ assertTrue(src.contains("R.id.big_buttons_b, if (large) View.VISIBLE else View.GONE"))
+ }
+
+ @Test fun mochiKeepsAtLeastFortyPercentOfTheBigCardWheneverButtonsShow() {
+ val src = read(main + "app/MochiBigWidget.kt")
+ val medium = Regex("""MEDIUM_AT = SizeF\(0f, (\d+)f""").find(src)!!.groupValues[1].toDouble()
+ val large = Regex("""LARGE_AT = SizeF\(0f, (\d+)f""").find(src)!!.groupValues[1].toDouble()
+ val tile = dimens.getValue("widget_tile_height")
+ // dp: padding 12 + 12, the bubble in two lines (8 + 2 x 20 + 8 = 56) and its tail 10, the status line 20, then the buttons.
+ val fixed = 24 + 56 + 10 + 20
+ val rowA = 8 + tile
+ val rowB = 6 + tile
+ assertTrue("one row from $medium dp: Mochi ${medium - fixed - rowA}", (medium - fixed - rowA) / medium >= 0.40)
+ assertTrue("two rows from $large dp: Mochi ${large - fixed - rowA - rowB}", (large - fixed - rowA - rowB) / large >= 0.40)
+ // And with no buttons there is more room still.
+ val minHeight = Regex("""android:minHeight="(\d+)dp"""").find(read(res + "xml/coucou_big_widget_info.xml"))!!.groupValues[1].toDouble()
+ assertTrue((minHeight - fixed) / minHeight >= 0.40)
+ assertTrue("the steps are in order", medium < large && minHeight < medium)
+ }
+
+ // ── Nothing here can approve, deny or send ──────────────────────────────────────────────────────
+
+ @Test fun everyButtonOpensAScreenOfTheClosedListAndNothingElse() {
+ for (f in listOf("app/StatusPillWidget.kt", "app/MochiBigWidget.kt")) {
+ val src = read(main + f)
+ for (word in listOf("PendingLaunch", "launch.request", "ActionReceiver", "approve", "Allow", "Deny", "decide", "send", "BiometricGate", "putExtra")) {
+ assertFalse("$f uses $word", src.contains(word, ignoreCase = word != "send" && word != "Allow" && word != "Deny"))
+ }
+ }
+ // Every screen a button names is on the list.
+ val named = (read(main + "app/StatusPillWidget.kt") + read(main + "app/MochiBigWidget.kt"))
+ for (m in Regex("""LaunchScreen\.([A-Z]+)""").findAll(named)) assertTrue(m.groupValues[1], LaunchScreen.values().any { it.name == m.groupValues[1] })
+ }
+}
diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetPreviewTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetPreviewTest.kt
index 5409ef68..6d11e02b 100644
--- a/android/app/src/test/kotlin/com/coucou/android/WidgetPreviewTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetPreviewTest.kt
@@ -19,8 +19,11 @@ class WidgetPreviewTest {
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 val providers = listOf("solo", "list", "big", "pill", "alert", "ring", "today", "mood", "glance")
+
+ /** The provider file of a Widget: the summary widget keeps the name it has always had. */
+ private fun infoName(name: String) = if (name == "glance") "coucou_widget_info" else "coucou_${name}_widget_info"
+ private fun info(name: String) = read("${res}xml/${infoName(name)}.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_") }
@@ -41,11 +44,13 @@ class WidgetPreviewTest {
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())
+ @Test fun theSummaryWidgetKeepsItsNamesAndGainsAPreview() {
val first = read(res + "xml/coucou_widget_info.xml")
- assertFalse(first.contains("preview"))
+ assertTrue(first.contains("""android:previewLayout="@layout/widget_preview_glance""""))
assertTrue(first.contains("""android:initialLayout="@layout/widget_glance""""))
+ assertTrue(first.contains("""android:updatePeriodMillis="0""""))
+ assertTrue(read("src/main/AndroidManifest.xml").contains("""android:name=".app.GlanceWidget""""))
+ assertTrue(File(res + "xml/coucou_widget_info.xml").exists())
}
// ── Names and descriptions ─────────────────────────────────────────────────────────────────────
@@ -55,7 +60,7 @@ class WidgetPreviewTest {
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)
+ val label = Regex("""android:name="\.app\.\w+"\s+android:exported="true"\s+android:label="@string/(\w+)"[^>]*>\s*<intent-filter>(?:(?!</receiver>).)*?${infoName(n)}""", RegexOption.DOT_MATCHES_ALL)
.find(manifest)?.groupValues?.get(1)
assertNotNull("$n has no label in the manifest", label)
val l = strings.getValue(label!!)
@@ -77,7 +82,7 @@ class WidgetPreviewTest {
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",
+ "widget_today_label" to "Finished today", "widget_mood_label" to "Mochi's mood", "widget_glance_label" to "Agents summary",
)
for ((k, v) in expected) assertEquals(k, v, strings[k])
}
@@ -129,8 +134,11 @@ class WidgetPreviewTest {
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"))
+ assertTrue(text("big").containsAll(listOf("Claude Code is waiting for you", "Claude Code", "Waiting", "Home", "Chat", "Settings", "Recent", "Top agent", "Pair again")))
+ assertEquals(listOf("2 agents are working", "Claude Code", "Working", "Codex", "Thinking", "Gemini CLI", "Idle"), text("glance"))
assertEquals(listOf("Claude Code", "Working"), text("pill"))
+ // The pill shows its four buttons: home, chat, settings and recent, in that order.
+ assertEquals(listOf("ic_widget_home", "ic_widget_chat", "ic_widget_settings", "ic_widget_recent"), Regex("""@drawable/(ic_widget_\w+)""").findAll(preview("pill")).map { it.groupValues[1] }.toList())
assertEquals(listOf("2 waiting", "Claude Code"), text("alert"))
assertEquals(listOf("70%", "Claude · 5 h"), text("ring"))
assertTrue(text("today").containsAll(listOf("5", "done today")))
@@ -139,7 +147,8 @@ class WidgetPreviewTest {
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("big").contains("preview_mochi_waiting") && preview("big").contains("widget_tile_bg_attention"))
+ assertTrue(preview("glance").contains("preview_mochi_working") && preview("glance").contains("widget_tint_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"))
@@ -214,7 +223,7 @@ class WidgetPreviewTest {
// ── 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")
+ 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", "glance" to "glance")
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")
@@ -226,4 +235,16 @@ class WidgetPreviewTest {
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")))
}
+
+ @Test fun noWidgetLayoutSaysCommandStepOrFileEvenWithButtons() {
+ val files = File(res + "layout").listFiles()!!.filter { it.name.startsWith("widget_") } + File(res + "drawable").listFiles()!!.filter { it.name.startsWith("ic_widget_") || it.name.startsWith("widget_") }
+ for (f in files) {
+ 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))
+ }
+ for (k in listOf("widget_btn_home", "widget_btn_chat", "widget_btn_settings", "widget_btn_recent", "widget_btn_session", "widget_btn_pair")) {
+ for (word in listOf("statusText", "steps", ".command", "files")) assertFalse("$k says $word", strings.getValue(k).contains(word) && strings.getValue(k + "_cd").contains(word))
+ }
+ }
}
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 2b3b5c0f..2f0b23aa 100644
--- a/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
@@ -17,10 +17,12 @@ class WidgetSurfacesTest {
"SoloWidget" to "coucou_solo_widget_info", "ListWidget" to "coucou_list_widget_info", "MochiBigWidget" to "coucou_big_widget_info",
"StatusPillWidget" to "coucou_pill_widget_info", "WaitingAlertWidget" to "coucou_alert_widget_info",
"UsageRingWidget" to "coucou_ring_widget_info", "TodayWidget" to "coucou_today_widget_info", "MoodWidget" to "coucou_mood_widget_info",
+ // The summary widget (3x2): same class, receiver and provider file as ever, in the shared look since Widgets C.
+ "GlanceWidget" to "coucou_widget_info",
)
private val sources = (
widgets.map { "app/${it.first}.kt" } +
- listOf("app/WidgetHub.kt", "app/MochiBitmap.kt", "app/RingBitmap.kt", "app/TodayStore.kt", "core/WidgetData.kt", "core/TodayCounter.kt")
+ listOf("app/WidgetHub.kt", "app/MochiBitmap.kt", "app/RingBitmap.kt", "app/TodayStore.kt", "core/WidgetData.kt", "core/TodayCounter.kt", "core/LaunchScreen.kt")
).associateWith { read(main + it) }
@Test fun theWidgetsAreRegisteredAndNeverWakeOnATimer() {
@@ -56,9 +58,10 @@ class WidgetSurfacesTest {
@Test fun everyPendingIntentIsImmutableAndExplicit() {
val hub = sources.getValue("app/WidgetHub.kt")
- assertEquals(2, Regex("PendingIntent.getActivity").findAll(hub).count())
- assertEquals(2, Regex("FLAG_IMMUTABLE").findAll(hub).count())
- assertTrue(hub.contains("Intent(context, LaunchActivity::class.java)"))
+ // Open the app, open a session, open a screen: three, all immutable, the last two through LaunchActivity.
+ assertEquals(3, Regex("PendingIntent.getActivity").findAll(hub).count())
+ assertEquals(3, Regex("FLAG_IMMUTABLE").findAll(hub).count())
+ assertEquals(2, Regex("Intent\\(context, LaunchActivity::class.java\\)").findAll(hub).count())
assertTrue(hub.contains("Intent(context, MainActivity::class.java)"))
for ((name, src) in sources) {
if (name == "app/WidgetHub.kt") continue
@@ -70,7 +73,7 @@ class WidgetSurfacesTest {
@Test fun everyRowAndEveryWidgetHasItsOwnRequestCode() {
val hub = sources.getValue("app/WidgetHub.kt")
val codes = Regex("""const val CODE_\w+ = (0x[0-9A-Fa-f]+)""").findAll(hub).map { it.groupValues[1] }.toList()
- assertEquals(9, codes.size)
+ assertEquals(12, codes.size)
assertEquals(codes.size, codes.toSet().size)
// The rows use CODE_LIST_ROW + index: the ranges must not run into the next code.
val values = codes.map { it.removePrefix("0x").toInt(16) }.sorted()
@@ -89,7 +92,7 @@ class WidgetSurfacesTest {
assertTrue(sources.getValue("app/ListWidget.kt").contains("setContentDescription(R.id.list_badge"))
// Every Widget with a picture describes it; every layout image that is not decoration has a description or is hidden from it.
for ((cls, _) in widgets) assertTrue("$cls has no content description", sources.getValue("app/$cls.kt").contains("setContentDescription("))
- for (layout in File("src/main/res/layout").listFiles()!!.filter { it.name.startsWith("widget_") && it.name != "widget_glance.xml" }) {
+ for (layout in File("src/main/res/layout").listFiles()!!.filter { it.name.startsWith("widget_") }) {
for (img in Regex("""<ImageView[^>]*>""").findAll(layout.readText())) {
val tag = img.value
assertTrue("${layout.name}: an image with neither a description nor importantForAccessibility=no: $tag",
@@ -106,11 +109,25 @@ class WidgetSurfacesTest {
assertTrue(sources.getValue("app/WidgetHub.kt").contains("if (content == last) return"))
}
- @Test fun theFirstWidgetIsUntouched() {
- // GlanceSurfacesTest guards its registration; this guards that the new widgets did not take its names.
+ @Test fun theSummaryWidgetKeepsItsNamesAndItsRefreshPath() {
+ // GlanceSurfacesTest guards its registration; this guards that the restyle kept the names, the size and the refresh path.
+ assertTrue(manifest.contains("""android:name=".app.GlanceWidget""""))
assertTrue(manifest.contains("@xml/coucou_widget_info"))
assertTrue(File("src/main/res/layout/widget_glance.xml").exists())
- assertTrue(read("src/main/res/xml/coucou_widget_info.xml").contains("""android:targetCellWidth="3""""))
+ val info = read("src/main/res/xml/coucou_widget_info.xml")
+ assertTrue(info.contains("""android:targetCellWidth="3""""))
+ assertTrue(info.contains("""android:targetCellHeight="2""""))
+ assertTrue(info.contains("""android:initialLayout="@layout/widget_glance""""))
+ val src = read(main + "app/GlanceWidget.kt")
+ assertTrue(src.contains("fun update(context: Context, glance: Glance)"))
+ assertTrue(src.contains("model.glance()"))
+ // Its data is the Glance's, and a tap anywhere opens the app: no button, no session, no screen.
+ for (word in listOf("g.headline", "g.detail", "g.lines", "g.waiting")) assertTrue(word, src.contains(word))
+ assertTrue(src.contains("WidgetHub.openApp("))
+ for (word in listOf("openScreen", "openSession", "LaunchScreen")) assertFalse(word, src.contains(word))
+ val layout = read("src/main/res/layout/widget_glance.xml")
+ assertFalse(layout.contains("<Button"))
+ assertFalse("no icon button in the summary", layout.contains("ic_widget_"))
}
@Test fun theListRowsAreAtLeastFortyEightDpAndTheEmptyStateFillsTheCard() {
@@ -123,7 +140,7 @@ class WidgetSurfacesTest {
}
@Test fun theCardsUseTheSharedLook() {
- for (layout in listOf("widget_solo", "widget_list")) {
+ for (layout in listOf("widget_solo", "widget_list", "widget_glance", "widget_pill", "widget_big")) {
val xml = read("src/main/res/layout/$layout.xml")
assertTrue(layout, xml.contains("@drawable/widget_card"))
assertTrue(layout, xml.contains("@drawable/widget_tint_muted"))
@@ -192,7 +209,7 @@ class WidgetSurfacesTest {
val expected = mapOf(
"coucou_solo_widget_info" to (2 to 2), "coucou_list_widget_info" to (4 to 3), "coucou_big_widget_info" to (4 to 4),
"coucou_pill_widget_info" to (4 to 1), "coucou_alert_widget_info" to (2 to 2), "coucou_ring_widget_info" to (2 to 2),
- "coucou_today_widget_info" to (2 to 2), "coucou_mood_widget_info" to (1 to 1),
+ "coucou_today_widget_info" to (2 to 2), "coucou_mood_widget_info" to (1 to 1), "coucou_widget_info" to (3 to 2),
)
assertEquals(widgets.map { it.second }.toSet(), expected.keys)
for ((info, cells) in expected) {
@@ -230,7 +247,7 @@ class WidgetSurfacesTest {
@Test fun everyWidgetIsOnTheSharedCardAndOnlyUsesWhatRemoteViewsAllow() {
val allowed = setOf("FrameLayout", "LinearLayout", "RelativeLayout", "GridLayout", "TextView", "ImageView", "ProgressBar", "Button")
- for (layout in File("src/main/res/layout").listFiles()!!.filter { it.name.startsWith("widget_") && it.name != "widget_glance.xml" }) {
+ for (layout in File("src/main/res/layout").listFiles()!!.filter { it.name.startsWith("widget_") }) {
val xml = layout.readText()
assertTrue(layout.name, xml.contains("@drawable/widget_card"))
// A real layout starts muted and is repainted by WidgetHub; a preview is already in the tone of its sample.
diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetToneTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetToneTest.kt
index b3303b4b..cc350b03 100644
--- a/android/app/src/test/kotlin/com/coucou/android/WidgetToneTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetToneTest.kt
@@ -1,6 +1,9 @@
package com.coucou.android
+import com.coucou.android.core.Glance
import com.coucou.android.core.GlanceTone
+import com.coucou.android.core.GlanceLine
+import com.coucou.android.core.mood
import com.coucou.android.core.WidgetContent
import com.coucou.android.core.WidgetTile
import com.coucou.android.core.WidgetTone
@@ -97,4 +100,25 @@ class WidgetToneTest {
assertEquals(WidgetTone.DONE, content(states = arrayOf(BotState.FINISHED)).look)
assertEquals(WidgetTone.MUTED, content().look)
}
+
+ // ── The summary widget: the existing Glance, in the shared look ──────────────────────────────────
+
+ @Test fun theFiveToneOfTheGlanceBecomeTheFiveToneOfTheWidgets() {
+ assertEquals(WidgetTone.MUTED, WidgetTone.of(GlanceTone.CALM))
+ assertEquals(WidgetTone.DONE, WidgetTone.of(GlanceTone.OK))
+ assertEquals(WidgetTone.WORKING, WidgetTone.of(GlanceTone.BUSY))
+ assertEquals(WidgetTone.ATTENTION, WidgetTone.of(GlanceTone.ATTENTION))
+ assertEquals(WidgetTone.TROUBLE, WidgetTone.of(GlanceTone.TROUBLE))
+ for (t in GlanceTone.values()) WidgetTone.of(t)
+ }
+
+ private fun glance(connected: Boolean, vararg states: BotState) =
+ Glance("h", "d", GlanceTone.CALM, connected, states.map { GlanceLine("A", "t", it) }, 0)
+
+ @Test fun mochiOnTheSummaryFollowsTheMostUrgentLine() {
+ assertEquals(BotState.APPROVAL, glance(true, BotState.APPROVAL, BotState.WORKING).mood())
+ assertEquals(BotState.WORKING, glance(true, BotState.WORKING).mood())
+ assertEquals(BotState.IDLE, glance(true).mood())
+ assertEquals(BotState.SLEEPING, glance(false).mood())
+ }
}