Feat: Allow users to remove one than 1 connection#398
Conversation
There was a problem hiding this comment.
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
removeAzureConnectionfunction wrapper - Added performance.now() timing measurements for cluster connection deletion
- 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>
| context.telemetry.properties.error = 'RemoveConnectionError'; | ||
| context.telemetry.properties.errorMessage = error instanceof Error ? error.message : String(error); |
There was a problem hiding this comment.
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:
- Recording only the first error (move these lines outside the loop after it completes)
- Using array-based telemetry to capture all errors
- 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;
}There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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;
}| if (connectionsToDelete.length === 0) { | |
| if (connectionsToDelete.length === 0) { | |
| ext.outputChannel.warn(l10n.t('No connections selected to remove.')); |
There was a problem hiding this comment.
@copilot agreed, please add this line, remember about running 'npm run prettier-fix' and 'npm run l10n' after making the edits.
There was a problem hiding this comment.
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.
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 This branch is outdated, do not attempt to fast forward, or resolve merge issues. |
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>
Done in
|
|
@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. |
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:
removeConnectioncommand 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: