Skip to content

Commit 66244ac

Browse files
refactor(plugin-grid): move ObjectGrid's row load into a sibling hook (slice 5) (#26537)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi94Cr2fbhp665MVvsYFfqYFe)_ Part of #25994 (slice 5 of the move-only split; slices 1–4 landed as #26323, #26354, #26364 and #26499, and the card stays open for the slices listed below). Clause-②: no Metadata-protocol: none ## What moved Base `14f30991` (`main` with slice 4). `ui/packages/plugin-grid/src/ObjectGrid.tsx` is 6307 lines there. This slice moves concerns **K** and **L** of the seam table in #26364, as re-planned in #26499. They are adjacent and above the first early return, so they become one custom hook, `useObjectGridRowLoad`, in the new sibling `ui/packages/plugin-grid/src/objectGridRowLoad.ts`, called where the lines stood: | # | Concern | Lines on `14f30991` | |---|---|---| | K | The data-invalidation nonce (`invalidationNonce`) and the unified async load effect: object definition, then rows, totals, `lastFindParamsRef` and the server-grouped row query | 1278–1894 | | L | The host `findParams` reset of "select all matching" (`hostFindParamsKey`) and the page-1 reset when the query changes | 1896–1923 | | — | `toOrderByClause` with its docblock (module level) | 104–134 | `toOrderByClause` moves with the load effect because that effect is its only caller (slice 2 left it beside its call sites for that reason; the call sites now live in the new module). `parseSchemaSort` stays in `ObjectGrid.tsx`, pinned by `gridArrayArmOrderby-8973`. Its docblock's `{@link toOrderByClause}` now names a function in the sibling module; the sentence is unchanged. The hook takes 35 inputs, passed explicitly and typed from their source; no context is added and no `any` is introduced: - The values from slice 4's hooks are typed as `ReturnType<typeof useObjectGridQueryInputs>[name]` and `ReturnType<typeof useObjectGridGroupingDecisions>[name]`. - The rest: `schema: ObjectGridSchema`, `dataSource: DataSource | undefined`, `objectName: string | undefined`, `dataConfig: ViewData | { provider: string; items: unknown[] } | null`, `hasInlineData: boolean`, `perms: ReturnType<typeof usePermissions>`, `refreshKey: number`, `hostFindParams: ObjectGridExternalPaginationProps['findParams']`, `lastFindParamsRef: React.RefObject<Record<string, unknown> | null>`, and the six setters as `React.Dispatch<React.SetStateAction<…>>` of their state's type. `data` and `objectSchema` are `useState<any…>` in the component, so their setters are typed with `unknown[]` and `unknown` in the hook, and the effect type-checks against that unchanged. The hook returns `{ invalidationNonce }`, the one name the rest of the component reads (`groupReloadKey`). No identifier is renamed. Nothing new is exported from `ObjectGrid.tsx`, and the package entry is untouched. Twelve import specifiers and the `findParamsSignature` import move with their only readers. `ObjectGrid.tsx` goes from 6307 to 5639 lines. The diff is 1464 changed lines. Move-only proof: the multiset of non-blank lines of the base `ObjectGrid.tsx` equals the new `ObjectGrid.tsx` plus `objectGridRowLoad.ts`. Nothing is missing except the 4 edited import lines, which differ only by the removed specifiers. The only added lines are the module header and imports, the two `ReturnType` aliases, the hook signature, `return { invalidationNonce };`, and in `ObjectGrid.tsx` the import plus the call with its two-line comment. ## Open PRs on `ObjectGrid.tsx` None. I checked all 22 open PRs at the claim (06:15Z): none touches `ObjectGrid.tsx`, its `objectGrid*` siblings or `gridArrayArmOrderby-8973.test.tsx`. ## Test edits One, a path edit, as the seat ruled. `gridArrayArmOrderby-8973.test.tsx` pins `params.$orderby = headerSort.map(…)` in the load effect, now in `objectGridRowLoad.ts`, and `export function parseSchemaSort`, which stays. Its source probe now reads the two files joined: ```diff - const src = readFileSync(join(REPO_ROOT, 'packages/plugin-grid/src/ObjectGrid.tsx'), 'utf8'); + const src = ['ObjectGrid.tsx', 'objectGridRowLoad.ts'] + .map((file) => readFileSync(join(REPO_ROOT, 'packages/plugin-grid/src', file), 'utf8')) + .join('\n'); ``` Every assertion is unchanged. No other test reads the moved lines as source: I matched every string literal of every source-reading test against the moved lines, and the only other hits were prose in test comments. `column-identity.ratchet` still finds its `columnIdentity(` call in `ObjectGrid.tsx` (line 1859 there). ## Remaining slices As re-planned in #26499: **6 — N + O + P** (group value formatter and temporal faces, server grouping, bulk fan-out and column summaries), **7 — C + D + E** (row-height sync, column-state persistence, pull to refresh; re-points `gridNonAuthorKeys`' `columnState` reads), **8 — R + U + V** (closes the card; re-points the five `generateColumns` pins). ## Verification Run on `5345a340` (this head): - `pnpm --dir ui exec vitest run packages/plugin-grid/ --maxWorkers=2`, the whole package suite, under the verification lock: 253 of 253 files, 2256 of 2256 tests. The before reading is the same count on slice 4 (#26499, CI green on `09fc0d22`). - The 52 test files outside plugin-grid that read sources (the list slices 1–4 used): 52 of 52 files, 2258 of 2258 tests. - `pnpm --filter @object-ui/plugin-grid type-check` exit 0. - `turbo run build --filter=@object-ui/console`: 70 of 70 tasks. - eslint on the three touched files: 0 errors, and 229 warnings before and after. As in slice 4, the setters now come from the hook's parameters, so two `react-hooks/exhaustive-deps` messages name different variables (the load effect's now lists `lastFindParamsRef`, `setData`, `setError`… instead of `setGroupRowQuery`; the `findParams` reset's now names `setSelectAllMatching`), and one `set-state-in-effect` warning is no longer raised. No dependency array changed. - `node scripts/pm/dispatch-gates.mjs --commands`: 35 derived gates, all exit 0 (the `vitest run scripts/` gate ran under the lock: 178 files, 5097 tests); `--ran` reconciles 35 of 35 (0 NOT-MEASURED, 0 UNRUN). ## Landing No other open PR touches these files, so this can land as soon as CI is green. Changeset: `.changeset/25994-objectgrid-row-load-hook.md` (patch, `@object-ui/plugin-grid`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Bdrd2yH4eqnz2QobtN3haE Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5065db8 commit 66244ac

4 files changed

Lines changed: 780 additions & 684 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/plugin-grid': patch
3+
---
4+
5+
refactor(plugin-grid): `ObjectGrid`'s row load moves into a sibling hook
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The row load of the `ObjectGrid` component moves verbatim out of `ObjectGrid.tsx` into `useObjectGridRowLoad` (`objectGridRowLoad.ts`): the data-invalidation nonce, the one async load effect, the host `findParams` reset of "select all matching" and the page-1 reset on a query change. `toOrderByClause`, whose only caller is the load effect, moves with it. `ObjectGrid` calls the hook where the block stood, so its hook order, its queries and its rendered output do not change. No name is renamed, and the package entry is unchanged.
11+
12+
What to do: nothing.

0 commit comments

Comments
 (0)