Ask before leaving the page while a world is open (Ctrl+W closed the game)

Ctrl (replace) + W (fly) hits the browser's close-tab shortcut, which a page
cannot block. A beforeunload prompt now catches it. Autosave on hiding the
tab no longer depends on the audio context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 19:47:27 -04:00
co-authored by Claude Opus 5.5
parent fec4f3bfe1
commit 97c5ca4668
3 changed files with 24 additions and 1 deletions
+15
View File
@@ -4,6 +4,21 @@ What agents have done, newest first. Add an entry for every piece of work: the d
note or request it was for, what changed, the files touched, the tests run, and anything left
open or not verified. Keep each entry short; the git history has the details.
## 2026-10-23: Ctrl+W no longer closes the game without asking (Claude Code)
Note: "crash: hoplding crtl and pressing W crashes the whole browser."
- Cause: Ctrl+W is the browser's close-tab shortcut (the whole window if it is the last tab);
holding Ctrl for replace while pressing W to fly hits it. Chrome and Brave reserve it, so the
page never sees the key and cannot cancel it.
- `src/ui/input.js`: a `beforeunload` handler makes the browser ask before leaving while
`GAME.running`. The `visibilitychange` autosave no longer depends on the audio context
existing (it used to return early before any sound had played).
- `test/play.py`: 2 checks (leaving asks while a world is open, not on the title screen); 120
checks pass. All 11 headless suites pass; `t_smooth.py` passed on its rerun (the known flaky
half-resolution check failed once at load ~5).
- Open: the real Ctrl+W prompt can only be seen in a headed browser; the owner checks it.
## 2026-10-23: build menu hover popup, top-left card hidden while building (Claude Code, with Codex)
Notes: "mouse hover reviels a new info popup…" and "dont need the short description in the build