[BUG] cwd incorrectly inherited while in state-grouped agent view
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?
When dispatching a new session from Agent View (state-grouped view, the default), the new session's cwd is set to the highlighted row's directory rather than the directory claude agents was opened from.
The docs state this cwd-inheritance behavior only applies when grouped by directory (Ctrl+S). In state-grouped view, the shell cwd should always win.
What Should Happen?
In state-grouped view, new sessions dispatched from the Agent View input should always use the cwd of the shell that opened claude agents, regardless of which row is highlighted. The highlighted-row cwd override should only apply when explicitly grouped by directory (Ctrl+S), as the docs describe.
Error Messages/Logs
Steps to Reproduce
Steps to reproduce:
- Run
claude agentsfrom~ - Leave grouping as default (by state, not by directory)
- Have existing sessions from a different directory (e.g.
~/<something>) highlighted in the list - Type a prompt and press Enter to dispatch a new session
- Check
~/.claude/jobs/<id>/state.json: cwd is the highlighted row's directory, not~
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.161 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_