Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

When branches are automatically deleted after merging a PR, users receive no feedback about the deletion or branch switch. This required manually checking git status to confirm what happened.

Changes

Modified autoDeleteBranchesAfterMerge in pullRequestReviewCommon.ts to:

  • Show contextual notifications based on deletion outcome:
    • Local and remote deleted: "Deleted local and remote branches for {name} and switched to {default}"
    • Local branch deleted: "Deleted local branch {name} and switched to {default}"
    • Remote only: "Deleted remote branch {name}"
  • Only show notification when branch name is available

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

This section details on the original issue you should resolve

<issue_title>Branch auto delete has no signal to the user</issue_title>
<issue_description>Verifying #1497

The verification worked as expected, but I had to verify by manually checking which branch I was on. I would have expected some sort of signal that the branch I was on was deleted and I was moved back to master.</issue_description>

<agent_instructions>Show a notification when the branch is deleted after merge. </agent_instructions>

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


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

Copilot AI and others added 5 commits January 8, 2026 16:29
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>
Copilot AI changed the title [WIP] Add notification for branch deletion after merge Add notification when branch is auto-deleted after merge Jan 8, 2026
Copilot AI requested a review from alexr00 January 8, 2026 16:43
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);
Copy link
Member

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.

Copy link
Contributor Author

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>
Copilot AI requested a review from alexr00 January 9, 2026 09:10
@alexr00 alexr00 marked this pull request as ready for review January 9, 2026 14:47
Copilot AI review requested due to automatic review settings January 9, 2026 14:47
@alexr00 alexr00 enabled auto-merge (squash) January 9, 2026 14:47
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 9, 2026
Copy link
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 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 autoDeleteBranchesAfterMerge to display contextual notifications based on which branches were deleted (local, remote, or both)
  • Updated the return value handling from performBranchDeletion to 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)

Comment on lines 477 to 481
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)
Copy link

Copilot AI Jan 9, 2026

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.

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

Copilot uses AI. Check for mistakes.
@alexr00 alexr00 merged commit 001bf72 into main Jan 9, 2026
6 checks passed
@alexr00 alexr00 deleted the copilot/show-notification-on-branch-delete branch January 9, 2026 14:59
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.

Branch auto delete has no signal to the user

3 participants