S059: tab lifecycle: page dialogs and views go with a tab's web page, shortcut recording ends, message handler unregistered

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-18 04:00:18 -06:00
commit 9b7ea2b255

View file

@ -464,6 +464,15 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Not done: no real 10-tab list (tune list has six tabs); no visible/real-GPU run; `tc netem` not used (paced server instead); idle CPU varies a lot between runs.
- Later: a file without validators or cache headers (like `bare.js`) is refetched on every visit, as in any browser.
## S059 — Tab lifecycle: stuck tab, views freed, script message handler (2026-11-18)
- Root cause of the stuck tab (reproduced in `stuck.txt`): a web page's open question ("Leave this page?" from a Reload or close, or an alert) stayed on the tab when it moved to one of Nacre's pages, with the web view kept hidden behind, so the page kept waiting on it and Reload went to that hidden view. A second stuck state: a shortcut being recorded in settings (`capture_key`) stayed on after leaving the section/tab, and every shortcut of the window (Ctrl+R/F5 too) was eaten.
- Fixes: `Tab::take_web` (navigating to nacre://, memory saver, Free memory) detaches + forgets the view, denies/dismisses its open dialog and keeps its back/forward list (`HistoryState`, WebKit session state); Back from the page builds a new view with that list (`View::restore_history`, goes to the current entry). Shortcut recording ends when its button isn't drawn in a frame (`capture_shown`). The tick's 3 s close timeout now only waits for a "Leave this page?" (`Tab::close_overdue`), not any dialog.
- Guard: Reload on a closing tab is ignored with `tab N: Reload ignored, the tab is closing (x s, dialog true)`.
- Views: `Engine::forget` disconnects and unregisters the `nacre` message handler before the content manager can drop; selftest status `lifecycle` {views, views_leaked, capture_key}.
- Verified: `cargo test` 88 + webext 1; hidden `stuck.txt` (new, offline, `pages/chatty.html`) and `basics.txt` exit 0, `grep -c CRITICAL nacre.log` = 0 both; shots read.
- Not done: the CRITICAL line never showed in a hidden run before the fix either (not reproduced; fix by reading the API); settings wheel scroll had no cause of its own found (the dialog left over the page is the likely one); a real key press of Reload while recording not scripted (status check instead); no visible run.
- Later: when the app is busy at a render, `EguiArea` keeps the previous page rect (egui_area.rs `if let Ok(rect)`), which could route input to a stale rect.
## Later
- A link followed inside a frame still goes through the tab's navigation policy (WebKit's GTK API has no frame info; S050).
- file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043).