You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 04e7b90
Browse filesBrowse the repository at this point in the historyBrowse files
fix(components): badge page:tabs tabs whose related list binds its parent by parentDataSource (#34264)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9DWZEpY9vJu5mawox5gNXXf)_Fixes#34250
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:应用页上的 `page:tabs`,标签里的关联列表如果用 `parentDataSource`
绑定父记录,标签在打开前就显示数量徽标;列表自己把它显示的条数报给所在标签,该标签预先挂载(隐藏)。
- 为什么改:云端 Team 页的「邀请」标签发出邀请后没有数字,只有点开才看到;原因是徽标只按页面的记录去计数,应用页没有记录。
- 风险与回滚:每个这样的标签在页面加载时多读一次父记录和一页子记录(默认 5 行);记录页上没有绑定的关联列表计数方式不变。回滚即还原本
PR。
-
先看:`ui/packages/components/src/renderers/layout/containers.tsx`(哪些标签预挂载、哪些列表不再探测)、`ui/packages/plugin-detail/src/RelatedList.tsx`(上报时机)、`ui/packages/plugin-detail/src/renderers/record-related-list.tsx`(只在绑定父记录时上报)。
- 两分钟验证:`cd ui && pnpm exec vitest run
packages/plugin-detail/src/renderers/__tests__/record-related-list.parentDataSource-12294.test.tsx`,预期
16 个用例全过,其中 5 个是本卡新增。
- 需要你做的:无,席位落地。
## What changes
- `page:tabs` (`containers.tsx`): a `record:related_list` whose
`parentDataSource` is a binding (`isElementDataSourceConfig`, the
predicate `ParentRecordBinding` reads it by) is no longer probed by the
strip, and a tab that holds such a list (among the lists its gates let
the badge count) is kept mounted while inactive, the way a `list-view`
tab already is (objectstack#26613).
- `record:related_list` (`record-related-list.tsx`): when its parent is
bound by `parentDataSource`, it hands its panel's count reporter
(`usePageTabCountReporter`) to the list through a package-internal
context, `RelatedListTotalReportContext` (`relatedListCompact.ts`, not
exported from the package entry, so no public prop is added).
- `RelatedList`: reports the number its header shows (`recordCount`)
once its read has settled; a list still reading, whose read failed or
whose filter was refused says nothing.
Route: the card offered (a) resolving the probe's parent from
`parentDataSource`, or (b) the list reporting its count. (a) cannot
reuse the list's own parent read: that read is `BoundRecordProvider`,
module-private in `@object-ui/plugin-detail`, and
`@object-ui/components` cannot import from `@object-ui/plugin-detail`
(the dependency runs the other way), so (a) would mean a second
hand-written parent read beside it. (b) reuses the list's own parent
binding, scope and filter, and the #26613 force-mount gives the number
before the tab is opened.
Invalidation: there is no new `RelatedCountStore` key. A create or
delete on the child object reaches the list through the data-change bus
(`notifyDataChanged` dispatches the `objectui:related-changed` event
`RelatedList` re-reads on), and the re-read reports the new number.
Pinned below.
Unchanged: lists whose parent is the page's record are probed with the
same store keys and the same invalidation; an authored `count` on a tab
item still wins and leaves the tab mounted on open only.
## Why
The hosted console Team page (objectstack-ai/cloud#4304, item 4) is an
app page whose tabs are related lists bound to the current organization
by `parentDataSource`. The strip keyed its probe on `ctx?.recordId`,
which an app page does not have, so no badge was drawn. On a record page
the same list was probed against the page's record, which is not its
parent, so the badge counted the wrong parent's rows.
## Tests
Five pins, a new top-level `describe` in the existing harness
`record-related-list.parentDataSource-12294.test.tsx` (the REAL
`page:tabs` around the REAL block):
1. App page: the Members tab is badged `2` (the bound parent's rows)
while the first tab is still active; every child read is scoped to the
bound parent.
2. A create, then a delete, on the child object (announced through
`notifyDataChanged`) moves the badge 2 → 3 → 2.
3. An authored `count: 7` wins, and the inactive tab reads nothing (no
parent read, no child read).
4. CONTROL, record page, unbound list: exactly one child read, the
strip's `$top: 1` probe keyed on the page's record; the list is not
mounted.
5. Record page, bound list: the badge is the bound parent's count; no
child read uses the page's record.
No existing test was edited.
<details><summary>Ablations (each leg through
scripts/ablation-replace.mjs; mutation landed and restored with blob ==
HEAD)</summary>
| Leg | Mutation | Result |
|:--|:--|:--|
| 1 | `containers.tsx`: the force-mount arm for a parent-bound list
replaced by `false` | 3 failed / 13 passed (pins 1, 2, 5) |
| 2 | `containers.tsx`: the probe exclusion disabled | 1 failed / 15
passed (pin 5: badge counts the page record too) |
| 3 | `RelatedList.tsx`: the report call removed | 3 failed / 13 passed
(pins 1, 2, 5) |
| 4 | `record-related-list.tsx`: the reporter never handed down | 3
failed / 13 passed (pins 1, 2, 5) |
Vitest resolves `@object-ui/*` to source here, so each leg ran against
the mutated source with no build step.
</details>
<details><summary>Page-load cost (asked for by the seat): an app page
with two parent-bound tabs, neither opened</summary>
A throwaway harness (not committed): `page:tabs` with Overview (active),
Members (30 members) and Invitations (3 invitations), each list bound to
one `sys_organization` row by `parentDataSource`, spec default `limit`
5.
- Base `7be32d39`: 0 `find` calls, no badges.
- This head: 4 `find` calls — `sys_organization` `$top: 1` twice (each
list's parent read), `sys_member` `$top: 5` (5 rows), `sys_invitation`
`$top: 5` (3 rows); badges `Members 30`, `Invitations 3`. Plus 6
`getObjectSchema` calls (parent and child object per list, the reads the
lists make when shown).
- Route (a) would also send 2 reads per tab (a parent read and a one-row
count probe); the difference is the up-to-`limit` rows each hidden list
loads.
</details>
## Acceptance notes
- `usePageTabCountReporter` returns a fresh function each render, so the
list's report effect re-runs on each render; `report` returns the
previous state for an equal count, so it causes no extra render. Same as
the `list-view` reporter today.
- A list whose re-read fails after a success keeps its last reported
number on the badge (the reporter has no withdraw short of unmount), as
a `list-view` tab does.
- `ui` lint on the five touched files: 0 errors (warnings are
pre-existing `any` and fast-refresh notices; one new `any` in
`isParentBoundList(rl: any)`, matching the walk helpers beside it).
## Verification
Head `eb87f29c`.
<details><summary>Local runs</summary>
- `pnpm --filter @object-ui/components --filter @object-ui/plugin-detail
type-check` — exit 0 (both packages, `tsc --noEmit` and
`tsconfig.test.json`).
- `cd ui && pnpm exec vitest run packages/plugin-detail/` (whole
package) — Test Files 379 passed, 1 skipped (380); Tests 3388 passed, 18
skipped.
- `cd ui && pnpm exec vitest run` over the 26 components test files
naming `page:tabs`, `RelatedCountStore` or `usePageTabCountReporter` —
Test Files 26 passed; Tests 221 passed. The rest of
`@object-ui/components` and the app-shell consumers are left to CI's
Test UI shards (narrowed, declared).
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` — 38 derived families, each run, all exit 0;
`--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmR5vV6DUixezqnpkyP)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(components): a `page:tabs` tab holding a related list bound by `parentDataSource` shows its count badge before it is opened, on an app page too
8
+
9
+
Clause-②: no
10
+
Metadata-protocol: none
11
+
12
+
The tab strip counts a `record:related_list` by probing it against the record the page is about. An app page has no such record, so a tab whose related list reads its parent through `parentDataSource` (a team page listing members and invitations of the current organization, say) drew no badge: the number showed only inside the opened tab. On a record page the same list was probed against the page's record, which is not its parent.
13
+
14
+
Such a list now says how many records it holds to its tab, the same number its own header shows, and the strip keeps that tab mounted while inactive so the badge is there before the tab is opened. A create or delete on the listed object re-reads the list and moves the badge. Lists whose parent is the page's record are counted by the strip's own probe exactly as before, and an authored `count` on a tab still wins.
0 commit comments