feat(app-tauri): fermeture des fenêtres auxiliaires quand la principale se ferme (#39)

Ajoute close_non_main_webview_windows sur l'event de fermeture de la
fenêtre principale, avec le prédicat should_close_with_main_window qui
exclut la fenêtre "main" et cible toutes les fenêtres auxiliaires
(vues détachées, settings…). Couvert par 3 tests unitaires.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-13 07:45:27 +02:00
parent 9ee7290cde
commit 13d45cb752

View File

@ -124,6 +124,8 @@ pub fn run() {
let _ = model_servers.stop_on_app_exit().await;
});
}
close_non_main_webview_windows(&handle);
}
});
}
@ -253,3 +255,39 @@ pub fn run() {
.run(tauri::generate_context!())
.expect("error while running IdeA Tauri application");
}
fn close_non_main_webview_windows(handle: &tauri::AppHandle) {
for (label, window) in handle.webview_windows() {
if !should_close_with_main_window(&label) {
continue;
}
let _ = window.close();
}
}
fn should_close_with_main_window(label: &str) -> bool {
label != "main"
}
#[cfg(test)]
mod tests {
use super::should_close_with_main_window;
#[test]
fn main_window_close_does_not_target_main_again() {
assert!(!should_close_with_main_window("main"));
}
#[test]
fn main_window_close_targets_detached_view_windows() {
assert!(should_close_with_main_window(
"view-work-00000000-0000-0000-0000-000000000001"
));
}
#[test]
fn main_window_close_targets_other_auxiliary_windows() {
assert!(should_close_with_main_window("settings"));
}
}