Skip to content

Feat: Allow users to remove one than 1 connection#398

Closed
tnaum-ms wants to merge 17 commits into
mainfrom
dev/tnaum/connection-multi-delete
Closed

Feat: Allow users to remove one than 1 connection#398
tnaum-ms wants to merge 17 commits into
mainfrom
dev/tnaum/connection-multi-delete

Conversation

@tnaum-ms

@tnaum-ms tnaum-ms commented Nov 21, 2025

Copy link
Copy Markdown
Collaborator

This pull request enhances the connection removal feature by adding support for batch deletion of connections, improving user feedback, and making the process more resilient to errors. The changes include updates to both the localization file and the connection removal logic to provide clear messages and robust error handling during single or multiple connection deletions.

Connection Removal Improvements:

  • Refactored the removeConnection command to support deleting multiple connections at once, including confirmation prompts tailored for single or multiple deletions. The deletion process now continues even if some deletions fail, and a summary of successes and failures is displayed to the user.

User Feedback and Localization:

  • Added new localized strings for batch deletion prompts, success notifications, and error messages related to connection removal, ensuring users receive clear and context-appropriate feedback. [1] [2] [3] [4]

@tnaum-ms tnaum-ms requested a review from a team as a code owner November 21, 2025 11:12
Copilot AI review requested due to automatic review settings November 21, 2025 11:12
@tnaum-ms tnaum-ms marked this pull request as draft November 21, 2025 11:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes the unused removeAzureConnection wrapper function and adds performance timing for cluster connection deletion operations. However, the PR title suggests enabling multi-connection removal ("Allow users to remove one than 1 connection"), which doesn't align with the actual changes made - no multi-selection functionality has been added.

Key Changes:

  • Removed the deprecated removeAzureConnection function wrapper
  • Added performance.now() timing measurements for cluster connection deletion

Comment thread src/commands/removeConnection/removeConnection.ts Outdated
Comment thread src/commands/removeConnection/removeConnection.ts Outdated
Copilot AI and others added 6 commits November 21, 2025 11:24
- Add support for multi-selection (node and nodes parameters)
- Remove performance timing logs (performance.now() calls)
- Implement resilient deletion loop that continues on failure
- Add detailed logging to ext.outputChannel for each deletion
- Add summary messages for multi-deletion operations
- Add telemetry measurement for number of removed connections
- Update confirmation logic for single vs. multiple deletions
- Update localization files with new strings

Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
- Replace complex ternary chain with explicit if-else statements
- Add error handling for single connection deletion failure
- Update localization with new error message string

Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
- Renamed removedConnections to connectionsToDelete for clarity
- Added connectionsDeleted to track successfully deleted connections
- Now collects both metrics: connections targeted for deletion and actual deletions

Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
@tnaum-ms tnaum-ms marked this pull request as ready for review November 21, 2025 17:46
@tnaum-ms tnaum-ms requested a review from Copilot November 21, 2025 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +90 to +91
context.telemetry.properties.error = 'RemoveConnectionError';
context.telemetry.properties.errorMessage = error instanceof Error ? error.message : String(error);

Copilot AI Nov 21, 2025

Copy link

Choose a reason for hiding this comment

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

When multiple deletions fail, the telemetry properties for error and errorMessage are overwritten in each iteration of the loop. This means only the last error's details are preserved in telemetry, losing information about previous failures.

Consider either:

  1. Recording only the first error (move these lines outside the loop after it completes)
  2. Using array-based telemetry to capture all errors
  3. Using a different telemetry property for multi-connection deletion errors

Example fix for option 1:

let firstError: Error | undefined;
// ... in the catch block:
if (!firstError) {
    firstError = error instanceof Error ? error : new Error(String(error));
}
// ... after the loop:
if (firstError) {
    context.telemetry.properties.error = 'RemoveConnectionError';
    context.telemetry.properties.errorMessage = firstError.message;
}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot, this is totally fine, capturing one is enough, I was aware of it. Please add a comment explaining that we're aware of it. and.. well, add, once when metrics are set, the errorCount as well. This is a derived value, but will add context.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added the comment at line 116-117 explaining that we intentionally capture only the last error, and added context.telemetry.measurements.errorCount = failureCount at line 130 for context. See 62d739b.


await removeConnection(context, node);
}
if (connectionsToDelete.length === 0) {

Copilot AI Nov 21, 2025

Copy link

Choose a reason for hiding this comment

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

When the function is called with no connections to delete (both node and nodes are undefined or empty), it returns silently without any user feedback. This could leave users confused if the command is invoked unexpectedly without a selection.

Consider logging a warning or showing a message to inform the user:

if (connectionsToDelete.length === 0) {
    ext.outputChannel.warn(l10n.t('No connections selected to remove.'));
    return;
}
Suggested change
if (connectionsToDelete.length === 0) {
if (connectionsToDelete.length === 0) {
ext.outputChannel.warn(l10n.t('No connections selected to remove.'));

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot agreed, please add this line, remember about running 'npm run prettier-fix' and 'npm run l10n' after making the edits.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added at line 45: ext.outputChannel.warn(l10n.t('No connections selected to remove.')). Ran npm run prettier-fix and npm run l10n. See 62d739b.

Copilot AI commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

@tnaum-ms I've opened a new pull request, #399, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

@tnaum-ms I've opened a new pull request, #400, to work on those changes. Once the pull request is ready, I'll request review from you.

@tnaum-ms tnaum-ms modified the milestones: 0.6.2, 0.7.0 "October 2025" Nov 24, 2025
@tnaum-ms tnaum-ms moved this from In review to Done in DocumentDB for VSCode: Release Plan Jan 8, 2026
@tnaum-ms tnaum-ms self-assigned this Jan 8, 2026
@tnaum-ms tnaum-ms moved this from Done to In review in DocumentDB for VSCode: Release Plan Jan 8, 2026
@tnaum-ms tnaum-ms marked this pull request as draft January 12, 2026 22:12
@tnaum-ms tnaum-ms modified the milestones: 0.7.0 - January 2025, 0.7.1 Jan 29, 2026
@tnaum-ms tnaum-ms modified the milestones: 0.7.1, 0.7.2 Feb 5, 2026
@tnaum-ms tnaum-ms removed their assignment Feb 5, 2026
@tnaum-ms tnaum-ms modified the milestones: 0.7.2, 0.7.3 Mar 12, 2026
@tnaum-ms tnaum-ms removed this from the 0.7.3 milestone Apr 2, 2026
@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

@copilot This branch is outdated, do not attempt to fast forward, or resolve merge issues.
Instead: Investigate the intent from the changes made on this branch (ability to delete more than 1 connection at once) and the approach chosen. summarize it and prepare a plan, then, reset to 'next' come back with a clean implementation according to the plan.

@tnaum-ms tnaum-ms added this to the 0.8.1 milestone May 21, 2026
Copilot AI and others added 2 commits May 21, 2026 05:50
Reset to `next` branch and cleanly re-implemented multi-connection
deletion. Supports single and multi-select from the tree view.

- Accept optional `nodes` parameter for multi-select support
- Show warning when no connections are selected
- Check running tasks for all selected connections
- Different confirmation prompts for single vs. multiple deletions
- Resilient deletion loop that continues on individual failures
- Telemetry with errorCount and comment about single error capture
- Summary messages for batch results

Agent-Logs-Url: https://github.com/microsoft/vscode-documentdb/sessions/2b9f1774-8f24-49aa-a99c-f0292102457a

Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>

Copilot AI commented May 21, 2026

Copy link
Copy Markdown
Contributor

@copilot This branch is outdated, do not attempt to fast forward, or resolve merge issues.
Instead: Investigate the intent from the changes made on this branch (ability to delete more...

Done in 62d739b. Reset branch to next and cleanly re-implemented multi-connection deletion. The new implementation:

  • Accepts optional nodes parameter for tree view multi-select
  • Warns when no connections are selected
  • Checks running tasks for all selected connections
  • Uses different confirmation prompts for single vs. multiple
  • Resilient deletion loop that continues on failures
  • Includes telemetry (errorCount, connectionsDeleted, connectionsToDelete)
  • Preserves SchemaStore and CredentialCache cleanup from next
  • Uses withConnectionsViewProgress and refreshParentInConnectionsView

@tnaum-ms

Copy link
Copy Markdown
Collaborator Author

@copilot The PR reports 600+ changed files, this does not look right. isolate your changes, reinitialize the branch, force push, once the PR is created and the isolated changes are applied, verify the PR status. Anything with ~20+ files touched should be considered incorrect.

Copilot AI commented May 21, 2026

Copy link
Copy Markdown
Contributor

@tnaum-ms I've opened a new pull request, #663, to work on those changes. Once the pull request is ready, I'll request review from you.

@tnaum-ms tnaum-ms changed the base branch from next to main May 21, 2026 10:37
@tnaum-ms tnaum-ms closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants