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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(windows): prevent tao event loop panic on tray click (#2535)
Rotted Brain1a08d1f7a9b9
diff --git a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx b/apps/screenpipe-app-tauri/components/settings/connections-section.tsxindex da8c8e6ed..f50ed6511 100644--- a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/connections-section.tsx@@ -164,6 +164,21 @@ function CursorLogo({ className }: { className?: string }) {);}+function MstyLogo({ className }: { className?: string }) {+ const gradientId = React.useId();+ return (+ <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" className={className ?? "w-5 h-5"}>+ <defs>+ <linearGradient id={gradientId} x1="0%" y1="0%" x2="100%" y2="100%">+ <stop offset="0%" stopColor="#a855f7" />+ <stop offset="100%" stopColor="#7c3aed" />+ </linearGradient>+ </defs>+ <rect width="100" height="100" rx="20" fill={`url(#${gradientId})`} />+ <text x="50" y="65" textAnchor="middle" fontSize="50" fontWeight="bold" fontFamily="system-ui, sans-serif" fill="white">M</text>+ </svg>+ );+}function IntegrationIcon({ icon }: { icon: string }) {const icons: Record<string, React.ReactNode> = {@@ -209,7 +224,7 @@ function IntegrationIcon({ icon }: { icon: string }) {</svg>),anythingllm: <img src="/images/anythingllm.png" alt="AnythingLLM" className="w-5 h-5 rounded" />,- msty: <img src="/images/msty.webp" alt="Msty" className="w-5 h-5 rounded" />,+ msty: <MstyLogo />,ollama: <img src="/images/ollama.png" alt="Ollama" className="w-5 h-5 rounded" />,lmstudio: <img src="/images/lmstudio.png" alt="LM Studio" className="w-5 h-5 rounded" />,whatsapp: <img src="/images/whatsapp.svg" alt="WhatsApp" className="w-5 h-5" />,diff --git a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs b/apps/screenpipe-app-tauri/src-tauri/src/tray.rsindex e249b366a..d02c305b0 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs@@ -470,16 +470,32 @@ fn setup_tray_click_handlers(main_tray: &TrayIcon) -> Result<()> {{main_tray.set_show_menu_on_left_click(false)?;main_tray.on_tray_icon_event(|tray, event| {- if let tauri::tray::TrayIconEvent::Click {- button: tauri::tray::MouseButton::Left,- button_state: tauri::tray::MouseButtonState::Up,- ..- } = event- {- let app = tray.app_handle().clone();- let _ = tray.app_handle().run_on_main_thread(move || {- let _ = ShowRewindWindow::Home { page: None }.show(&app);- });+ // Fix for issue #2495: on_tray_icon_event fires INSIDE the tao Windows event+ // loop dispatcher (synchronously). Calling run_on_main_thread() directly from+ // here causes re-entrancy — tao panics at runner.rs:245 with:+ // "either event handler is re-entrant (likely), or no event handler is registered"+ // Solution: wrap in catch_unwind for safety, and use async_runtime::spawn to+ // exit the tao callback context before dispatching work to the main thread.+ if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {+ if let tauri::tray::TrayIconEvent::Click {+ button: tauri::tray::MouseButton::Left,+ button_state: tauri::tray::MouseButtonState::Up,+ ..+ } = event+ {+ let app = tray.app_handle().clone();+ // ⚠️ Do NOT call run_on_main_thread() directly here — that would+ // re-enter the tao event loop and trigger the panic.+ // Instead: spawn onto tokio so we exit the tao callback first, then+ // safely dispatch to the main thread from outside tao's dispatcher.+ tauri::async_runtime::spawn(async move {+ let _ = app.run_on_main_thread(move || {+ let _ = ShowRewindWindow::Home { page: None }.show(&app);+ });+ });+ }+ })) {+ tracing::error!("panic caught in on_tray_icon_event (Windows): {:?}", e);}});}