Repository navigation
Commit 20badae
fix(console): a lookup target the presence read served is not read again by name (#35398)
Fixes #35306
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:控制台列表页上,查找字段指向包外对象(showcase 上是 `sys_user`)时,`?names=`
存在性读取已经带回了对象定义,之后不再按名字(`meta/object/sys_user`)再读一次;应用导航 `requiresObject`
与仪表盘部件对象同理。
- 为什么改:卡片要求列表页对查找目标只读一次;实测 showcase 列表页同一对象先后读两次,相隔约 0.7
秒,后一次是列表页的尾部请求之一。
- 风险与回滚:只动 `MetadataProvider.readObjectScope`
一处分支,只复用存在性读取「已返回定义」的答案;被省略(不存在或被拒)的名字照旧按名字读,所以「不存在」与「被拒(OBJECT_PACKAGE_DISABLED)」的区分不变;草稿预览不复用。回滚即
revert 本 PR。
-
先看:`ui/packages/app-shell/src/providers/MetadataProvider.tsx`(`readObjectScope`
里 `presentDefinition` 分支与随后的
`bump()`),`ui/packages/app-shell/src/providers/__tests__/MetadataProvider.scopeRefusal-13052.test.tsx`(新增的拒绝边界钉子)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/providers/__tests__/MetadataProvider.scopeRefusal-13052.test.tsx
packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx`,预期
2 个文件全绿。
- 需要你做的:无,席位落地。
## What changes
**Traced first, on a real app** (showcase, `pnpm dev -- --fresh --ui` on
a private port, production console build, signed in through the login
page, headless Chromium 1440x900, one warm-up load, then a fresh page
per load; every `/api/` Resource Timing entry to network idle plus 3 s;
request initiators from the DevTools protocol).
1. **Both reads, in that order (A1 holds).** On the list page
`/apps/com.example.showcase/showcase_task`, every run sent
`meta/object?names=sys_user` and then `meta/object/sys_user`, 0.64 to
0.76 s later. Both initiator stacks run from a React render through
`appObjectScope`; the second ends in the adapter's `getObjectSchema`
(`fetchScopeName`, `readItem`).
2. **The presence answer carries everything the by-name path hands its
callers (A2 holds).** Read live from the same server and session: the
`sys_user` item in the `?names=` answer is deep-equal to `item` in the
by-name answer. The by-name envelope adds `sortability` and
`cascadeDeleteObjects`; the adapter puts both on its own copy under
symbol keys, and the provider's `cloneServedObject` (a
`structuredClone`) drops them, so no scope reader ever saw them.
Switched-off actions ride both answers (`disabledActions`, keyed by
object on the list door).
3. **The fix.** `readObjectScope`: before asking a name by name for a
scope, take the definition the batched names scope (the presence read)
already SERVED for it. Only a served answer is taken. A name the
presence read left out, has not answered yet, or failed is asked by name
exactly as before, so the by-name door stays the one authority on absent
versus refused. The draft preview never takes it. A reader that asked
the name for its side effect (a route's lookup targets) learns of it on
the render the provider's `bump()` causes, as it would on a by-name
answer landing.
4. **The same rule also answers** an app entry's `requiresObject` and a
dashboard widget's object once their presence read has served them.
Those were the same double read: on an app whose package holds no
objects of its own, three by-name reads go away (the updated pins below
show it).
5. **The ~0.7 s gap (A4).** The presence answer lands inside a long
main-thread task (390 to 468 ms, the list page's render and chunk work),
and in both instrumented runs the by-name request starts at the end of a
later render task (start 2022 ms with a task ending 2022; start 1954
with a task ending 1955). The by-name read waited for the render that
consumed the presence answer. With the read gone, that wait is gone too.
<details><summary>Readings: before (origin/main 81c0947) and after
(this branch, a949078 product code plus the bump fix)</summary>
Requests counted from navigation, chain depth = 1 + the deepest request
that ENDED before this one STARTED.
| showcase list page | before | after |
|:--|:--|:--|
| `/api/` requests per load | 26, 26, 26, 26, 26 | 25, 25, 25 |
| reads of `sys_user`'s definition | 2 (`?names=`, then by name) every
run | 1 (`?names=`) every run |
| chain depth | 11, 11, 10, 12, 10 | 11, 12, 9 |
| the card's grouping (requests that run together) | 6 | 6 |
Before, run 2:
```
L5 1214->1232 meta/object?names=sys_user
L9 1789->1858 data/showcase_task, data/sys_user/ID, data/sys_inbox_message, approvals/requests
L10 1919->1942 meta/object/sys_user
L11 2083->2108 data/sys_notification_receipt
```
After, run 1:
```
L6 927->946 meta/object?names=sys_user
L10 1334->1421 data/showcase_task, data/sys_user/ID, data/sys_inbox_message, approvals/requests
L11 1598->1623 data/sys_notification_receipt
```
Long tasks (start, duration in ms) beside the before runs: run 1
`[1235,468] [1781,71] [1865,51] [1930,92]` with the presence answer at
1259 and the by-name start at 2022; run 2 `[1286,390] [1749,65]
[1876,79]` with the presence answer at 1316 and the by-name start at
1954.
</details>
## Tests
- `MetadataProvider.scopeRefusal-13052.test.tsx`, new top-level describe
on its real-`ObjectStackAdapter` harness: a name the presence read
served joins the route scope with that definition and is asked by name
zero times; a name it left out is asked by name and its refusal is still
named `OBJECT_PACKAGE_DISABLED` (flat and wrapped envelope); CONTROL:
left out and answered 404 `RESOURCE_NOT_FOUND` is the plain absence.
- The pins that encoded the old second read now pin one read:
`appObjectScope-12811`, `AppContent.objectScope-12811` (the held-read
case now holds the presence read), `AppContent.emptyPackageScope-13046`,
`AppContent.packagelessReads-29416`,
`AppContent.packagelessRecordRelated-29552`,
`AppContent.packagelessRoot-29552` (a `note-entry` probe: the bundle
answers it through the presence read, no request),
`AppContent.pageRouteObjects-12980`,
`AppContent.dashboardRouteReads-28784`, `packagelessChromeScope-12980`.
Where a pin read the scope or the sidebar gate, it still asserts the
object arrives there; the by-name call is what is gone.
- The no-404 pins of the presence read (an unregistered lookup target or
`requiresObject` is never asked by name) pass unchanged.
<details><summary>Ablations (scripts/ablation-replace.mjs; each
restored: blob == HEAD, git diff HEAD empty)</summary>
- `if (present) {` to `if (present && false) {`: 16 failed / 21 passed
across `scopeRefusal-13052`, `appObjectScope-12811`,
`AppContent.objectScope-12811`, the new served-name pin among them.
- `if (answeredFromPresence) bump();` deleted: 2 failed / 16 passed in
`appObjectScope-12811` (`expected 'sys_invitation' to be
'sys_invitation,sys_user'`): without the bump a packageless list route
never shows the target that joined its scope.
</details>
## Acceptance notes
- **HotCRM: NOT MEASURED.** HotCRM is not in this container; a shallow
clone worked, but installing its dependencies (`pnpm install` in the
clone) was refused by the session's permission classifier, so it could
not be booted. The change is app-neutral (it keys on the presence read,
not on any object name); the showcase readings above are the measured
app.
- **The layer count does not drop on the showcase.** The by-name read
shared the trailing group with `data/sys_notification_receipt`, which
waits on `data/sys_inbox_message`, so the card's grouping stays at 6 and
the chain depth stays in its noise band (9 to 12). What goes away is one
request per load and the 0.6 to 0.8 s the page kept a request open after
its data had landed.
- The absent/refused distinction of the batched names scope is unchanged
and now pinned at the boundary this PR touches (Tests, first item). The
batched scope's own doc comment and the lookup-target comment in
`appObjectScope.ts` now say which part of its answer a route takes.
- The by-name read used to warm the adapter's own `getObjectSchema`
cache for the target as a side effect. Nothing on the list page read
that cache (the after trace has no by-name read of `sys_user` at all); a
later reader that needs the schema reads it then.
## Verification
On head `047e7f29` (`origin/main` merged; the incoming commits touch no
file of this diff; workspace rebuilt after the merge):
- `cd ui && pnpm exec vitest run packages/app-shell/src/console/
packages/app-shell/src/providers/ packages/app-shell/src/hooks/
packages/app-shell/src/views/__tests__/ apps/console/src/` under the
verify lock: Test Files 847 passed (847), Tests 7852 passed (7852);
`pnpm --filter @object-ui/app-shell run type-check`: exit 0.
- `node scripts/pm/dispatch-gates.mjs --commands` on `047e7f29`: 38
derived families, 38 run, each exit 0; `--ran` reconciliation: 38
derived, 38 run, 0 NOT-MEASURED, 0 UNRUN. `check:type-check-debt` was
re-run under the lock after its first call timed out in the queue: `OK —
0 ledger entr(ies) re-measured`. `pnpm --dir ui exec vitest run
scripts/`: Test Files 171 passed, 2 skipped. `pnpm
check:new-line-citations` (ui): 0 new citations.
- Dogfood battery: not run (no `!` in the title, no `(narrowing)` arm).
- The CI families (Lint & Repo Gates, Type Check UI, Test UI, Build &
E2E UI and the rest of the required set) are this PR's check-runs.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5f18b9b commit 20badae
15 files changed
Lines changed: 274 additions & 86 deletions
File tree
- .changeset
- ui/packages/app-shell/src
- console
- __tests__
- home/__tests__
- hooks/__tests__
- providers
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
| 244 | + | |
244 | 245 | | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | 251 | | |
254 | 252 | | |
255 | 253 | | |
| |||
284 | 282 | | |
285 | 283 | | |
286 | 284 | | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | 285 | | |
291 | 286 | | |
292 | 287 | | |
| |||
320 | 315 | | |
321 | 316 | | |
322 | 317 | | |
323 | | - | |
324 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
325 | 321 | | |
326 | 322 | | |
327 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | | - | |
| 124 | + | |
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| |||
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
147 | 151 | | |
148 | 152 | | |
149 | 153 | | |
| |||
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
| 224 | + | |
220 | 225 | | |
221 | 226 | | |
222 | 227 | | |
| |||
240 | 245 | | |
241 | 246 | | |
242 | 247 | | |
243 | | - | |
| 248 | + | |
| 249 | + | |
244 | 250 | | |
245 | | - | |
| 251 | + | |
246 | 252 | | |
247 | 253 | | |
248 | 254 | | |
| |||
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
262 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
263 | 271 | | |
264 | 272 | | |
265 | 273 | | |
| |||
299 | 307 | | |
300 | 308 | | |
301 | 309 | | |
302 | | - | |
| 310 | + | |
303 | 311 | | |
304 | 312 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
311 | 319 | | |
312 | 320 | | |
313 | 321 | | |
314 | 322 | | |
315 | 323 | | |
| 324 | + | |
316 | 325 | | |
317 | 326 | | |
318 | 327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
| |||
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
360 | | - | |
| 362 | + | |
361 | 363 | | |
362 | 364 | | |
363 | 365 | | |
364 | 366 | | |
365 | 367 | | |
366 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
367 | 371 | | |
368 | 372 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
330 | | - | |
331 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
| |||
367 | 368 | | |
368 | 369 | | |
369 | 370 | | |
370 | | - | |
| 371 | + | |
371 | 372 | | |
372 | 373 | | |
373 | 374 | | |
| |||
469 | 470 | | |
470 | 471 | | |
471 | 472 | | |
472 | | - | |
473 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
| |||
505 | 507 | | |
506 | 508 | | |
507 | 509 | | |
508 | | - | |
| 510 | + | |
509 | 511 | | |
510 | 512 | | |
511 | 513 | | |
| |||
563 | 565 | | |
564 | 566 | | |
565 | 567 | | |
566 | | - | |
| 568 | + | |
567 | 569 | | |
568 | 570 | | |
569 | 571 | | |
| |||
574 | 576 | | |
575 | 577 | | |
576 | 578 | | |
577 | | - | |
| 579 | + | |
578 | 580 | | |
579 | 581 | | |
580 | 582 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
252 | 257 | | |
253 | 258 | | |
254 | 259 | | |
| |||
263 | 268 | | |
264 | 269 | | |
265 | 270 | | |
266 | | - | |
| 271 | + | |
267 | 272 | | |
268 | 273 | | |
269 | | - | |
| 274 | + | |
270 | 275 | | |
271 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
272 | 282 | | |
273 | 283 | | |
274 | 284 | | |
| |||
278 | 288 | | |
279 | 289 | | |
280 | 290 | | |
281 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
282 | 294 | | |
283 | 295 | | |
284 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
| 301 | + | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
| |||
0 commit comments