# Fix session not restarting when switching to a worktree branch · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/commit/5b7af7b9f641b8e8f1bdffabcdd423d3f09e9d80)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

Requested revision: 5b7af7b9f641b8e8f1bdffabcdd423d3f09e9d80

Requested commit: 5b7af7b9f641b8e8f1bdffabcdd423d3f09e9d80

Commit: 5b7af7b9f641b8e8f1bdffabcdd423d3f09e9d80

Tree: b97b3f84878aac084e8d9d40a518e5f3ffd59b16

Author: Julius Marminge

Committer: Julius Marminge

## Message

```
Fix session not restarting when switching to a worktree branch

When selecting a branch that lives in a different worktree, the store
updated the thread's worktreePath but the running session kept its
original cwd. The agent continued operating in the old directory.

- SET_THREAD_BRANCH now clears the session when worktreePath changes
- BranchToolbar stops the server-side session before dispatching the
  branch change, so the next message creates a fresh session with the
  correct cwd

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

```

## Parents

- [8324949b54c9aadc5d5db1b6cebbd10325a0ea79](https://git.cafe/pingdotgg/t3code/commit/8324949b54c9aadc5d5db1b6cebbd10325a0ea79?format=markdown)

[Source at this commit](https://git.cafe/pingdotgg/t3code/tree/5b7af7b9f641b8e8f1bdffabcdd423d3f09e9d80?format=markdown)
