Skip to content

fix(datagrid): make the controls JSON result mode offers do what they say - #2250

Merged
datlechin merged 3 commits into
mainfrom
fix/2244-json-mode-controls
Aug 19, 2026
Merged

fix(datagrid): make the controls JSON result mode offers do what they say#2250
datlechin merged 3 commits into
mainfrom
fix/2244-json-mode-controls

Conversation

@datlechin

Copy link
Copy Markdown
Member

Fixes #2244.

JSON result mode offered three controls that did nothing. Each is fixed at its own cause, and the investigation changed what one of those causes turned out to be.

The Filters toggle drew nothing

showsRowFilters is .data || .json, so the funnel button and Cmd+Option+F were live in JSON mode, but FilterPanelView only existed inside the case .data: arm. The panel is now a rowFilterChrome builder both arms call.

Filtering rebuilds the query and re-runs it, so once the panel renders, JSON shows filtered rows with no further plumbing. The builder is deliberately not hoisted above the switch: that would paint it over explain plans and the statement-succeeded view in .data.

Row editing appeared to do nothing, for a different reason than the issue says

The issue predicted a missing pending-change overlay. That is not what happens. Pending inserts are real rows in TableRows (appendInsertedRow) and cell edits are written into the same buffer (tableRows.edit), so JSON already carries every pending value.

The actual cause is the selection. Add Row, Duplicate Row, Paste and Delete each set selectionState.indices to the row they just touched so the grid can highlight it and scroll to it, and ResultsJsonView reads that same selection as "show only these rows". So in JSON mode Add Row collapsed the document to one all-null object, Paste collapsed it to the pasted rows, and Delete collapsed it to a single surviving neighbour. It looked like nothing happened; in fact everything happened and the view narrowed to it.

Those four writes are now guarded by selectionPointsTheGrid. The grid calls immediately after them (applyDelta, beginEditing) already no-op through a nil coordinator when the grid is unmounted, so the selection write was the only line with an effect in JSON mode, which is what makes this safe. Undo and redo index adjustments are untouched, since those keep the selection valid rather than pointing at anything.

Cmd+F opened a find bar that could not find

FindCoordinator.runSearch() reads the data grid's cells through dataTabDelegate?.tableViewCoordinator, which exists only while the grid is mounted. In JSON mode the bar rendered and reported no matches whatever you typed.

ResultsViewMode gains showsFindBar, true only for .data, and the find commands and the Edit menu's Find validation now read it instead of showsRowFilters. The two predicates were doing one job for two different things: the filter panel is chrome above the results and works in any mode that shows rows, while the find bar searches one specific view's cells. JSON's Tree view keeps its own search field.

Verification

  • Debug build PASS.
  • MainStatusBarLayoutTests, ResultsJsonViewTests, MainMenuBuilderTests, RowEditingCoordinatorCopyTests, GridSelectionOwnerTests: 33 executed, 33 passed. Log grepped for Failing tests:, TEST FAILED and Crash:, 0 hits.
  • swiftlint --strict clean over the app target and over the changed test file.

findBarVisibilityByMode pins the new predicate and asserts the invariant that any mode which finds must also filter, so the two cannot be split the wrong way later.

No UI automation

The three fixes are a view-tree branch, a menu validation arm, and a guarded assignment. Driving them through XCUITest needs a live connection with a loaded table, which TableProUITests has no deterministic fixture for. The behaviour is pinned by the predicate test and by reading; a UI test here would assert the app launched.

Deliberately not in this PR

Two defects share one cause and need their own design, so I have filed them rather than half-fixing them here.

Display order does not survive the grid unmounting. activeGridDisplayIDs resolves through dataTabDelegate?.tableViewCoordinator, which is weak on an object owned by the mounted grid, and sortedIDs / valueFilteredIDs live on that same view-layer coordinator. So switching a sorted or value-filtered result to JSON drops to storage order, and a selection made in Data mode then maps to different rows. That is the display-position invariant CLAUDE.md records from #1837.

Pending deletions are not shown, and cannot be until the above is fixed, because a deletion is recorded by display position rather than by RowID.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin
datlechin merged commit dfbdca7 into main Aug 19, 2026
3 checks passed
@datlechin
datlechin deleted the fix/2244-json-mode-controls branch August 19, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON result mode offers filters and row editing whose effects it never shows

1 participant