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.

Tray: never hold the update item's lock while the menu waits for the main thread

Claudec034bff6a687
diff --git a/windows/src-tauri/src/tray.rs b/windows/src-tauri/src/tray.rs
index ff23a012..c70c5524 100644
--- a/windows/src-tauri/src/tray.rs
+++ b/windows/src-tauri/src/tray.rs
@@ -79,8 +79,10 @@ pub fn retitle(app: &AppHandle) {
let _ = item.set_text(t(label));
}
if let Some(update) = app.try_state::<UpdateItem>() {
- if let Some(version) = update.version.lock().unwrap().as_deref() {
- let _ = update.item.set_text(update_label(version));
+ // Copied out first: the menu calls wait for the main thread, never under the lock.
+ let version = update.version.lock().unwrap().clone();
+ if let Some(version) = version {
+ let _ = update.item.set_text(update_label(&version));
}
}
}
@@ -88,14 +90,19 @@ pub fn retitle(app: &AppHandle) {
/// Shows "Update Coucou to `version`…" right under Open, or takes it out (None).
pub fn set_update(app: &AppHandle, version: Option<&str>) {
let Some(update) = app.try_state::<UpdateItem>() else { return };
- let mut shown = update.version.lock().unwrap();
- if shown.as_deref() == version {
- return;
- }
+ let was_shown = {
+ let mut shown = update.version.lock().unwrap();
+ if shown.as_deref() == version {
+ return;
+ }
+ let was = shown.is_some();
+ *shown = version.map(str::to_string);
+ was
+ };
match version {
Some(v) => {
let _ = update.item.set_text(update_label(v));
- if shown.is_none() {
+ if !was_shown {
let _ = update.menu.insert(&update.item, 1);
}
}
@@ -103,5 +110,4 @@ pub fn set_update(app: &AppHandle, version: Option<&str>) {
let _ = update.menu.remove(&update.item);
}
}
- *shown = version.map(str::to_string);
}