Skip to content

Start a new shell in the project chosen with project-switch-project - #949

Open
OSadovy wants to merge 1 commit into
xenodium:mainfrom
OSadovy:project-switch-new-shell-cwd
Open

OSadovy wants to merge 1 commit into
xenodium:mainfrom
OSadovy:project-switch-new-shell-cwd

Conversation

@OSadovy

@OSadovy OSadovy commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

When I start a new shell with C-x p p, pick a project, and run agent-shell-new-shell while I'm in another agent-shell buffer, the new shell starts in the current shell's directory instead of the project I picked. It also lists that directory's sessions to resume.

This happens because agent-shell-cwd gives a shell's own directory when called inside a shell, so it never looks at project-current-directory-override.

The change is limited to agent-shell--start. When project-current-directory-override is set, the new shell's directory comes from the new-shell half of agent-shell-cwd, which I split out as agent-shell--new-shell-cwd. Otherwise nothing changes, and a new shell started from a shell still starts in that shell's directory.

Checklist

  • I agree to communicate (PR description and comments) with the author myself (not AI-generated).
  • I've reviewed all code in PR myself and will vouch for its quality.
  • I've read and followed the Contributing guidelines.
  • I've filed a feature request/discussion for a new feature.
  • I'm making visual changes, so I'm including screenshots so you can view and discuss.
  • I've added tests where applicable.
  • I've updated documentation where necessary.
  • I've run M-x checkdoc and M-x byte-compile-file.

From within a shell, agent-shell-cwd answers with that shell's own
directory, so a shell started from one through C-x p p started in the
current shell's directory rather than in the chosen project, and listed
that directory's sessions to resume.

A new shell now ignores the shell it was started from while
project-switch-project is running the command for a project.  Asked
about an existing shell, agent-shell-cwd still answers with that
shell's directory, which is how shells are matched to projects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant