Belén Albeza 79aebcca49
🐛 Free the worker's copy of a page when leaving it (#12751)
* 🐛 Stop worker index updates from adding nil-keyed entries

When a commit touched a page the worker had not indexed, or deleted the
indexed page, `:index/update` ran the selection and snap updates with a
nil page. That left entries under a nil key (and a stale selection index
for a deleted page) for the rest of the session.

Skip updates for pages the worker does not hold, since a later
`:index/initialize` sends the whole page again, and drop the selection
and snap indexes when the changes delete the page.

AI-assisted-by: claude-opus-5-5

* 🐛 Free the worker's copy of a page when leaving it

The worker kept every visited page, with its selection and snap
indexes, for the whole session. On large files each visited page added
hundreds of MB to the worker heap.

Add an `:index/finalize` worker command that drops a page and its
indexes, and send it from `finalize-page`, which runs on every page
switch and when leaving the workspace. Coming back to a page indexes it
again from the full page, as before.

Closes #12738

AI-assisted-by: claude-opus-5-5
2026-11-02 12:12:57 +01:00
..