Repository navigation
Commit 40be9b5
perf(console): opening a record re-reads no list, asks its field access once, and the bell polls once a minute (#27907)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgDFH4S5pR1C8YvYCWWsZfXx)_
## 维护者速读
- 改了什么:打开/关闭记录不再重取列表(冷:抽屉在 scope 旁读全量注册表、不再用骨架屏顶掉列表;热:列表页按值持有
`columns`/`searchableFields`);同一记录的 field-access 并发 4 次合为 1
次;铃铛与审批角标前台轮询改为 60 s,并留好"推送通道打开即停轮询"的接缝。
- 为什么改:#27626 实测每次打开、关闭记录都多一次列表查询,冷打开还多一次计数探测;field-access 同一毫秒 4 次;铃铛
10 s 一次。
- 风险与回滚:仅 ui 两个包,无协议/元数据变更;冷打开时抽屉的关联列表在全量注册表落地前只看到 scope
内对象(落地后补齐);新消息最多晚约 60 s 出现。回滚即 revert 本 PR。
- 先看:`ui/packages/app-shell/src/console/AppContent.tsx`(抽屉读注册表的位置)与
`appObjectScope.ts`,再看 `ui/packages/data-objectstack/src/index.ts` 的
`getRecordFieldAccess`。
- 两分钟验证:app-crm 列表页打开一条记录再关闭,Network 里没有 `top=50` 的列表请求、`field-access`
只有 1 次;页面静置 2 分钟,`sys_inbox_message` 只有 2 次。
- 需要你做的:无(draft,席位审核通过后再请你审;#27626 的 Acceptance 3 由 epic 席位在 console
预览复测)。
Fixes #27626
Clause-②: no
Metadata-protocol: none
## What changes
**1. Opening or closing a record re-reads no list** (Target 1)
- `console/appObjectScope.ts` — the record drawer (`?recordId=`) no
longer turns the route's object scope off. Only the record form overlay
(`?form=`, `?formObject=`) still does, as before.
- `console/AppContent.tsx` — under a drawer, the whole registry is read
beside the route's scope (`useLazyMetadataSettled('object', …)`), the
route slot never waits on it, and once it has landed it joins the scope
(`joinRegistryToScope`): the scope's documents first, by identity, then
the registry objects the scope does not hold. The drawer's related lists
still see every object, as the seat ruled. `ObjectView.tsx` is
untouched.
- `views/objectViewListRenderer.tsx` — `columns` and `searchableFields`
go through the page's existing `holdBlock` (objectui#10046's value
hold), because `ListView` names both by identity in its fetch effect
(objectui#4567 put the stabilisation at the producer). This covers any
host that hands the page new documents of equal content.
**2. One field-access request per record** (Target 2)
- `data-objectstack/src/index.ts` — `getRecordFieldAccess` shares one
in-flight request per `object::id` (the adapter's existing
`shareInFlight`), remembers a 404 as "no answer" for that record until a
write to its object, and stops asking a server that answers 501. A
settled projection is not cached: the next ask after a save reaches the
server. A write to the object (`emitMutation` → `dropInflightReads`)
drops both the shared ask and the remembered 404.
**3. The bell polls once a minute, and not at all while a push channel
is open** (Target 4, seat ruling B)
- `hooks/sharedUserFeeds.ts` — `INBOX_POLL_MS` 10 s → 60 s,
`APPROVALS_POLL_MS` 30 s → 60 s. The hidden-tab stop and the
retire/probe logic are unchanged. A package-internal seam,
`setUserFeedPushChannelOpen(open)` / `notifyUserFeedPushed(feed)`: while
a channel is open the two feeds arm no poll and read only on a push;
when it closes they read once and resume the 60 s fallback. Nothing
reports a channel today (see Acceptance notes), so the fallback is what
runs.
**Not changed**
- `security/explain` ×2 on a record open are `update` and `delete`: two
different questions, each already shared in flight and cached per
(record, operation, principal) by `useRecordEditable` (objectui#11699,
`useRecordEditable.inflightShare-11699.test.tsx`).
- Child metadata (Target 3): each related object's `meta/object/<name>`
is read once, on the first open (0 on the warm open, below). The repeat
the card measured on the cold path came from the remount in 1.
- No metadata key, nothing under `packages/spec/**` (Target 5).
## Why
Two root causes for the list re-read, measured with request logging and
render tracing in the console:
- **Cold (the first open of a session):** `?recordId=` made
`readAppObjectScope` treat the route as a non-scope route, so
`AppContent` switched from the app's object scope to the whole registry.
The registry had not been read yet, so `routeReadsSettled` went false
and `RouteMetadataSkeleton` replaced `<Routes>`: the list unmounted,
mounted again when the registry landed, and its mount fetch re-read the
rows (`top=50`) and the count (`top=0`).
- **Warm (every later open, and every close):** no skeleton, but opening
switched `allObjects` from the scope's documents to the registry's, and
closing switched back. The documents have equal content but different
identity, so the page rebuilt `schema.columns`, and `ListView`'s fetch
effect re-ran into an identical `find`.
field-access ×4: `record:details` and `record:highlights` each mount a
`RecordFieldAccessScope`, and the drawer's form and the page host ask
too; all four reach `getRecordFieldAccess` in the same tick, which had
no in-flight sharing (unlike `findOne`).
## Tests
- `views/ObjectView.objectDocSwapNoRefetch-27626.test.tsx` (new, real
`ObjectView` / `plugin-view` / `ListView`): opening and closing records
while the documents swap each time → 1 list query in total; a
content-equal swap → 0; CONTROL: a real column change still refetches.
- `console/__tests__/AppContent.recordDrawerKeepsScope-27626.test.tsx`
(new, real `MetadataProvider` + `AppContent`, whole-registry read held
open): cold open keeps the list on its scope with no skeleton and no
remount, the registry is read and joins once it lands, one document for
the list's object before/during/after; warm open asks the registry no
more; a deep link to a drawer draws the list before the registry lands;
CONTROL: `?form=` still reads the whole registry and no scope.
-
`data-objectstack/src/getRecordFieldAccess.inflightShare-27626.test.ts`
(new, real adapter and client over a held transport): 4 concurrent asks
→ 1 request; other records are other questions; a settled answer is not
remembered; a 404 is remembered per record; a 501 stops all asks; a
write drops both.
- `hooks/__tests__/sharedUserFeeds.pushChannel-27626.test.tsx` (new): no
channel → read at mount then once per 60 s, never sooner; channel open →
0 polls over 10 minutes and a push reads only its feed; channel open at
mount; channel closing → one read then 60 s; returning to the tab with
the channel open reads nothing; a push with no consumer reads nothing.
- Updated, each restating the changed behaviour: `appObjectScope-12811`
(the drawer now prefetches the list's scope; the form-overlay CONTROL
keeps "asks nothing"), `AppContent.objectScope-12811` (the overlay
CONTROL waits for the registry to join rather than for the first paint),
`sharedInboxFeed.cadence-7249`, `sharedUserFeeds.hiddenStop-12439` and
`sharedInboxFeed.transient404` (restated cadence: 60 s; the revival case
now tells a live feed from one on probes by the probe budget, since both
cadences are 60 s).
- Reverse runs: with the `holdBlock` lines reverted the doc-swap cases
read 5 and 3 list queries (asserted 1 and 1), CONTROL green; with the
`AppContent` / `appObjectScope` change reverted the three drawer cases
and the prefetch case fail (skeleton up, route element mounted twice, no
scope asked), CONTROLs green.
## Acceptance notes
- **Measured on `examples/app-crm`, not HotCRM** (deviation, accepted by
the seat): HotCRM is not in this repo's tree; app-crm is the in-repo CRM
with the same list → record drawer path. Local dev server (`objectstack
dev` + console Vite), so absolute times are dev-mode times; the counts
are what this card fixes.
- **Push channel:** there is none to subscribe to.
`page.on('websocket')` over every measured page saw only the Vite dev
server's HMR socket (`ws://localhost:<vite-port>/?token=…`, 1–2 per page
load), and discovery reports `capabilities.websockets.enabled = false`
and `services.realtime = false`; `service-realtime`'s in-memory adapter
serves no channel route. Realtime stays out of the open core per the
2026-09-04 ruling (A), so per the seat's ruling B this PR keeps polling
as the fallback at 60 s with the hidden-tab stop, and ships the "socket
open → no polling" seam pinned by tests for a host that has a channel.
Consequence: **a new inbox message or approval can show up to about 60 s
later than before (10 s / 30 s).**
- **Cold-open drawer:** before the registry lands, the drawer's related
lists are derived from the scope's objects (the app's package plus
lookup targets); objects outside it join when the registry lands. On
app-crm the related objects measured here are all in the app's package,
so nothing visibly changes; the related reads start at about the same
time as before (≈1.0–1.2 s after the click, below).
- Acceptance 3 (re-measure in the console preview) is the epic seat's,
after this PR is green.
## Verification
Same script for both columns (Playwright, signed in as the seeded
admin): open the first record's primary link from the list, wait 7 s
(`cold`), Escape and wait 4 s (`close1`), open the second record
(`warm`), Escape (`close2`). Every `/api/` request logged. `before` =
the sources at the merge base `9ae6384e`, `after` = this branch.
| phase | contact before | contact after | account before | account
after |
|---|---|---|---|---|
| cold open — total requests | 17 | 11 | 26 | 20 |
| ↳ list `top=50` / count `top=0` | 1 / 1 | 0 / 0 | 1 / 1 | 0 / 0 |
| ↳ `field-access` | 4 | 1 | 4 | 1 |
| ↳ `security/explain` (update + delete) | 2 | 2 | 2 | 2 |
| ↳ `meta/object/<child>` | 1 | 1 | 4 | 4 |
| close — total (all list) | 1 | 0 | 1 | 0 |
| warm open — total | 12 | 7 | 15 | 10 |
| ↳ list `top=50` / `field-access` | 1 / 4 | 0 / 1 | 1 / 4 | 0 / 1 |
| ↳ `meta/object/<child>` | 0 | 0 | 0 | 0 |
| close — total (all list) | 1 | 0 | 1 | 0 |
| URLs sent twice in one phase | field-access ×4 | none | field-access
×4 | none |
Bell, page left alone on the list: before, `sys_inbox_message` 6 and
`approvals/requests` 2 in 58 s; after, 2 and 2 in 125 s (at ≈33 s and
≈93 s).
<details><summary>crm_contact — before (9ae6384)</summary>
```
== cold: 17 requests, last at 5835 ms
1 54ms GET /api/v1/meta/object
1 662ms GET /api/v1/approvals/requests
1 663ms POST /api/v1/security/explain {"object":"crm_contact","operation":"update",…}
1 664ms POST /api/v1/security/explain {"object":"crm_contact","operation":"delete",…}
2 669ms GET /api/v1/data/crm_contact (top=0 count; top=1 record)
1 784ms GET /api/v1/data/crm_contact [LIST] (top=50)
1 784ms GET /api/v1/meta/object/crm_activity
4 785ms GET /api/v1/data/crm_contact/RMS_jNMhqn0Rd_Nj/field-access
1 803ms GET /api/v1/approvals/records/crm_contact/RMS_jNMhqn0Rd_Nj/lock
2 1018ms GET /api/v1/data/crm_activity
1 1433ms PATCH /api/v1/data/sys_user_preference/…
1 5835ms GET /api/v1/data/sys_inbox_message
== close1: 1 requests
1 562ms GET /api/v1/data/crm_contact [LIST]
== warm: 12 requests, last at 4505 ms
1 484ms GET /api/v1/approvals/requests
1 484ms POST /api/v1/security/explain {…"operation":"update"…}
1 485ms POST /api/v1/security/explain {…"operation":"delete"…}
1 497ms GET /api/v1/data/crm_contact [LIST]
1 497ms GET /api/v1/data/crm_contact (top=1 record)
4 553ms GET /api/v1/data/crm_contact/sC9tNijBazanHlLI/field-access
1 780ms GET /api/v1/data/crm_activity
1 1194ms PATCH /api/v1/data/sys_user_preference/…
1 4505ms GET /api/v1/data/sys_inbox_message
== close2: 1 requests
1 619ms GET /api/v1/data/crm_contact [LIST]
```
</details>
<details><summary>crm_contact — after (this branch)</summary>
```
== cold: 11 requests, last at 1470 ms
1 577ms GET /api/v1/meta/object
1 600ms GET /api/v1/approvals/requests
1 609ms POST /api/v1/security/explain {"object":"crm_contact","operation":"update",…}
1 609ms POST /api/v1/security/explain {"object":"crm_contact","operation":"delete",…}
1 610ms GET /api/v1/data/crm_contact (top=1 record)
1 696ms GET /api/v1/meta/object/crm_activity
1 698ms GET /api/v1/data/crm_contact/RMS_jNMhqn0Rd_Nj/field-access
1 737ms GET /api/v1/approvals/records/crm_contact/RMS_jNMhqn0Rd_Nj/lock
2 1074ms GET /api/v1/data/crm_activity
1 1470ms PATCH /api/v1/data/sys_user_preference/…
== close1: 0 requests
== warm: 7 requests, last at 1168 ms
1 478ms GET /api/v1/approvals/requests
1 478ms POST /api/v1/security/explain {…"operation":"update"…}
1 479ms POST /api/v1/security/explain {…"operation":"delete"…}
1 490ms GET /api/v1/data/crm_contact (top=1 record)
1 589ms GET /api/v1/data/crm_contact/sC9tNijBazanHlLI/field-access
1 777ms GET /api/v1/data/crm_activity
1 1168ms PATCH /api/v1/data/sys_user_preference/…
== close2: 0 requests
```
</details>
<details><summary>crm_account — before (9ae6384)</summary>
```
== cold: 26 requests, last at 6108 ms
1 52ms GET /api/v1/meta/object
1 593ms GET /api/v1/approvals/requests
1 595ms POST /api/v1/security/explain {…"operation":"update"…}
1 595ms POST /api/v1/security/explain {…"operation":"delete"…}
2 617ms GET /api/v1/data/crm_account (top=0 count; top=1 record)
1 773ms GET /api/v1/data/crm_account [LIST]
4 774ms GET /api/v1/meta/object/{crm_activity,crm_contact,crm_lead,crm_opportunity}
4 777ms GET /api/v1/data/crm_account/94WoprwapOuiBt6q/field-access
1 794ms GET /api/v1/approvals/records/crm_account/94WoprwapOuiBt6q/lock
8 1009ms GET /api/v1/data/{crm_activity,crm_contact,crm_lead,crm_opportunity} ×2
1 1486ms PATCH /api/v1/data/sys_user_preference/…
1 6108ms GET /api/v1/data/sys_inbox_message
== close1: 1 requests
1 606ms GET /api/v1/data/crm_account [LIST]
== warm: 15 requests, last at 4854 ms
3 480ms approvals/requests, explain update, explain delete
1 495ms GET /api/v1/data/crm_account [LIST]
1 495ms GET /api/v1/data/crm_account (top=1 record)
4 560ms GET /api/v1/data/crm_account/Nzuqe9nNMQzwpEMt/field-access
4 776ms GET /api/v1/data/{crm_activity,crm_contact,crm_lead,crm_opportunity}
1 1177ms PATCH /api/v1/data/sys_user_preference/…
1 4854ms GET /api/v1/data/sys_inbox_message
== close2: 1 requests
1 564ms GET /api/v1/data/crm_account [LIST]
```
</details>
<details><summary>crm_account — after (this branch)</summary>
```
== cold: 20 requests, last at 1749 ms
1 584ms GET /api/v1/meta/object
1 632ms GET /api/v1/approvals/requests
1 632ms POST /api/v1/security/explain {…"operation":"update"…}
1 632ms POST /api/v1/security/explain {…"operation":"delete"…}
1 643ms GET /api/v1/data/crm_account (top=1 record)
4 739ms GET /api/v1/meta/object/{crm_activity,crm_contact,crm_lead,crm_opportunity}
1 739ms GET /api/v1/data/crm_account/94WoprwapOuiBt6q/field-access
1 792ms GET /api/v1/approvals/records/crm_account/94WoprwapOuiBt6q/lock
8 1229ms GET /api/v1/data/{crm_activity,crm_contact,crm_lead,crm_opportunity} ×2
1 1749ms PATCH /api/v1/data/sys_user_preference/…
== close1: 0 requests
== warm: 10 requests, last at 1180 ms
3 506ms approvals/requests, explain update, explain delete
1 517ms GET /api/v1/data/crm_account (top=1 record)
1 606ms GET /api/v1/data/crm_account/Nzuqe9nNMQzwpEMt/field-access
4 681ms GET /api/v1/data/{crm_activity,crm_contact,crm_lead,crm_opportunity}
1 1180ms PATCH /api/v1/data/sys_user_preference/…
== close2: 0 requests
```
</details>
The two `data/<child>` reads per related object on the account's cold
open are different queries (the related list's `top=1` for the opened
record, and a `select=id` probe for another row of the list), present
before and after; no URL is sent twice in any phase after this change.
Local checks: the 35 gates `dispatch-gates --commands` derives for this
diff, each exit 0, reconciled with `--ran` (35 run, 0 not measured);
`check-sdui-manifest` exit 0; 415 test files (app-shell console, views,
feeds; all of data-objectstack): 414 passed on the full run, and the one
failure, `sharedInboxFeed.transient404` restating the 10 s cadence, is
updated above and re-run green; `@object-ui/data-objectstack` type-check
exit 0; eslint on the 14 changed TS files exit 0 (warnings only,
pre-existing kinds).
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(`packages/spec` not touched.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the changed
files.)
- [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. (Except the 维护者速读
block, which the maintainer asks for in Chinese.)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CXJLrFrzeHHa8StCja
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8a1f467 commit 40be9b5
15 files changed
Lines changed: 1183 additions & 46 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- console
- __tests__
- hooks
- __tests__
- views
- data-objectstack/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
465 | 480 | | |
466 | | - | |
| 481 | + | |
467 | 482 | | |
468 | 483 | | |
469 | 484 | | |
| |||
1941 | 1956 | | |
1942 | 1957 | | |
1943 | 1958 | | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
1944 | 1978 | | |
1945 | 1979 | | |
1946 | 1980 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
253 | 255 | | |
254 | 256 | | |
255 | 257 | | |
256 | | - | |
| 258 | + | |
257 | 259 | | |
258 | 260 | | |
259 | | - | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
| |||
0 commit comments