Skip to content

Commit 1f89909

Browse files
authored
fix(cortex-gui): prevent double window on IDE mode startup (#533)
Fixed two related issues in cortex-gui: 1. Double window on startup: When the app was closed while a new window (created via "New Window") was open, it was saved to window_sessions.json with a label like "main-xxxxxxxx". On restart, restore_windows() would recreate this window since it only checked for exact match with "main". This caused two windows to appear (the default main window from tauri.conf.json plus the restored main-* window). 2. Infinite loading in IDE mode: Related to the double window issue, when two windows competed for resources, the file explorer could get stuck in a loading state. Fix: Skip restoring windows with labels starting with "main-" during window restoration. These are temporary additional IDE windows that users create at runtime and shouldn't persist across restarts. Auxiliary windows (aux-*) are still restored normally.
1 parent a7d236f commit 1f89909

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cortex-gui/src-tauri/src/window.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,25 @@ pub async fn restore_windows(app: &AppHandle) {
204204
}
205205
};
206206
for session in sessions {
207+
// Skip restoring windows that start with "main-" (additional IDE windows)
208+
// These windows were created by the user via "New Window" and shouldn't
209+
// persist across restarts to avoid the double window bug.
210+
// Only restore auxiliary windows (aux-*) or update the main window bounds.
211+
if session.label.starts_with("main-") {
212+
info!(
213+
"Skipping restoration of additional IDE window: {}",
214+
session.label
215+
);
216+
continue;
217+
}
218+
207219
guard.insert(
208220
session.label.clone(),
209221
(session.path.clone(), session.bounds.clone()),
210222
);
211223

212224
// Re-create the window if it's not the main one (which is created by default)
225+
// Note: "main" window is created by tauri.conf.json, we only update its bounds
213226
if session.label != "main" {
214227
let _ =
215228
create_window_internal(app, session.label, session.path, session.bounds);

0 commit comments

Comments
 (0)