From 5deadbca9e6754dc508de42d3d8b3aec177810bc Mon Sep 17 00:00:00 2001 From: Vaishnav Mhetre Date: Fri, 17 Apr 2026 09:00:19 +0530 Subject: [PATCH] fix(electron): quit app on window-all-closed to kill sidecar on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, closing all Electron windows does not quit the application — the process stays alive in the Dock and the opencode-cli sidecar keeps running indefinitely, leaking CPU and memory. Add a window-all-closed handler that kills the sidecar and quits the app, ensuring cleanup matches the before-quit/will-quit handlers. Fixes anomalyco/opencode#17068 --- packages/desktop-electron/src/main/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/desktop-electron/src/main/index.ts b/packages/desktop-electron/src/main/index.ts index 946e01e325d0..ab7b9101d316 100644 --- a/packages/desktop-electron/src/main/index.ts +++ b/packages/desktop-electron/src/main/index.ts @@ -94,6 +94,14 @@ function setupApp() { killSidecar() }) + // On macOS, closing all windows does not quit the app by default — + // the process stays alive in the Dock with the sidecar still running. + // Explicitly quit so the sidecar is cleaned up via before-quit/will-quit. + app.on("window-all-closed", () => { + killSidecar() + app.quit() + }) + for (const signal of ["SIGINT", "SIGTERM"] as const) { process.on(signal, () => { killSidecar()