#619
mux-activity: group Claude background agents under the session they belong to
Claude background agents in mux-activity all sit in one background agents group at the top of AGENTS, away from the session they belong to. They should be listed in the session they belong to.
What the machine says
- A true background agent runs under Claude's daemon (
claude bg-spare←bg-pty-host← pid 1). Its environment has noREX_SESSION, and itsjobs/<id>/state.jsonnames no pane. Its parent processes lead to no pane. - A job that was resumed with
claude --resumein a pane runs under that pane's shell and hasREX_SESSIONin its environment. Today it is still drawn as a separateno panerow (for exampleBLOCKED 18d · process not running). - Every job records
cwd, and sometimesworktreePathandoriginCwd. On this machine 4 of 6 jobs share a directory with exactly one Rex session's panes.
Scope
Grouping (Rex first, the same rule under Herdr and Luvus):
- Exact: the job's process carries the multiplexer's session marker (
REX_SESSION). List it in that session. If itsREX_BLOCKis a pane already on the board, do not draw it a second time. - By directory: otherwise, if exactly one session has a pane at or under the job's
cwd,worktreePathororiginCwd, list it in that session, markedby directory. - Otherwise it stays in the
background agentsgroup. That includes a directory open in more than one session: no guessing.
The matching is a pure, always-compiled function with unit tests.
Out: focusing a background agent's pane (secondary).
OPS-292