[BUG] Agent Teams tmux mode treats the window's first pane as the leader, so an existing pane is resized and the leader is stacked with teammates

Status Open
Reported on v2.1.285
Maintainer reply None cached
Activity 0 comments · opened Sep 30, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

With teammateMode: "tmux", the leader-layout code assumes the leader is the first pane in the window. When Claude Code runs in a window that already has another pane to its left (for example a shell pane at index 0 and Claude Code at index 1), teammate spawning:

  1. treats the other pane (index 0) as the leader: it becomes the main-vertical main pane and is resized to 30% width;
  2. treats the real leader as a teammate: the first teammate is split from the leader vertically, and the leader ends up stacked in the right column with the teammates, getting shorter with each spawn.

The unrelated pane is resized, and the leader pane loses the full-height column that the layout reserves for it.

From the bundled code in 2.1.285 (TmuxBackend):

  • createTeammatePaneWithLeader: the 70% split from the leader runs only when the window has exactly one pane. Otherwise it lists the window's panes, drops the first one (slice(1)), and splits the middle pane of the rest. With a pre-existing pane at index 0, that list starts with the leader.
  • rebalancePanesWithLeader: select-layout main-vertical, then resize-pane -t <first listed pane> -x 30%. The first listed pane is index 0, which is not the leader here.

The current leader pane id is already known in createTeammatePaneWithLeader (getCurrentPaneId()), but the layout code does not use it.

What Should Happen?

The pane Claude Code runs in stays the leader: it gets the main (left, full-height) slot and the leader width, teammates are split off the teammate area, and panes Claude Code did not create are not resized or reordered. Alternatively, when the window already has other panes, teammates could go to a separate window.

Error Messages/Logs

None; no error is shown.

Steps to Reproduce

  1. In tmux, open a window and split it so it has two side-by-side panes: a shell on the left (index 0) and a second pane on the right (index 1).
  2. Start Claude Code with teammateMode: "tmux" in the right pane.
  3. Ask it to create an agent team with 2 teammates.

Replaying the same tmux commands in a 200x50 window (%15 = pre-existing shell pane, %16 = leader):

| Step | %15 (shell) | %16 (leader) |
|---|---|---|
| before | 100x50 | 99x50 |
| after teammate 1 | 60x50 | 139x25 |
| after teammate 2 | 60x50 | 139x16 |

Claude Model

Opus (Opus 5.5)

Is this a regression?

I don't know

Claude Code Version

2.1.285

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other: tmux (TERM_PROGRAM=tmux)

Additional Information

  • tmux 3.7c
  • Related: #23615 (existing tmux layout is disturbed when teammates spawn).

View original on GitHub ↗