fix(shutdown): stop instances before app exit

Prevent desktop wrappers from SIGKILLing the CLI during shutdown, which could orphan OpenCode workspace processes. Shut down workspaces earlier/in parallel and increase the quit grace period.
This commit is contained in:
Shantur Rathore
2026-01-25 11:01:50 +00:00
parent 9ee7ff9509
commit c74e0b89f7
5 changed files with 59 additions and 34 deletions

View File

@@ -34,6 +34,8 @@ fn workspace_root() -> Option<PathBuf> {
const SESSION_COOKIE_NAME: &str = "codenomad_session";
const CLI_STOP_GRACE_SECS: u64 = 30;
fn navigate_main(app: &AppHandle, url: &str) {
if let Some(win) = app.webview_windows().get("main") {
let mut display = url.to_string();
@@ -290,7 +292,7 @@ impl CliProcessManager {
match child.try_wait() {
Ok(Some(_)) => break,
Ok(None) => {
if start.elapsed() > Duration::from_secs(4) {
if start.elapsed() > Duration::from_secs(CLI_STOP_GRACE_SECS) {
#[cfg(unix)]
unsafe {
libc::kill(child.id() as i32, libc::SIGKILL);