Skip to content

chat: fix GitHub context repository selection - #334594

Merged
Megan Rogge (meganrogge) merged 9 commits into
microsoft:mainfrom
meganrogge:agents/bugfix-attach-issue-pr-context-menu
Sep 4, 2026
Merged

chat: fix GitHub context repository selection#334594
Megan Rogge (meganrogge) merged 9 commits into
microsoft:mainfrom
meganrogge:agents/bugfix-attach-issue-pr-context-menu

Conversation

@meganrogge

@meganrogge Megan Rogge (meganrogge) commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes GitHub issue and pull request attachment selection across the Agents window and editor window.

  • avoid waiting on unresolved local Git metadata before opening GitHub context in the Agents window
  • in a multi-root editor workspace, choose a workspace folder before resolving its GitHub repository
  • pass unresolved folder selections to Copilot Chat so the Issue/Pull Request search remains repository-scoped
  • resolve remotes without waiting for repository HEAD state, including direct .git/config lookup
  • support Git worktrees by following their gitdir and commondir pointers
  • preserve normal remote preference ordering and folder identity
  • add regressions for unresolved local metadata, different multi-root repositories, multiple roots of the same repository, and folder-based repository resolution

Fixes #334603

Validation:

  • npm run transpile-client
  • ./scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/actions/chatContext.test.ts --run src/vs/sessions/contrib/providers/copilotChatSessions/test/browser/copilotChatSessionsProvider.test.ts (92 passing)
  • npm --prefix extensions/copilot run test:unit -- src/extension/chatSessions/vscode-node/test/copilotCloudSessionsProvider.spec.ts (37 passing)
  • npm --prefix extensions/copilot run typecheck
  • live Code OSS verification with a two-folder workspace: Issue and Pull Request searches for both a normal Git repository and a Git worktree were scoped exclusively to the selected repository

Avoid waiting for unresolved local Git metadata in the Agents window, and initialize every workspace root before choosing a repository in multi-root editor windows.\n\nFixes microsoft#334563\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 4, 2026 19:32
Keep multi-root workspace folders as distinct Issue and Pull Request picker entries, even when they resolve to the same GitHub repository.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Multi-root repository discovery can hang indefinitely when any repository lacks resolved HEAD metadata.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​vs/​workbench/​contrib/​chat/​browser/​actions/​chatContext.tsIGitService.openRepository is not safe to await for every workspace folder here: its main-thread…
What changed in this PR

Fixes GitHub issue/PR repository scoping across editor and Agents windows.

Changes:

  • Adds folder-aware repository choices for multi-root workspaces.
  • Avoids waiting for local Git metadata in Agents sessions.
  • Adds regression coverage for repository-selection scenarios.
File Description
chatContext.ts Adds multi-root repository choices.
chatContext.test.ts Tests distinct and shared repositories.
copilotChatSessionsProvider.ts Removes blocking local metadata lookup.
copilotChatSessionsProvider.test.ts Tests immediate repository selection.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/workbench/contrib/chat/browser/actions/chatContext.ts Outdated
Show multi-root workspace folders before resolving GitHub metadata so Issue and Pull Request attachment never skips folder selection while repository state is still loading.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Build multi-root choices from workspace folders and already-known repositories so unresolved Git state cannot prevent the Issue or Pull Request picker from opening.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pass unresolved workspace folder selections to Copilot Chat and resolve their remotes without waiting for repository HEAD state. This keeps issue and pull request searches limited to the chosen repository even while Git discovery is incomplete.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Follow Git worktree directory pointers and common directories when resolving the selected folder's remote. Preserve normal remote preference ordering so origin is chosen consistently when repository discovery is unavailable.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pass a single selected local folder directly to Issue and Pull Request attachment commands. Only offer repository selection when that folder cannot be resolved.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make the repository quick pick explicitly single-select and pass a mutable pick array so Compile & Hygiene resolves the correct overload.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@roblourens roblourens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Experimental performance review bot]

Automated experimental performance review.

(Written by Copilot)

Comment thread extensions/copilot/src/platform/git/vscode-node/gitServiceImpl.ts
@meganrogge
Megan Rogge (meganrogge) merged commit d2368d9 into microsoft:main Sep 4, 2026
30 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Sep 4, 2026
@meganrogge Megan Rogge (meganrogge) added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Sep 5, 2026
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub issue and pull request attachment uses the wrong repository

5 participants