Skip to content

fix(app): keep Snapora alive when all BrowserWindows close - #22

Merged
aryasadeghy merged 1 commit into
mainfrom
fix/macos-window-all-closed-keeps-app-alive
May 10, 2026
Merged

fix(app): keep Snapora alive when all BrowserWindows close#22
aryasadeghy merged 1 commit into
mainfrom
fix/macos-window-all-closed-keeps-app-alive

Conversation

@aryasadeghy

Copy link
Copy Markdown
Contributor

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).

Summary

Type

  • feat — new feature
  • fix — bug fix
  • docs — documentation only
  • refactor — code restructure, no behavior change
  • perf — performance improvement
  • test — adds or changes tests
  • chore / ci / build — tooling

Screenshots / recording

Test plan

  • npm run lint
  • npm run typecheck
  • npm test
  • Manual smoke: launched the app, exercised the changed feature
  • Manual smoke: nothing else regressed

Clean-room confirmation

  • I confirm this contribution is not derived from decompiled or leaked commercial software (see CONTRIBUTING.md).

Linked issues

Closes #

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
aryasadeghy enabled auto-merge (squash) May 10, 2026 09:59
@aryasadeghy
aryasadeghy merged commit 37e592c into main May 10, 2026
3 checks passed
@aryasadeghy
aryasadeghy deleted the fix/macos-window-all-closed-keeps-app-alive branch May 10, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant