Commit a093055
authored
Query history improvments (#336)
* Fix sort issues on the QueryHistory
* What changed
1. QueryStoreGridControl.Selection.cs — ViewHistory_Click now walks up the visual tree to find the parent QuerySessionControl and calls AddHistorySubTab(), placing the history as a sub-tab alongside "Query Store — DB" and "QS Overview" (instead of at the top-level MainTabControl).
2. QuerySessionControl.QueryStore.cs — Added two new methods:
• AddHistorySubTab() — creates a closeable sub-tab with the history control, including long-press (~500ms) to detach into a free-floating window
• DetachHistorySubTabToWindow() — pops the history content into a standalone non-modal window (movable to another screen). When that window is minimized or closed, the content automatically re-docks back as a sub-tab
3. MainWindow.Tabs.cs — Removed the now-unused AddHistoryTab() method since history tabs no longer live at the top level
User flow
• View History → opens as a sub-tab next to Query Store / QS Overview
• Long-press the history sub-tab → detaches into a free window (can move to another screen)
• Minimize or close the free window → content returns to the sub-tab
* What was added
1. QueryStoreService.FetchPlanByHashAsync() — New method that fetches a plan XML from sys.query_store_plan by query_plan_hash. The oldest parameter controls whether it returns the first (smallest plan_id) or last (largest plan_id) plan.
2. Context menu on QueryStoreHistoryControl — Right-clicking on the DataGrid or chart shows:
• "Load the First Plan" — fetches the oldest plan for the selected plan hash
• "Load the Last Plan" — fetches the most recent plan for the selected plan hash
The selected plan hash is determined from either the grid selection or chart selection.
3. PlanLoadRequested event — Raised when the user picks a plan from the context menu. The parent QuerySessionControl subscribes to this event and opens the plan XML as a new sub-tab (using the existing AddPlanTab mechanism).
User flow
• Select a row in the history grid (or a dot on the chart)
• Right-click → "Load the First Plan" or "Load the Last Plan"
• The plan opens as a new sub-tab (e.g., "QS 42 / 17")
* Code review :
Bugs Fixed
1. Shared ContextMenu — BuildContextMenu() now creates separate ContextMenu instances for DataGrid and Chart via CreatePlanContextMenu()
2. Silent catch — LoadPlanFromSelection now shows errors in StatusText with catch (Exception ex)
3. Wrong type check — Close_Click now checks is not PlanViewer.App.MainWindow instead of IClassicDesktopStyleApplicationLifetime
4. Event handler leak — AddHistorySubTab now unsubscribes before subscribing: -= OnHistoryPlanLoadRequested before +=
Improvements
5. Loading feedback — Shows "Loading plan…" / "Plan not found" / error in StatusText
6. Disable menu when no selection — Opening handler disables items when GetSelectedPlanHash() is null
7. IndexOf — Added clarifying comment (list is <500 items, no better API available)
8. ScrollIntoView — Moved after ItemsSource reset so the target row exists
9. Long-press duplication — Extracted TabHeaderLongPressBehavior helper, used in both MainWindow.Tabs.cs and QuerySessionControl.QueryStore.cs
10. HistoryPlanLoadEventArgs — Moved to its own file
Nits
11. Removed unnecessary ?. on non-nullable orderBy parameter
12. Changed bare catch to catch (Exception) in tooltip handler
13. Changed bare catch to catch (Exception ex) in LoadPlanFromSelection
* When the MainWindow closes, it now iterates all open windows via IClassicDesktopStyleApplicationLifetime.Windows and closes any that aren't the MainWindow itself. This ensures all detached free-floating windows (from tab detach, history detach, advice windows, etc.) are closed when the app's main window is closed.
* Must-fix fixed
* use pin/unpin button to fix ux-must-fix
* fix error truncation to 80 chars : truncation removed
* fix most remaining nice to have
* add spinner and cancel for history fetches1 parent d774c7b commit a093055
11 files changed
Lines changed: 1704 additions & 1205 deletions
File tree
- src
- PlanViewer.App
- Controls
- Dialogs
- Helpers
- PlanViewer.Core/Services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 137 additions & 91 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 48 | | |
64 | 49 | | |
65 | | - | |
| 50 | + | |
66 | 51 | | |
67 | 52 | | |
68 | 53 | | |
| |||
73 | 58 | | |
74 | 59 | | |
75 | 60 | | |
76 | | - | |
| 61 | + | |
77 | 62 | | |
78 | 63 | | |
79 | 64 | | |
| |||
85 | 70 | | |
86 | 71 | | |
87 | 72 | | |
88 | | - | |
| 73 | + | |
89 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
90 | 79 | | |
91 | | - | |
| 80 | + | |
92 | 81 | | |
93 | 82 | | |
94 | 83 | | |
95 | 84 | | |
| 85 | + | |
| 86 | + | |
96 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
97 | 122 | | |
98 | 123 | | |
| 124 | + | |
99 | 125 | | |
100 | 126 | | |
101 | 127 | | |
| |||
106 | 132 | | |
107 | 133 | | |
108 | 134 | | |
109 | | - | |
| 135 | + | |
110 | 136 | | |
111 | 137 | | |
112 | 138 | | |
| |||
127 | 153 | | |
128 | 154 | | |
129 | 155 | | |
130 | | - | |
| 156 | + | |
131 | 157 | | |
132 | 158 | | |
133 | 159 | | |
| |||
152 | 178 | | |
153 | 179 | | |
154 | 180 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 181 | + | |
| 182 | + | |
187 | 183 | | |
188 | | - | |
189 | | - | |
| 184 | + | |
| 185 | + | |
190 | 186 | | |
191 | 187 | | |
192 | 188 | | |
| |||
244 | 240 | | |
245 | 241 | | |
246 | 242 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 243 | + | |
254 | 244 | | |
255 | 245 | | |
256 | 246 | | |
257 | | - | |
| 247 | + | |
| 248 | + | |
258 | 249 | | |
259 | 250 | | |
260 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
261 | 258 | | |
262 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
263 | 281 | | |
264 | 282 | | |
265 | 283 | | |
266 | | - | |
| 284 | + | |
267 | 285 | | |
268 | 286 | | |
269 | | - | |
| 287 | + | |
270 | 288 | | |
271 | 289 | | |
272 | 290 | | |
273 | 291 | | |
| 292 | + | |
274 | 293 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
280 | 297 | | |
281 | | - | |
282 | | - | |
283 | | - | |
| 298 | + | |
| 299 | + | |
284 | 300 | | |
285 | 301 | | |
286 | | - | |
| 302 | + | |
287 | 303 | | |
288 | 304 | | |
289 | 305 | | |
290 | 306 | | |
291 | 307 | | |
292 | 308 | | |
293 | | - | |
| 309 | + | |
294 | 310 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
300 | 315 | | |
301 | | - | |
302 | | - | |
303 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
304 | 350 | | |
305 | 351 | | |
Lines changed: 22 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
110 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
111 | 127 | | |
| 128 | + | |
112 | 129 | | |
113 | 130 | | |
114 | 131 | | |
| |||
0 commit comments