Port - Query Profiler database filter#21574
Conversation
* refactor to filtering parse types in both filters and columns values * refactor on method signature used by sorting functionality * Update extensions/mssql/src/profiler/profilerConfigService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update extensions/mssql/src/profiler/profilerWebviewController.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Adding launch from OE for databases to include a filter at database level * reverting changes from merge * reverting merged changes adding duplicate tests * removing duplicate test * fix for azure database launch * reverting unwanted changes * PR comment * test refactor * adding constant * test changes * tests updates * making note to unit test instructions for agents --------- Co-authored-by: Allan Cascante <acascante@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Ports the “Query Profiler database filter” feature to allow launching Profiler from an Object Explorer Database node and auto-applying a client-side DatabaseName filter (while skipping the UI filter for Azure where sessions are already database-scoped).
Changes:
- Adds
mssql.profiler.launchFromDatabasecommand and wires it to pass the selected database into the Profiler UI as an initial filter. - Updates Profiler filtering UI/state to support pre-set categorical values (so filters are visible even before events arrive).
- Expands unit test coverage for the new command and for filtering with a row converter.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/mssql/src/profiler/profilerController.ts | Registers new “launch from database” command and plumbs database scope into UI setup. |
| extensions/mssql/src/profiler/profilerWebviewController.ts | Adds initial database filter support and related filter-state handling updates. |
| extensions/mssql/src/profiler/profilerConfigService.ts | Introduces canonical FIELD_DATABASE_NAME constant for consistent filtering. |
| extensions/mssql/src/reactviews/pages/Profiler/profilerColumnFilterPopover.tsx | Ensures categorical filter UI can display pre-set clause values before distinct values exist. |
| extensions/mssql/package.json | Contributes new command + Object Explorer context menu entry. |
| extensions/mssql/test/unit/profiler/profilerController.test.ts | Refactors to stubbed instances and adds tests for the new command behavior. |
| extensions/mssql/test/unit/profiler/filteredBuffer.test.ts | Adds tests for database-name filtering with a row converter and string equality behavior. |
| extensions/mssql/test/unit/AGENTS.md | Documents preferred Sinon stubbing patterns for unit tests. |
| extensions/mssql/AGENTS.md | Links to unit test conventions doc for consistency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| const base = new Set(distinctValues); | ||
| // Merge values from active clause so pre-set filters are always visible | ||
| if (currentClause?.operator === FilterOperator.In && currentClause.values) { | ||
| for (const v of currentClause.values) { | ||
| base.add(v); |
There was a problem hiding this comment.
When merging currentClause.values into the categorical options, the list can end up with duplicate "" (empty string) if the active clause includes the empty-category value. That makes allCategoricalValues.length larger than the set of selectable values, which breaks the selectedValues.size === allCategoricalValues.length check (so “Select all” won’t clear the filter) and can also show a duplicate empty option. Filter out "" when merging clause values (and apply the same rule anywhere else you merge currentClause.values for categorical lists).
| const base = new Set(distinctValues); | |
| // Merge values from active clause so pre-set filters are always visible | |
| if (currentClause?.operator === FilterOperator.In && currentClause.values) { | |
| for (const v of currentClause.values) { | |
| base.add(v); | |
| // Exclude the empty string here; it's added explicitly below as the "(empty)" option. | |
| const base = new Set(distinctValues.filter(v => v !== "")); | |
| // Merge values from active clause so pre-set filters are always visible | |
| if (currentClause?.operator === FilterOperator.In && currentClause.values) { | |
| for (const v of currentClause.values) { | |
| if (v !== "") { | |
| base.add(v); | |
| } |
| }, | ||
| { | ||
| "command": "mssql.profiler.launchFromDatabase", | ||
| "title": "%mssql.profiler.launchFromObjectExplorer%", |
There was a problem hiding this comment.
mssql.profiler.launchFromDatabase is contributed as a command with the same title as mssql.profiler.launchFromObjectExplorer. Since commands are shown in the Command Palette by default, this will create two indistinguishable “Launch Profiler” entries. Consider either hiding launchFromDatabase from the Command Palette via a contributes.menus.commandPalette entry with when: "false", or give it its own localized title that clearly indicates the database-scoped behavior.
| "title": "%mssql.profiler.launchFromObjectExplorer%", | |
| "title": "%mssql.profiler.launchFromDatabase%", |
PR Changes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/1.41 #21574 +/- ##
===============================================
Coverage ? 72.73%
===============================================
Files ? 331
Lines ? 98598
Branches ? 5481
===============================================
Hits ? 71715
Misses ? 26883
Partials ? 0
🚀 New features to boost your workflow:
|
Description
Port for PR: #21417 to close: #21093
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines