After the saga: purge the block’s persisted broker history and its tool
statuses, and lift the respawn guard. If the block somehow survived
(dispatch failed), it keeps its stopped state and can be closed again.
Close block_ids (normally every member of one pane’s stack). Ids that no
longer exist are skipped; ids in different tabs are rejected. On success
returns {"tab_id": "...", "block_ids": [...closed...], "leaf_removed": bool}.
Clear session:active_pid (so the next boot doesn’t read this as an
interrupted session) and mark the local instance row stopped. The session
id itself is left everywhere it is — block meta, instance row, shared
registry — so reopening the agent resumes it (spec §4.2 step 6).
Tell the window the pane is gone, after srv’s own tree already lost it. A window that still shows
every member (frontend_waits, §5.5) gets one delete each, in one batch: its handler removes just
that member, and the last one removes the leaf. That is queued whether or not the leaf goes, since
closing one tab of a kept pane needs it just as much. Otherwise one delete for the pane, keyed on
its visible block, not one per member, which is what produced the “could not find leaf node with
blockId” errors when each member sent its own.
Serialises tab closes within one workspace, from delete_tab’s last-tab
pre-check through its DeleteTab dispatch (spec §9.5). One lock per
workspace id; entries are tiny and bounded by the number of workspaces.