Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/29416-packageless-app-reads-by-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@object-ui/app-shell': patch
---

perf(app-shell): an app built in the console and a page outside the app bundle read what they name by name

Clause-②: no
Metadata-protocol: none

An app created in the console has no package, and three of its reads still downloaded a whole metadata list:

- Every route of such an app read the whole `/meta/view` list: the sidebar's capability gate composed its union of `requiresObject` names, which names other apps' objects outside this app's bundle, with their views. It now asks those names without views, as it already did outside an app, and a names-only object read composes only the views of the names its reader asked.
- An object's route read the whole object registry. It now reads the route's object, the app's `requiresObject` entries and the object's lookup targets by name; the lookup targets are asked without views. The view tabs and the view crumb keep reading their served labels from the same documents, so labels are unchanged.
- A page the app bundle does not hold (in any app) read the whole `/meta/page` list in the route, the page view and the phone title. It is now read by name, and the list is read only when the by-name answer cannot be the prefer-local pick (ADR-0048): another package's page in a packaged app, or no page at all.

Once something else has loaded a list, these readers read it and ask nothing more.
20 changes: 14 additions & 6 deletions ui/packages/app-shell/src/console/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
import { buildExpressionUser } from '../providers/expressionUser.js';
import { useTrackRouteAsRecent } from '../hooks/useTrackRouteAsRecent.js';
import { useHomePath } from '../hooks/useHomePath.js';
import { readItemPreferLocal, useReadItemsByName } from '../hooks/useObjectPresence.js';
import { useLauncherApps } from '../hooks/useLauncherApps.js';
import { useSignedInUserLocale } from '../hooks/useUserLocale.js';
import { resolveRecordFormTarget, resolveRecordFormModalLayout, resolveFormViewChrome, selectRecordFormView, resolveNavigateCreateUrl, resolveNavigateEditUrl, resolvePostCreateTarget, recordFormCreateValues, readRecordFormCreateValues, RECORD_FORM_CREATE_VALUES_STATE } from '../utils/recordFormNavigation.js';
Expand Down Expand Up @@ -343,6 +344,8 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
// objectstack#28645 — what the app bundle answers in render (null outside a
// `MetadataProvider`): the page a page route opens is read there first.
const bundledReads = useBundledReads();
// objectstack#29416 — a page the bundle does not hold is asked by name.
const readItemsByName = useReadItemsByName(metadata);
// objectui#7373 — where this file's two "you cannot be here" exits land. Both
// sit BELOW the readiness gate further down (`metadataLoading` &c), so the
// list they resolve against has settled; an app list that failed to load is
Expand Down Expand Up @@ -481,15 +484,20 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
hostRoutePaths,
(pageName) => {
// objectstack#28645 — the bundle's page when it holds this package's;
// the `/meta/page` list, prefer-local, for a page it does not hold.
// objectstack#29416 — else the page by name, prefer-local, and the
// `/meta/page` list only when the by-name answer cannot be the pick.
const bundled = bundledReads?.item('page', pageName, (activeApp as any)?._packageId);
if (bundled?.state === 'hit') return { page: bundled.value, settled: true };
if (bundled?.state === 'pending') return { page: undefined, settled: false };
const status = getTypeStatus?.('page');
return {
page: preferLocal(metadata.pages as any[], pageName, (activeApp as any)?._packageId),
settled: status === undefined || status === 'ready' || status === 'error',
};
const { item, settled } = readItemPreferLocal(
readItemsByName,
'page',
pageName,
(activeApp as any)?._packageId,
() => metadata.pages,
getTypeStatus?.('page'),
);
return { page: item, settled };
},
// objectui#13046 — a record route reads the objects its declared record
// page binds, picked from the page list as `RecordDetailView` picks it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
* one `requiresObject` entry, and `useActionModal` is mounted beside it, as
* `ConsoleShell` mounts it.
*
* CONTROLs: an app item with no package id asks the whole registry, as before,
* and so does the root of an app whose package holds no objects of its own (a
* platform app such as Setup; its object routes read by name, objectui#13046);
* a record overlay (`?recordId=`) reads the whole registry, because a record's
* An app item with no package id asks its route's names by name instead
* (objectstack#29416; it read the whole registry).
*
* CONTROLs: the root of an app whose package holds no objects of its own (a
* platform app such as Setup; its object routes read by name, objectui#13046)
* asks the whole registry, as before; a record overlay (`?recordId=`) reads the whole registry, because a record's
* related lists come from every object that points at it (since
* objectstack#27626 the drawer reads it beside the list's scope, and the list
* does not wait for it: `AppContent.recordDrawerKeepsScope-27626.test.tsx`).
Expand Down Expand Up @@ -231,14 +233,15 @@ describe('one console open asks for the app\'s objects, not the whole registry (
expect(screen.getByTestId('console-layout').getAttribute('data-chrome-objects')).toBe('crm_account,crm_contact,sys_user');
});

it('CONTROL: an app item with no package id asks the whole registry, as before', async () => {
it('an app item with no package id asks the route object and its lookup target by name, never the whole registry (objectstack#29416)', async () => {
server.apps = [{ name: 'crm', label: 'CRM', navigation: NAVIGATION }];
boot('/apps/crm/crm_account');
await waitFor(() => expect(screen.getByTestId('object-view')).toBeInTheDocument());
await waitFor(() => expect(screen.getByTestId('object-view')).toHaveTextContent('sys_user'));

expect(objectCalls()).toContain('object');
expect(objectCalls()).not.toContain('object');
expect(objectCalls().some((c) => c.startsWith('object?'))).toBe(false);
expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account,crm_contact,crm_case,sys_user');
expect(objectCalls()).toEqual(expect.arrayContaining(['object/crm_account', 'object/sys_user']));
expect(screen.getByTestId('object-view')).toHaveTextContent('crm_account');
});

it("CONTROL: the root of an app whose package holds no objects of its own reads the whole registry, and asks none by name", async () => {
Expand Down
Loading
Loading