diff --git a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs index 1b1f617..a192af6 100644 --- a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs +++ b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs @@ -40,6 +40,7 @@ public partial class QueryStoreGridControl : UserControl private bool _initialOrderByLoaded; private bool _suppressRangeChanged; private string? _waitHighlightCategory; + private const int AutoSelectTopN = 1; // number of rows auto-selected after each fetch private bool _waitStatsSupported; // false until version + capture mode confirmed private bool _waitStatsEnabled = true; private bool _waitPercentMode; @@ -64,7 +65,6 @@ public QueryStoreGridControl(ServerConnection serverConnection, ICredentialServi SetupColumnHeaders(); PopulateDatabaseBox(databases, initialDatabase); TimeRangeSlicer.RangeChanged += OnTimeRangeChanged; - TimeRangeSlicer.IsExpanded = true; WaitStatsProfile.CategoryClicked += OnWaitCategoryClicked; WaitStatsProfile.CategoryDoubleClicked += OnWaitCategoryDoubleClicked; @@ -211,7 +211,7 @@ private async System.Threading.Tasks.Task FetchPlansForRangeAsync() ApplyFilters(); LoadButton.IsEnabled = true; - SelectToggleButton.Content = "Select None"; + SelectToggleButton.Content = "Select All"; // Fetch per-plan wait stats after grid is populated (needs plan IDs) if (_waitStatsSupported && _waitStatsEnabled && _slicerStartUtc.HasValue && _slicerEndUtc.HasValue) @@ -496,6 +496,7 @@ private void OnWaitCategoryDoubleClicked(object? sender, string category) // Clear column sort indicators since we're using custom sort _sortedColumnTag = null; UpdateSortIndicators(null); + ReapplyTopNSelection(); UpdateBarRatios(); } @@ -937,6 +938,13 @@ private static string GetColumnLabel(StackPanel header) return tb.Text?.TrimEnd(' ', '▲', '▼') ?? string.Empty; } + private void ReapplyTopNSelection() + { + if (_filteredRows.Count == 0) return; + foreach (var r in _rows) r.IsSelected = false; + foreach (var r in _filteredRows.Take(AutoSelectTopN)) r.IsSelected = true; + } + private void ApplySortAndFilters() { IEnumerable source = _rows.Where(RowMatchesAllFilters); @@ -952,6 +960,7 @@ private void ApplySortAndFilters() foreach (var row in source) _filteredRows.Add(row); + ReapplyTopNSelection(); UpdateStatusText(); UpdateBarRatios(); } @@ -1046,7 +1055,7 @@ private static IComparable GetSortKey(string columnTag, QueryStoreRow r) => public class QueryStoreRow : INotifyPropertyChanged { - private bool _isSelected = true; + private bool _isSelected = false; // Bar ratios [0..1] per column private double _execsRatio; diff --git a/src/PlanViewer.App/Controls/TimeRangeSlicerControl.axaml b/src/PlanViewer.App/Controls/TimeRangeSlicerControl.axaml index ef28a01..068d20f 100644 --- a/src/PlanViewer.App/Controls/TimeRangeSlicerControl.axaml +++ b/src/PlanViewer.App/Controls/TimeRangeSlicerControl.axaml @@ -5,26 +5,88 @@ BorderBrush="{DynamicResource SlicerBorderBrush}" BorderThickness="0,0,0,1"> - - + VerticalAlignment="Center" Margin="12,0,0,0" + TextTrimming="CharacterEllipsis"/> + +