#619

mux-activity: group Claude background agents under the session they belong to

Openwiiiimmopened 13d ago

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 no REX_SESSION, and its jobs/<id>/state.json names no pane. Its parent processes lead to no pane.
  • A job that was resumed with claude --resume in a pane runs under that pane's shell and has REX_SESSION in its environment. Today it is still drawn as a separate no pane row (for example BLOCKED 18d · process not running).
  • Every job records cwd, and sometimes worktreePath and originCwd. 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):

  1. Exact: the job's process carries the multiplexer's session marker (REX_SESSION). List it in that session. If its REX_BLOCK is a pane already on the board, do not draw it a second time.
  2. By directory: otherwise, if exactly one session has a pane at or under the job's cwd, worktreePath or originCwd, list it in that session, marked by directory.
  3. Otherwise it stays in the background agents group. 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).

Activity

1
linear-code[bot]13d ago