Support COPILOT_HOME for Copilot CLI state#314917
Support COPILOT_HOME for Copilot CLI state#314917praneethhere wants to merge 2 commits intomicrosoft:mainfrom
Conversation
|
@microsoft-github-policy-service agree |
|
Agreed Montiwa11 |
There was a problem hiding this comment.
Pull request overview
Adds support for the COPILOT_HOME environment variable when resolving Copilot CLI state directories in the Copilot extension, while preserving the existing XDG and home-directory fallback behavior. This aligns the extension with the documented Copilot CLI configuration mechanism and helps Windows users avoid creating ~/.copilot by default.
Changes:
- Add
COPILOT_HOMEas the highest-precedence location for Copilot CLI state. - Refactor CLI state and session-state directory resolution to be based on
getCopilotHome().
| export function getCopilotHome(): string { | ||
| const copilotHome = process.env.COPILOT_HOME; | ||
| if (copilotHome) { | ||
| return copilotHome; | ||
| } | ||
|
|
There was a problem hiding this comment.
Thanks, addressed by adding unit coverage for COPILOT_HOME precedence and restoring COPILOT_HOME/XDG_STATE_HOME between test cases
| const copilotHome = process.env.COPILOT_HOME; | ||
| if (copilotHome) { | ||
| return copilotHome; | ||
| } | ||
|
|
||
| const xdgHome = process.env.XDG_STATE_HOME; | ||
| return xdgHome ? join(xdgHome, COPILOT_HOME_DIRECTORY) : join(homedir(), COPILOT_HOME_DIRECTORY); | ||
| return xdgHome | ||
| ? join(xdgHome, COPILOT_HOME_DIRECTORY) | ||
| : join(homedir(), COPILOT_HOME_DIRECTORY); |
There was a problem hiding this comment.
Nice catch. Aligned the agentHost session-state resolver with same COPILOT_HOME -> XDG_STATE_HOME -> home precedence so session-state paths remain consistent
8e74877 to
ebfc4ef
Compare
Summary
Adds support for
COPILOT_HOMEwhen resolving Copilot CLI state directoriesThe lookup order is now:
COPILOT_HOMEXDG_STATE_HOME/.copilot~/.copilotThis keeps the existing XDG and home-directory fallback behavior while allowing users to explicitly relocate Copilot CLI state
Fixes #314806
Validation
npm run eslintnpm run watch; Copilot build/typecheck completed with 0 errorsValidation second run
git diff --checknpm --prefix extensions/copilot run test:unit -- src/extension/chatSessions/copilotcli/node/test/cliHelpers.spec.tsnpm run eslint