From ece0ea1a14adf9c36ff8f9689aa5e340175cfcb7 Mon Sep 17 00:00:00 2001 From: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> Date: Fri, 19 Jun 2026 17:30:54 +0300 Subject: [PATCH] fix white screen on autostart and hotkey toggle --- src-tauri/src/main.rs | 12 ++++++++++-- src-tauri/tauri.conf.json | 4 ++-- src/main.ts | 18 ++++++++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index f8db79e..c90a22b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -452,6 +452,13 @@ fn exit_app(app: AppHandle) { app.exit(0); } +/// True when the app was launched by autostart (passes --hidden arg). +/// The frontend uses this to stay in the tray instead of showing the window. +#[tauri::command] +fn is_hidden_launch() -> bool { + std::env::args().any(|a| a == "--hidden") +} + /// Quit via the frontend so the debounced autosave gets flushed first; /// a watchdog exits anyway in case the webview is unresponsive. fn request_quit(app: &AppHandle) { @@ -494,7 +501,7 @@ fn main() { .plugin(tauri_plugin_global_shortcut::Builder::new().build()) .plugin(tauri_plugin_autostart::init( tauri_plugin_autostart::MacosLauncher::LaunchAgent, - None, + Some(vec!["--hidden"]), )) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_dialog::init()) @@ -513,7 +520,8 @@ fn main() { open_extensions_folder, get_launch_file, read_text_file, - exit_app + exit_app, + is_hidden_launch ]) .setup(|app| { let handle = app.handle().clone(); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index fccc44a..09ec552 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Summarum", - "version": "1.1.2", + "version": "1.1.3", "identifier": "app.summarum.calc", "build": { "beforeDevCommand": "npm run dev", @@ -18,7 +18,7 @@ "minWidth": 320, "minHeight": 240, "center": true, - "visible": true, + "visible": false, "decorations": false } ], diff --git a/src/main.ts b/src/main.ts index 98c155f..190c561 100644 --- a/src/main.ts +++ b/src/main.ts @@ -308,8 +308,13 @@ async function registerHotkey(old: string | null, combo: string): Promise { void onOpenFile((content) => newDoc(content)); editor.focus(); + + if (isTauri()) { + const { invoke } = await import("@tauri-apps/api/core"); + const hidden = await invoke("is_hidden_launch"); + if (!hidden) { + const { getCurrentWindow } = await import("@tauri-apps/api/window"); + await getCurrentWindow().show(); + } + } } void boot();