From 4a2bebec96999728adbbed868359a9d414dcbb0f Mon Sep 17 00:00:00 2001 From: Faizan Asad Date: Sun, 27 Sep 2026 18:27:23 +0500 Subject: [PATCH] feat: hide tray icon when minimize to tray is off The tray only restores a hidden window, so it now follows the minimize-to-tray setting, applied at startup and on toggle (#145). --- src-tauri/src/lib.rs | 11 +++++++++++ src/ui/pages/SettingsPage.tsx | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 25335ac6..fe06c522 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1225,6 +1225,9 @@ fn app_setting_set( message: "application settings lock unavailable".to_string(), })?; let mut settings = read_app_settings(&app)?; + if key == MINIMIZE_TO_TRAY_SETTING { + set_tray_visible(&app, value.as_bool().unwrap_or(false)); + } settings.insert(key, value); write_json_file(&app_settings_path(&app)?, &settings) } @@ -1648,6 +1651,13 @@ fn close_or_hide_main_window(app: &tauri::AppHandle) { app.exit(0); } +// The tray only exists to bring back a hidden window, so it follows minimize-to-tray (#145). +fn set_tray_visible(app: &tauri::AppHandle, visible: bool) { + if let Some(tray) = app.tray_by_id("main-tray") { + let _ = tray.set_visible(visible); + } +} + fn build_tray(app: &tauri::AppHandle) -> tauri::Result<()> { use tauri::menu::{Menu, MenuItem}; use tauri::tray::{TrayIconBuilder, TrayIconEvent}; @@ -5346,6 +5356,7 @@ pub fn run() { if let Err(error) = build_tray(app.handle()) { std::eprintln!("[internal][tauri][warn] tray unavailable: {error}"); } + set_tray_visible(app.handle(), minimize_to_tray_enabled(app.handle())); Ok(()) }) .on_window_event(move |window, event| match event { diff --git a/src/ui/pages/SettingsPage.tsx b/src/ui/pages/SettingsPage.tsx index 90f79f52..01253fe1 100644 --- a/src/ui/pages/SettingsPage.tsx +++ b/src/ui/pages/SettingsPage.tsx @@ -1729,7 +1729,7 @@ export function SettingsPage({