fix(app): keep Snapora alive when all BrowserWindows close - #22
Merged
Conversation
Electron's default `window-all-closed` behavior quits the app — even on
macOS — when the last BrowserWindow goes away. `LSUIElement: true` only
applies to packaged builds, so in `npm run dev` (and likely in any code
path that spawns Electron without the packaged Info.plist) the app would
silently quit between captures.
Reproduction (before this fix):
1. Fresh `npm run dev`.
2. First action: take an area capture (Cmd+Shift+2).
3. Selection overlay creates BrowserWindows; user commits the rect;
overlays `close()`.
4. `window-all-closed` fires → default → `app.quit()` → exit code 0.
5. The pending screencapture promise dies with the process; main.log
ends at "spawning screencapture" with no follow-up.
The window-mode flow happened to work because screencapture's UI is a
separate process — Snapora itself never opened or closed a window, so
the event never fired. Doing window-then-area also worked because the
HUD window stays in the BrowserWindow registry (it `hide()`s, not
`close()`s) and keeps the count positive.
Fix: subscribe to `window-all-closed` and refuse to quit on macOS.
Snapora is a menu-bar app — the tray keeps it running. The packaged
build's `LSUIElement` was already doing this for production users; this
hooks it for the dev build (and as a belt-and-suspenders production
guard).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
aryasadeghy
enabled auto-merge (squash)
May 10, 2026 09:59
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.
Electron's default
window-all-closedbehavior quits the app — even on macOS — when the last BrowserWindow goes away.LSUIElement: trueonly applies to packaged builds, so innpm run dev(and likely in any code path that spawns Electron without the packaged Info.plist) the app would silently quit between captures.Reproduction (before this fix):
npm run dev.close().window-all-closedfires → default →app.quit()→ exit code 0.The window-mode flow happened to work because screencapture's UI is a separate process — Snapora itself never opened or closed a window, so the event never fired. Doing window-then-area also worked because the HUD window stays in the BrowserWindow registry (it
hide()s, notclose()s) and keeps the count positive.Fix: subscribe to
window-all-closedand refuse to quit on macOS. Snapora is a menu-bar app — the tray keeps it running. The packaged build'sLSUIElementwas already doing this for production users; this hooks it for the dev build (and as a belt-and-suspenders production guard).Summary
Type
Screenshots / recording
Test plan
npm run lintnpm run typechecknpm testClean-room confirmation
Linked issues
Closes #