fix: navigate main window after bridge ready to prevent white screen (#398)
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.
This commit is contained in:
1 parent
b0635186a5
commit
4c550cbb72
1 file changed
+15
-1
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user