Description
Opening a terminal canvas from a worktree-backed Copilot project session can start the terminal in a different checkout instead of the session's assigned worktree. This makes git status appear clean for files created through the terminal and risks modifying or committing files on the wrong branch.
Reproduction
- Open a repository project session configured with
workspace_type: worktree.
- Confirm the session workspace and branch differ from the repository's main checkout.
- Open a terminal from the session UI.
- Run:
pwd
git rev-parse --show-toplevel
git branch --show-current
- Create a file under a repository-relative path, such as
.github/extensions/<name>/extension.mjs.
- Check
git status from the session worktree.
Actual behavior
The terminal can start outside the active session worktree. Files created there do not appear in the session worktree's git status, and Git commands target the wrong checkout/branch.
In the observed case, the session worktree was:
/Users/<user>/.copilot/repos/copilot-worktrees/am-ops/chore-refactor-set-delivered
but the initially opened terminal did not use that worktree. A terminal explicitly launched with cd <workspace_path> && exec $SHELL -l behaved correctly.
Expected behavior
A terminal opened from a project session should inherit that session's workspace_path as its initial working directory. For a worktree-backed session, git branch --show-current should therefore report the session's worktree branch without requiring a manual cd.
Impact
This is a data-placement and source-control safety issue. Users can unknowingly edit the main checkout or another workspace, fail to see changes in the active session, and commit or push from the wrong branch.
Environment
- GitHub Copilot app/CLI version:
1.0.87-0
- OS: macOS
- Session type: repository project, worktree-backed
- Terminal surface: terminal canvas opened from the Copilot project session
Workaround
Open the terminal with an explicit command that changes to the session workspace before starting the shell:
cd '<session workspace_path>' && exec "${SHELL:-/bin/zsh}" -l
Description
Opening a terminal canvas from a worktree-backed Copilot project session can start the terminal in a different checkout instead of the session's assigned worktree. This makes
git statusappear clean for files created through the terminal and risks modifying or committing files on the wrong branch.Reproduction
workspace_type: worktree.pwd git rev-parse --show-toplevel git branch --show-current.github/extensions/<name>/extension.mjs.git statusfrom the session worktree.Actual behavior
The terminal can start outside the active session worktree. Files created there do not appear in the session worktree's
git status, and Git commands target the wrong checkout/branch.In the observed case, the session worktree was:
but the initially opened terminal did not use that worktree. A terminal explicitly launched with
cd <workspace_path> && exec $SHELL -lbehaved correctly.Expected behavior
A terminal opened from a project session should inherit that session's
workspace_pathas its initial working directory. For a worktree-backed session,git branch --show-currentshould therefore report the session's worktree branch without requiring a manualcd.Impact
This is a data-placement and source-control safety issue. Users can unknowingly edit the main checkout or another workspace, fail to see changes in the active session, and commit or push from the wrong branch.
Environment
1.0.87-0Workaround
Open the terminal with an explicit command that changes to the session workspace before starting the shell: