-
Notifications
You must be signed in to change notification settings - Fork 707
Add notification when branch is auto-deleted after merge #8377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
| const defaultBranch = await folderRepositoryManager.getPullRequestRepositoryDefaultBranch(item); | ||
|
|
||
| // Check if the branch is currently active before deletion | ||
| const isBranchActive = item.equals(folderRepositoryManager.activePullRequest) || (folderRepositoryManager.repository.state.HEAD?.name && folderRepositoryManager.repository.state.HEAD.name === branchInfo?.branch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Don't check if isBranchActive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ec41eb4. Removed the isBranchActive check - the notification now always mentions switching to the default branch when a local branch is deleted.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
There was a problem hiding this 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 pull request adds user notifications when branches are automatically deleted after merging a PR. The change addresses a user experience gap where users had to manually check git status to confirm branch deletion and branch switching.
Key changes:
- Modified
autoDeleteBranchesAfterMergeto display contextual notifications based on which branches were deleted (local, remote, or both) - Updated the return value handling from
performBranchDeletionto determine what notifications to show - Included unrelated VS Code Chat Session Provider API updates
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/github/pullRequestReviewCommon.ts | Added notification logic to inform users when branches are auto-deleted after merge, with contextual messages based on deletion type |
| src/@types/vscode.proposed.chatSessionsProvider.d.ts | Removed deprecated provideNewChatSessionItem method and added onDidChangeChatSessionProviderOptions event (unrelated to PR purpose) |
| vscode.l10n.t('Deleted local and remote branches for {0} and switched to {1}.', branchName, defaultBranch) | ||
| ); | ||
| } else if (wasLocalDeleted) { | ||
| vscode.window.showInformationMessage( | ||
| vscode.l10n.t('Deleted local branch {0} and switched to {1}.', branchName, defaultBranch) |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notification messages claim that the user was "switched to {defaultBranch}", but this is only accurate when the deleted branch was the currently active branch. Looking at the performBranchDeletion function (line 396-410), when deleting a local branch, the switch to the default branch only occurs if isBranchActive is true. If the deleted branch was not active, no branch switch happens, making these messages misleading.
Consider checking whether a branch switch actually occurred before including "and switched to {defaultBranch}" in the message, or track whether the branch was active and only mention the switch when it actually happened.
| vscode.l10n.t('Deleted local and remote branches for {0} and switched to {1}.', branchName, defaultBranch) | |
| ); | |
| } else if (wasLocalDeleted) { | |
| vscode.window.showInformationMessage( | |
| vscode.l10n.t('Deleted local branch {0} and switched to {1}.', branchName, defaultBranch) | |
| vscode.l10n.t('Deleted local and remote branches for {0}.', branchName) | |
| ); | |
| } else if (wasLocalDeleted) { | |
| vscode.window.showInformationMessage( | |
| vscode.l10n.t('Deleted local branch {0}.', branchName) |
When branches are automatically deleted after merging a PR, users receive no feedback about the deletion or branch switch. This required manually checking
git statusto confirm what happened.Changes
Modified
autoDeleteBranchesAfterMergeinpullRequestReviewCommon.tsto:The notification always mentions switching to the default branch when a local branch is deleted, providing clear feedback to users about the automatic cleanup and branch state.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.