pub fn agent_started(
members: Vec<TrackedProcess>,
roots: &HashSet<u32>,
) -> Vec<TrackedProcess>Expand description
Filter a tracker’s raw membership down to the processes the agent started through its tools — what the Swarm list, the pane-close confirmation and the process events should count.
The raw job also holds the agent’s own plumbing: the CLI itself
(roots — every PID handed to assign_process), its conhost.exe, and
MCP servers such as agentmux-mcp.exe (direct non-shell children of the
root, plus their own conhosts/children). Counting those made every idle
agent report ~3 processes and every pane close ask for confirmation.
Rule: drop roots and conhost; keep a process iff walking its parents
inside the job passes through a shell before reaching a root. A root
that is itself a shell (terminal blocks) counts as that shell. A chain
that hits a parent no longer in the job — a launching shell that exited
(npm run dev &), or a root that exited (a terminal’s shell, a
respawned CLI) — is kept: those orphans are exactly what the user needs
to see.