Skip to content

Fix worktree context menu items no-op for Copilot CLI sessions created from terminal#4016

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-worktree-context-menu-issue
Draft

Fix worktree context menu items no-op for Copilot CLI sessions created from terminal#4016
Copilot wants to merge 2 commits intomainfrom
copilot/fix-worktree-context-menu-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

When a CLI session is created from an integrated terminal, the CLI manages worktree creation independently—setWorktreeProperties is never called by the extension, so getWorktreePath(sessionId) returns undefined and all worktree context menu commands silently no-op.

Changes

  • IChatSessionWorktreeService + ChatSessionWorktreeService: Add detectAndRegisterWorktreeFromPath(sessionId, path) that checks the in-memory store and metadata store first, then falls back to gitService.getRepository(path). If the path is a git worktree (kind === 'worktree'), it derives ChatSessionWorktreeProperties using worktrees[0] as the parent repo (always first in git worktree list output) and persists them via setWorktreeProperties.

  • CopilotCLIChatSessionItemProvider._toChatSessionItem: When getWorktreeProperties returns undefined and session.workingDirectory is set, call detectAndRegisterWorktreeFromPath. This runs during sessions-list rendering—before the user can invoke any context menu—so subsequent getWorktreePath calls succeed.

  • Tests: 8 new unit tests covering the detection/caching flow and edge cases (non-worktree paths, missing git repo, already-registered properties, metadata store fallback, empty HEAD).

Original prompt

This section details on the original issue you should resolve

<issue_title>Open Worktree context menu items no-op for Copilot CLI sessions from terminal</issue_title>
<issue_description>

  • + a new Copilot CLI session to be used in an integrated terminal
  • See the session in the sessions list
    • My session is Implement Theme Toggle
  • ❓ Right-clicking to use the worktree context menu options no-ops
  • The worktree context menu options work for a CLI session created in the chat panel
    • So in recording below, it works for add a theme toggle that I created via the chat panel

https://github.com/user-attachments/assets/93900a97-080f-41f5-90ec-d6a16c8ef02f</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: DonJayamanne <1948812+DonJayamanne@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix worktree context menu options for Copilot CLI sessions Fix worktree context menu items no-op for Copilot CLI sessions created from terminal Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open Worktree context menu items no-op for Copilot CLI sessions from terminal

2 participants