Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ tauri-plugin-window-state = "2"
tauri-plugin-clipboard-manager = "2"
tauri-plugin-http = "2"
tauri-plugin-notification = "2"
tauri-plugin-single-instance = "2"

serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
14 changes: 14 additions & 0 deletions packages/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ pub fn run() {
let updater_enabled = option_env!("TAURI_SIGNING_PRIVATE_KEY").is_some();

let mut builder = tauri::Builder::default()
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
// When a second instance is launched, focus the existing window instead
if let Some(window) = app.get_webview_window("main") {
let _ = window.set_focus();
#[cfg(target_os = "windows")]
{
let _ = window.unminimize();
}
}
}))
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_window_state::Builder::new().build())
.plugin(tauri_plugin_store::Builder::new().build())
Expand Down Expand Up @@ -222,6 +232,10 @@ pub fn run() {
let timestamp = Instant::now();
loop {
if timestamp.elapsed() > Duration::from_secs(7) {
// Kill the sidecar before showing dialog to prevent orphaned processes
let _ = child.kill();
println!("Killed sidecar due to startup timeout");

let res = app.dialog()
.message("Failed to spawn OpenCode Server. Copy logs using the button below and send them to the team for assistance.")
.title("Startup Failed")
Expand Down