Skip to content

Port - Query Profiler database filter#21574

Merged
allancascante merged 1 commit into
release/1.41from
port/allancascante/profiler_database_filter
Mar 11, 2026
Merged

Port - Query Profiler database filter#21574
allancascante merged 1 commit into
release/1.41from
port/allancascante/profiler_database_filter

Conversation

@allancascante
Copy link
Copy Markdown
Contributor

Description

Port for PR: #21417 to close: #21093

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

* 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>
@allancascante allancascante added this to the March 2026 Release milestone Mar 11, 2026
@allancascante allancascante self-assigned this Mar 11, 2026
@allancascante allancascante requested a review from kburtram as a code owner March 11, 2026 22:17
Copilot AI review requested due to automatic review settings March 11, 2026 22:17
@allancascante allancascante changed the title Port Query Profiler database filter Port - Query Profiler database filter Mar 11, 2026
@allancascante allancascante changed the base branch from main to release/1.41 March 11, 2026 22:18
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

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.launchFromDatabase command 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.

Comment on lines +175 to +179
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);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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);
}

Copilot uses AI. Check for mistakes.
},
{
"command": "mssql.profiler.launchFromDatabase",
"title": "%mssql.profiler.launchFromObjectExplorer%",
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"title": "%mssql.profiler.launchFromObjectExplorer%",
"title": "%mssql.profiler.launchFromDatabase%",

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 6411 KB 6409 KB ⚪ -2 KB ( 0% )
sql-database-projects VSIX 7061 KB 7061 KB ⚪ 0 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 34 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/1.41@0b696eb). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ns/mssql/src/profiler/profilerWebviewController.ts 74.56% 29 Missing ⚠️
...xtensions/mssql/src/profiler/profilerController.ts 90.19% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##             release/1.41   #21574   +/-   ##
===============================================
  Coverage                ?   72.73%           
===============================================
  Files                   ?      331           
  Lines                   ?    98598           
  Branches                ?     5481           
===============================================
  Hits                    ?    71715           
  Misses                  ?    26883           
  Partials                ?        0           
Files with missing lines Coverage Δ
...nsions/mssql/src/profiler/profilerConfigService.ts 99.49% <100.00%> (ø)
...xtensions/mssql/src/profiler/profilerController.ts 49.38% <90.19%> (ø)
...ns/mssql/src/profiler/profilerWebviewController.ts 64.04% <74.56%> (ø)
🚀 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.

@allancascante allancascante merged commit b34b63c into release/1.41 Mar 11, 2026
6 of 7 checks passed
@allancascante allancascante deleted the port/allancascante/profiler_database_filter branch March 11, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Enhanced Database-Level Profiler Launch with Automatic Filtering

4 participants