agentmux_srv/server/browser_pane_gone.rs
1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! What the browser state forgets about a pane when its block is deleted
5//! (`backend::wcore::set_block_gone_hook`).
6
7/// Installs the hook; `browser_host_sync::spawn` calls it once at startup.
8pub(crate) fn install() {
9 crate::backend::wcore::set_block_gone_hook(pane_gone);
10}
11
12fn pane_gone(block_id: &str) {
13 // An agent's ownership of a browser pane ends with the pane
14 // (SPEC_AGENT_DRIVEN_BROWSER_PANES_2026_10_07.md ยง3).
15 super::browser_owner::forget(block_id);
16 // And whoever opened it may no longer place it (it is gone).
17 super::pane_openers::forget(block_id);
18 // So does anything it was waiting on the user for: an agent mid
19 // hand-off or approval gets Cancelled now, not after the timeout.
20 super::browser_attention::cancel_for(block_id);
21 // And its share of a site limit (its chain's other panes keep theirs).
22 super::browser_allowlist::drop_pane(block_id);
23 // Its action log and pause go with it (Take over keeps the log).
24 super::browser_actions::drop_pane(block_id);
25 // The host drops an Incognito jar once no tab uses it: tell it now.
26 super::browser_owner::changed().notify_one();
27}