-
Notifications
You must be signed in to change notification settings - Fork 571
Extension UI cleanup with multiple SQL extension #21101
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
base: main
Are you sure you want to change the base?
Conversation
…and UI visibility
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 PR implements a URI ownership coordination system between the MSSQL and PostgreSQL VS Code extensions to prevent duplicate UI elements (status bar items, CodeLens, editor buttons) when both extensions are installed. The coordination is achieved through a shared API that allows extensions to query which extension owns a given file URI.
Changes:
- Introduced
UriOwnershipCoordinatorclass to manage coordination with other database extensions - Added command name suffixes "(MSSQL)" to disambiguate from PostgreSQL commands in the command palette
- Implemented UI hiding logic in status bar, CodeLens, and editor menus based on URI ownership
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/mssql/src/uriOwnership.ts | New coordinator class that manages URI ownership API and listens for ownership changes from other extensions |
| extensions/mssql/typings/vscode-mssql.d.ts | Added UriOwnershipApi interface to the public API |
| extensions/mssql/src/extension.ts | Instantiates and initializes the URI ownership coordinator |
| extensions/mssql/src/views/statusView.ts | Hides status bar items when active file is owned by another extension |
| extensions/mssql/src/queryResult/sqlCodeLensProvider.ts | Hides CodeLens when URI is owned by another extension |
| extensions/mssql/package.json | Added context-based visibility conditions to editor menu commands |
| extensions/mssql/src/controllers/mainController.ts | Added ownership checks to prevent command execution on files owned by other extensions |
| extensions/mssql/src/constants/locConstants.ts | Added localized error message for files owned by other extensions |
| extensions/mssql/package.nls.json | Updated command titles with "(MSSQL)" suffix |
| localization/xliff/vscode-mssql.xlf | Updated localization resources |
| extensions/mssql/l10n/bundle.l10n.json | Updated l10n bundle with new messages |
Comments suppressed due to low confidence (2)
extensions/mssql/package.json:440
- For defensive programming and consistency, consider adding the
!mssql.hideUIElementscondition to other MSSQL-specific commands in the editor/title menu (disconnect, changeConnection, changeDatabase, showEstimatedPlan, etc.), not just runQuery and connect. While theresource in mssql.connectionscheck should prevent these buttons from showing when a file is owned by another extension, adding the explicit hideUIElements check would provide an extra layer of protection against potential race conditions during connection handoff between extensions.
"editor/title": [
{
"command": "mssql.runQuery",
"when": "editorLangId == sql && !isInDiffEditor && resourcePath not in mssql.runningQueries && !mssql.hideUIElements",
"group": "navigation@1"
},
{
"command": "mssql.cancelQuery",
"when": "editorLangId == sql && !isInDiffEditor && resourcePath in mssql.runningQueries",
"group": "navigation@2"
},
{
"command": "mssql.revealQueryResult",
"when": "editorLangId == sql && resource in mssql.connections && !isInDiffEditor",
"group": "navigation@2"
},
{
"command": "mssql.connect",
"when": "editorLangId == sql && !isInDiffEditor && resource not in mssql.connections && !mssql.hideUIElements",
"group": "navigation@3"
},
{
"command": "mssql.disconnect",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@3"
},
{
"command": "mssql.changeConnection",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@4"
},
{
"command": "mssql.changeDatabase",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@5"
},
{
"command": "mssql.showEstimatedPlan",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@10"
},
{
"command": "mssql.enableActualPlan",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && (resource not in mssql.executionPlan.urisWithActualPlanEnabled) && (resourcePath not in mssql.runningQueries)",
"group": "navigation@11"
},
{
"command": "mssql.disableActualPlan",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && (resource in mssql.executionPlan.urisWithActualPlanEnabled) && (resourcePath not in mssql.runningQueries)",
"group": "navigation@12"
}
extensions/mssql/src/controllers/mainController.ts:241
- The cmdChangeConnection command handler doesn't check for URI ownership like cmdConnect and cmdRunQuery do. While the editor menu buttons are hidden via package.json conditions, users can still invoke this command from the command palette. If a file is owned by another extension (e.g., PostgreSQL), users could potentially invoke "Change Connection (MSSQL)" from the command palette and get unexpected behavior. Consider adding the same ownership check here for consistency.
this.registerCommand(Constants.cmdChangeConnection);
this._event.on(Constants.cmdChangeConnection, () => {
void this.runAndLogErrors(this.onNewConnection());
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Changes
|
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (35.29%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #21101 +/- ##
==========================================
- Coverage 68.29% 68.22% -0.08%
==========================================
Files 242 242
Lines 23543 23594 +51
Branches 3114 3127 +13
==========================================
+ Hits 16078 16096 +18
- Misses 7336 7369 +33
Partials 129 129
🚀 New features to boost your workflow:
|
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
Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (1)
extensions/mssql/package.json:440
- Several editor/title menu items that should be hidden when the URI is owned by another extension are missing the
&& !mssql.hideUIElementscondition:
- mssql.disconnect (line 413)
- mssql.changeConnection (line 418)
- mssql.changeDatabase (line 423)
- mssql.revealQueryResult (line 403)
- mssql.cancelQuery (line 398)
- mssql.showEstimatedPlan (line 428)
- mssql.enableActualPlan (line 433)
- mssql.disableActualPlan (line 438)
These commands all operate on the active editor and should not be visible when the file is owned by a coordinating extension like PostgreSQL, for consistency with the mssql.runQuery and mssql.connect commands that already have this condition.
{
"command": "mssql.cancelQuery",
"when": "editorLangId == sql && !isInDiffEditor && resourcePath in mssql.runningQueries",
"group": "navigation@2"
},
{
"command": "mssql.revealQueryResult",
"when": "editorLangId == sql && resource in mssql.connections && !isInDiffEditor",
"group": "navigation@2"
},
{
"command": "mssql.connect",
"when": "editorLangId == sql && !isInDiffEditor && resource not in mssql.connections && !mssql.hideUIElements",
"group": "navigation@3"
},
{
"command": "mssql.disconnect",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@3"
},
{
"command": "mssql.changeConnection",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@4"
},
{
"command": "mssql.changeDatabase",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@5"
},
{
"command": "mssql.showEstimatedPlan",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && resourcePath not in mssql.runningQueries",
"group": "navigation@10"
},
{
"command": "mssql.enableActualPlan",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && (resource not in mssql.executionPlan.urisWithActualPlanEnabled) && (resourcePath not in mssql.runningQueries)",
"group": "navigation@11"
},
{
"command": "mssql.disableActualPlan",
"when": "editorLangId == sql && !isInDiffEditor && resource in mssql.connections && (resource in mssql.executionPlan.urisWithActualPlanEnabled) && (resourcePath not in mssql.runningQueries)",
"group": "navigation@12"
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nd PostgreSQL extensions
manujoseph85
left a comment
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.
It would be nice if we can find a way to share this code with PG without duplicating the code. Coordinating fixes with them if we need changes would be a hassle
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
Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…adability and maintainability
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
Copilot reviewed 24 out of 28 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… package.json and related files for consistency
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
Copilot reviewed 23 out of 27 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private _refreshCoordinatingExtensions(): void { | ||
| const newExtensions = discoverCoordinatingExtensions(this._context.extension.id); | ||
|
|
||
| // Find newly added extensions | ||
| for (const extInfo of newExtensions) { | ||
| if (!this._coordinatingExtensionApis.has(extInfo.extensionId)) { | ||
| const extension = vscode.extensions.getExtension(extInfo.extensionId); | ||
| if (extension?.isActive) { | ||
| this._registerCoordinatingExtensionApi(extInfo.extensionId, extension.exports); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| this._coordinatingExtensions = newExtensions; | ||
| } |
Copilot
AI
Feb 6, 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 _refreshCoordinatingExtensions method does not handle the case where an extension is uninstalled or deactivated. When an extension is removed, it remains in _coordinatingExtensionApis Map and its event listener remains registered in context.subscriptions, potentially causing errors when the extension tries to call the API or when events fire. The method should check for removed extensions and clean up their entries from _coordinatingExtensionApis.
… and adding releaseUri callback
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
Copilot reviewed 24 out of 28 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Fixes: #20357
This PR implements a URI ownership coordination system between the MSSQL and PostgreSQL VS Code extensions. When both extensions are installed, they now coordinate to ensure only one extension shows UI elements (status bar, CodeLens) for a given SQL file at a time, based on which extension has an active connection to that file.
Problem
When both MSSQL and PostgreSQL extensions are installed, users experienced:
Solution
Implemented a
UriOwnershipCoordinatorthat:uriOwnershipApi) for other extensions to query URI ownershipBehavior
User-Facing Messages
When a user tries to connect or run a query on a file connected to PostgreSQL through commands:
Backward Compatibility
uriOwnershipApi(older version)Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines