[BUG] cwd incorrectly inherited while in state-grouped agent view

Open 💬 0 comments Opened Jun 3, 2026 by r-j-taylor

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:

  1. Run claude agents from ~
  2. Leave grouping as default (by state, not by directory)
  3. Have existing sessions from a different directory (e.g. ~/<something>) highlighted in the list
  4. Type a prompt and press Enter to dispatch a new session
  5. 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_

View original on GitHub ↗