Skip to content

Fixing recent connections in connection dialog#21646

Open
aasimkhan30 wants to merge 8 commits intomainfrom
aasim/fix/recentConnections
Open

Fixing recent connections in connection dialog#21646
aasimkhan30 wants to merge 8 commits intomainfrom
aasim/fix/recentConnections

Conversation

@aasimkhan30
Copy link
Copy Markdown
Contributor

@aasimkhan30 aasimkhan30 commented Mar 17, 2026

Description

Fixes: #21540

  1. Previously recent connections were not being highlighted because the dedup logic in read connections got rid of any connections with the same id.
  2. Also fixing the order of recent and saved connections in sidebar
Now Before
image image

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Copy link
Copy Markdown
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

Fixes connection dialog hydration/display of recent connections by ensuring saved and recent connections with the same connection ID aren’t deduplicated away, and updates the sidebar list ordering to show recent connections first.

Changes:

  • Update ConnectionStore.readAllConnections(true) deduplication to key by (id, profileSource) so saved+MRU entries with the same ID are preserved.
  • Swap the UI ordering in the Connection Dialog sidebar to display “Recent connections” above “Saved connections”, with the correct delete/remove actions per section.
  • Add a unit test to validate that saved and recent entries sharing the same ID are both returned.

Reviewed changes

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

File Description
extensions/mssql/src/models/connectionStore.ts Adjusts deduplication to preserve both saved and MRU entries with the same connection ID.
extensions/mssql/src/reactviews/pages/ConnectionDialog/connectionsListContainer.tsx Reorders recent/saved connection sections and wires the corresponding remove/delete actions.
extensions/mssql/test/unit/connectionStore.test.ts Adds coverage to ensure readAllConnections(true) keeps both saved and recent entries when IDs collide.

Comment thread extensions/mssql/src/models/connectionStore.ts Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 17, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 78037 KB 78037 KB ⚪ 0 KB ( 0% )
sql-database-projects VSIX 6201 KB 6201 KB ⚪ 0 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )
keymap VSIX 7 KB 7 KB ⚪ 0 KB ( 0% )

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 85.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.09%. Comparing base (16e6d77) to head (c66b9b8).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
extensions/mssql/src/models/connectionStore.ts 86.11% 5 Missing ⚠️
...tensions/mssql/src/webviews/common/locConstants.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21646      +/-   ##
==========================================
+ Coverage   74.05%   74.09%   +0.03%     
==========================================
  Files         339      339              
  Lines      103055   103081      +26     
  Branches     6053     6064      +11     
==========================================
+ Hits        76321    76375      +54     
+ Misses      26734    26706      -28     
Files with missing lines Coverage Δ
...nectionconfig/connectionDialogWebviewController.ts 64.85% <100.00%> (+0.44%) ⬆️
...tensions/mssql/src/webviews/common/locConstants.ts 29.30% <0.00%> (ø)
extensions/mssql/src/models/connectionStore.ts 46.96% <86.11%> (+3.92%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

kburtram
kburtram previously approved these changes Mar 17, 2026
lewis-sanchez
lewis-sanchez previously approved these changes Mar 17, 2026
@aasimkhan30 aasimkhan30 dismissed stale reviews from lewis-sanchez and kburtram via abb9a5c March 17, 2026 21:41
@Benjin
Copy link
Copy Markdown
Contributor

Benjin commented Mar 18, 2026

Let's discuss what the intended behavior should be for MRU connections. I've added some comments in #21540

Copilot AI review requested due to automatic review settings March 20, 2026 19:46
Copy link
Copy Markdown
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

Fixes the Connection Dialog’s “Recent Connections” behavior by preventing recent entries from being dropped during connection list loading, and updates the sidebar list ordering to show “Recent Connections” before “Saved Connections”.

Changes:

  • Update ConnectionStore.readAllConnections() deduplication to consider both connection id and profile source (saved vs MRU).
  • Reorder the Connection Dialog sidebar sections so Recent Connections appears above Saved Connections.
  • Add a unit test to ensure saved and recent entries with the same id are both preserved.

Reviewed changes

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

File Description
extensions/mssql/src/models/connectionStore.ts Adjusts deduplication key to preserve both saved and recent entries that share an id.
extensions/mssql/src/reactviews/pages/ConnectionDialog/connectionsListContainer.tsx Reorders recent/saved sections and updates list rendering keys + actions accordingly.
extensions/mssql/test/unit/connectionStore.test.ts Adds a regression test for preserving saved+recent entries with the same id.
Comments suppressed due to low confidence (1)

extensions/mssql/src/models/connectionStore.ts:704

  • The dedupe key is now id + profileSource, but the verbose log message still says "Duplicate connection ID found". This is misleading because duplicates are now defined by the composite key (and the duplicate might only exist within the same source). Update the message to reflect the actual dedupe criteria (e.g. include profileSource or the composite key).
            const key = `${conn.id}-${conn.profileSource}`; // Use both ID and source as key to allow same profile in both lists
            if (!uniqueConnections.has(key)) {
                uniqueConnections.set(key, conn);
            } else {
                dupeCount++;
                this._logger.verbose(
                    `Duplicate connection ID found: ${conn.id}. Ignoring duplicate connection.`,
                );

Copilot AI review requested due to automatic review settings April 14, 2026 20:13
Copy link
Copy Markdown
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

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

Files not reviewed (2)
  • extensions/mssql/package-lock.json: Language not supported
  • extensions/sql-database-projects/package-lock.json: Language not supported

Comment thread extensions/mssql/src/models/connectionStore.ts Outdated
Comment thread extensions/mssql/test/unit/connectionStore.test.ts
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.

[Bug]: Connection Recent Connections doesn't populate

6 participants