fix(desktop): quit when the window close button is pressed - #9
Open
cabichahine wants to merge 1 commit into
Open
fix(desktop): quit when the window close button is pressed#9cabichahine wants to merge 1 commit into
cabichahine wants to merge 1 commit into
Conversation
On macOS the top-left X did nothing: the window stayed on screen and the process kept running. `deno desktop` emits a `close` event on the BrowserWindow when the native close button is pressed but takes no default action of its own — it neither destroys the window nor terminates the process. main.ts listened for `focus`, `resize` and `move` but not `close`, so the click was a no-op. Verified against a minimal `deno desktop` app with no BrowserWindow code at all, which reproduces identically. Cmd+Q was unaffected because it quits via the app menu. Handle `close` explicitly: flush the pending geometry write, destroy the window, then exit. Persisting on the close path also fixes geometry being lost when the window was resized within 400ms of closing — the debounced write never landed. Window lifecycle moves to src/deno/window.ts with I/O injected so it is unit testable; the geometry write is now synchronous so it completes before exit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117fevYXwnaG5Kr8MLX6YfQ
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.
Fixes #10
Problem
On macOS, clicking the close button (top-left X) does nothing — the window stays on screen and the process keeps running.
Root cause
deno desktopemits acloseevent on theBrowserWindowwhen the native close button is pressed, but takes no default action of its own — it neither destroys the window nor terminates the process.src/deno/main.tsregistered listeners forfocus,resizeandmove, but notclose, so the click was a no-op.Verified against a minimal
deno desktopapp containing noBrowserWindowcode at all — it reproduces identically, confirming this is runtime default behavior rather than something the window-adoption code introduced. Cmd+Q was never affected because it quits via the app menu, which is why the app was still closable.Fix
Handle
closeexplicitly: flush the pending geometry write, destroy the window, then exit.Persisting on the close path also fixes a second bug — geometry was silently lost when the window was resized within 400ms of closing, because the debounced write never landed.
Window lifecycle moves into
src/deno/window.tswith I/O injected so it can be unit tested; the geometry write is now synchronous so it completes beforeDeno.exit.Verification
window.jsonrecorded{"width":1100,"height":700,...}where it previously kept the stale size.tests/deno/window.test.ts. Mutation-checked: disabling thecloselistener fails 5 of them.just cigreen — 138 unit tests, 10 e2e,tsc --noEmitanddeno checkclean.Note
Closing the window now quits the app, matching the Linux behavior. This is a deliberate choice over the macOS convention of keeping an app alive with no windows — this is a single-window utility with no dock-reopen handling, so staying alive windowless would leave it unreachable.
🤖 Generated with Claude Code
https://claude.ai/code/session_0117fevYXwnaG5Kr8MLX6YfQ