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.

Windows/Linux: the tray Mochi turns blue while a new version waits

Claudedc672ba4d537
diff --git a/windows/src-tauri/src/lib.rs b/windows/src-tauri/src/lib.rs
index 7960a992..c8f57a90 100644
--- a/windows/src-tauri/src/lib.rs
+++ b/windows/src-tauri/src/lib.rs
@@ -950,6 +950,7 @@ pub fn run() {
update::update_shown,
update::update_show,
update::update_later,
+ tray::tray_update_hint,
update::update_dismiss,
update::update_install,
update::update_open_page,
diff --git a/windows/src-tauri/src/tray.rs b/windows/src-tauri/src/tray.rs
index c70c5524..a43d477f 100644
--- a/windows/src-tauri/src/tray.rs
+++ b/windows/src-tauri/src/tray.rs
@@ -1,11 +1,12 @@
// Notification-area icon: Open, Weekly recap, Wardrobe, Settings, Pause, Quit.
// "Update Coucou to X…" shows under Open only while a new version is out
-// (update.rs).
+// (update.rs). While one waits, the tray Mochi turns blue like the island's.
use std::sync::Mutex;
use tauri::menu::{Menu, MenuItem, PredefinedMenuItem};
use tauri::tray::TrayIconBuilder;
+use tauri::image::Image;
use tauri::{AppHandle, Emitter, Manager, Wry};
use crate::i18n::{n_, t, tf};
@@ -111,3 +112,57 @@ pub fn set_update(app: &AppHandle, version: Option<&str>) {
}
}
}
+
+/// Coucou's update blue, #3B82F6, the colour of Mochi while a new version waits.
+const UPDATE_BLUE: [f32; 3] = [59.0, 130.0, 246.0];
+
+/// The tray Mochi in the update blue: the light body takes the blue and keeps its
+/// shading, the dark outline and eyes stay as they are, transparency untouched.
+pub fn tint_blue(rgba: &[u8]) -> Vec<u8> {
+ let mut out = Vec::with_capacity(rgba.len());
+ for p in rgba.chunks_exact(4) {
+ let light = (0.2126 * p[0] as f32 + 0.7152 * p[1] as f32 + 0.0722 * p[2] as f32) / 255.0;
+ // 0 for the outline and eyes, 1 for the white body.
+ let body = ((light - 0.35) / 0.65).clamp(0.0, 1.0);
+ for (i, blue) in UPDATE_BLUE.iter().enumerate() {
+ let shaded = blue * (0.8 + 0.2 * light);
+ out.push((p[i] as f32 * (1.0 - body) + shaded * body).round().clamp(0.0, 255.0) as u8);
+ }
+ out.push(p[3]);
+ }
+ out
+}
+
+/// The island says whether a new version waits (consent, newer, not put off with
+/// Later): blue Mochi in the tray, or the usual one.
+#[tauri::command]
+pub fn tray_update_hint(app: AppHandle, on: bool) {
+ let Some(tray) = app.tray_by_id("coucou") else { return };
+ let Some(base) = app.default_window_icon() else { return };
+ let icon = if on {
+ Image::new_owned(tint_blue(base.rgba()), base.width(), base.height())
+ } else {
+ base.clone().to_owned()
+ };
+ let _ = tray.set_icon(Some(icon));
+}
+
+#[cfg(test)]
+mod tests {
+ use super::tint_blue;
+
+ #[test]
+ fn the_body_turns_blue_the_outline_stays() {
+ let px = [
+ 245, 240, 235, 255, // the off-white body
+ 10, 10, 10, 255, // the outline
+ 250, 250, 250, 0, // transparent around Mochi
+ ];
+ let out = tint_blue(&px);
+ let body = &out[0..4];
+ assert!(body[2] > 220 && body[0] < 80 && body[1] > 100 && body[1] < 150, "body {body:?}");
+ assert_eq!(&out[4..8], &[10, 10, 10, 255], "the outline stays dark");
+ assert_eq!(out[11], 0, "transparency is kept");
+ assert_eq!(out.len(), px.len());
+ }
+}
diff --git a/windows/src/core/bridge.ts b/windows/src/core/bridge.ts
index 69033fa0..a9cfbfff 100644
--- a/windows/src/core/bridge.ts
+++ b/windows/src/core/bridge.ts
@@ -454,6 +454,8 @@ export const Bridge = {
/** Settings → Install X: opens the island's update card. */
updateShow: () => call<void>("update_show"),
updateLater: () => call<void>("update_later"),
+ /** Blue Mochi in the tray while a new version waits (tray.rs). */
+ trayUpdateHint: (on: boolean) => call<void>("tray_update_hint", { on }),
updateDismiss: () => call<void>("update_dismiss"),
/** "Update now" (Windows): download, check the SHA-256, run the installer, quit. */
updateInstall: () => call<void>("update_install"),
diff --git a/windows/src/island/update.ts b/windows/src/island/update.ts
index b2b5b3ad..09fdc20e 100644
--- a/windows/src/island/update.ts
+++ b/windows/src/island/update.ts
@@ -58,8 +58,27 @@ class UpdateController {
await onEvent<UpdateStatus>("update-status", (s) => {
this.status = s;
State.notify();
+ this.syncTray();
});
await onEvent<UpdateOffer>("update-offer", (offer) => this.offer(offer));
+ this.syncTray();
+ // A day after Later the blue comes back, island hidden or not: a look every half hour.
+ if (!this.trayLook) {
+ const look = setInterval(() => this.syncTray(), 30 * 60 * 1000) as unknown as { unref?: () => void };
+ look.unref?.(); // the tests run this in Node: the timer must not keep them alive
+ this.trayLook = true;
+ }
+ }
+
+ private trayBlue = false;
+ private trayLook = false;
+
+ /** The tray Mochi follows: blue while a new version waits, like the island's. */
+ private syncTray() {
+ const on = this.waiting();
+ if (on === this.trayBlue) return;
+ this.trayBlue = on;
+ void Bridge.trayUpdateHint(on);
}
offer(offer: UpdateOffer) {
@@ -97,6 +116,7 @@ class UpdateController {
answer(yes: boolean) {
this.asking = false;
void Bridge.updateSetConsent(yes);
+ this.syncTray();
this.host?.collapse();
}
@@ -117,6 +137,7 @@ class UpdateController {
void Bridge.updateLater();
this.host?.collapse();
State.notify();
+ this.syncTray();
}
private laterMemo: Later | null | undefined;