fix(electron): quit app on window-all-closed to kill sidecar on macOS#23018
Open
vaishnavmhetre wants to merge 1 commit intoanomalyco:devfrom
Open
fix(electron): quit app on window-all-closed to kill sidecar on macOS#23018vaishnavmhetre wants to merge 1 commit intoanomalyco:devfrom
vaishnavmhetre wants to merge 1 commit intoanomalyco:devfrom
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
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Member
|
Electron doesn't use a sidecar CLI anymore, and closing the window does quit the app for me. Is this PR still relevant? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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