Skip to content

Terminal canvas opens outside the active worktree session #4979

Description

@legoesbenr

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

  1. Open a repository project session configured with workspace_type: worktree.
  2. Confirm the session workspace and branch differ from the repository's main checkout.
  3. Open a terminal from the session UI.
  4. Run:
pwd
git rev-parse --show-toplevel
git branch --show-current
  1. Create a file under a repository-relative path, such as .github/extensions/<name>/extension.mjs.
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions