Extract renderGrid state/repaint wiring before Panels (#167)#181
Merged
Conversation
…nder.js (#167) Move the shared sortable/resizable grid out of results.js into its own module and centralize the hand-rolled sort-update + repaint wiring: - src/ui/grid-render.js: renderGrid (stateless, unchanged; onCell now optional per the issue's degrade-safely requirement), colResizeWidth, the resize primitives behind two small shared helpers (resizeHandle, reapplyWidths — the col-resize-h span + reapply guard were copy-pasted three times), PLAIN_KEY, GRID_VIS_CAP, and the new renderGridView adapter (explicit sort/setSort/widths/rerender seams). - results.js: the three consumers (renderTable, script rows viewer, detached Data pane) migrate to renderGridView, each keeping its exact state lifetime and repaint scope; the script grids reuse the shared resize helpers. No dependency from grid-render.js back into results.js. - tests: new per-module spec tests/unit/grid-render.test.js (adapter contract + grid mechanics, 100/100/100/100); results.test.js keeps only wiring-level resize specs and gains coverage for the toolbar Expand button and the script-grid handle click (the extraction surfaced them as the file's only uncovered functions, along with two unreachable no-op cancelDrawerDrag initializers now removed). Behavior-preserving preparation for the Panels track: #166's table panel becomes the fourth consumer without another copy of the wiring. Closes #167 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvqMJNyxUAJQcEm1Tn29Qr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Closes #167 — the behavior-preserving preparation step for the Panels track (#166).
The complex grid surface was already shared (
renderGrid), but its state wiring ({sort, widths} holder + repaint-on-sort closure) was hand-rolled at three sites, each slightly different. This PR:src/ui/grid-render.js—renderGrid(moved verbatim, stays stateless;onCellis now optional so a consumer without a cell-detail surface degrades safely instead of throwing),colResizeWidth, the column-resize logic behind two shared helpers (resizeHandle,reapplyWidths— the 8-line handle span + reapply guard were previously copy-pasted three times),PLAIN_KEY,GRID_VIS_CAP, and the newrenderGridViewadapter with the issue's explicit seams (sort/setSort/widths/rerender/onCell/cap):setSortis called exactly once per sort click,rerenderafter the state update,widthspasses through by reference. No dependency back intoresults.js(prevents theresults → panels → renderer → resultscycle Extract the renderGrid local-state wiring (sort/widths + repaint) — four hand-rolled copies #167 called out).renderGridView, each preserving its exact state lifetime and repaint scope: main results table (app.state.resultSort+r.colWidths, fullrenderResultsrepaint,visCap(r)), script-result rows viewer (entry-persisted state, drawer-body repaint), detached Data pane (snapshot-local state, caller-owned Table/JSON/Chart repaint + Chart.js cleanup, detached-document cell detail). The script grids reuse the shared resize helpers withPLAIN_KEY.tests/unit/grid-render.test.js(adapter contract per the issue's Tests section + grid/resize mechanics; 100/100/100/100).results.test.jskeeps the wiring-level specs and gains coverage for the toolbar Expand button and the script-grid resize-handle click — the extraction exposed them as the file's only uncovered functions, along with two unreachable no-opcancelDrawerDraginitializers (always reassigned before any close can fire), now removed per the repo's no-dead-defensive-code philosophy.Explicitly out of scope (per the issue): panel/dashboard/saved-query knowledge,
gridStateForSchema(deferred until #166 has a consumer), and any sorting/resizing behavior change.visCapstays inresults.js(it's result-shaped policy; the adapter takescapas an input).Reviewed via an 8-angle finder/verify pass; three confirmed findings (test duplication, unguarded optional
onCell, thrice-copied resize wiring) are fixed in this diff.Checklist
npm testpasses (2118 tests;grid-render.jsat 100/100/100/100,results.jswithin the gate)npm run buildsucceeds (single-filedist/sql.html)src/ui/, state seams injected by the caller; nosrc/core//src/net/changesCHANGELOG.md([Unreleased]) updated🤖 Generated with Claude Code
https://claude.ai/code/session_01KvqMJNyxUAJQcEm1Tn29Qr