Skip to content

Commit 20badae

Browse files
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
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
---
5+
6+
fix(console): an object the presence read served is not read again by name
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A list page whose object has a lookup to an object outside the app's package (on the showcase, `sys_user`) asked for that object twice: first in the `GET /api/v1/meta/object?names=` presence read, which already answers with the object's definition, and then by name (`GET /api/v1/meta/object/sys_user`) about 0.7 s later. The by-name read now takes the definition from the presence read when that read served it, so the lookup target costs one request. The same holds for the objects an app's entries require (`requiresObject`) and a dashboard's widget objects, which were also asked by name after their presence read had served them.
12+
13+
What does not change: a name the presence read left out is still asked by name, so an object that is refused (`OBJECT_PACKAGE_DISABLED`) is still told apart from one that does not exist. A name the presence read has not answered yet is still asked by name. The draft preview still reads every object by name. The definition a scope holds is the same document the by-name read returned. No metadata key, value or default changes.

‎ui/packages/app-shell/src/console/__tests__/AppContent.dashboardRouteReads-28784.test.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,9 @@ describe('a dashboard route reads from the app bundle and asks its widgets\' obj
281281
// An object this runtime does not register is never asked by name: that
282282
// read answers 404 on every open (a cloud-only `requiresObject`).
283283
expect(objectCalls()).not.toContain('object/cloud_only');
284-
// A served widget object is still read by name for the route's scope.
285-
expect(objectCalls()).toContain('object/crm_case');
284+
// A served widget object joins the route's scope from that read
285+
// (objectstack#35306): it is not asked again by name.
286+
expect(objectCalls()).not.toContain('object/crm_case');
286287
expect(objectCalls()).not.toContain('object');
287288
expect(server.calls).not.toContain('dashboard');
288289
});

‎ui/packages/app-shell/src/console/__tests__/AppContent.emptyPackageScope-13046.test.tsx‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,14 @@ describe('an object route in an app whose package holds none of its objects read
240240

241241
expect(objectCalls()[0]).toBe(`object?package=${CLOUD}`);
242242
// objectstack#34244 — the requiresObject entry and the lookup targets are
243-
// asked by name once the `?names=` presence read has answered them served.
243+
// asked in `?names=` presence reads, whose served answers are their
244+
// definitions (objectstack#35306): no by-name read of any of them.
244245
expect(sorted(objectCalls())).toEqual(
245246
sorted([
246247
`object?package=${CLOUD}`,
247248
'object?names=sys_member',
248249
'object?names=sys_organization,sys_user',
249250
'object/sys_environment',
250-
'object/sys_organization',
251-
'object/sys_user',
252-
'object/sys_member',
253251
]),
254252
);
255253
// The sidebar's capability gate answers from the same scope.
@@ -284,9 +282,6 @@ describe('a record route reads the objects its declared record page binds (objec
284282
'object?names=sys_organization,sys_user',
285283
'object/sys_environment',
286284
'object/sys_environment_member',
287-
'object/sys_organization',
288-
'object/sys_user',
289-
'object/sys_member',
290285
]),
291286
);
292287
});
@@ -320,8 +315,9 @@ describe('CONTROLs: the shapes this card does not change ask what they asked bef
320315
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));
321316
await settle();
322317

323-
// objectstack#34244 — the target outside the package after one presence read.
324-
expect(objectCalls()).toEqual([`object?package=${CRM}`, 'object?names=sys_user', 'object/sys_user']);
318+
// objectstack#34244 — the target outside the package in one presence read,
319+
// whose served answer is its definition (objectstack#35306).
320+
expect(objectCalls()).toEqual([`object?package=${CRM}`, 'object?names=sys_user']);
325321
});
326322

327323
it('a record route with no declared record page reads the whole registry, and nothing by name', async () => {

‎ui/packages/app-shell/src/console/__tests__/AppContent.objectScope-12811.test.tsx‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ interface Server {
117117
calls: string[];
118118
apps: unknown[];
119119
holdByName: boolean;
120+
/** objectstack#35306 — hold the `?names=` presence reads too. */
121+
holdNames: boolean;
120122
release: () => void;
121123
}
122-
const server: Server = { calls: [], apps: [], holdByName: false, release: () => {} };
124+
const server: Server = { calls: [], apps: [], holdByName: false, holdNames: false, release: () => {} };
123125

124126
function makeAdapter() {
125127
const held: Array<() => void> = [];
@@ -143,7 +145,9 @@ function makeAdapter() {
143145
if (options?.names) {
144146
server.calls.push(`${type}?names=${options.names.join(',')}`);
145147
const named: any[] = type === 'object' ? OBJECTS.filter((o: any) => options.names!.includes(o.name)) : [];
146-
return Promise.resolve({ type, items: structuredClone(named) });
148+
const answer = { type, items: structuredClone(named) };
149+
if (!server.holdNames) return Promise.resolve(answer);
150+
return new Promise((resolve) => held.push(() => resolve(answer)));
147151
}
148152
server.calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type);
149153
const all = type === 'object' ? OBJECTS : type === 'app' ? server.apps : [];
@@ -217,6 +221,7 @@ const splashUp = () => document.querySelector('[data-boot-splash]') !== null;
217221
beforeEach(() => {
218222
server.calls = [];
219223
server.holdByName = false;
224+
server.holdNames = false;
220225
server.apps = [{ name: 'crm', label: 'CRM', _packageId: CRM, navigation: NAVIGATION }];
221226
localStorage.clear();
222227
sessionStorage.clear();
@@ -240,9 +245,10 @@ describe('one console open asks for the app\'s objects, not the whole registry (
240245
// The route's lookup target outside the package, and the object the app's
241246
// `requiresObject` entry names, each in a `?names=` presence read
242247
// (objectstack#34244): the unregistered `cloud_only` is never asked by
243-
// name, and the gate still hides its entry; the served `sys_user` is.
248+
// name, and the gate still hides its entry; the served `sys_user` is
249+
// answered by its presence read and not asked again (objectstack#35306).
244250
expect([...objectCalls()].sort()).toEqual(
245-
[`object?package=${CRM}`, 'object?names=cloud_only', 'object?names=sys_user', 'object/sys_user'].sort(),
251+
[`object?package=${CRM}`, 'object?names=cloud_only', 'object?names=sys_user'].sort(),
246252
);
247253
// The route element and the chrome are handed the scope.
248254
expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account,crm_contact,sys_user');
@@ -259,7 +265,9 @@ describe('one console open asks for the app\'s objects, not the whole registry (
259265
// target's, and (objectstack#34244) the `requiresObject` entry's.
260266
expect([...objectCalls().filter((c) => c.startsWith('object?'))].sort()).toEqual(['object?names=cloud_only', 'object?names=sys_user']);
261267
expect(objectCalls()).not.toContain('object/cloud_only');
262-
expect(objectCalls()).toEqual(expect.arrayContaining(['object/crm_account', 'object/sys_user']));
268+
// objectstack#35306 — the lookup target's presence read served it: no by-name read of it.
269+
expect(objectCalls()).toContain('object/crm_account');
270+
expect(objectCalls()).not.toContain('object/sys_user');
263271
expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account');
264272
});
265273

@@ -299,20 +307,21 @@ describe('an object outside the package is read by name, behind the skeleton (ob
299307
});
300308

301309
it('does not hold the route for its lookup targets: they are asked beside it, and the list renders meanwhile', async () => {
302-
server.holdByName = true;
310+
server.holdNames = true;
303311
boot('/apps/crm/crm_account');
304312
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account,crm_contact'));
305-
// The lookup target's by-name read goes out once its `?names=` presence
306-
// read has answered it served (objectstack#34188), a render after the
307-
// package list let the route draw: wait for that read, never assume it
308-
// went out in the same render as the list's first paint. It is held, so
309-
// the list drawn without it is still the route not waiting for it.
310-
await waitFor(() => expect(server.calls).toContain('object/sys_user'));
313+
// The lookup target is asked in a `?names=` presence read (objectstack#34188),
314+
// whose served answer is its definition (objectstack#35306): wait for that
315+
// read, never assume it went out in the same render as the list's first
316+
// paint. It is held, so the list drawn without it is still the route not
317+
// waiting for it.
318+
await waitFor(() => expect(server.calls).toContain('object?names=sys_user'));
311319
expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account,crm_contact');
312320
expect(screen.getByTestId('object-view')).not.toHaveTextContent('sys_user');
313321

314322
act(() => server.release());
315323
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));
324+
expect(server.calls).not.toContain('object/sys_user');
316325
});
317326

318327
it('after the first paint, shows the route skeleton inside the chrome, never an empty route, until it lands', async () => {

‎ui/packages/app-shell/src/console/__tests__/AppContent.packagelessReads-29416.test.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ describe('a package-less app reads what its routes name, by name (objectstack#29
276276

277277
expect(screen.getByTestId('object-view')).toHaveTextContent('note');
278278
expect(screen.getByTestId('object-view').getAttribute('data-views')).toContain('note.all');
279-
expect(byNameCalls()).toEqual(expect.arrayContaining(['object/note', 'object/sys_user']));
279+
expect(byNameCalls()).toContain('object/note');
280+
// objectstack#35306 — the lookup target's presence read served it: no by-name read of it.
281+
expect(byNameCalls()).not.toContain('object/sys_user');
280282
// objectstack#34244 — the entries' required objects are asked in the presence read, never by name.
281283
expect(byNameCalls()).not.toContain('object/gone_obj');
282284
expect(byNameCalls()).not.toContain('object/crm_account');
@@ -357,12 +359,14 @@ describe('objectstack#34244 — a requiresObject the host does not register is n
357359
expect(byNameCalls()).not.toContain('object/gone_obj');
358360
});
359361

360-
it('(e) CONTROL: in a packaged app a registered requiresObject outside the package is shown, and asked by name', async () => {
362+
it('(e) CONTROL: in a packaged app a registered requiresObject outside the package is shown, and joins the scope from the presence read', async () => {
361363
boot('/apps/app.crm/crm_account');
362364
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));
363365
await waitFor(() => expect(screen.getByTestId('gone-entry')).toHaveTextContent('false'));
364366

365367
expect(screen.getByTestId('user-entry')).toHaveTextContent('true');
366-
expect(byNameCalls()).toContain('object/sys_user');
368+
// objectstack#35306 — the presence read served it, so it is not asked again by name.
369+
expect(server.calls.filter((c) => c.startsWith('object?names=') && c.includes('sys_user')).length).toBeGreaterThan(0);
370+
expect(byNameCalls()).not.toContain('object/sys_user');
367371
});
368372
});

‎ui/packages/app-shell/src/console/__tests__/AppContent.packagelessRecordRelated-29552.test.tsx‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ describe('a package-less app’s record route with no declared record page reads
327327
await settle();
328328

329329
expect(objectCalls()).not.toContain('object');
330-
// Every bundled object is answered from the bundle; the lookup target outside it is asked by name.
331-
expect(objectCalls()).toEqual(['object?names=sys_user', 'object/sys_user']);
330+
// Every bundled object is answered from the bundle; the lookup target outside it by the
331+
// presence read that served it (objectstack#35306), with no by-name read.
332+
expect(objectCalls()).toEqual(['object?names=sys_user']);
332333
expect(sorted((screen.getByTestId('record-view').textContent ?? '').split(','))).toEqual(
333334
sorted(['crm_account', 'crm_activity', 'crm_contact', 'crm_lead', 'crm_opportunity', 'sys_user']),
334335
);
@@ -367,7 +368,7 @@ describe('a package-less app’s record route with no declared record page reads
367368
land();
368369
await waitFor(() => expect(screen.getByTestId('record-view')).toHaveTextContent('crm_activity'));
369370
await settle();
370-
expect(objectCalls()).toEqual(['object?names=sys_user', 'object/sys_user']);
371+
expect(objectCalls()).toEqual(['object?names=sys_user']);
371372
});
372373
});
373374

@@ -469,8 +470,9 @@ describe('a packaged app’s record route with no declared record page reads its
469470

470471
expect(objectCalls()).not.toContain('object');
471472
// The object of another package is answered from the bundle, asked of no route.
472-
// objectstack#34244 — the lookup target outside the package after one presence read.
473-
expect(objectCalls()).toEqual(['object?package=app.crm', 'object?names=sys_user', 'object/sys_user']);
473+
// objectstack#34244 — the lookup target outside the package in one presence read, which
474+
// answers it (objectstack#35306).
475+
expect(objectCalls()).toEqual(['object?package=app.crm', 'object?names=sys_user']);
474476
});
475477

476478
it('draws the registry’s related lists in the registry’s order, the object of another package in its place', async () => {
@@ -505,7 +507,7 @@ describe('a packaged app’s record route with no declared record page reads its
505507
await waitFor(() => expect(screen.getByTestId('record-view')).toHaveTextContent('crm_contact'));
506508
await settle();
507509

508-
expect(objectCalls()).toEqual(['object?package=app.crm', 'object?names=sys_user', 'object/sys_user']);
510+
expect(objectCalls()).toEqual(['object?package=app.crm', 'object?names=sys_user']);
509511
expect(screen.getByTestId('record-view').textContent).not.toContain('ops_visit');
510512
});
511513

@@ -563,7 +565,7 @@ describe('a tracked object’s record route asks sys_audit_log by name (objectst
563565

564566
expect(firstRender()).toContain('sys_audit_log');
565567
expect(objectCalls()).not.toContain('object');
566-
expect(sorted(objectCalls())).toEqual(sorted(['object?package=app.crm', 'object?names=sys_user', 'object/sys_user', 'object/sys_audit_log']));
568+
expect(sorted(objectCalls())).toEqual(sorted(['object?package=app.crm', 'object?names=sys_user', 'object/sys_audit_log']));
567569
expect(drawnRelated()).toEqual(registryRelated('crm_account'));
568570
});
569571

@@ -574,7 +576,7 @@ describe('a tracked object’s record route asks sys_audit_log by name (objectst
574576

575577
expect(firstRender()).toContain('sys_audit_log');
576578
expect(objectCalls()).not.toContain('object');
577-
expect(sorted(objectCalls())).toEqual(sorted(['object?names=sys_user', 'object/sys_user', 'object/sys_audit_log']));
579+
expect(sorted(objectCalls())).toEqual(sorted(['object?names=sys_user', 'object/sys_audit_log']));
578580
expect(drawnRelated()).toEqual(registryRelated('crm_account'));
579581
});
580582

‎ui/packages/app-shell/src/console/__tests__/AppContent.packagelessRoot-29552.test.tsx‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
*
1414
* Pins:
1515
* (a) a root that stays on screen (its only entry is a link, so it has no
16-
* landing) asks the object its entry requires by name, and no list;
16+
* landing) answers the object its entry requires from the bundle, through
17+
* the presence read (objectstack#34211, objectstack#35306), and asks no list;
1718
* (b) a root whose landing is a page lands on it, and no list is asked on
1819
* the way;
1920
* (c) CONTROL: with the lists already loaded, the root asks nothing by name;
@@ -44,6 +45,7 @@ vi.mock('../../layout/ConsoleLayout', async () => {
4445
return (
4546
<div data-testid="console-layout">
4647
<span data-testid="gone-entry">{String(gates.checkCapability('object', 'gone_obj'))}</span>
48+
<span data-testid="note-entry">{String(gates.checkCapability('object', 'note'))}</span>
4749
{children}
4850
</div>
4951
);
@@ -249,6 +251,9 @@ function boot(url: string, options: { listsLoaded?: boolean } = {}) {
249251
/** The calls that read a whole list of one of the three types. */
250252
const listCalls = () => server.calls.filter((c) => c === 'object' || c === 'view' || c === 'page');
251253
const byNameCalls = () => server.calls.filter((c) => c.startsWith('object/') || c.startsWith('page/'));
254+
/** Every object read that names `note`: by name, or in a `?names=` presence read. */
255+
const noteReads = () =>
256+
server.calls.filter((c) => c === 'object/note' || (c.startsWith('object?names=') && c.slice('object?names='.length).split(',').includes('note')));
252257

253258
beforeEach(() => {
254259
server.calls = [];
@@ -263,12 +268,17 @@ afterEach(() => {
263268
});
264269

265270
describe('a package-less app’s root reads the objects it requires by name (objectstack#29552)', () => {
266-
it('(a) a root with no landing asks the object its entry requires by name, and no list', async () => {
271+
it('(a) a root with no landing answers the object its entry requires from the bundle, and asks no list', async () => {
267272
boot('/apps/links');
268273
await waitFor(() => expect(screen.getByTestId('gone-entry')).toHaveTextContent('false'));
269-
await waitFor(() => expect(byNameCalls()).toContain('object/note'));
274+
await waitFor(() => expect(screen.getByTestId('note-entry')).toHaveTextContent('true'));
270275
await new Promise((resolve) => setTimeout(resolve, 50));
271276

277+
// objectstack#34211 — the bundle holds `note`, so the presence read answers
278+
// it with no request; objectstack#35306 — and that answer is its definition,
279+
// so it is not asked by name either.
280+
expect(noteReads()).toEqual([]);
281+
272282
expect(screen.queryByTestId('object-view')).toBeNull();
273283
expect(listCalls()).toEqual([]);
274284
});
@@ -278,7 +288,9 @@ describe('a package-less app’s root reads the objects it requires by name (obj
278288
await waitFor(() => expect(screen.getByTestId('page-blocks')).toHaveTextContent('Notes home'));
279289
await waitFor(() => expect(screen.getByTestId('gone-entry')).toHaveTextContent('false'));
280290

281-
expect(byNameCalls()).toContain('object/note');
291+
// objectstack#35306 — the bundle answers it through the presence read: no request of its own.
292+
expect(screen.getByTestId('note-entry')).toHaveTextContent('true');
293+
expect(noteReads()).toEqual([]);
282294
expect(listCalls()).toEqual([]);
283295
});
284296

‎ui/packages/app-shell/src/console/__tests__/AppContent.pageRouteObjects-12980.test.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,10 @@ describe('a page route reads the objects its page binds, never the whole registr
297297
await waitFor(() => expect(screen.getByTestId('cloud-only-entry')).toHaveTextContent('false'));
298298

299299
// objectstack#34244 — the `requiresObject` entry and the lookup target in
300-
// presence reads; the unregistered `cloud_only` is never asked by name.
300+
// presence reads; the unregistered `cloud_only` is never asked by name, and
301+
// the served `sys_user` is answered by its read (objectstack#35306).
301302
expect([...objectCalls()].sort()).toEqual(
302-
[`object?package=${CRM}`, 'object?names=cloud_only', 'object?names=sys_user', 'object/sys_user'].sort(),
303+
[`object?package=${CRM}`, 'object?names=cloud_only', 'object?names=sys_user'].sort(),
303304
);
304305
});
305306

0 commit comments

Comments
 (0)