Repository navigation
Commit 14f3099
refactor(plugin-grid): move ObjectGrid's query inputs and grouping decisions into sibling hooks (slice 4) (#26499)
<!-- 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 4 of the move-only split; slices 1–3 landed as
#26323, #26354 and #26364, and the card stays open for the slices listed
below).
Clause-②: no
Metadata-protocol: none
## What moved
Base `d0a7e748` (`main` with slice 3).
`ui/packages/plugin-grid/src/ObjectGrid.tsx` is 6571 lines there.
Following the seat's grouping ruling (2–3 adjacent concerns per PR),
this slice moves concerns **H**, **I** and **J** of the seam table in
#26364. They are adjacent in the component body, all above the first
early return, so each becomes a custom hook called where its lines
stood:
| # | Concern | Lines on `d0a7e748` | New home |
|---|---|---|---|
| H | Projection keys: `schemaFields`/`schemaColumns`, concurrency
token, row colour field, grouping and predicate projection keys |
1175–1233 | `useObjectGridQueryInputs` in `objectGridQueryInputs.ts` |
| I | The view's filter (lowered once, refusal kept), sort, search and
server-paging state | 1234–1327 | the same hook (H and I are one run of
lines, both read only `schema` plus three inputs) |
| J | Grouping decisions: the masked grouping-key refusal and its
warning, `serverGroupedFetch`, the two grouping refusals, the fetch
window and the held `groupRowQuery` | 1376–1540 |
`useObjectGridGroupingDecisions` in `objectGridGroupingDecisions.ts` |
The two inline-data effects between I and J (lines 1329–1374) stay in
`ObjectGrid.tsx`. They belong to the record source (F), which stays in
the component, and the hooks are called around them, so the component's
hook order does not change.
Hook inputs are passed explicitly and typed from their source; no
context is added and no `any` is introduced:
- `useObjectGridQueryInputs({ schema, objectName,
externalManualPagination, hostSearch })`, with `hostSearch:
ObjectGridExternalPaginationProps['search']`.
- `useObjectGridGroupingDecisions({ schema, objectName, objectFields,
objectTypesPending, perms, dataSource, hasInlineData, dataConfig,
externalManualPagination, hostRowCount, serverPageSize })`, with `perms:
ReturnType<typeof usePermissions>`, `hostRowCount:
ObjectGridExternalPaginationProps['rowCount']`, `dataConfig: ViewData |
{ provider: string; items: unknown[] } | null` (the type the
`dataConfig` memo infers, with `any[]` read as `unknown[]`), and
`objectFields: Readonly<Record<string, { type?: unknown } | undefined>>
| undefined` (the hook reads only `.type`).
Each hook returns exactly the names the rest of the component reads (23
and 9), and the component destructures them under the same names. No
identifier is renamed. Nothing new is exported from `ObjectGrid.tsx`,
and the package entry is untouched. Five import specifiers move with
their only readers (`useFilterScope`, `toFilterNodeSafely`,
`useResolvedGridFilters`, `NO_GROUPING_REFUSAL`,
`DEFAULT_FETCH_BATCH_SIZE`). `ObjectGrid.tsx` goes from 6571 to 6307
lines. The diff is 820 changed lines.
Move-only proof: the multiset of non-blank lines of the base
`ObjectGrid.tsx` equals the new `ObjectGrid.tsx` plus the two modules.
Nothing is missing except the 4 edited import lines, which differ only
by the removed specifiers. The only added lines are the two module
headers, their imports, the hook signatures, the two `return { … }`
lists, and in `ObjectGrid.tsx` the two imports plus the two calls with
their two-line comments and destructuring lists.
## Open PRs on `ObjectGrid.tsx`
None. I checked all 17 open PRs at the claim (05:00Z): none touches
`ObjectGrid.tsx` or its `objectGrid*` siblings. The version-packages PR
#25640 touches only the plugin-grid `CHANGELOG.md` and `package.json`.
## Source pins
No test reads the moved lines as source. I grepped every file that reads
`ObjectGrid.tsx` (the plugin-grid `__tests__` source scans, the census
tests elsewhere, `ui/scripts/__tests__`) for each moved name. The only
hits are in prose, and `gridArrayArmOrderby-8973`'s `params.$orderby =
headerSort…` pin, which is in the load effect (K) and stays.
`gridNonAuthorKeys`' `NON-AUTHOR SURFACE — \`key\`` anchors are not in
H–J (the `rowActionDefsRaw` comment names the exemption without that
anchor). No census row is re-keyed in this slice.
## Test edits
None.
## Seam table update, and the remaining slices
The table in #26364 still holds, shifted: on this branch H, I and J are
gone, and every later region starts about 264 lines earlier. The plan
below follows the seat's ruling (2–3 adjacent concerns per PR, census
pins may be re-pointed path-only):
- **Slice 5 — K + L:** the row load effect and the host `findParams`
sync (adjacent), into one hook with every input typed from its source.
`gridArrayArmOrderby-8973` pins one `$orderby` line in K beside `export
function parseSchemaSort`, which stays; the slice has that test read the
new module as well (a path edit).
- **Slice 6 — N + O + P:** group value formatter and temporal group
faces, server grouping, bulk fan-out params and column summaries
(adjacent; #26341 has landed, so N is free).
- **Slice 7 — C + D + E:** row-height sync, column-state persistence and
pull-to-refresh with the card-view breakpoint (adjacent, at the top of
the body). D re-points `gridNonAuthorKeys`' `columnState` reads
(path-only).
- **Slice 8 — R + U + V (closes the card):** `generateColumns`, column
post-processing and the actions column, re-pointing the five
`generateColumns` pins path-only.
The regions after the early returns (S, T, W–AG) and G stay in
`ObjectGrid.tsx` unless the seat wants further slices.
## Verification
Run on `09fc0d22` (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 3
(#26364, CI green on `b871ab8f`).
- The 52 test files outside plugin-grid that read sources (the list
slices 1–3 used): 52 of 52 files, 2258 of 2258 tests.
- `pnpm --filter @object-ui/plugin-grid type-check` exit 0 (after
rebuilding `@object-ui/plugin-grid^...` so no dependency dist is stale).
- `turbo run build --filter=@object-ui/console`: 70 of 70 tasks.
- eslint on the three files: 0 errors, and 226 warnings before and
after. The modules draw only warnings the moved lines already drew. Two
`react-hooks/exhaustive-deps` messages in `ObjectGrid.tsx` now also name
`setGroupRowQuery` and `setServerPage`, because a setter returned from a
custom hook is not known to be stable; one `set-state-in-effect` warning
is no longer raised for the same reason. No dependency array changed.
- `node scripts/pm/dispatch-gates.mjs --commands`: 29 derived gates, all
exit 0; `--ran` reconciles 29 of 29 (0 NOT-MEASURED, 0 UNRUN). `pnpm
--dir ui exec vitest run scripts/` first hit two 15 s timeouts
(`check-i18n-dead-keys`, `js-comment-mask-returns-interpolation-9424`)
while the locked suite was running beside it; both files passed alone,
and the whole `scripts/` run then passed under the lock (178 files, 5097
tests).
## Landing
No other open PR touches `ObjectGrid.tsx`, so this can land as soon as
CI is green.
Changeset: `.changeset/25994-objectgrid-query-grouping-hooks.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 e890bed commit 14f3099
4 files changed
Lines changed: 498 additions & 322 deletions
File tree
- .changeset
- ui/packages/plugin-grid/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments