Skip to content

Sessions - detect GitHub remote#308620

Merged
lszomoru merged 5 commits intomainfrom
lszomoru/conservation-bonobo
Apr 8, 2026
Merged

Sessions - detect GitHub remote#308620
lszomoru merged 5 commits intomainfrom
lszomoru/conservation-bonobo

Conversation

@lszomoru
Copy link
Copy Markdown
Member

@lszomoru lszomoru commented Apr 8, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 21:59
@lszomoru lszomoru enabled auto-merge (squash) April 8, 2026 21:59
@lszomoru lszomoru self-assigned this Apr 8, 2026
@lszomoru lszomoru added this to the 1.116.0 milestone Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 remotes end-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.hasGitHubRemote context.
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

Comment on lines +21 to +24
if (
hosts.some(host => equalsIgnoreCase(remote.host, host)) ||
hosts.some(host => remote.host.endsWith(host))
) {
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.

// Pull request state
const gitHubInfo = activeSession?.gitHubInfo.read(reader);
const hasGitHubRemote = hasGitHubRemotes(repositoryState!);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
const hasGitHubRemote = hasGitHubRemotes(repositoryState!);
const hasGitHubRemote = repositoryState !== undefined
? hasGitHubRemotes(repositoryState)
: false;

Copilot uses AI. Check for mistakes.
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'))) {
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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'))) {

Copilot uses AI. Check for mistakes.
@lszomoru lszomoru merged commit 6c60260 into main Apr 8, 2026
26 of 27 checks passed
@lszomoru lszomoru deleted the lszomoru/conservation-bonobo branch April 8, 2026 23:26
joshspicer pushed a commit that referenced this pull request Apr 9, 2026
* Add context key got GitHub remote

* Sdopt the new context key

* Fix issue with detecting the repository path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants