[BUG] Agent spawning steals tmux focus from the user's pane
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?
(This intersects with #23615 but is distinct)
When Claude Code spawns Agent Teams teammates, it creates new tmux panes that steal focus from the user's active pane — the cursor jumps to the new agent pane every time a teammate is spawned.
Impact: When spawning multiple agents in quick succession (common for parallel workloads), the user's pane loses focus repeatedly. Particularly disruptive for daemon-style Claude sessions that spawn agents autonomously — the human loses their cursor mid-typing and can break the command being tmux send-keys pasted
Workaround: None found. Tested tmux set-hook after-split-window "select-pane -l" — focus still jumps (hook may fire before Claude Code's focus switch completes, or Claude Code may use a different mechanism than split-window).
Suggested fix: Add the -d flag to pane creation calls so new panes are created without stealing focus. If Claude Code uses send-keys or another mechanism to switch focus after creation, that should also be gated.
What Should Happen?
Expected: New pane is created in the background. User's focus stays on their active pane.
Error Messages/Logs
Steps to Reproduce
- Be working in a tmux session with Claude Code
- Spawn an Agent Teams teammate (via the Agent tool)
- Focus jumps to the new pane
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.110
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗