Skip to content

Commit f9120b8

Browse files
fix(console): ask a requiresObject and a packaged app's off-package lookup target by name only once the host serves it (#34299)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9MVfcuum36AeADC9kpjLcCN)_ Fixes #34244 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:控制台对「带包应用里不在本包的查找目标」和「导航条目的 `requiresObject`」不再直接按名字读对象定义,而是先用一次 `GET /meta/object?names=` 问服务端有没有,只有存在的才按名字读。路由、侧栏闸门、视图项读取、命令面板和 `nav:menu` 积木共用同一个判断函数。 - **为什么改**:宿主没注册的对象(如免费环境的 `sys_approval_request`)按名字读,每次打开页面都会 404,cloud#4300 的 staging 噪音多半就是这个。 - **风险与回滚**:只改控制台读取顺序,不改协议。带包应用有包外目标时每个路由多一次批量请求;记录抽屉深链时包外查找目标要等整表落地才出现链接(见 Acceptance notes)。回滚即 revert 本 PR。 - **先看**:`ui/packages/app-shell/src/console/appObjectScope.ts`(`readObjectPresence`、`servedByName`)、`ui/packages/app-shell/src/hooks/useNavMemberGates.ts`(侧栏闸门改读存在性答案)、`ui/packages/app-shell/src/views/nav-menu-renderer.tsx`。 - **两分钟验证**:`cd ui && pnpm exec vitest run packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx packages/app-shell/src/console/__tests__/AppContent.packagelessReads-29416.test.tsx`,预期全部用例通过,且没有任何 `object/gone_obj`、`object/cloud_billing` 请求。 - **需要你做的**:无,席位落地。 ## What changes One rule for both app arms, in one exported helper, `readObjectPresence` (`ui/packages/app-shell/src/console/appObjectScope.ts`): a name a reader would otherwise ask by name is asked first in ONE `GET /meta/object?names=` read, which leaves an absent name out. In a packaged app the names the package list holds are registered and asked nothing more. A name joins a by-name scope only once that read answers it served (`servedByName`, the generalisation of #34188's `servedLookupTargets`, which skipped the package arm). - **Off-package lookup targets** (package arm of `readPageObjectScope` / `readObjectRouteNames`): now go through the presence read; package-held targets read as before. - **`requiresObject`** had several by-name readers, not one, so the claim's surface was amended on the card by the seat: - the route's scope (`appObjectScope.ts`, object, page, record and dashboard arms) asks only the served required names (`servedRequiredObjectNames`), and the command palette's navigation objects drop an entry object that is required and not served (`paletteObjectNames`); - the sidebar gate (`hooks/useNavMemberGates.ts`): a package-less app asks its `requiresObject` union in the one `?names=` read inside an app too (it asked by name there); a packaged app reads the same presence answer as the route for its own required names, so it still hides an entry the answer leaves out; - the served view items (`hooks/useServedViewItems.ts`, package-less arm): a required object, including an entry that opens the object it requires, is asked by name only once served; - the `nav:menu` block (`views/nav-menu-renderer.tsx`): reads the package list plus the same presence answer, never by name. - Route, gate, served view items and `nav:menu` pass the same names to the helper, so the provider's batched names scope asks them once. ### Request counts (measured, `AppContent.packagelessReads-29416` harness: real provider, `AppContent` and sidebar gate) | Route | Before (main 43dd565) | After | |:--|:--|:--| | package-less `/apps/notes/note` | 5 requests, 1 × 404 (`object/gone_obj`) | 5 requests, 0 × 404 | | packaged `/apps/app.crm/crm_account` | 3 requests, 1 × 404 | 3 requests, 0 × 404 | | packaged page `/apps/app.crm/page/crm_only` | 3 requests, 1 × 404 | 3 requests, 0 × 404 | <details><summary>Raw request sequences</summary> ```text BEFORE /apps/notes/note object/note, object/gone_obj, object?names=sys_user, object/crm_account, object/sys_user AFTER /apps/notes/note object/note, object?names=gone_obj, object?names=sys_user, object?names=crm_account, object/sys_user BEFORE /apps/app.crm/crm_account object?package=app.crm, object/sys_user, object/gone_obj AFTER /apps/app.crm/crm_account object?package=app.crm, object?names=sys_user,gone_obj, object/sys_user BEFORE /apps/app.crm/page/crm_only object?package=app.crm, object/sys_user, object/gone_obj AFTER /apps/app.crm/page/crm_only object?package=app.crm, object?names=sys_user,gone_obj, object/sys_user ``` Fixture: the harness's `CRM_APP` with the two `requiresObject` entries this PR adds (`sys_user`, `gone_obj`), both runs. </details> **One presence read or one per reader?** For one set of names, one: the route, the sidebar gate, the served view items and `nav:menu` all ask the same required names through `readObjectPresence`, and the provider asks a name of the batched scope once (the packaged rows above: one `?names=sys_user,gone_obj` serves the route and the gate). A packaged page with an off-package lookup AND an off-package `requiresObject` makes **two** presence reads (pinned in `appObjectScope-12811`): the app's required names as the package list lands, then the route object's lookup targets once its definition lands. Folding them into one would hold the sidebar gate's answer until the page's bound object answers; not done. In the package-less arm the gate asks the app list's whole `requiresObject` union (the bell's cross-app roster) while the route asks its own app's names, so the rest of the union is a separate `?names=` read (the `?names=crm_account` above). `nav:menu` sharing the request: by construction and by the fake-context pin in `pageObjectReads-12980`; NOT MEASURED against the real provider (mounting `nav:menu` needs the page renderer). ## Tests - New pins (top-level describes in existing harnesses): - `appObjectScope-12811`: "objectstack#34244 — a packaged app asks an off-package lookup target or a requiresObject by name only once it is served" (page and object route arms: no `object/sys_approval_request`, no `object/cloud_billing`, the exact two presence reads; the command palette open asks no unregistered entry object by name) + CONTROL (registered off-package `sys_user` still asked by name and in scope). - `AppContent.packagelessReads-29416` (e): in a package-less and a packaged app, `gone_obj` only in a `?names=` read and its entry hidden by the real sidebar gate; CONTROL: a registered off-package `requiresObject` is shown and asked by name. - `packagelessChromeScope-12980`: the served view items ask an entry's required object the host lacks only in the presence read. - Ablations (each mutation through `scripts/ablation-replace.mjs`, restore verified `blob == HEAD`, `git diff HEAD` empty; ui vitest reads `@object-ui/*` from `src/`, no build leg): 1. `servedByName` returns every candidate: 7 red (both 34188 pins, both new 12811 pins, 29416 (a) and both (e)). 2. gate drops the presence answer's `missing` (`useNavMemberGates.ts`): 2 red (29416 (e) packaged + its CONTROL, which waits on the hidden entry). 3. `paletteObjectNames` returns every opened object: 2 red (both palette pins). 4. served view items keep required nav objects by name (`useServedViewItems.ts`): 1 red (new chrome pin). 5. `nav:menu` drops the presence answer's `missing`: 1 red (`pageObjectReads-12980` nav:menu pin). - **Forced test edits** (declared; each is a call-sequence pin that now sees the presence read): - `appObjectScope-12811`: the card's named CONTROL `the same lookups drawn ask every target by name` flipped to `… ask every registered target by name, once one presence read has answered them`; four package-arm sequences gain `object?names=sys_user` (root prefetch, record drawer, #29551 bundled, #33343 hidden lookup); the #29551 bundled adapter double learns `options.names` (it answered a `?names=` ask as the whole list). - `AppContent.packagelessReads-29416` (a): `object/crm_account` and `object/gone_obj` no longer by-name calls (the card's flip); the ConsoleLayout mock adds a `user-entry` probe; `CRM_APP` gains two `requiresObject` entries for (e). - `AppContent.emptyPackageScope-13046` (a), (b), CONTROL; `AppContent.objectScope-12811` (2); `AppContent.packagelessRecordRelated-29552` (3); `AppContent.pageRouteObjects-12980` (b): the expected sequences gain the presence reads, and `cloud_only` moves from by-name to `?names=`. - `navGateUnionScope-12980`: (a) the union is asked in `?names=` reads, each name once, none by name; (b) rewritten from "a by-name read that fails" to "a presence read that fails leaves its entries shown" (new `failNamesRead` behaviour on the double); (c) and CONTROL (d): the off-package name in the presence read. - `packagelessChromeScope-12980` (a), `packagelessServedViews-29416`: the presence read of the required names appears in the call list. - `pageObjectReads-12980` nav:menu: the gate reads `{ packageId, views: false }` plus `{ names: ['cloud_only'], views: false, batch: true }`, never `cloud_only` by name. - `AppContent.recordDrawerKeepsScope-27626` deep link: before the held registry lands the list draws `crm_account,crm_contact`; `sys_user` joins once it lands (see Acceptance notes). - Six adapter doubles (`13046`, `packagelessRoot-29552`, `pageRouteObjects-12980`, `recordDrawerKeepsScope-27626`, `packagelessChromeScope-12980`, `packagelessServedViews-29416`) learn `options.names`, as #34188's doubles did; without it a `?names=` ask read as the whole list. - Four `AppContent.*` harnesses gain the module-top `import '@objectstack/lint';` that `check:test-source-alias` requires of an edited file reaching `AppContent`. ## Acceptance notes - **Record drawer deep link:** the provider's batched names scope waits for a whole object list already in flight rather than asking twice (`MetadataProvider.readObjectScope`). On a deep link to a drawer, the drawer starts the registry before the presence read, so a packaged list's off-package lookup target (its link in a lookup cell) now appears when the registry lands, not before; the list itself still draws on its scope before the registry. A package-less app's lookups have waited the same way since #34188. Not changed here: asking during an in-flight registry read would add a request beside it. - The package-less gate's union read moved from by-name to the one `?names=` read inside an app as well. Its old comment kept the in-app union by name so the route object's by-name read was shared with the record form (objectui#13044); the route still reads its object by name, so that sharing is unchanged. - A package-less app whose entries require the objects they open now makes one presence read for those names beside their by-name reads (`packagelessChromeScope-12980` (a): `object?names=note`). ## Verification Final head `c9f6b80b` (main `01598d93` merged in; no overlap with this diff). - Affected-test run: the 375 test files under `ui/packages/app-shell/src` and `ui/apps/console/src` that name a changed module, `requiresObject`, `readObjectScope`, `AppContent`, `ConsoleLayout`, `UnifiedSidebar`, `ObjectView` or `AppHeader`: `Test Files 375 passed (375)`, `Tests 3344 passed (3344)`, lock VERDICT command-exit 0. Narrowed from the whole package (CI's Test UI shards run it). - `@object-ui/app-shell` type-check and the 37 derived gates (`dispatch-gates --commands`, reconciled with `--ran`): verdicts in the os-dev-report on #34244. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmRxEQg2W4PJKcnZzTr)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9346353 commit f9120b8

17 files changed

Lines changed: 499 additions & 116 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+
---
4+
5+
fix(console): a packaged app's lookup targets outside its package, and an app entry's `requiresObject`, are asked by name only once the host serves them
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The console asked two kinds of object definition by name even when the host does not register the object, and each answered `404` on every open of the route.
11+
12+
- **A packaged app's lookup targets outside its package.** An object's route and a page in an app with a package asked each lookup target the package list does not hold by name (`sys_approval_request` on a Free environment). Those targets are now asked first in the one `GET /api/v1/meta/object?names=` read an app with no package already uses, which leaves an absent object out, and only the ones it serves are then read by name. A target the package list holds is read as before, with no extra request.
13+
- **An entry's `requiresObject`.** The objects an app's navigation and area entries require were asked by name, by the route's scope, the sidebar's capability gate, the served view items and the `nav:menu` block. They are now asked in the same `?names=` presence read, in one request shared by those readers; the route reads by name only the ones it answers served. The sidebar and the `nav:menu` block still hide an entry whose object the answer leaves out, and show one it serves or has not answered yet. In a packaged app the package's own objects are answered by its list and are not asked again.

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ vi.mock('@object-ui/react', async (importOriginal) => ({
9494
useMutationInvalidationBridge: () => {},
9595
}));
9696

97+
// `AppContent` reaches a dynamic `import('@objectstack/lint')` (through
98+
// `ConsoleLayout` → `DraftPreviewBar`, statically): pay its load at collection,
99+
// never inside a case's clocked window (`check:test-source-alias`).
100+
import '@objectstack/lint';
97101
import { AppContent } from '../AppContent';
98102
import { MetadataProvider } from '../../providers/MetadataProvider';
99103

@@ -145,7 +149,13 @@ function makeAdapter() {
145149
},
146150
getClient: () => ({
147151
meta: {
148-
getItems: (type: string, options?: { packageId?: string }) => {
152+
getItems: (type: string, options?: { packageId?: string; names?: readonly string[] }) => {
153+
// objectstack#34244 — the `?names=` presence read answers the asked names it holds and leaves an absent one out, as the list door does.
154+
if (options?.names) {
155+
server.calls.push(`${type}?names=${options.names.join(',')}`);
156+
const named: any[] = type === 'object' ? (OBJECTS as any[]).filter((o: any) => options.names!.includes(o.name)) : [];
157+
return Promise.resolve({ type, items: structuredClone(named) });
158+
}
149159
server.calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type);
150160
const all = type === 'object' ? OBJECTS : type === 'app' ? server.apps : type === 'page' ? server.pages : [];
151161
const items = options?.packageId ? all.filter((o: any) => o._packageId === options.packageId) : all;
@@ -227,8 +237,18 @@ describe('an object route in an app whose package holds none of its objects read
227237
await settle();
228238

229239
expect(objectCalls()[0]).toBe(`object?package=${CLOUD}`);
240+
// objectstack#34244 — the requiresObject entry and the lookup targets are
241+
// asked by name once the `?names=` presence read has answered them served.
230242
expect(sorted(objectCalls())).toEqual(
231-
sorted([`object?package=${CLOUD}`, 'object/sys_environment', 'object/sys_organization', 'object/sys_user', 'object/sys_member']),
243+
sorted([
244+
`object?package=${CLOUD}`,
245+
'object?names=sys_member',
246+
'object?names=sys_organization,sys_user',
247+
'object/sys_environment',
248+
'object/sys_organization',
249+
'object/sys_user',
250+
'object/sys_member',
251+
]),
232252
);
233253
// The sidebar's capability gate answers from the same scope.
234254
expect(screen.getByTestId('members-entry')).toHaveTextContent('true');
@@ -258,6 +278,8 @@ describe('a record route reads the objects its declared record page binds (objec
258278
expect(sorted(objectCalls())).toEqual(
259279
sorted([
260280
`object?package=${CLOUD}`,
281+
'object?names=sys_member',
282+
'object?names=sys_organization,sys_user',
261283
'object/sys_environment',
262284
'object/sys_environment_member',
263285
'object/sys_organization',
@@ -291,7 +313,8 @@ describe('CONTROLs: the shapes this card does not change ask what they asked bef
291313
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));
292314
await settle();
293315

294-
expect(objectCalls()).toEqual([`object?package=${CRM}`, 'object/sys_user']);
316+
// objectstack#34244 — the target outside the package after one presence read.
317+
expect(objectCalls()).toEqual([`object?package=${CRM}`, 'object?names=sys_user', 'object/sys_user']);
295318
});
296319

297320
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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,13 @@ describe('one console open asks for the app\'s objects, not the whole registry (
237237

238238
expect(objectCalls()).not.toContain('object');
239239
expect(objectCalls()[0]).toBe(`object?package=${CRM}`);
240-
// The route's lookup target outside the package, and the object the app's `requiresObject` entry names.
241-
expect([...objectCalls()].sort()).toEqual([`object?package=${CRM}`, 'object/cloud_only', 'object/sys_user'].sort());
240+
// The route's lookup target outside the package, and the object the app's
241+
// `requiresObject` entry names, each in a `?names=` presence read
242+
// (objectstack#34244): the unregistered `cloud_only` is never asked by
243+
// name, and the gate still hides its entry; the served `sys_user` is.
244+
expect([...objectCalls()].sort()).toEqual(
245+
[`object?package=${CRM}`, 'object?names=cloud_only', 'object?names=sys_user', 'object/sys_user'].sort(),
246+
);
242247
// The route element and the chrome are handed the scope.
243248
expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account,crm_contact,sys_user');
244249
expect(screen.getByTestId('console-layout').getAttribute('data-chrome-objects')).toBe('crm_account,crm_contact,sys_user');
@@ -250,8 +255,10 @@ describe('one console open asks for the app\'s objects, not the whole registry (
250255
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));
251256

252257
expect(objectCalls()).not.toContain('object');
253-
// objectstack#34188 — the one list-shaped read is the lookup target's presence, by name.
254-
expect(objectCalls().filter((c) => c.startsWith('object?'))).toEqual(['object?names=sys_user']);
258+
// objectstack#34188 — the list-shaped reads are presence reads: the lookup
259+
// target's, and (objectstack#34244) the `requiresObject` entry's.
260+
expect([...objectCalls().filter((c) => c.startsWith('object?'))].sort()).toEqual(['object?names=cloud_only', 'object?names=sys_user']);
261+
expect(objectCalls()).not.toContain('object/cloud_only');
255262
expect(objectCalls()).toEqual(expect.arrayContaining(['object/crm_account', 'object/sys_user']));
256263
expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account');
257264
});

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@
2424
* another package cannot be the pick, so the `/meta/page` list is read
2525
* and the app's own page is drawn; the app's own answer is taken as is;
2626
* in a package-less app the by-name answer is the first match, as the
27-
* list's pick is.
27+
* list's pick is;
28+
* (e) objectstack#34244 — an entry's `requiresObject` naming an object the
29+
* host does not register (`gone_obj`) is asked only in the one `?names=`
30+
* presence read, never by name, in a package-less app and a packaged
31+
* one, and the sidebar's gate still hides its entry on that answer.
32+
* CONTROL: a registered one outside the package (`sys_user`) is shown,
33+
* and asked by name.
2834
*/
2935

3036
import '@testing-library/jest-dom/vitest';
@@ -50,6 +56,7 @@ vi.mock('../../layout/ConsoleLayout', async () => {
5056
return (
5157
<div data-testid="console-layout">
5258
<span data-testid="gone-entry">{String(gates.checkCapability('object', 'gone_obj'))}</span>
59+
<span data-testid="user-entry">{String(gates.checkCapability('object', 'sys_user'))}</span>
5360
{children}
5461
</div>
5562
);
@@ -139,7 +146,12 @@ const NOTES_APP = {
139146
navigation: [objectEntry('note'), { id: 'nav_home', type: 'page', label: 'Home', pageName: 'notes_home' }, objectEntry('gone_obj', 'gone_obj')],
140147
};
141148
/** Another app the list carries: it requires an object outside the notes bundle. */
142-
const CRM_APP = { name: 'crm', label: 'CRM', _packageId: 'app.crm', navigation: [objectEntry('crm_account', 'crm_account')] };
149+
const CRM_APP = {
150+
name: 'crm',
151+
label: 'CRM',
152+
_packageId: 'app.crm',
153+
navigation: [objectEntry('crm_account', 'crm_account'), objectEntry('sys_user', 'sys_user'), objectEntry('gone_obj', 'gone_obj')],
154+
};
143155

144156
/** The notes app's bundle, keyed as the adapter's `AppBundleItems` keys it. */
145157
function bundleItems() {
@@ -264,7 +276,10 @@ describe('a package-less app reads what its routes name, by name (objectstack#29
264276

265277
expect(screen.getByTestId('object-view')).toHaveTextContent('note');
266278
expect(screen.getByTestId('object-view').getAttribute('data-views')).toContain('note.all');
267-
expect(byNameCalls()).toEqual(expect.arrayContaining(['object/note', 'object/sys_user', 'object/crm_account', 'object/gone_obj']));
279+
expect(byNameCalls()).toEqual(expect.arrayContaining(['object/note', 'object/sys_user']));
280+
// objectstack#34244 — the entries' required objects are asked in the presence read, never by name.
281+
expect(byNameCalls()).not.toContain('object/gone_obj');
282+
expect(byNameCalls()).not.toContain('object/crm_account');
268283
expect(listCalls()).toEqual([]);
269284
});
270285

@@ -324,3 +339,30 @@ describe('prefer-local holds for a page read by name (ADR-0048, objectstack#2941
324339
expect(listCalls()).not.toContain('page');
325340
});
326341
});
342+
343+
describe('objectstack#34244 — a requiresObject the host does not register is never asked by name', () => {
344+
const goneObjCalls = () => server.calls.filter((c) => c.includes('gone_obj'));
345+
346+
it.each([
347+
['a package-less app', '/apps/notes/note'],
348+
['a packaged app', '/apps/app.crm/crm_account'],
349+
])('(e) in %s it is asked only in the presence read, and its entry is hidden', async (_arm, url) => {
350+
boot(url);
351+
await waitFor(() => expect(screen.getByTestId('object-view')).toBeInTheDocument());
352+
await waitFor(() => expect(screen.getByTestId('gone-entry')).toHaveTextContent('false'));
353+
await new Promise((resolve) => setTimeout(resolve, 50));
354+
355+
expect(goneObjCalls().length).toBeGreaterThan(0);
356+
expect(goneObjCalls().every((c) => c.startsWith('object?names='))).toBe(true);
357+
expect(byNameCalls()).not.toContain('object/gone_obj');
358+
});
359+
360+
it('(e) CONTROL: in a packaged app a registered requiresObject outside the package is shown, and asked by name', async () => {
361+
boot('/apps/app.crm/crm_account');
362+
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));
363+
await waitFor(() => expect(screen.getByTestId('gone-entry')).toHaveTextContent('false'));
364+
365+
expect(screen.getByTestId('user-entry')).toHaveTextContent('true');
366+
expect(byNameCalls()).toContain('object/sys_user');
367+
});
368+
});

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ describe('a packaged app’s record route with no declared record page reads its
469469

470470
expect(objectCalls()).not.toContain('object');
471471
// The object of another package is answered from the bundle, asked of no route.
472-
expect(objectCalls()).toEqual(['object?package=app.crm', 'object/sys_user']);
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']);
473474
});
474475

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

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

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

563564
expect(firstRender()).toContain('sys_audit_log');
564565
expect(objectCalls()).not.toContain('object');
565-
expect(sorted(objectCalls())).toEqual(sorted(['object?package=app.crm', 'object/sys_user', 'object/sys_audit_log']));
566+
expect(sorted(objectCalls())).toEqual(sorted(['object?package=app.crm', 'object?names=sys_user', 'object/sys_user', 'object/sys_audit_log']));
566567
expect(drawnRelated()).toEqual(registryRelated('crm_account'));
567568
});
568569

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ vi.mock('@object-ui/react', async (importOriginal) => {
9595
};
9696
});
9797

98+
// `AppContent` reaches a dynamic `import('@objectstack/lint')` (through
99+
// `ConsoleLayout` → `DraftPreviewBar`, statically): pay its load at collection,
100+
// never inside a case's clocked window (`check:test-source-alias`).
101+
import '@objectstack/lint';
98102
import { AppContent } from '../AppContent';
99103
import { MetadataProvider, useMetadata } from '../../providers/MetadataProvider';
100104

@@ -176,7 +180,13 @@ function makeAdapter() {
176180
},
177181
getClient: () => ({
178182
meta: {
179-
getItems: (type: string, options?: { packageId?: string }) => {
183+
getItems: (type: string, options?: { packageId?: string; names?: readonly string[] }) => {
184+
// objectstack#34244 — the `?names=` presence read answers the asked names it holds and leaves an absent one out, as the list door does.
185+
if (options?.names) {
186+
server.calls.push(`${type}?names=${options.names.join(',')}`);
187+
const named: any[] = type === 'object' ? (OBJECTS as any[]).filter((o: any) => options.names!.includes(o.name)) : [];
188+
return Promise.resolve({ type, items: structuredClone(named) });
189+
}
180190
server.calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type);
181191
const all: Doc[] =
182192
type === 'object' ? OBJECTS : type === 'view' ? VIEWS : type === 'page' ? PAGES : type === 'app' ? [NOTES_APP, CRM_APP, LINKS_APP, HOME_FIRST_APP] : [];

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ vi.mock('@object-ui/react', async (importOriginal) => {
100100
};
101101
});
102102

103+
// `AppContent` reaches a dynamic `import('@objectstack/lint')` (through
104+
// `ConsoleLayout` → `DraftPreviewBar`, statically): pay its load at collection,
105+
// never inside a case's clocked window (`check:test-source-alias`).
106+
import '@objectstack/lint';
103107
import { AppContent } from '../AppContent';
104108
import { MetadataProvider } from '../../providers/MetadataProvider';
105109
import { useActionModal } from '../../hooks/useActionModal';
@@ -168,7 +172,13 @@ function makeAdapter() {
168172
},
169173
getClient: () => ({
170174
meta: {
171-
getItems: (type: string, options?: { packageId?: string }) => {
175+
getItems: (type: string, options?: { packageId?: string; names?: readonly string[] }) => {
176+
// objectstack#34244 — the `?names=` presence read answers the asked names it holds and leaves an absent one out, as the list door does.
177+
if (options?.names) {
178+
server.calls.push(`${type}?names=${options.names.join(',')}`);
179+
const named: any[] = type === 'object' ? (OBJECTS as any[]).filter((o: any) => options.names!.includes(o.name)) : [];
180+
return Promise.resolve({ type, items: structuredClone(named) });
181+
}
172182
server.calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type);
173183
const all = type === 'object' ? OBJECTS : type === 'app' ? server.apps : type === 'page' ? server.pages : [];
174184
const items = options?.packageId ? all.filter((o: any) => o._packageId === options.packageId) : all;
@@ -286,7 +296,11 @@ describe('a page route reads the objects its page binds, never the whole registr
286296
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));
287297
await waitFor(() => expect(screen.getByTestId('cloud-only-entry')).toHaveTextContent('false'));
288298

289-
expect([...objectCalls()].sort()).toEqual([`object?package=${CRM}`, 'object/cloud_only', 'object/sys_user'].sort());
299+
// objectstack#34244 — the `requiresObject` entry and the lookup target in
300+
// presence reads; the unregistered `cloud_only` is never asked by name.
301+
expect([...objectCalls()].sort()).toEqual(
302+
[`object?package=${CRM}`, 'object?names=cloud_only', 'object?names=sys_user', 'object/sys_user'].sort(),
303+
);
290304
});
291305

292306
it('(c) an object a block asks about outside the read set is read by name, and its link appears when it lands', async () => {

‎ui/packages/app-shell/src/console/__tests__/AppContent.recordDrawerKeepsScope-27626.test.tsx‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ vi.mock('@object-ui/react', async (importOriginal) => ({
9797
useMutationInvalidationBridge: () => {},
9898
}));
9999

100+
// `AppContent` reaches a dynamic `import('@objectstack/lint')` (through
101+
// `ConsoleLayout` → `DraftPreviewBar`, statically): pay its load at collection,
102+
// never inside a case's clocked window (`check:test-source-alias`).
103+
import '@objectstack/lint';
100104
import { AppContent } from '../AppContent';
101105
import { MetadataProvider } from '../../providers/MetadataProvider';
102106
import { useActionModal } from '../../hooks/useActionModal';
@@ -146,7 +150,13 @@ function makeAdapter() {
146150
},
147151
getClient: () => ({
148152
meta: {
149-
getItems: (type: string, options?: { packageId?: string }) => {
153+
getItems: (type: string, options?: { packageId?: string; names?: readonly string[] }) => {
154+
// objectstack#34244 — the `?names=` presence read answers the asked names it holds and leaves an absent one out, as the list door does.
155+
if (options?.names) {
156+
server.calls.push(`${type}?names=${options.names.join(',')}`);
157+
const named: any[] = type === 'object' ? (OBJECTS as any[]).filter((o: any) => options.names!.includes(o.name)) : [];
158+
return Promise.resolve({ type, items: structuredClone(named) });
159+
}
150160
server.calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type);
151161
const all = type === 'object' ? OBJECTS : type === 'app' ? server.apps : [];
152162
const items = options?.packageId ? all.filter((o: any) => o._packageId === options.packageId) : all;
@@ -288,7 +298,12 @@ describe('objectstack#27626 — a record drawer reads the registry beside the sc
288298
it('a deep link to a drawer draws the list on its scope before the registry has landed', async () => {
289299
server.holdRegistry = true;
290300
boot('/apps/crm/crm_account?recordId=r1');
291-
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent(SCOPE));
301+
// objectstack#34244 — the route's own objects draw before the registry
302+
// lands. The lookup target outside the package (`sys_user`) is asked in
303+
// the `?names=` presence read, which waits for a whole list already in
304+
// flight rather than asking twice (`MetadataProvider`), so it joins once
305+
// the registry lands; it is never asked by name.
306+
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account,crm_contact'));
292307
expect(registryReads()).toBe(1);
293308
expect(screen.getByTestId('object-view')).not.toHaveTextContent('crm_case');
294309

0 commit comments

Comments
 (0)