You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split out of #2244 while fixing the controls half in #2250. Both halves below share one cause, so they belong together.
Display order does not survive the grid unmounting.
MainContentCoordinator.activeGridDisplayIDs resolves through dataTabDelegate?.tableViewCoordinator?.displayIDs. That reference is weak (DataTabGridDelegate.swift:114), assigned only from dataGridAttach, and the coordinator's only strong owner is the mounted DataGridView. The order itself lives on that same view-layer object: sortedIDs and valueFilteredIDs at DataGridCoordinator.swift:40-41, combined by displayIDs at :49. Nothing in the model knows the display order.
JSON mode does not mount the grid (MainEditorContentView.swift, the case .json: arm), so the reference goes nil and DisplayRowMapping falls back to storage order. Two consequences:
A sorted or value-filtered result switched to JSON is shown in storage order, not the order on screen.
selectedRowIndices are display positions. With displayIDs nil they index storage instead, so rows selected in Data mode resolve to different rows in JSON. This is exactly the invariant CLAUDE.md records from Faulty Details for Json column #1837.
Pending deletions are not shown in JSON, and cannot be until the above is fixed.
ResultsJsonView renders the loaded rows. Inserts and cell edits already appear, because both are written into TableRows itself. A deletion is not: RowOperationsManager.deleteSelectedRows removes pending inserts outright but records existing rows through recordBatchRowDeletion, keyed by display position. So a row marked for deletion keeps rendering in JSON, and the Save button lights up with nothing visibly changed. Filtering those rows out of the JSON needs a trustworthy display order, which is the first half of this issue.
What to do: give the display order an owner that outlives the grid, most likely the tab or TabSessionRegistry rather than TableViewCoordinator, then have ResultsJsonView read it directly. Once positions are trustworthy, teach ResultJsonSerializer to skip deleted rows behind a parameter that defaults to off, since it is shared with the grid's Copy as JSON (DataGridView+RowActions.swift:179) and that path should keep serialising every row.
Verified by reading main at a0881299a, not at runtime: the weak declaration, the assignment site, the ownership chain, and the case .json: arm which does not mount the grid. Worth confirming with a breakpoint that the reference is nil in practice before designing the fix, since SwiftUI's retention of an NSViewRepresentable coordinator is the one link I did not measure.
Split out of #2244 while fixing the controls half in #2250. Both halves below share one cause, so they belong together.
Display order does not survive the grid unmounting.
MainContentCoordinator.activeGridDisplayIDsresolves throughdataTabDelegate?.tableViewCoordinator?.displayIDs. That reference isweak(DataTabGridDelegate.swift:114), assigned only fromdataGridAttach, and the coordinator's only strong owner is the mountedDataGridView. The order itself lives on that same view-layer object:sortedIDsandvalueFilteredIDsatDataGridCoordinator.swift:40-41, combined bydisplayIDsat:49. Nothing in the model knows the display order.JSON mode does not mount the grid (
MainEditorContentView.swift, thecase .json:arm), so the reference goes nil andDisplayRowMappingfalls back to storage order. Two consequences:selectedRowIndicesare display positions. WithdisplayIDsnil they index storage instead, so rows selected in Data mode resolve to different rows in JSON. This is exactly the invariantCLAUDE.mdrecords from Faulty Details for Json column #1837.Pending deletions are not shown in JSON, and cannot be until the above is fixed.
ResultsJsonViewrenders the loaded rows. Inserts and cell edits already appear, because both are written intoTableRowsitself. A deletion is not:RowOperationsManager.deleteSelectedRowsremoves pending inserts outright but records existing rows throughrecordBatchRowDeletion, keyed by display position. So a row marked for deletion keeps rendering in JSON, and the Save button lights up with nothing visibly changed. Filtering those rows out of the JSON needs a trustworthy display order, which is the first half of this issue.What to do: give the display order an owner that outlives the grid, most likely the tab or
TabSessionRegistryrather thanTableViewCoordinator, then haveResultsJsonViewread it directly. Once positions are trustworthy, teachResultJsonSerializerto skip deleted rows behind a parameter that defaults to off, since it is shared with the grid's Copy as JSON (DataGridView+RowActions.swift:179) and that path should keep serialising every row.Verified by reading
mainata0881299a, not at runtime: theweakdeclaration, the assignment site, the ownership chain, and thecase .json:arm which does not mount the grid. Worth confirming with a breakpoint that the reference is nil in practice before designing the fix, since SwiftUI's retention of anNSViewRepresentablecoordinator is the one link I did not measure.