Repository navigation
Description
Problem
An unchanged VS Code OSS browser workbench can lose freshly stored workspace state during an immediate same-origin reload on WebScene. Its beforeunload handler calls storageService.flush(SHUTDOWN), which schedules the zero-delay IndexedDB flush. WebScene currently dispatches pagehide synchronously in the same native close/navigation call. VS Code handles pagehide by disposing the workbench and cancels the flush timer before any IndexedDB request starts.
Exact AppScene cd0a02e / WebScene a39280e4 Release evidence:
beforeunload=1,pagehide=1,navigationCount=2;- the reopened real
IMcpRegistry.getSavedInputs(WORKSPACE)map is empty; - the preserved native
.wsidbfiles contain nomcpInputsrecord; - the exception is VS Code
McpRegistry.editSavedInput()reading the absent entry; - WebScene Keep lifecycle-descended IndexedDB commits ahead of terminal navigation #878 / PR Persist lifecycle IndexedDB work before navigation #879 correctly retains lifecycle-descended timers and IndexedDB requests, but cannot help because the synchronous
pagehideteardown cancels the timer before it becomes a request.
Proposed fix
Split the terminal lifecycle into bounded phases for top-level close/reload/navigation:
- dispatch cancelable
beforeunloadand honor veto/error synchronously; - if it scheduled terminal-critical work, defer
pagehide; - drain only the already bounded lifecycle-descended zero-delay timer/IndexedDB lineage from Keep lifecycle-descended IndexedDB commits ahead of terminal navigation #878;
- dispatch
pagehideexactly once, with the same bounded lineage rules; - publish the terminal host request only after that work drains.
Do not admit intervals, delayed timers, unrelated pre-existing work, animation frames, or unbounded refilling. Clear phase state on veto, error, failed capacity reservation, successful handoff, realm reset, and teardown.
Acceptance
- Add a focused native V8 regression modeling VS Code:
beforeunloadschedules a zero-delay persistence task andpagehidecancels outstanding timers; persistence completes beforepagehide, then navigation is published. - Assert one
beforeunload, onepagehide, one terminal request, preserved event order, and durable read in the replacement realm. - Retain Persist lifecycle IndexedDB work before navigation #879 budget/starvation exclusions.
- Rebuild exact AppScene SDK/package and prove unchanged VS Code stores and reopens the real password input after reload.
- Record focused wall time and repeated-cycle queue/live-count bounds.
Activity