Add "Copy As" submenu to Notebook Query Result context menus#22395
Add "Copy As" submenu to Notebook Query Result context menus#22395lewis-sanchez wants to merge 15 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a “Copy As” submenu to the Notebook query results grid context menu (matching the regular query editor grid UX) and implements the associated client-side formatting/copying behavior, including an iframe→extension-host path for displaying errors.
Changes:
- Adds a “Copy As” submenu to the notebook grid context menu with CSV/JSON/INSERT INTO/IN clause formatting.
- Plumbs
postMessagethrough the notebook renderer so the context menu can surface errors via the extension host. - Introduces unit tests covering the new formatter behaviors.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| localization/xliff/vscode-mssql.xlf | Adds localized string entry for the IN-clause single-column error. |
| extensions/mssql/test/unit/notebooks/notebookContextMenu.test.ts | New unit tests validating CSV/JSON/IN clause/INSERT formatting behavior. |
| extensions/mssql/src/webviews/pages/NotebookRenderer/notebookResultsOutput.tsx | Passes postMessage down to the result grid component. |
| extensions/mssql/src/webviews/pages/NotebookRenderer/notebookResultGrid.tsx | Extends grid props with postMessage and wires it into the context menu plugin. |
| extensions/mssql/src/webviews/pages/NotebookRenderer/notebookResultGrid.css | Updates context menu styling and adds focused/hover/submenu indicator styling. |
| extensions/mssql/src/webviews/pages/NotebookRenderer/notebookRendererEntry.tsx | Passes renderer postMessage into the notebook result grid. |
| extensions/mssql/src/webviews/pages/NotebookRenderer/notebookContextMenu.plugin.ts | Implements submenu + new “Copy As” actions and client-side formatters; adds keyboard navigation and error posting. |
| extensions/mssql/src/webviews/common/locConstants.ts | Adds localized constant for the IN-clause single-column error message. |
| extensions/mssql/src/sharedInterfaces/notebookQueryResult.ts | Adds NotebookShowErrorMessage interface for renderer messaging. |
| extensions/mssql/src/notebooks/sqlNotebookController.ts | Handles showError renderer messages by calling vscode.window.showErrorMessage. |
| extensions/mssql/l10n/bundle.l10n.json | Adds localized string entry for the IN-clause single-column error. |
| // Use setTimeout so the current right-click event doesn't immediately dismiss the menu | ||
| setTimeout(() => { | ||
| menu.focus(); | ||
| document.addEventListener("mousedown", this.dismissHandler!); | ||
| }, 0); |
PR Changes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22395 +/- ##
===========================================
- Coverage 88.25% 75.59% -12.67%
===========================================
Files 415 408 -7
Lines 131028 131338 +310
Branches 8393 8426 +33
===========================================
- Hits 115640 99282 -16358
- Misses 15388 32056 +16668
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Description
This PR fixes #22209
This PR adds a sub-context menu for "Copy As" commands, so that they are similar to the ones present in the query results grid for regular query editors. There are a total of 4 "Copy As" commands that are being added:
Because the iframe where the query results grid is rendered doesn't have a way to communicate back to SQL Tools Service, the copying logic had to be implemented client side, otherwise we most likely could have reused the same copying functionality used by the regular query results grid.
The new context menu options appear in the results grid that appears after a query is executed in a SQL notebook:

Result Grid and Notebook Result Grid
Result Grid:
Copy as CSV
Copy as JSON
Copy as INSERT INTO
Copy as IN Clause
Notebook Result Grid:
Copy as CSV
Copy as JSON
Copy as INSERT INTO
Copy as IN clause
Provide a clear, concise summary of the changes in this PR. What problem does it solve? Why is it needed? Link any related issues using issue closing keywords.
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines