fix(quick-pane): polish spotlight lifecycle

This commit is contained in:
2026-08-25 21:53:00 +02:00
parent bab754714e
commit a204eea7da
5 changed files with 213 additions and 47 deletions
+26 -9
View File
@@ -49,14 +49,29 @@ fn requested_quick_pane(args: &[String]) -> bool {
args.iter().any(|arg| arg == "--quick")
}
fn show_quick_pane(app: &AppHandle) {
if let Some(main) = app.get_webview_window("main") {
let _ = main.hide();
fn quick_pane_action(is_visible: bool) -> WindowAction {
if is_visible {
WindowAction::Hide
} else {
WindowAction::ShowAndFocus
}
}
fn toggle_quick_pane(app: &AppHandle) {
if let Some(window) = app.get_webview_window("quick-pane") {
let _ = window.show();
let _ = window.unminimize();
let _ = window.set_focus();
match quick_pane_action(window.is_visible().unwrap_or(false)) {
WindowAction::Hide => {
let _ = window.hide();
}
WindowAction::ShowAndFocus => {
if let Some(main) = app.get_webview_window("main") {
let _ = main.hide();
}
let _ = window.show();
let _ = window.unminimize();
let _ = window.set_focus();
}
}
}
}
@@ -388,7 +403,7 @@ pub fn run() {
})
.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
if requested_quick_pane(&args) {
show_quick_pane(app);
toggle_quick_pane(app);
return;
}
launch_new_session(app.clone(), &args);
@@ -406,7 +421,7 @@ pub fn run() {
}))
.setup(move |app| {
if requested_quick_pane(&launch_args) {
show_quick_pane(app.handle());
toggle_quick_pane(app.handle());
} else {
launch_new_session(app.handle().clone(), &launch_args);
}
@@ -482,9 +497,11 @@ mod tests {
}
#[test]
fn quick_flag_is_detected_without_affecting_toggle() {
fn quick_flag_is_detected_and_toggles_its_own_window() {
assert!(requested_quick_pane(&["--quick".to_owned()]));
assert!(!requested_quick_pane(&["--toggle".to_owned()]));
assert_eq!(quick_pane_action(false), WindowAction::ShowAndFocus);
assert_eq!(quick_pane_action(true), WindowAction::Hide);
}
#[test]