Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 9, 2025

Problem

Users working with pull requests often need to know the commit count to perform operations like interactive rebasing (e.g., git rebase -i HEAD~<count>). Previously, this information was not readily visible in the VS Code UI and required expanding the Commits tree node or using external commands.

Solution

This PR adds a decoration to the "Commits" tree element in the Pull Request changes tree view that displays the number of commits in the pull request. The commit count is now shown as a badge next to the "Commits" label, making it immediately visible without needing to expand the tree.

Implementation

The implementation uses VS Code's file decoration provider pattern:

  1. URI System: Added a new CommitsNode scheme and helper functions (createCommitsNodeUri, fromCommitsNodeUri) in src/common/uri.ts to create unique URIs for Commits tree nodes that include the PR number and commit count.

  2. CommitsNode Updates: Modified CommitsNode in src/view/treeNodes/commitsCategoryNode.ts to set a resourceUri property using the new URI helper.

  3. Decoration Provider: Created CommitsDecorationProvider in src/view/commitsDecorationProvider.ts that implements the file decoration provider pattern. It returns a badge with the commit count and a tooltip showing "{count} commits".

  4. Registration: Registered the CommitsDecorationProvider in src/extension.ts alongside other tree decoration providers.

This approach follows the same pattern used by other decorations in the extension (file type decorations, comment decorations) and provides clean separation between tree node structure and visual presentation.

Example

Before: Commits
After: Commits with a badge showing 5 (where 5 is the number of commits)

Fixes #6606
Fixes #5150

Original prompt

This section details on the original issue you should resolve

<issue_title>Show the pull request commit count somewhere</issue_title>
<issue_description>

I'd love to be able to see the commit count somewhere in the tree, status bar, or both. I often interactively rebase all pull request commits and need to know the count so I can do something like: git rebase -i HEAD~<count>.</issue_description>

<agent_instructions>Show the commit count as a decoration on the "Commits" tree element of the PullRequestChangesTreeDataProvider.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #5150

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Show commit count in pull request tree Show commit count as decoration on Commits tree node Oct 9, 2025
@Copilot Copilot AI requested a review from alexr00 October 9, 2025 08:34
Copilot finished work on behalf of alexr00 October 9, 2025 08:34
@andyshinn
Copy link

Cool! I could try it out if there was a way for me to build or pull down a pre-built VS Code to test. Is that a thing that exists?

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

@andyshinn, not really. But, once the PR is merged then the next day you'll be able to try it out in the pre-release version of the GitHub Pull Request extension.

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

@copilot, don't use the description of the tree node. Instead use a file decoration.

Copy link
Contributor Author

Copilot AI commented Oct 10, 2025

@copilot, don't use the description of the tree node. Instead use a file decoration.

Done in 861832d. Changed to use a file decoration with badge showing the commit count instead of using the tree node's description property.

The implementation:

  • Added a new CommitsNode scheme to the URI system
  • Created CommitsDecorationProvider that provides file decorations for the Commits node
  • Set resourceUri on the CommitsNode so it receives the decoration
  • The badge displays the commit count (e.g., "5") with a tooltip showing "{count} commits"

The decoration will appear as a badge next to the "Commits" label in the tree view, similar to how other decorations work in VS Code (e.g., file status badges).

@Copilot Copilot AI requested a review from alexr00 October 10, 2025 12:38
Copilot finished work on behalf of alexr00 October 10, 2025 12:38
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.

Feature Request: Pull request description in full editor Show the pull request commit count somewhere

3 participants