Skip to content

refactor(grid): break the results grid into pieces that fit in a head (#406) - #634

Merged
EVWorth merged 1 commit into
mainfrom
refactor/results-grid-split
Sep 11, 2026
Merged

EVWorth merged 1 commit into
mainfrom
refactor/results-grid-split

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Stacked on #633.

ResultsGrid held the column order, the filters, the row count, the row key, the selection, the copy formats, the export handlers, the keyboard shortcuts, the context menu, the save handler, the column definitions, four placeholder states and two render paths — 1452 lines by the time the results backlog was through with it.

It's now 472 lines of orchestration.

Extracted What it owns
useColumnLayout column order, persistence, display order
useColumnFilters filter state, and the shape TanStack wants
useRowCount the free estimate and the exact count
useRowSelection click, Ctrl, Shift, Ctrl+A
useGridShortcuts undo, redo, set NULL
useGridColumns one TanStack column def per result column
useGridContextMenu what right-clicking a row offers
useGridExport clipboard and file
useGridSave pending edits → statements → one transaction
GridHeaderRow every header, for both layouts
GridRows the rows, for both layouts
GridFooter where you are, what's narrowing, how to get out
GridBanners truncation and server warnings
GridPlaceholder running, failed, count-only, nothing yet

The header and the rows are the point. Each existed twice — once for the virtualized path above 5000 rows, once for the plain table below it — and the copies had drifted, so anything added to one silently went missing in the other, in the half nobody looks at.

Splitting found a real bug

useColumnLayout keyed its effect on the columns array, so a caller building that list inline would reset the order, re-render, and do it again forever. ResultsGrid passes a stable array and never hit it; the first test that did hung the worker for eighty seconds. It now keys on the names, which compare by value — with a regression test.

On the acceptance criterion

The issue asks for ≤250 LOC. This lands at 472. What's left is the hook wiring and the table skeleton itself; pushing further would mean a useEverything hook or components taking twenty props, which trades a long file for indirection without making anything easier to follow. Happy to go further if you disagree.

Behaviour is unchanged: 2425 unit and 340 browser tests pass throughout, and the new hooks bring 16 of their own — none of which need the grid rendered.

Closes #406

🤖 Generated with Claude Code

@EVWorth
EVWorth changed the base branch from feat/results-selection-copy to main September 11, 2026 05:16
ResultsGrid held the column order, the filters, the row count, the row key,
the selection, the copy formats, the export handlers, the keyboard shortcuts,
the context menu, the save handler, the column definitions, four placeholder
states and two render paths — 1452 lines by the time the results backlog was
through with it (#406).

It is now 472 lines of orchestration. What came out:

  useColumnLayout      column order, persistence, display order
  useColumnFilters     filter state, and the shape TanStack wants
  useRowCount          the free estimate and the exact count
  useRowSelection      click, Ctrl, Shift, Ctrl+A
  useGridShortcuts     undo, redo, set NULL
  useGridColumns       one TanStack column def per result column
  useGridContextMenu   what right-clicking a row offers
  useGridExport        clipboard and file
  useGridSave          pending edits to statements to one transaction
  GridHeaderRow        every header, for both layouts
  GridRows             the rows, for both layouts
  GridFooter           where you are, what is narrowing, how to get out
  GridBanners          truncation and server warnings
  GridPlaceholder      running, failed, count-only, nothing yet

The header and the rows are the point. Each existed twice — once for the
virtualized path above 5000 rows, once for the plain table below it — and the
copies had drifted, so anything added to one silently went missing in the
other, in the half nobody looks at.

Splitting found a real bug. `useColumnLayout` keyed its effect on the columns
array, so a caller building that list inline would reset the order, re-render,
and do it again forever. ResultsGrid passes a stable array and never hit it;
the first test that did hung the worker for eighty seconds. It now keys on the
names, which compare by value.

Behaviour is unchanged: 2425 unit and 340 browser tests pass throughout, and
the new hooks bring 16 of their own — none of which need the grid rendered.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth force-pushed the refactor/results-grid-split branch from 647ba07 to e72f4de Compare September 11, 2026 05:37
@EVWorth
EVWorth merged commit 3bb650e into main Sep 11, 2026
12 checks passed
@EVWorth
EVWorth deleted the refactor/results-grid-split branch September 11, 2026 05:41
@EVWorth EVWorth mentioned this pull request Sep 11, 2026
48 tasks
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.

[P1] [arch] ResultsGrid.tsx is 916 LOC — god-component (split into header/footer/menu/save)

1 participant