Draft
Prompt for working directory on prefixed AI CLI start/resume#416
Conversation
Copilot
AI
changed the title
[WIP] Fix starting directory for agent to match active buffer
Prompt for working directory on prefixed AI CLI start/resume
Jul 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves native CLI backend session startup/resume reliability by ensuring prefixed start/resume flows explicitly prompt for a working directory (avoiding accidental inheritance of unrelated default-directory), while preserving existing CLI-args prompting behavior.
Changes:
- Updates shared backend infra startup flow so CLI args are resolved first, then (when prefixed) the working directory is prompted with a project-aware default.
- Enhances resume picker behavior to prefer the last accessed matching session buffer for a backend.
- Updates docstrings and adds ERT coverage for prompt ordering, directory prompting, and resume-buffer selection.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
ai-code-backends-infra.el |
Adds optional working-directory prompting and reorders startup resolution; prefers last accessed session buffer in resume picker. |
ai-code-backends.el |
Updates user-facing start/resume docstrings about prefix behavior and adds a compile-time var declaration. |
ai-code-opencode.el |
Updates resume docstring to reflect new prefix behavior. |
ai-code-kilo.el |
Updates resume docstring to reflect new prefix behavior. |
test/test_ai-code-backends-infra.el |
Adds/updates tests for directory prompting, prompt ordering, and resume picker buffer preference. |
Comment on lines
+191
to
+194
| ((symbol-function 'read-directory-name) | ||
| (lambda (prompt &optional dir default-filename mustmatch initial) | ||
| (setq seen (list prompt dir default-filename mustmatch initial)) | ||
| "/custom/"))) |
Comment on lines
118
to
+121
| "Start the current backend's CLI session when supported. | ||
| Argument ARG is passed to the backend's start function." | ||
| Argument ARG is passed to the backend's start function. | ||
| Interactively, a prefix argument keeps the existing CLI-args prompt and | ||
| also prompts for the working directory before the session starts." |
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.
Starting or resuming an AI CLI session could inherit
default-directoryfrom an unrelated Emacs context, including$HOME. This change makes prefixed start/resume flows ask for the working directory explicitly while preserving the existing args prompt.Behavior change
C-uon start/resume now keeps the current CLI-args prompt and then prompts for a working directory.Shared startup flow
Resume/session selection
Docs and coverage
C-ubehavior.