Repository navigation
fix(fields): a failed first load of the line-item grid body recovers on the next mount - #36607
Merged
objectstack-fleet[bot] merged 4 commits intoNov 23, 2026
Merged
Conversation
Claude-Session: https://claude.ai/code/session_01ADHkmNmMEXS4EzeVz9RjvD Co-authored-by: Claude <noreply@anthropic.com>
…reload The lazy face replaces a React.lazy whose load failed, so the next mount asks the loader again; the grid form-field loader now resolves to that face. Claude-Session: https://claude.ai/code/session_01ADHkmNmMEXS4EzeVz9RjvD Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmNmMEXS4EzeVz9RjvD Co-authored-by: Claude <noreply@anthropic.com>
…React.lazy A render React discards before it commits requests nothing, so a failed load cannot retry in a loop; each later mount asks the loader again. Claude-Session: https://claude.ai/code/session_01ADHkmNmMEXS4EzeVz9RjvD Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Nov 23, 2026
Contributor
Author
|
repo:objectstack#2 · os-steve · session_01ADHkmNmMEXS4EzeVz9RjvD 席位核对ACCEPT — one card, one PR, not governed (
Landing: area lands it (non-governed, under 3000 lines): ready + auto-merge. |
objectstack-fleet
Bot
deleted the
claude/issue-36451-grid-field-lazy-retry
branch
November 23, 2026 03:19
247257110
pushed a commit
to 247257110/objectstack
that referenced
this pull request
Nov 23, 2026
…l as null, reads names once per object, mutes an empty list (objectstack-ai#36616) Fixes objectstack-ai#36552 Clause-②: no Metadata-protocol: none ## 维护者速读 - 编辑带明细行表格的记录时(控制台里人员列、多选查找列),清空多选查找格现在存为空值而不是空列表;二十行的人员列从二十次读取变成一次;列表模式下空列表的破折号变灰。 - 属于明细行表格(多选、标签、人员单元格)那一批工作的收尾,替上次评审留下的四个非阻塞项收口。 - 若出错,碰到的是明细行表格里人员和查找列的名字显示或清空后的存值;改动只在表格组件内,可直接撤回这一个合并。 - 无。 Opened for `repo:objectstack#2 · os-steve · session_01ADHkmNmMEXS4EzeVz9RjvD` (area s2-A). ## What changes The editable line-item grid (`@object-ui/fields`, `GridFieldWidget`), the four items of objectstack-ai#36552: 1. **An emptied multi-record lookup cell writes `null`.** The lookup cell's `onChange` now goes through `emptyListAsNull`, the helper the multi-select, tags and people cells already use. Measured on `origin/main` at `e7399fcdb` before the change: un-picking the last record of a `lookup` column with `multiple: true` wrote `[{"products":[]}]`. 2. **Names are read once per referenced object, not once per line.** Measured on `origin/main` at `e7399fcdb`: twenty lines with a `user` column and a `lookup` column (naming two products) made **20 `findOne` on `sys_user` and 20 on `product`**, 0 `find`. Each cell is its own `LookupField`, whose hydration reads its one bare id with `findOne`. The grid now hands every people and lookup cell it draws (editable cell, the people cell's resting face and panel, the read-only table, list mode) a data source from the new `grid-field/lineReferenceReads.ts`: the page's source, with the plain by-id read (`findOne(object, id)`, no options) gathered per tick into one `find(object, { $filter: { id: { $in: ids } } })` per object, ids de-duplicated, at most 50 ids per read (`LookupField`'s own `$in` page size). Every other member, and a by-id read carrying options, passes to the page's source unchanged (bound to it). Same grid after the change: **1 `$in` read of `sys_user` (20 ids), 1 of `product` (2 ids), 0 `findOne`**, in editable, read-only and list mode. **Why not `$expand` on the child read (Prime Directive 5, SQL first):** the grid does not make that read. Its rows arrive as a value: from `MasterDetailForm`'s and `LineItemsPanel`'s reads of the child object (both in `@object-ui/plugin-form`, outside this card's file surface), or stored inline as the `grid` field's JSON, where no `$expand` reaches the ids inside. An expanded reference in a row is also what the save diff and the blank-line check would read and send back. One `$in` read per object is one SQL `IN` query, at the one place every host's rows pass through. 3. **The multi-person cell's `null` on Clear is pinned** (it was right by reading). 4. **Display leftovers.** `cellDisplayText`'s `multiselect` arm loses its unreachable empty-list return (the guard at the top already answers an empty list with the em dash). In list mode the muted class reads `isEmptyCell`, so a stored `[]` draws the em dash muted, as `null` and `''` did. Changeset: `.changeset/36552-line-item-grid-followups.md`, patch for `@object-ui/fields`. ### Read first (by risk) 1. `ui/packages/fields/src/widgets/grid-field/lineReferenceReads.ts`: the `Proxy` around the page data source, and `flush` (chunking, de-duplication, rows keyed by `id` else `_id` as `LookupField`'s own `$in` read keys them, `null` for an id the read did not return, rejection fan-out). 2. `ui/packages/fields/src/widgets/grid-field/GridFieldWidget.tsx`: the `cellSource` line and the `dataSource={cellSource}` props on the five cell sites; the lookup `onChange` hunk. 3. `ui/packages/fields/src/widgets/GridField.test.tsx`: the pins, one top-level describe at the end of the file (`line-item grid follow-ups: ... (objectstack#36552)`). ## Tests Seven pins in one top-level describe at the end of `GridField.test.tsx` (moved there from a separate file once objectstack-ai#36607 landed, per ruling record 6583487846; names and assertions unchanged): multi-record lookup un-pick writes `null`; multi-person Clear writes `null`; one `$in` read per object and zero `findOne` with all 20 names drawn, in editable, read-only and list mode; a backend answering with `_id` only still draws each name from the one read; list-mode `[]` multi-select and tags cells draw the muted em dash. <details><summary>Package runs at head fbdfc7d (after merging origin/main at ed0edb1, which brought objectstack-ai#36607)</summary> - `pnpm --filter @object-ui/fields type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`): clean. - `GridField.test.tsx` + `GridField.lookupAutofill-28245.test.tsx`: `Test Files 2 passed (2)`, `Tests 140 passed (140)`; the seven pins alone (`-t 36552`): `Tests 7 passed`. - Earlier, at 2431b1b, the whole package: `Test Files 323 passed | 1 skipped (324)`, `Tests 4897 passed | 7 skipped (4904)`. </details> <details><summary>Ablation (one leg per pinned behaviour, through scripts/ablation-replace.mjs, restored and proven)</summary> The subject is imported by relative path from source, so no `dist/` is involved. Each leg: anchor x1 to x0, blob changed, run, restore with blob == HEAD and `git diff HEAD` empty. - lookup `onChange` without `emptyListAsNull`: the multi-record lookup pin fails, 1 failed / 5 passed. - people `onWrite` without `emptyListAsNull`: the multi-person pin fails, 1 failed / 5 passed. - `cellSource` forced to `undefined` (cells read the page source directly): the three one-read pins fail, 3 failed / 3 passed. - list-mode muted test back to `null`/`''`: the muted pin fails, 1 failed / 5 passed. - (at fbdfc7d) rows keyed by `id` only: `× a backend that answers with _id only`, 1 failed / 6 passed. The first four legs ran while the pins were in their own file; the moved pins are byte-identical in name and assertion. </details> ## Acceptance notes - **Test placement.** The pins first lived in their own file because open PR objectstack-ai#36607 edited `GridField.test.tsx`; objectstack-ai#36607 has merged, so they now sit in `GridField.test.tsx` as one top-level describe (ruling record 6583487846), and the separate file is deleted. - **Reads that still go per cell.** A by-id read with options, a lookup column whose `idField` is not `id` (`LookupField` reads those with `find` on an equality filter, not `findOne`), and an id the batched read did not return (deleted or unreadable; the cell's own read gets the same answer). Out of the card's shape; noted, not changed. - **README / docs.** No sentence in `ui/packages/fields/README.md` or `content/docs/frontend/` describes the per-line read, the stored `[]` or the muted class, so none was made false; none edited. - **Seen while measuring, not changed:** a `lookup` column with `multiple: true` reads `undefined` in read-only and list mode (the two read-only `LookupField` sites pass no `multiple`), while the editable cell reads `2 selected`. Reported to the seat. ## Verification Two minutes: from `ui/`, run `pnpm --filter @object-ui/fields exec vitest run --root ../.. -t 36552 packages/fields/src/widgets/GridField.test.tsx`. Expect `Tests 7 passed`, the rest of the file skipped. Gates: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 38 families at 2b1bd44 and the same 38 at fbdfc7d; all 38 ran locally with exit 0 at each head (`--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, all with exit codes). Everything else is CI's. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmNmMEXS4EzeVz9RjvD)_ <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmNmMEXS4EzeVz9RjvD --> --------- Co-authored-by: Claude <noreply@anthropic.com>
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.
Fixes #36451
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
GridField/LineItemsField(ui/packages/fields/src/widgets/GridField.ts) no longer render the body through a module-scopeReact.lazy. A lazy component keeps its first outcome for good, a rejection included, so after one failed load of the body every later mount rethrew that failure until the page was reloaded, althoughloadGridFieldWidgetalready forgot the failure. A mount that finds the body still loading now rendersGridFieldOnceLoaded: it shows the existing loading placeholder, asks the one loader from an effect (so only a committed mount requests anything; a render React discards before commit cannot loop on a failing chunk), throws a failed load to the nearest error boundary, and the next mount asks again. A mount after the body has loaded still renders it directly in the same render;preloadGridField()is unchanged and never rejects.gridentry of the form-field loader map (ui/packages/fields/src/index.tsx) resolves to that face instead of aReact.lazyaround the body, so the registeredfield:gridwidget andgetLazyFieldWidget('grid')recover the same way. The face is already in the eager chunk (the entry exports it), so this adds no edge to the body.@object-ui/fields.Read first, by risk:
GridField.ts, theGridFieldOnceLoadedfunction: the effect-driven load, the cleanup guard, the throw of a failed outcome.index.tsx, thegridentry of the loader map.GridField.test.tsx, the newafter one failed load of the bodydescribe inside the existing lazy-face block.Tests
Two pins in the existing lazy-face block of
GridField.test.tsx: the body module is mocked to fail its first load once and then load normally; the first mount must reach the error boundary and a later mount must render the grid, once for theGridFieldface and once forgetLazyFieldWidget('grid').Premise, measured on main's code (both pins red)
GridField.tsandindex.tsxreplaced by their blobs at the branch pointe17c2ae1a(hash-verified on disk), then the pins run:Both failures: the later mount shows the boundary fallback (
grid-load-failed), neverline-items. Restored withgit checkout HEAD,git diff HEADempty, HEAD blob hashes matched.Ablation, one half at a time
index.tsxfixed: both pins red (the form-field entry reaches the reverted face).index.tsxreverted to main, face fixed: only the form-field pin red (1 failed | 1 passed).Each leg restored and verified the same way.
Package run at head 66d9f58
pnpm --dir ui exec vitest run --maxWorkers=2 packages/fields/ && pnpm --filter @object-ui/fields run type-checkunder the shared verify lock:pnpm --dir ui exec vitest run scripts/(derived gate): 172 files passed, VERDICT command-exit 0. ESLint on the three changed files: 0 errors (warnings pre-existing).Derived gates at head 66d9f58
dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 39 families; all 39 run, all exit 0,--ranreconciliation: 39 run, 0 NOT-MEASURED, 0 UNRUN. First pass:check:query-options-erasureandcheck:type-check-debthit a 300 s harness timeout andcheck:watch-hint-literalexited 1 once (cause not established); each re-run to completion, exit 0.Acceptance notes
gridfield now shows the grid's own loading placeholder (a dashed box of the header's height) while the body loads, where it showed the form's own suspense fallback before.import()again for the same chunk URL. Whether a given browser re-fetches a module whose earlier dynamic import failed is engine behaviour; the pins run under vitest/jsdom only.React.lazykeeping a failed first load until reload, holds forFieldEditWidget's date picker (measured; its datetime picker and rich-text panel are the same construction),richTextDisplay's markdown content (measured),FilterConditionCell(measured), the per-type lazy cache ofgetLazyFieldWidgetandregisterFieldfor every other type (measured fordate), andImageField's cropper dialog (same construction, not measured). None is changed here; they are listed for the seat.Verification
Two-minute check:
pnpm --dir ui exec vitest run packages/fields/src/widgets/GridField.test.tsx -t "after one failed load"from the repo root; expect2 passed.Generated by Claude Code