Conversation
There was a problem hiding this comment.
Pull request overview
Adds Git remote awareness to the Sessions Changes view so Copilot CLI PR actions are only shown when the active repository appears to be hosted on GitHub (including ghe.com).
Changes:
- Extend the Git repository state DTO plumbing to include
remotesend-to-end (ext host ↔ main thread). - Introduce a Git utility to detect GitHub-backed remotes and surface it as a Sessions context key.
- Gate Copilot “Create/Update PR” session actions on the new
sessions.hasGitHubRemotecontext.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/git/common/utils.ts | Adds URL parsing + heuristics to detect GitHub remotes from repository remotes. |
| src/vs/workbench/contrib/git/common/gitService.ts | Extends GitRepositoryState with remotes and introduces GitRemote type. |
| src/vs/workbench/api/common/extHostGitExtensionService.ts | Ext host DTO mapping now includes state.remotes. |
| src/vs/workbench/api/common/extHost.protocol.ts | Adds GitRemoteDto and remotes on GitRepositoryStateDto. |
| src/vs/workbench/api/browser/mainThreadGitExtensionService.ts | Main thread converts and propagates remotes into GitRepositoryState. |
| src/vs/sessions/contrib/changes/common/changes.ts | Adds sessions.hasGitHubRemote context key. |
| src/vs/sessions/contrib/changes/browser/changesViewModel.ts | Computes hasGitHubRemote for the active session state. |
| src/vs/sessions/contrib/changes/browser/changesView.ts | Binds and updates the new context key from view model state. |
| extensions/copilot/package.json | Updates Copilot Sessions menu enablement to require sessions.hasGitHubRemote. |
Copilot's findings
- Files reviewed: 9/9 changed files
- Comments generated: 3
| if ( | ||
| hosts.some(host => equalsIgnoreCase(remote.host, host)) || | ||
| hosts.some(host => remote.host.endsWith(host)) | ||
| ) { |
There was a problem hiding this comment.
hasGitHubRemotes considers any host that endsWith('github.com' | 'ghe.com') as GitHub. This will return true for unrelated domains like evilgithub.com / myghe.com and can incorrectly enable GitHub-only UI/actions. Consider requiring a domain boundary (e.g. exact match or endsWith('.' + host)) and avoid overly-broad matching.
|
|
||
| // Pull request state | ||
| const gitHubInfo = activeSession?.gitHubInfo.read(reader); | ||
| const hasGitHubRemote = hasGitHubRemotes(repositoryState!); |
There was a problem hiding this comment.
repositoryState can be undefined here (e.g. no git repo, cloud session, or while the repo is still loading), but this code uses a non-null assertion and will throw when hasGitHubRemotes reads repositoryState.remotes. Compute hasGitHubRemote only when repositoryState is available (or when hasGitRepository is true), otherwise return false/undefined to keep the view model stable during loading.
| const hasGitHubRemote = hasGitHubRemotes(repositoryState!); | |
| const hasGitHubRemote = repositoryState !== undefined | |
| ? hasGitHubRemotes(repositoryState) | |
| : false; |
| const repoUrl = URI.parse(fetchUrl); | ||
| const authority = repoUrl.authority; | ||
| const path = repoUrl.path; | ||
| if (!(equalsIgnoreCase(repoUrl.scheme, 'ssh') || equalsIgnoreCase(repoUrl.scheme, 'https') || equalsIgnoreCase(repoUrl.scheme, 'http'))) { |
There was a problem hiding this comment.
parseRemoteUrl ignores valid git remote URLs that use the git:// scheme (Git supports git://host/owner/repo.git). This will make hasGitHubRemotes return false for those remotes and can hide GitHub-specific actions. Consider allowing the git scheme (and/or treating unknown schemes more defensively by returning undefined without hardcoding a short allowlist if the host can still be extracted safely).
| if (!(equalsIgnoreCase(repoUrl.scheme, 'ssh') || equalsIgnoreCase(repoUrl.scheme, 'https') || equalsIgnoreCase(repoUrl.scheme, 'http'))) { | |
| if (!(equalsIgnoreCase(repoUrl.scheme, 'ssh') || equalsIgnoreCase(repoUrl.scheme, 'https') || equalsIgnoreCase(repoUrl.scheme, 'http') || equalsIgnoreCase(repoUrl.scheme, 'git'))) { |
* Add context key got GitHub remote * Sdopt the new context key * Fix issue with detecting the repository path
No description provided.