Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(tray): add step-by-step diagnostics to catch_unwind blocks

Louis Beaumontec8d3ba22ae7
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index 980a95cf2..90bc03e8e 100755
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -9007,7 +9007,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.0.339"
+version = "2.0.340"
dependencies = [
"anyhow",
"async-stream",
@@ -9100,7 +9100,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.125"
+version = "0.3.126"
dependencies = [
"anyhow",
"bytemuck",
@@ -9148,7 +9148,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.125"
+version = "0.3.126"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -9199,7 +9199,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.125"
+version = "0.3.126"
dependencies = [
"anyhow",
"chrono",
@@ -9223,7 +9223,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.125"
+version = "0.3.126"
dependencies = [
"anyhow",
"chrono",
@@ -9239,7 +9239,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.3.125"
+version = "0.3.126"
dependencies = [
"anyhow",
"image 0.25.9",
@@ -9254,7 +9254,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.3.125"
+version = "0.3.126"
dependencies = [
"anyhow",
"async-trait",
@@ -9320,7 +9320,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.3.125"
+version = "0.3.126"
dependencies = [
"accessibility-sys",
"anyhow",
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs
index 33adb3e24..21d9aa0c0 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs
@@ -115,9 +115,11 @@ pub fn recreate_tray(app: &AppHandle) {
};
// Remove the old tray icon (must be on main thread for NSStatusBar)
+ debug!("recreate_tray: removing old tray icon");
let _old = app.remove_tray_by_id("screenpipe_main");
// Drop the old tray icon explicitly on main thread
drop(_old);
+ debug!("recreate_tray: old tray removed, building new one");
// Create a new tray icon — macOS assigns it the rightmost position
let icon = match app.path().resolve("assets/screenpipe-logo-tray-white.png", tauri::path::BaseDirectory::Resource) {
@@ -135,8 +137,10 @@ pub fn recreate_tray(app: &AppHandle) {
error!("failed to load tray icon for recreation");
}
+ debug!("recreate_tray: calling builder.build()");
match builder.build(&app) {
Ok(new_tray) => {
+ debug!("recreate_tray: build succeeded, setting menu");
// Setup menu
if let Ok(menu) = create_dynamic_menu(&app, &MenuState::default(), &update_item) {
let _ = new_tray.set_menu(Some(menu));
@@ -152,7 +156,16 @@ pub fn recreate_tray(app: &AppHandle) {
}
}
})) {
- error!("panic caught in recreate_tray: {:?}", e);
+ // The panic hook already sent the panic message + backtrace to Sentry
+ // (as a Fatal-level capture_message). Log here for local diagnostics.
+ let panic_msg = if let Some(s) = e.downcast_ref::<&str>() {
+ s.to_string()
+ } else if let Some(s) = e.downcast_ref::<String>() {
+ s.clone()
+ } else {
+ format!("{:?}", e)
+ };
+ error!("panic caught in recreate_tray (ObjC exception?): {}", panic_msg);
}
});
}
@@ -441,9 +454,11 @@ async fn update_menu_if_needed(
let _ = app.run_on_main_thread(move || {
if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
if let Some(tray) = app_for_thread.tray_by_id("screenpipe_main") {
+ debug!("tray_menu_update: setting menu");
if let Ok(menu) = create_dynamic_menu(&app_for_thread, &new_state, &update_item) {
let _ = tray.set_menu(Some(menu));
}
+ debug!("tray_menu_update: setting tooltip");
// Update tooltip to show permission status
let tooltip = if has_perm_issue {
"screenpipe — ⚠️ permissions needed"
@@ -453,7 +468,14 @@ async fn update_menu_if_needed(
let _ = tray.set_tooltip(Some(tooltip));
}
})) {
- error!("panic caught in tray menu update: {:?}", e);
+ let panic_msg = if let Some(s) = e.downcast_ref::<&str>() {
+ s.to_string()
+ } else if let Some(s) = e.downcast_ref::<String>() {
+ s.clone()
+ } else {
+ format!("{:?}", e)
+ };
+ error!("panic caught in tray menu update (ObjC exception?): {}", panic_msg);
}
});
}