Repository navigation
refactor(plugin-grid): move ObjectGrid's row-height sync, column state and mobile affordances into sibling hooks (slice 7) - #26773
Merged
Conversation
…e and mobile affordances into sibling hooks Slice 7 of the move-only ObjectGrid split: regions C, D and E move verbatim into useObjectGridRowHeightSync, useObjectGridColumnState and useObjectGridMobile, called where the lines stood. Claude-Session: https://claude.ai/code/session_01JQwxbXqCPeUA7ztE9YWKwP Co-authored-by: Claude <noreply@anthropic.com>
…; add the slice changeset Claude-Session: https://claude.ai/code/session_01JQwxbXqCPeUA7ztE9YWKwP Co-authored-by: Claude <noreply@anthropic.com>
Contributor
Author
维护者速读
席位核对ACCEPT · seat
Generated by Claude Code |
This was referenced Oct 27, 2026
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.
Requested by Warren · project thread
Part of #25994 (slice 7 of the move-only split: regions C, D and E. Slices 1 to 6 have landed; slice 8, regions R, U and V, stays on the card and closes it.)
Clause-②: no
Metadata-protocol: none
维护者速读
ObjectGrid.tsx组件顶部三段代码(行高同步、列状态持久化、下拉刷新与卡片视图断点)原样搬进三个同目录 hook 文件,组件在原位置调用它们。ui/packages/plugin-grid/src/objectGridColumnState.ts(NON-AUTHOR SURFACE 注释仍紧贴columnState种子)、ObjectGrid.tsx里三处调用、gridNonAuthorKeys.test.tsx的路径改动。pnpm --dir ui exec vitest run packages/plugin-grid/ --maxWorkers=2,预期 253 个文件、2256 个测试全绿,与 main 相同。What changes
Base
5cc31c78(origin/main).ui/packages/plugin-grid/src/ObjectGrid.tsxis 5250 lines there. This slice moves regions C, D and E of the seam table in #26364, the three adjacent blocks at the top of the component body, verbatim into three custom hooks in new sibling modules:schema.rowHeightuseObjectGridRowHeightSyncinobjectGridRowHeight.tsschema,rowHeightMode,setRowHeightModecolumnStorageKey, thecolumnStateseed with its NON-AUTHOR SURFACE comment, the externalcolumnStatesync,saveColumnStateuseObjectGridColumnStateinobjectGridColumnState.tsschema,onColumnStateChangecolumnState,saveColumnStateuseObjectGridMobileinobjectGridMobile.tsschema,dataSource,setRefreshKey,setUseCardViewpullRef,isRefreshing,pullDistanceObjectGridcalls the three hooks exactly where the blocks stood, in the same order, so the component's hook order does not change. The state the blocks read or set (rowHeightMode,refreshKey,useCardView) stays in the component, and its setters are passed in.DispatchofSetStateActionover the state's own type,onColumnStateChangeasObjectGridExternalPaginationProps['onColumnStateChange'],dataSourceasDataSource | undefined. No context and no newany; the four(schema as any).columnStatereads move as they were.columnStorageKey,setColumnState,externalColumnStateKeyandhandlePullRefreshhave no reader outside their block, so they stay inside the hooks.usePullToRefreshmoves with its only reader; thetype ObjectGridColumnStateimport specifier leavesObjectGrid.tsx(its only reader moved). Theexport type { ObjectGridColumnState, … }re-export is untouched, so the package entry and every exported name are unchanged.ObjectGrid.tsxgoes from 5250 to 5160 lines. The diff is 307 changed lines in 6 files.Move-only proof. The multiset of non-blank lines of the base
ObjectGrid.tsxequals the newObjectGrid.tsxplus the three modules. Missing: 1 line, the edited./objectGridPropsimport (it only lost thetype ObjectGridColumnStatespecifier). Added: 81 lines, all of them the three module headers and docblocks, their imports, the three hook signatures and parameter types, the tworeturn { … }lists, and inObjectGrid.tsxthe three new imports plus the three calls with their comments.No open PR touches these files. I checked the 18 open PRs at the claim: only #26556 touches plugin-grid, and only its
package.json.Why
The card's ruling, verbatim: 「大文件互踩: 立重构卡把 ObjectView 和 ObjectGrid 拆成小模块。这个可以立卡」. One move-only slice per PR, per the card's ask 1 to 5 and the hand-off notes on the card.
Tests
One test edit, path-only, forced by the move:
ui/packages/plugin-grid/src/__tests__/gridNonAuthorKeys.test.tsx: the control case "and the four keys ruled in objectui#5091 still carry theirs" now readsObjectGrid.tsxandobjectGridColumnState.tsjoined, because the NON-AUTHOR SURFACE comment oncolumnStatemoved with the seed it documents. TheonNavigate: onNavigate ?? schema.onNavigateread and its comment block stay inObjectGrid.tsx, so thegridLinesreads are unchanged. Assertions unchanged; one new path constant, one changed line.No other test reads the moved lines as source.
columnStatePersistenceandrowHeightOffSpecBoundaryare behavioural and render the realObjectGrid, so they cover the hooks. I matched every string literal of every tracked test and script against the lines that leftObjectGrid.tsx; the hits outsidegridNonAuthorKeyswere generic words (innerWidth,JSON.parse,@object-ui/mobile) in behavioural tests or in gates that scan their own surfaces, and all of those ran green below.Acceptance notes
react-hooks/set-state-in-effectonsetRowHeightModeis no longer raised, because the rule only knows setters declared byuseStatein the same function: hidden, not fixed.react-hooks/exhaustive-depsnow namessetRefreshKey(the pull-to-refreshuseCallback) andsetUseCardView(the breakpoint effect) as missing dependencies, for the same reason: a setter passed in as a hook parameter is not known to be stable. No dependency array changed. The other messages are the same findings at shifted lines or in the new module.saveColumnStatebelow" and "the seed above" inside the new module, where they remain true; they are kept verbatim.Verification
Run on head
02d40dc8:pnpm --dir ui exec vitest run packages/plugin-grid/ --maxWorkers=2under the verification lock: 253 of 253 files, 2256 of 2256 tests after the move. Before: the same command on base5cc31c78(a separate worktree, deps built): 253 of 253 files, 2256 of 2256 tests.pnpm --filter @object-ui/plugin-grid type-checkexit 0, afterturbo run build --filter='@object-ui/plugin-grid^...'(48 of 48 tasks).check:*steps plustype-check:coverage: all exit 0 (check:spec-symbolsandcheck:doc-example-readersincluded; no new local type shares a spec name, and no single-return wrapper is exported).pnpm --dir ui run check:new-line-citations: 0 new citations.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 35 derived commands, all exit 0 (pnpm --dir ui exec vitest run scripts/under the lock: 178 passed and 2 skipped files, 5065 passed and 2 skipped tests);--ranreconciles 35 of 35 (0 NOT-MEASURED, 0 UNRUN); the 18 Type Check UI commands above are recorded as outside the derivation.Changeset:
.changeset/25994-objectgrid-column-state-mobile-hooks.md(patch,@object-ui/plugin-grid).Human Minimum
packages/specholds no runtime logic. (not touched)main, one pull request.packages/specnot touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbXqCPeUA7ztE9YWKwP
Generated by Claude Code