Fix restart using wrong default-directory#450
Merged
xenodium merged 1 commit intoxenodium:mainfrom Mar 25, 2026
Merged
Conversation
xenodium
requested changes
Mar 24, 2026
Owner
xenodium
left a comment
There was a problem hiding this comment.
Thanks for the PR. Left a minor comment. Could you take a look please?
agent-shell.el
Outdated
| (config (map-elt (buffer-local-value 'agent-shell--state shell-buffer) | ||
| :agent-config))) | ||
| :agent-config)) | ||
| (shell-dir (buffer-local-value 'default-directory shell-buffer))) |
Owner
There was a problem hiding this comment.
We can likely just do (default-directory (buffer-local-value 'default-directory shell-buffer)) here and drop the change below.
Contributor
Author
There was a problem hiding this comment.
Makes sense, yeah I think there was a part in the contributing guide about excluding redundant variables - my bad! I'll push that up sometime later :)
Contributor
Author
There was a problem hiding this comment.
addressed in latest force push, also rebased onto current main!
`agent-shell-restart` kills the buffer and calls `agent-shell--start` directly after. Since `kill-buffer` will have the effect of changing the default directory to the "other buffer", `agent-shell--start` can possibly end up creating the new shell an unexpected project (e.g if the user's last buffer was in a different project, the new shell will be made for this project instead of the expected behavior of being for the same project the original shell was for). The fix is to bind `default-directory` around calling `agent-shell--start`, since this will retain the default directory across the `kill-buffer` call. `agent-shell-reload` was also affected, since it delegates to `agent-shell-restart`. A new test is added to ensure that, in a frame whose last buffer was another project than the current shell's, calling restart will still use the shell's project as expected. Without the fix, the test fails. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30203b8 to
844af9e
Compare
xenodium
approved these changes
Mar 25, 2026
Owner
|
Thanks for the fix. Merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
agent-shell-restartkills the buffer and callsagent-shell--startdirectly after.Since
kill-bufferwill have the effect of changing the default directory to the "other buffer",agent-shell--startcan possibly end up creating the new shell an unexpected project (e.g if the user's last buffer was in a different project, the new shell will be made for this project instead of the expected behavior of being for the same project the original shell was for).The fix is to bind
default-directoryaround callingagent-shell--start, since this will retain the default directory across thekill-buffercall.agent-shell-reloadwas also affected, since it delegates toagent-shell-restart.A new test is added to ensure that, in a frame whose last buffer was another project than the current shell's, calling restart will still use the shell's project as expected. Without the fix, the test fails.
Thank you for contributing to agent-shell!
Checklist
M-x checkdocandM-x byte-compile-file.