Skip to content

Add base and compare branch names to Copilot PR title and description generation#8686

Merged
alexr00 merged 4 commits intomicrosoft:mainfrom
shaypet:add-branch-names-to-copilot-auto-title-and-description
Apr 24, 2026
Merged

Add base and compare branch names to Copilot PR title and description generation#8686
alexr00 merged 4 commits intomicrosoft:mainfrom
shaypet:add-branch-names-to-copilot-auto-title-and-description

Conversation

@shaypet
Copy link
Copy Markdown
Contributor

@shaypet shaypet commented Apr 21, 2026

Adds baseBranch and compareBranch to the context passed to TitleAndDescriptionProvider.provideTitleAndDescription, and forwards them from all three call sites where title and description generation is triggered.

Previously the model had no knowledge of which branches were involved, causing it to hallucinate branch names in the generated description. With this change, the actual branch names are passed to the provider so they can be included in the prompt.

Changes

  • src/api/api.d.ts: Added baseBranch? and compareBranch? to the TitleAndDescriptionProvider context interface.
  • src/github/createPRViewProvider.ts: Passes this.model.baseBranch and this.model.compareBranch when calling provideTitleAndDescription from the Create PR view.
  • src/github/pullRequestOverview.ts: Passes this._item.base.ref and this._item.head?.ref when regenerating a description from the PR overview.
  • src/commands.ts: Passes args.baseBranch and args.compareBranch when calling through the github.createPullRequest.generate command API.

Fixes #8662

The corresponding change to the Copilot Chat extension that uses these values to render them in the prompt is at microsoft/vscode-copilot-chat#5083.

@shaypet shaypet marked this pull request as ready for review April 21, 2026 20:52
Copilot AI review requested due to automatic review settings April 21, 2026 20:52
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

This PR improves PR title/description generation by including the actual base and compare branch names in the context passed to TitleAndDescriptionProvider.provideTitleAndDescription, reducing branch-name hallucinations during generation (fixes #8662).

Changes:

  • Extended the TitleAndDescriptionProvider context type to include optional baseBranch and compareBranch.
  • Forwarded baseBranch/compareBranch from the Create PR view generation flow.
  • Forwarded baseBranch/compareBranch from PR Overview “regenerate description” and from the command-based generation entry point.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
src/api/api.d.ts Adds optional baseBranch/compareBranch fields to the provider context type.
src/github/createPRViewProvider.ts Passes the Create PR model’s base/compare branch names into generation context.
src/github/pullRequestOverview.ts Passes PR base/head refs into generation context when regenerating description.
src/commands.ts Passes command args base/compare branch names into generation context.

@shaypet
Copy link
Copy Markdown
Contributor Author

shaypet commented Apr 21, 2026

@microsoft-github-policy-service agree

Comment thread src/api/api.d.ts Outdated
@alexr00 alexr00 enabled auto-merge (squash) April 24, 2026 09:28
Copilot AI review requested due to automatic review settings April 24, 2026 09:29
@alexr00
Copy link
Copy Markdown
Member

alexr00 commented Apr 24, 2026

/AzurePipelines run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@alexr00 alexr00 merged commit 22504bd into microsoft:main Apr 24, 2026
5 of 7 checks passed
@shaypet shaypet review requested due to automatic review settings April 24, 2026 09:53
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.

Missing Source Branch Name in pullRequestDescriptionGeneration

4 participants