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(macos): crash on Escape — nil guard in cancel_deferred_first_responder

Louis Beaumont934264971a17
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs
index 93234b58f..4d9a8e733 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs
@@ -513,9 +513,16 @@ pub unsafe fn make_webview_first_responder(panel: &tauri_nspanel::raw_nspanel::R
#[cfg(target_os = "macos")]
unsafe fn cancel_deferred_first_responder(panel: &tauri_nspanel::raw_nspanel::RawNSPanel) {
use objc::{class, msg_send, sel, sel_impl};
- use tauri_nspanel::cocoa::base::id;
+ use tauri_nspanel::cocoa::base::{id, nil};
+ let content_view: id = panel.content_view();
+ if content_view == nil {
+ return;
+ }
+ let window: id = msg_send![content_view, window];
+ if window == nil {
+ return;
+ }
let ns_object_class: id = msg_send![class!(NSObject), class];
- let window: id = msg_send![panel.content_view(), window];
let _: () = msg_send![ns_object_class,
cancelPreviousPerformRequestsWithTarget: window
selector: sel!(makeFirstResponder:)