diff --git a/src-tauri/src/commands/windows.rs b/src-tauri/src/commands/windows.rs index f511330..70726c0 100644 --- a/src-tauri/src/commands/windows.rs +++ b/src-tauri/src/commands/windows.rs @@ -16,6 +16,10 @@ pub struct CommitWindowState { owner_by_commit_label: Mutex>, } +pub fn folder_window_label(folder_id: i32) -> String { + format!("folder-{folder_id}") +} + pub(crate) fn apply_platform_window_style<'a, R, M>( builder: WebviewWindowBuilder<'a, R, M>, ) -> WebviewWindowBuilder<'a, R, M> @@ -208,8 +212,19 @@ pub async fn open_folder_window( .await .map_err(AppCommandError::from)?; - // Create folder window with unique label - let label = format!("folder-{}", uuid::Uuid::new_v4()); + let label = folder_window_label(entry.id); + if let Some(existing) = app.get_webview_window(&label) { + ensure_windows_undecorated(&existing); + let _ = existing.unminimize(); + existing.set_focus().map_err(|e| { + AppCommandError::window("Failed to focus folder window", e.to_string()) + })?; + if let Some(w) = app.get_webview_window("welcome") { + let _ = w.close(); + } + return Ok(()); + } + let url = WebviewUrl::App(format!("folder?id={}", entry.id).into()); let builder = WebviewWindowBuilder::new(&app, &label, url) .title(&entry.name) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 2166fcd..f88fa08 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -74,7 +74,7 @@ pub fn run() { let _ = windows::open_welcome_window(app.handle()); } else { for entry in &open_folders { - let label = format!("folder-{}", uuid::Uuid::new_v4()); + let label = windows::folder_window_label(entry.id); let url = tauri::WebviewUrl::App(format!("folder?id={}", entry.id).into()); let builder = tauri::WebviewWindowBuilder::new(app, &label, url) .title(&entry.name)