Skip to content

Agents - refactor pull request actions#315266

Merged
lszomoru merged 2 commits into
mainfrom
lszomoru/atomic-chickadee
May 8, 2026
Merged

Agents - refactor pull request actions#315266
lszomoru merged 2 commits into
mainfrom
lszomoru/atomic-chickadee

Conversation

@lszomoru
Copy link
Copy Markdown
Member

@lszomoru lszomoru commented May 8, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 8, 2026 14:11
@lszomoru lszomoru enabled auto-merge (squash) May 8, 2026 14:11
@lszomoru lszomoru self-assigned this May 8, 2026
@lszomoru lszomoru added this to the 1.120.0 milestone May 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

Refactors pull request-related actions in the Agents/Sessions experience by removing the “Sync Pull Request” action and introducing a direct “Create PR / Create Draft PR” flow backed by a new Copilot-side PR creation service and a new GitHub REST API method.

Changes:

  • Update Sessions/Changes toolbar action enablement and button rendering to reflect merge vs PR scenarios.
  • Add IOctoKitService.createPullRequest (REST) plumbing and return type for created PRs.
  • Introduce PullRequestCreationService and wire it into Copilot CLI session commands to commit/push and create PRs.
Show a summary per file
File Description
src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts Adjusts “Mark as Done” enablement for merge vs PR scenarios using additional context keys.
src/vs/sessions/contrib/changes/browser/changesView.ts Updates changes toolbar button configuration for commit/sync/PR actions.
extensions/copilot/src/platform/github/common/octoKitServiceImpl.ts Adds createPullRequest implementation using permissive auth.
extensions/copilot/src/platform/github/common/githubService.ts Extends IOctoKitService and BaseOctoKitService with PR creation support and response type.
extensions/copilot/src/extension/chatSessions/vscode-node/pullRequestCreationService.ts New service to push, generate PR title/description context, and create a PR via Octokit.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts Refactors CLI chat commands to use shared sync + new PR creation service (V1 wiring).
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts Same PR-creation refactor for the newer CLI chat sessions implementation.
extensions/copilot/src/extension/chatSessions/vscode-node/chatSessions.ts Registers PullRequestCreationService and injects it into CLI command registration.
extensions/copilot/src/extension/agents/vscode-node/test/mockOctoKitService.ts Updates Octokit mock to satisfy the new createPullRequest API.
extensions/copilot/package.nls.json Removes the localized label for the deleted “Sync Pull Request” command.
extensions/copilot/package.json Removes the “Sync Pull Request” command contribution and updates enablement/menus for the new PR actions.

Copilot's findings

  • Files reviewed: 11/11 changed files
  • Comments generated: 5

Comment on lines 187 to 205
@@ -198,7 +198,10 @@ class ChangesButtonBarWidget extends Disposable {
});
return { showIcon: false, showLabel: true, isSecondary: false, customLabelObs };
}
if (action.id === 'github.copilot.sessions.sync') {
if (
action.id === 'github.copilot.sessions.sync' ||
action.id === 'github.copilot.sessions.commitAndSync'
) {
const labelWithCount = outgoingChanges > 0
Comment on lines +57 to +85
async createPullRequest(options: CreatePullRequestOptions, token: vscode.CancellationToken): Promise<string | undefined> {
const { repositoryUri, branchName, baseBranchName, isDraft } = options;

const repository = await this.gitService.openRepository(repositoryUri);
const repositoryContext = await this.gitService.getRepository(repositoryUri);

if (!repository || !repositoryContext) {
throw new Error(l10n.t('Could not find the repository for branch \'{0}\'.', branchName));
}

// Resolve owner/repo from the (preferred upstream's) remote.
const githubRepoInfo = getGitHubRepoInfoFromContext(repositoryContext);
const remoteInformation = githubRepoInfo
? repository.state.remotes.find(remote =>
githubRepoInfo.remoteUrl === remote.fetchUrl || githubRepoInfo.remoteUrl === remote.pushUrl)
: undefined;

if (!githubRepoInfo || !remoteInformation) {
throw new Error(l10n.t('Could not determine the GitHub remote for branch \'{0}\'.', branchName));
}

// Push the branch (set upstream when missing).
const head = repository.state.HEAD;
const setUpstream = !head?.upstream;
await repository.push(remoteInformation.name, branchName, setUpstream);

if (token.isCancellationRequested) {
return undefined;
}
Comment on lines +168 to +179
}

const diffChanges = await repository.diffBetweenWithStats(mergeBase, branchName) ?? [];
const patches: Diff[] = [];
for (const change of diffChanges) {
const patch = await repository.diffBetweenPatch(mergeBase, branchName, change.uri.fsPath);
if (!patch) {
continue;
}

patches.push({ ...change, diff: patch });
}
head,
base,
draft,
});
Comment on lines +57 to +134
async createPullRequest(options: CreatePullRequestOptions, token: vscode.CancellationToken): Promise<string | undefined> {
const { repositoryUri, branchName, baseBranchName, isDraft } = options;

const repository = await this.gitService.openRepository(repositoryUri);
const repositoryContext = await this.gitService.getRepository(repositoryUri);

if (!repository || !repositoryContext) {
throw new Error(l10n.t('Could not find the repository for branch \'{0}\'.', branchName));
}

// Resolve owner/repo from the (preferred upstream's) remote.
const githubRepoInfo = getGitHubRepoInfoFromContext(repositoryContext);
const remoteInformation = githubRepoInfo
? repository.state.remotes.find(remote =>
githubRepoInfo.remoteUrl === remote.fetchUrl || githubRepoInfo.remoteUrl === remote.pushUrl)
: undefined;

if (!githubRepoInfo || !remoteInformation) {
throw new Error(l10n.t('Could not determine the GitHub remote for branch \'{0}\'.', branchName));
}

// Push the branch (set upstream when missing).
const head = repository.state.HEAD;
const setUpstream = !head?.upstream;
await repository.push(remoteInformation.name, branchName, setUpstream);

if (token.isCancellationRequested) {
return undefined;
}

// Collect commits and patches.
const context = await collectPullRequestContext(repository, baseBranchName, branchName, token);
if (token.isCancellationRequested) {
return undefined;
}

let title: string | undefined;
let description: string | undefined;
if (context && (context.commitMessages.length > 0 || context.patches.length > 0)) {
const generator = this.instantiationService.createInstance(GitHubPullRequestTitleAndDescriptionGenerator);
try {
const result = await generator.provideTitleAndDescription({
commitMessages: context.commitMessages,
patches: context.patches.map(p => p.diff),
compareBranch: branchName,
}, token);

title = result?.title;
description = result?.description;
} finally {
generator.dispose();
}
}

if (token.isCancellationRequested) {
return undefined;
}

// Base branch name may contain the remote name as a prefix, so we
// need to remove it since the API expects just the branch name.
const normalizedBaseBranchName = baseBranchName.replace(
new RegExp(`^${escapeRegExpCharacters(remoteInformation.name)}/`),
''
);

const createdPullRequest = await this.octoKitService.createPullRequest(
githubRepoInfo.id.org,
githubRepoInfo.id.repo,
title ?? branchName,
description ?? '',
branchName,
normalizedBaseBranchName,
isDraft,
{},
);

return createdPullRequest.url;
}
@lszomoru lszomoru merged commit 17d62bd into main May 8, 2026
29 checks passed
@lszomoru lszomoru deleted the lszomoru/atomic-chickadee branch May 8, 2026 14:29
lszomoru added a commit that referenced this pull request May 8, 2026
* Agents - switch pull request actions away from the agentic loop

* Fix compilation
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.

4 participants