Skip to content

fix(fields): line-item grid stores an emptied multi-record lookup cell as null, reads names once per object, mutes an empty list - #36616

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-36552-line-item-grid-followups
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-36552-line-item-grid-followups

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #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 #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 #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.

Package runs at head fbdfc7d (after merging origin/main at ed0edb1, which brought #36607)
  • 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).
Ablation (one leg per pinned behaviour, through scripts/ablation-replace.mjs, restored and proven)

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.

Acceptance notes

  • Test placement. The pins first lived in their own file because open PR fix(fields): a failed first load of the line-item grid body recovers on the next mount #36607 edited GridField.test.tsx; fix(fields): a failed first load of the line-item grid body recovers on the next mount #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

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 23, 2026
…tsx; batched name rows keyed by id or _id

Claude-Session: https://claude.ai/code/session_01ADHkmNmMEXS4EzeVz9RjvD
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmNmMEXS4EzeVz9RjvD
L1 · 2026-11-23T04:26Z · PR #36616 @ fbdfc7d · card #36552 · area s2-A

席位核对

ACCEPT — one card, one PR, not governed (check-governed-merges.mjs: NOT governed), +351/-8 over four files, Clause-② no, Metadata-protocol none.

  1. Shape. Fixes #36552; no other card bound; files: grid-field/GridFieldWidget.tsx, new grid-field/lineReferenceReads.ts, seven pins as one top-level describe in GridField.test.tsx, one @object-ui/fields patch changeset. The claim's "pins in a new file" line is superseded: fix(fields): a failed first load of the line-item grid body recovers on the next mount #36607 merged, so the pins moved into the component's shared test file (ruling 6583487846) after a merge of main.
  2. Premise measured. On main e7399fcdb: clearing a multi-record lookup cell wrote []; 20 lines with a user column and a lookup column made 20 findOne on sys_user and 20 on the target, 0 find.
  3. Code read. (1) The editable lookup cell's onChange goes through emptyListAsNull. (2) Every people and lookup cell the grid draws (editable, people panel, read-only table, list mode) reads through lineReferenceSource(pageSource): one wrapper per page source (WeakMap), plain findOne(object, id) calls in one tick gathered into find(object, { $filter: { id: { $in } } }) chunks of 50, de-duplicated, rows keyed id ?? _id, a missing row answered null; every other member and any findOne with options passes through bound to the page source. LookupField only calls findOne when idField === 'id', so the id filter matches its callers. No page source ⇒ undefined, cells resolve their own as before. After: 1 read per object, 0 findOne, in all three modes. SQL-first was weighed: the grid's rows arrive as a value (master-detail/line-items reads outside this package, or inline JSON), so there is no grid read to $expand, and expanded rows would enter the save diff. (3) Multi-person null on clear is pinned. (4) The unreachable multiselect empty return is gone; list mode mutes via isEmptyCell, so a stored [] is muted. Ablations: each of the five legs turns exactly its pin red; restored blob equals HEAD.
  4. Gates. At this head: 45 success, 15 expected skip, 0 failed; Check Changeset re-ran after the body edit and passed before landing. Dev's 38 derived gates with 0 NOT MEASURED; @object-ui/fields type-check and the grid test files under the lock. Head is 3 behind main.
  5. Accepted deviations. The batching lives in the grid's cell data source rather than on a server read (reason in 3). The PR body carries the Chinese 维护者速读 os-dev.md asks for.
  6. Out of scope. A multiple lookup column reads "undefined" in read-only and list mode (same on main); filed by the seat as Line-item grid: a multi-value lookup column shows "undefined" in read-only and list mode (the read-only LookupField is not told the field is multiple) #36618.

Landing: area lands it (non-governed, under 3000 lines): ready + auto-merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 23, 2026 04:26
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 3110de5 Nov 23, 2026
62 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36552-line-item-grid-followups branch November 23, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line-item grid follow-ups: an emptied lookup cell writes an empty list, people names read one by one, and two display leftovers

2 participants