Commit 9ef7f19
authored
refactor(datagrid): migrate callers to TableRows + delete legacy stack (#931)
* refactor(datagrid): introduce TableRowsStore alongside RowDataStore
* refactor(datagrid): introduce TableRowsController to drive NSTableView from Delta
* refactor(datagrid): mirror result delivery writes into TableRowsStore
* refactor(datagrid): switch JSON view and export to read TableRows
* refactor(datagrid): switch sidebar reads to TableRows
* refactor(datagrid): switch NSTableView delegate reads to TableRows
* refactor(datagrid): route cell edits through TableRows.edit and Delta
* refactor(datagrid): RowOperationsManager mutates TableRows and returns Delta
* refactor(datagrid): undo replay returns Delta and supports non-tail insert
* refactor(datagrid): sort moves to controller keyed by Row.id
* refactor(datagrid): display cache moves to coordinator keyed by Row.id
* refactor(datagrid): replace RowBuffer with TableRows; delete legacy row stack
* test(datagrid): update fixtures for RowDeltaApplying.applyDelta and StatusBarSnapshot rename
* fix(favorites): qualify ORDER BY columns in FTS-joined search query
* fix(datagrid): guard commitCellEdit against re-entry from reload-driven resignFirstResponder
* fix(datagrid): dispatch rowsInserted delta from loadMoreRows and read offset inside mutation
* fix(datagrid): dispatch fullReplace delta from fetchAllRows
* fix(datagrid): dispatch cellChanged delta from updateCellInTab
* fix(datagrid): remove TableRows entry on individual tab close
* refactor(datagrid): rebuildColumnMetadataCache reads live TableRows
* style(datagrid): drop doc comments per no-comments rule
* fix(datagrid): sync ResultSet snapshot with store on every mutation
Load More appended rows to the store but ResultSet.tableRows stayed
frozen at applyPhase1Result time. The data grid read through the active
ResultSet, so newly fetched rows showed empty cells.
Route every TableRows mutation through mutateActiveTableRows on
MainContentCoordinator. The helper updates the store, then writes the
new value back into the active ResultSet. Result-set switches go
through switchActiveResultSet so the store tracks the new active
snapshot. Read paths simplify to reading the store directly.
* fix(datagrid): unwrap optional result from addNewRow/duplicateRow
* fix(datagrid): clear modified cell highlight on undo, keep FK metadata across reloads
Two related visual regressions:
1. Edit cell -> yellow modified background -> undo -> value reverts but
highlight persists. applyDataUndo updated pending state but did not
bump reloadVersion, so the visual state cache was gated and the
stale modifiedColumns set survived. Bumping reloadVersion forces a
rebuild on the next render.
2. FK column arrow and dropdown chevron toggle visible/hidden on each
reload of a table tab. applyPhase1Result rebuilt TableRows from
scratch and only populated columnDefaults / columnForeignKeys /
columnNullable / columnEnumValues when a fresh schema fetch ran.
When isMetadataCached returned true (because metadata was in the
previous TableRows), no fetch ran and the new TableRows wiped the
metadata, which then caused the next reload to refetch -- so every
other reload had FK info and every other one didn't. Carry the
existing metadata over when the schema fetch is skipped.
* perf(datagrid): stop syncing ResultSet snapshot on every mutation
Inserting or undoing a row pegged the CPU at 100%. Each mutation went
through mutateActiveTableRows, which wrote the live TableRows back into
the active ResultSet's @observable tableRows property. That triggered a
full SwiftUI re-render of MainEditorContentView (which reads
rs.resultColumns / rs.errorMessage / etc), on top of the existing
observation triggers from changeManager.reloadVersion and
tabManager.tabs. Fast key-repeat undo or paste cascaded re-renders.
Move the per-ResultSet snapshot into a save-on-switch model:
mutateActiveTableRows now only writes the store, and
switchActiveResultSet saves the outgoing snapshot then loads the
incoming one. Edits in a pinned result set still survive switching
back, but routine inserts / undos / cell edits no longer cross the
@observable boundary on the ResultSet.
Also short-circuit the inserted-rows scan in
DataGridCoordinator.rebuildVisualStateCache: when the grid is unsorted,
read changeManager.insertedRowIndices directly instead of iterating
every row in TableRows. The full scan only runs in the sorted case
where display indices differ from storage indices.
* test(datagrid): fix EvictionTests — selected tab is intentionally not evicted
`evictInactiveRowData` deliberately skips the currently selected tab
("kept in memory so the user sees no refresh flicker"), but the migrated
tests added a tab and immediately called eviction — the new tab was the
selected tab, so eviction was a no-op and the assertions failed.
Fix: add a second tab so the first becomes background, then assert
eviction on the background tab.
* perf(datagrid): updateCache reads live tableRowsProvider so post-Delta count is fresh
* refactor(datagrid): replace editingCell binding with direct beginEditing call
addNewRow / duplicateSelectedRow now call coordinator.beginEditing(displayRow:column:) synchronously after applyDelta. The editingCell SwiftUI binding plumbing across 7 files is removed since no caller sets it to non-nil anymore. Each row-add press fully completes (commit prior edit, mutate model, apply delta, focus new cell) before the next press fires, so rapid Cmd+Shift+N keeps focus on the latest appended row instead of getting trapped in queued Tasks.
* chore: drop DATAGRID_REFACTOR.md handoff doc
* fix(datagrid): clear cell display cache when row data is replaced
setActiveTableRows now dispatches applyFullReplace to the active grid after every full row swap, routing through a single mutation surface instead of seven direct tableRowsStore.setTableRows callers across navigation, query helpers, multi-statement, FK navigation, and sidebar actions. Without the dispatch, the coordinator's RowID-keyed displayCache survived table switches and returned the previous table's formatted cell values for matching RowIDs, even though the cell views themselves had rebuilt with the new column set.
* refactor(datagrid): rename RowDeltaApplying to TableViewCoordinating, add dispatch regression tests
The protocol now exposes commitActiveCellEdit and beginEditing alongside the row-delta methods, so its name no longer matches its scope. Renaming to TableViewCoordinating tracks the conforming class TableViewCoordinator and the field DataTabGridDelegate.tableViewCoordinator.
TableRowsMutationTests verifies that setActiveTableRows dispatches applyFullReplace exactly once for the active tab and skips background tabs, locking in the displayCache invalidation contract that was missing before commit 0e967c2.1 parent 0129afb commit 9ef7f19
85 files changed
Lines changed: 2289 additions & 3420 deletions
File tree
- TableProTests
- Core/Services
- Query
- Helpers
- Models
- Query
- Views
- Main
- Child
- Results
- TablePro
- Core
- ChangeTracking
- Plugins
- SchemaTracking
- Services
- Export
- Formatting
- Query
- Storage
- Models
- Export
- Query
- Views
- Export
- Main
- Child
- Extensions
- Results
- Extensions
- Structure
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
| |||
259 | 274 | | |
260 | 275 | | |
261 | 276 | | |
262 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
263 | 281 | | |
264 | 282 | | |
265 | 283 | | |
| |||
274 | 292 | | |
275 | 293 | | |
276 | 294 | | |
277 | | - | |
| 295 | + | |
| 296 | + | |
278 | 297 | | |
279 | 298 | | |
280 | 299 | | |
281 | 300 | | |
282 | | - | |
| 301 | + | |
| 302 | + | |
283 | 303 | | |
284 | 304 | | |
285 | 305 | | |
| |||
292 | 312 | | |
293 | 313 | | |
294 | 314 | | |
295 | | - | |
| 315 | + | |
| 316 | + | |
296 | 317 | | |
297 | 318 | | |
298 | 319 | | |
299 | 320 | | |
300 | | - | |
| 321 | + | |
| 322 | + | |
301 | 323 | | |
302 | 324 | | |
303 | 325 | | |
| |||
315 | 337 | | |
316 | 338 | | |
317 | 339 | | |
318 | | - | |
| 340 | + | |
| 341 | + | |
319 | 342 | | |
320 | 343 | | |
321 | 344 | | |
322 | 345 | | |
323 | 346 | | |
324 | 347 | | |
325 | | - | |
| 348 | + | |
| 349 | + | |
326 | 350 | | |
327 | 351 | | |
328 | 352 | | |
| |||
335 | 359 | | |
336 | 360 | | |
337 | 361 | | |
| 362 | + | |
338 | 363 | | |
339 | 364 | | |
340 | 365 | | |
341 | | - | |
| 366 | + | |
| 367 | + | |
342 | 368 | | |
343 | 369 | | |
344 | 370 | | |
345 | 371 | | |
346 | | - | |
| 372 | + | |
| 373 | + | |
347 | 374 | | |
348 | 375 | | |
349 | 376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
| |||
20 | 17 | | |
21 | 18 | | |
22 | 19 | | |
23 | | - | |
| 20 | + | |
24 | 21 | | |
25 | 22 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
31 | 26 | | |
32 | 27 | | |
33 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
| 890 | + | |
| 891 | + | |
890 | 892 | | |
891 | 893 | | |
892 | 894 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
This file was deleted.
0 commit comments