Repository navigation
Commit 9b6db73
feat(spec, ui): master_detail children are overview body tables by default (#35691)
Fixes #35597
Part of #35590
Clause-②: yes (widening)
Metadata-protocol: semantic
Skills-docs: follow-up owed —
skills/objectstack-data/rules/relationships.md (line 368, "Default for a
master_detail FK with inlineEdit"),
skills/objectstack-ui/evals/record-page.json ("after the first field
section")
## 维护者速读
-
用户能看到什么变化:打开带主从子表的记录(例如项目的任务),子表默认以表格出现在概览里、关键字段下方和字段分组上方;没有数据也显示表头和一行“新建”,超过十行可“显示全部”,合计由服务器按全部子记录计算。
- 为什么做:这是“记录详情页改版”史诗的子卡,落实维护者“子表放在关键字段下面”的要求,不再要求作者额外打开行内编辑才能把子表放进正文。
- 出错会怎样:原来在侧栏或标签页里的主从子表会移到概览正文;作者在关系字段上改回“侧栏列表”即可恢复原样,本次改动也可以直接撤回。
- 要你做什么:本次修订了一条架构决策记录(配置驱动的主从关系),需要你审核并合并。
## What changes
The rule (`isBodyTableRelationship`, still the one judgement):
| FK | `relatedList` | before | after |
|---|---|---|---|
| master_detail | absent, no `inlineEdit` | side list | **body table** |
| master_detail | absent, `inlineEdit` set | body table | body table |
| master_detail | `false` | hidden | hidden |
| master_detail | `true` | side list | side list |
| any | `'primary'` | body table | body table |
| lookup | absent | side list | side list |
This supersedes two rulings, by id:
- **ruling B on #27055** (implemented by #27478): the body-table
predicate was `master_detail` + `inlineEdit`. Now the relation type
decides; `inlineEdit` stays the WRITE side only (ADR-0035 §3, form
derivation untouched).
- **ADR-0035 Amendment clause (1) from #27069**. Dated amendment note in
its own commit, d4364f4
(`docs/adr/0035-config-driven-master-detail.md`, "Amended (2026-11-19,
#35597; epic #35590)"). This makes the PR Tier H.
Readers that follow the predicate, measured:
- `deriveRelatedLists` (`isPrimary`), `RecordDetailView` (`isBody`), and
the Studio inspectors. `ObjectFieldInspector` reads a plain
master_detail FK as "primary"; "Show" now writes an explicit
`relatedList: true`. `ObjectGroupInspector` now offers plain
master_detail relationships as group placements.
- `fieldGroupBodyTableRefusal`, at defineStack and the lint publish
door: **widened**. A field group may now name a plain master_detail
child. It still refuses a lookup side list, `relatedList: true`, and
`relatedList: false`.
Placement (`buildDefaultPageSchema.ts`, `bodyTablePlacement`, the
section posted on the card in comment 7023388416):
- A body table that no field group positions is drawn above the field
sections, in the parent's `relatedLists` order. That puts it under the
header strip's stage bar and key fields.
- A group-positioned table keeps its position.
- With no section at all, the details node (the highlight fields) leads.
- A body table never gets a tab or a related-column card. The drawer
uses the same synthesized page.
The body-table face (`RelatedList.tsx`):
- **Totals are server-owned** (`useBodyTableTotals`). There are two
sources:
- When the parent has a `summary` field that rolls up the same rows (no
extra filter, and the list has no own filter), its stored value is used.
- Otherwise one `dataSource.aggregate(child, { aggregations: [sum…],
where: parent scope [AND list filter] })` call. A record-mode currency
amount is grouped by its code field, and it is totalled only when one
code comes back.
- This uses the existing `POST /api/v1/data/:object/query` aggregation
path. **No new endpoint.**
- Totals are drawn as the table's own `summaryRow`. The client "Totals
(this page)" sum is gone. A data source with no `aggregate` draws no
total.
- **Row cap:** 10 by default (`BODY_TABLE_PAGE_SIZE`), and the page's
`pageSize` overrides it. Past the cap, a "Show all N" button
(`data-body-table-show-all`) replaces the pager and expands in place.
- **↗** (`data-body-table-open-list`) calls the host's `onViewAll`. That
is the existing `useOpenRecordList` path, so the child list opens under
the parent filter.
- **Empty:** the column headers plus one row
(`data-body-table-empty-row`) holding "No related records found" and a
New button. The header's New button is hidden while the table is empty.
- No new i18n keys: the existing `list.showAll`, `detail.viewAll`,
`detail.noRelatedRecords` and `form.masterDetail.total` are reused.
Authored pages (`RecordDetailView.tsx`, the ~5099 `bodyTableIds` line
only): `authoredBodyTableIds(page, relations)`, a new export of
`deriveRelatedLists.ts`, names the `record:related_list` nodes an
authored page places whose relation is a body table. Those nodes get the
body treatment: totals, the empty row, and the cap.
Examples that flip (A1): `showcase_task.project`,
`showcase_field_zoo.f_master_detail`, `showcase_project_membership.team`
and `showcase_project_membership.project`. None is a comment, attachment
or activity association. The CRM opportunity line item and the showcase
expense and invoice lines already declared `inlineEdit`, so they are
unchanged.
## Tests
<details><summary>Migrated / added / retired tests</summary>
Spec and lint:
- `packages/spec/src/data/related-list-body-table.test.ts`: verdict
cells moved to the new rule (md with no keys → body; md + `inlineEdit:
false` → body; md + `true` → side; md + `false` → none). Added a
`plainOwned` control; the refusal text was updated.
- `packages/spec/src/stack-related-lists-order.test.ts`: a plain md is
now accepted. The refusal test now covers md + `relatedList: false` and
a hidden lookup.
- `packages/lint/src/validate-related-list-refs.test.ts`: added a
plain-md group control (no finding).
`ui/packages/plugin-detail`:
- `src/__tests__/RelatedList.bodyTable-27055.test.tsx`: rewritten
against a server `aggregate` mock. It covers the server total, the total
over ALL rows at a cap of 1 of 3, show-all, ↗, the empty row, no
aggregate meaning no total, the stored roll-up versus filtered lists,
and the record-mode groupBy.
- **Retired:** "draws the full table with a totals line and no View All"
(the client sum). It is replaced by the server-total cases.
- `src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts`:
the new order (tables before the sections), plus a no-section case.
- `src/__tests__/RelatedList.parentCurrency-31912.test.tsx`: the total
now comes from an aggregate mock and is read off the summary row.
-
`src/renderers/__tests__/record-related-list.emptyFold-25895.test.tsx`:
the empty sentence and New button are read off the empty row.
- `src/__tests__/RecordPageColumns.test.tsx` (the test only;
`RecordPageColumns.tsx` is untouched): the approval-band fixture places
LINES with a field group, so the split it pins still exists.
`ui/packages/app-shell`:
- `src/utils/__tests__/deriveRelatedLists.test.ts`: md is now
`isPrimary: true`. New describe for `authoredBodyTableIds`.
-
`src/utils/__tests__/deriveRelatedLists.relatedListsOrder-27069.test.ts`:
a plain md is primary. Added the true / false / 'primary' cells.
-
`src/views/metadata-admin/inspectors/ObjectFieldInspector.relatedList-27054.test.tsx`:
- the side-card fixture declares `relatedList: true`;
- the show/hide case uses a lookup;
- new case: a plain md reads as primary and "Show" writes `true`;
- collection-time `@objectstack/formula` / `@objectstack/lint` imports
(`check:test-source-alias`).
- `src/views/RecordDetailView.harness.test.tsx`: new describe "the
relation type decides, not inlineEdit" with 3 cases. The 27241 and 27524
side-list fixtures declare `relatedList: true`.
- `src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx`,
`RecordDetailView.recordPageTiers-26678.test.tsx` and
`RecordDetailView.relatedListFilter-4664.test.tsx`: these pin side-list
mechanics (tabs, badge probes), so their md fixtures declare
`relatedList: true`.
</details>
<details><summary>Local runs at f6595c5 (and the merge 2450e9d before
it)</summary>
- spec: `vitest run` over the whole package: Test Files 952 passed,
Tests 29054 passed | 1 todo. `pnpm --filter @objectstack/spec typecheck`
passed (VERDICT command-exit 0).
- lint: `vitest run`: Test Files 221 passed, Tests 9311 passed.
- ui, the record-page set (plugin-detail whole package plus app-shell
`RecordDetailView*`, `deriveRelatedLists*`, the inspectors,
`PagePreview`, `AppContent.packagelessRecordRelated-29552`): 13 failures
after the rule change, all of them side-list fixtures. Migrated as
listed above.
- Re-run of the changed files at the final head: Test Files 88 passed,
Tests 762 passed.
- `pnpm --filter @object-ui/plugin-detail type-check` + build: exit 0.
`pnpm --filter @object-ui/app-shell type-check`: exit 0.
</details>
## Acceptance notes
- Metadata-protocol is declared `semantic`, not the claim's "widened":
the vocabulary is `added|narrowed|semantic|none`, and this is a changed
default reading of an existing key.
- These comments outside the claimed surface still describe the old
`inlineEdit` predicate. Comments only, no behaviour:
- `ObjectFieldInspector.tsx` ~2977 / ~3006;
- `ObjectGroupInspector`;
- `RecordDetailView.tsx` ~4285 (out of the claimed region);
- the liveness notes in `field.json` / `object.json`;
- lint data-model-rules.
- The published skills text needs a follow-up, as named on the
`Skills-docs:` line.
- A4, the dogfood screenshots of the built console, was **NOT
MEASURED**. Reason: a console build plus a showcase/CRM stack boot did
not fit the memory-tight shared box next to the test runs. The overview
order, the empty row, the cap, ↗, and "no tab or card" are pinned by the
harness and the RelatedList suites above. A new checklist item,
`records-forms.master-detail-body-tables`, carries the live legs.
- Checklist: added `docs/qa/platform-checklist/areas/records-forms.json`
→ `records-forms.master-detail-body-tables` (rev 1).
`records-forms.related-list-server-pagination` still holds as written:
Contacts is a lookup child.
## Browser reading (A4)
Built console, headless Chromium (Playwright), 1440x900,
deviceScaleFactor 2, light theme, one server at a time on a private
port, signed in as the seeded admin. Same data on both sides: the AFTER
sqlite file was copied for the BEFORE boot, so record ids match.
- BEFORE = `d9801038` (`origin/main` merge-base of this PR).
- AFTER = `b4ba2a6d`. Commits since then (`719ca6f5` the two-key roll-up
choice, docs, a describe pin; head now `af275005`) do not touch the
cases read here: no case below has two keys to the same parent. The
AFTER side was not re-shot on the current head.
- This supersedes the "A4 ... NOT MEASURED" note under Acceptance notes.
- HotCRM is not in this repository. The showcase and CRM examples below
stand in for it.
- Local-only data, added through the REST API: 11 extra tasks on Website
Relaunch (13 in all), "A4 Empty Team" (no memberships), "A4 Big Team"
(12 memberships), and 3 line items on "Acme — Q3 Platform Renewal".
- Images are not committed: the repo keeps no review-screenshot
convention in-tree. The 36 PNGs (18 per side, `CASE-before.png` /
`CASE-after.png`) are in the area folder
`objectstack-seat5/area-ux/ux-2/a4-35597/` on the project files mount.
| Case | Before (`d9801038`) | After (`b4ba2a6d`) | Verdict |
|---|---|---|---|
| 1. Project with tasks, `showcase_task.project` (Data Platform, 2
tasks) | Authored page (Details / Tasks / Related tabs). The task list
is in the Related tab, footer "View All". | Same tabs and placement: an
authored page keeps its own layout. The Related-tab list gets the body
face: collapse chevron and ↗ in the header, no footer. No new tab. | As
designed. The side-card-to-body flip cannot be seen on the project page,
because it is authored. |
| 1t. Synthesized page: team with memberships,
`showcase_project_membership.team` (Platform, 2) | Memberships tab plus
a side card listing "Record #id" rows. | Memberships table in the
Overview body, above the Team and Other field sections. No Memberships
tab, no rail card. All columns, ↗, New. | Flip confirmed. No duplicate
tab or rail card. |
| 2. Empty child (A4 Empty Team; Legacy Sunset project) | Team: an empty
"Memberships 0" rail card, and the tab sits behind "+1". Project Related
tab: a folded one-line "Tasks 0 · No related records found" with New in
its header. No table. | Team: body table with column headers and one
row, "No related records found" plus New. The header New is hidden.
Project Related tab: the same empty row. | Pass. |
| 3. Over 10 rows (A4 Big Team, 12; Website Relaunch, 13 tasks) | Team:
rail card with 3 rows, plus a Memberships tab. Project Related tab: 5
rows a page, a "Page 1 of 3" pager, and "View All". | Team: 10 rows and
"Show all 12". It expands in place to 12 and the button goes away.
Project Related tab: 10 rows and "Show all 13", which expands in place.
| Pass. |
| 4. CRM opportunity with line items,
`crm_opportunity_line_item.opportunity` (3 lines; `line_total` 111,000)
| Body table under the field sections (Owner ... Products Total). No
totals line. | Body table above the field sections, with a ↗ added. **No
total row.** | Placement and ↗ as designed. The missing total is
unchanged from before and is not a regression; see the note below. |
| 4s. Control: showcase expense report EXP-2001 (4 lines) | Body table
under the Report section, with the approval lock band above it. | Body
table first, with a server total "Total $1,500.50" (equal to the stored
`total_amount`) and ↗. The lock band and Report section follow. | Pass.
The server total renders. |
| 5. Record drawer (project row; team row) | Project drawer: authored
tabs, the same as the page. Team drawer: a Memberships tab, plus a
Memberships card under the fields. | Project drawer: unchanged authored
tabs; the Related tab carries the body face. Team drawer: Memberships
body table above the field sections, no tab. | Pass. The drawer uses the
same synthesized page. |
Case 4 note: the CRM line item `amount` is a currency field with no
currency of its own, and the CRM example sets no tenant default. Its
cells draw without a symbol ("6,000.00"). `useBodyTableTotals` drops a
currency column whose currency does not resolve (`if (!currency)
continue`), and it does so before the stored roll-up branch, so the
111,000 the parent already holds is not drawn. Main's client "Totals
(this page)" line had the same gate, and neither side draws a total. Not
a defect of this PR, but the expected "server total" is not visible on
this record. Whether a stored same-rows roll-up should stand without a
resolved currency is the area's call.
Page errors captured during the runs: none on either side.
## Verification
Read first, by risk:
1. `packages/spec/src/data/related-list-body-table.ts`: the three-line
predicate.
2. `ui/packages/plugin-detail/src/RelatedList.tsx` `useBodyTableTotals`:
the stored versus aggregate choice, and the groupBy for record-mode
currency.
3. `ui/packages/plugin-detail/src/synth/buildDefaultPageSchema.ts`
`bodyTablePlacement`: unplaced tables go before the sections.
Two-minute check: from `ui/`, run `pnpm exec vitest run
packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx`.
Expect every case to pass, including "the total is the server's over
EVERY row, not the rows on show".
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ)_
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CZrgaiMgTJCnswR6jQ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e75a528 commit 9b6db73
30 files changed
Lines changed: 1108 additions & 272 deletions
File tree
- .changeset
- content/docs/references
- data
- system
- docs
- adr
- qa/platform-checklist/areas
- packages
- lint/src
- metadata-protocol/src
- spec/src
- data
- ui/packages
- app-shell/src
- utils
- __tests__
- views
- metadata-admin/inspectors
- plugin-detail/src
- __tests__
- renderers/__tests__
- synth
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
0 commit comments