From 870f517be262611c9a7d46db4914a090e87c1490 Mon Sep 17 00:00:00 2001 From: CJ Pais Date: Mon, 17 Feb 2025 12:12:48 -0800 Subject: [PATCH] Work in the background. --- src-tauri/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index cdb9c4c..8c12d13 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -9,6 +9,7 @@ use rig::streaming::StreamingChoice; use rig::{completion::Prompt, providers::anthropic}; use std::sync::{Arc, Mutex}; use std::{thread, time}; +use tauri::RunEvent; use tauri_plugin_autostart::MacosLauncher; use tauri_plugin_clipboard_manager::ClipboardExt; @@ -271,6 +272,13 @@ pub fn run() { }); Ok(()) }) + .on_window_event(|app, event| match event { + tauri::WindowEvent::CloseRequested { api, .. } => { + app.hide().unwrap(); + api.prevent_close(); + } + _ => {} + }) .invoke_handler(tauri::generate_handler![]) .run(tauri::generate_context!()) .expect("error while running tauri application");