From ce2a0c11ebc69c21a76b8c02fdd85b513fa062ba Mon Sep 17 00:00:00 2001 From: AspasZhang <24210980075@m.fudan.edu.cn> Date: Sat, 16 May 2026 20:01:43 +0800 Subject: [PATCH] fix: navigate main window after bridge ready to prevent white screen When setup window starts the bridge, the main window was already created with URL http://127.0.0.1:14168/ but failed to load (bridge not running yet). After bridge becomes ready, we now navigate the main window to reload the bridge URL before showing it, preventing the white screen issue. --- frontends/desktop/src-tauri/src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontends/desktop/src-tauri/src/lib.rs b/frontends/desktop/src-tauri/src/lib.rs index 0490296f..d47c9e3a 100644 --- a/frontends/desktop/src-tauri/src/lib.rs +++ b/frontends/desktop/src-tauri/src/lib.rs @@ -196,7 +196,7 @@ fn ensure_bridge_running() { } #[tauri::command] -fn start_bridge_with_config(python_path: String, project_dir: String) -> Result<(), String> { +fn start_bridge_with_config(app_handle: tauri::AppHandle, python_path: String, project_dir: String) -> Result<(), String> { // Save to settings let path = settings_path(); let obj = serde_json::json!({"python_path": python_path, "project_dir": project_dir}); @@ -222,6 +222,20 @@ fn start_bridge_with_config(python_path: String, project_dir: String) -> Result< if !wait_for_port(14168, Duration::from_secs(15)) { return Err("Bridge did not become ready within 15s".into()); } + + // Navigate main window to bridge URL and show it, hide setup + if let Some(main_win) = app_handle.get_webview_window("main") { + let url = tauri::Url::parse("http://127.0.0.1:14168/").unwrap(); + let _ = main_win.navigate(url); + // Small delay for page to start loading + thread::sleep(Duration::from_millis(300)); + let _ = main_win.show(); + let _ = main_win.set_focus(); + } + if let Some(setup_win) = app_handle.get_webview_window("setup") { + let _ = setup_win.hide(); + } + Ok(()) }