Repository navigation
fix(electron): quit app on window-all-closed to kill sidecar on macOS - #23018
vaishnavmhetre wants to merge 1 commit into
Conversation
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#17068
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Electron doesn't use a sidecar CLI anymore, and closing the window does quit the app for me. Is this PR still relevant? |
|
Thanks for the review @Brendonovich — you're right, the sidecar CLI is gone. I see That said, the Would it still make sense to add the |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #17068
Type of change
What does this PR do?
On macOS, closing the Electron window doesn't quit the app — it stays alive in the dock (standard macOS behavior). Because there's no
window-all-closedhandler, theopencode-cli servesidecar process is never killed. Over multiple sessions, zombie sidecar processes accumulate, each consuming ~1GB RAM and pegging a CPU core at 100%.The existing cleanup hooks (
before-quit,will-quit) only fire when the app actually quits, not when the last window is closed.This PR adds a
window-all-closedhandler that callskillSidecar()thenapp.quit(). This ensures the sidecar is terminated when the user closes the window on macOS, matching the behavior users expect.I understand why this works: on macOS, Electron keeps running after the last window closes unless
app.quit()is explicitly called. The existingwill-quithandler already callskillSidecar(), but it never fires because the app never quits. Addingwindow-all-closedbridges that gap. On Linux/Windows,window-all-closedalready triggers app quit by default, so this is a no-op there — but the explicit handler makes the intent clear across platforms.How did you verify your code works?
opencode-cli servewas runningopencode-cliprocesses remained viaps aux | grep opencode-clibefore-quit/will-quitflow (quitting via Cmd+Q still works)Screenshots / recordings
N/A — not a UI change.
Checklist