Skip to content

Commit 68cee82

Browse files
perf(console): the first load stops downloading the object list, the record view and the list view package (#33677)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XQiZMH6HiMoqxNgbryZTptN)_ Part of #33581 (PR 1 of the card: the boundaries; the helper subpaths are PR 2, not this one) Clause-②: no Metadata-protocol: none Seat `domain:ui#1` · os-project-manager · card thread `session_01FEkQ5mBsWKVFHwHpfLNx3a` · claim 6889356674 ## 维护者速读 - 改了什么:控制台首次加载不再预先下载对象列表页(默认列表与保存的列表视图)、记录详情视图和 `@object-ui/plugin-list`(列表视图与画廊)。列表页改为和其它路由页一样按需加载(路由一确定就开始下载);记录详情在抽屉里第一次打开记录时才下载;`list-view`、`view:list`、`object-gallery` 三个标签改为懒加载注册。首屏脚本从 2,165,721 字节(gzip)降到 2,060,434 字节,少了约 105 KB(4.9%)。 - 为什么改:#33581 测得仪表盘等任何路由都要先下载表格、表单、记录详情等约 287 KB 才开始取数。本 PR 去掉其中能在不动共享包接口的前提下去掉的部分:`RecordDetailView` 与 `plugins-views` 两块整块离开首屏,五块合计 287,260 → 220,463 字节。 - 风险与回滚:只改加载时机,不改任何页面画什么;8 条路由在构建好的 showcase 控制台里改前改后各测一遍,全部画出、无页面错误。抽屉里第一次打开记录时多一帧详情骨架屏。`plugin-grid`、`plugin-form`、`plugin-view` 仍在首屏:它们被控制台外壳按名字导入的辅助函数拉住(拆它们要给共享包新增无副作用子路径,属 PR 2),详见 Acceptance notes。回滚即还原本 PR。 - 先看:ui/packages/app-shell/src/console/AppContent.tsx(`ObjectView` 改为 `routeChunk.lazy` 并加入预加载表)、ui/apps/console/src/register-plugins.ts(`plugin-list` 改为三条 `registerLazy`)、ui/scripts/vite-declared-lazy-views.ts(新的正控 `ConsoleLayout` 与新台账 `DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS`)。 - 两分钟验证:在 `ui/apps/console` 跑 `CI=true pnpm exec vite build`,读 `dist/eager-closure.json` 的 `eagerGzipBytes`,应约为 2,060,434;打开任一对象列表点开一条记录,抽屉正常画出详情。 - 需要你做的:无,席位落地。 ## What changes Measured first, on `origin/main` `3c0033f9`, with #33580's instrument (the console's own `vite.config.ts` run through Vite's `build()` with one read-only plugin dumping the module graph; same `eager-closure.json` as a plain build): **107 eager chunks, 2,165,721 B gzip**. The five chunks the card names: `plugin-grid` 160,144 · `plugin-form` 44,267 · `RecordDetailView` 27,317 · `plugins-views` (plugin-list + plugin-detail group) 39,465 · `plugin-view` 16,067 = **287,260 B**. Three cuts, in the order the order lists them: 1. **`ObjectView` is a route element.** `console/AppContent.tsx` declared it in its always-eager block; it is now `routeChunk.lazy(() => import('../views/ObjectView.js'))` like the other route views, and its two paths (`:objectName`, `:objectName/view/:viewId`) join `APP_ROUTE_CHUNKS`, so its chunk starts downloading as soon as the route is known, in parallel with the route's metadata reads (the existing `preloadableLazy` path). `ObjectNotFoundState`, which AppContent also draws, is imported from its own module (`views/objectViewChrome.js`) instead of through `ObjectView.js`. `ObjectView.tsx` itself is not touched. 2. **`RecordDetailView` is lazy in the record pane.** `views/objectViewRecordOverlay.tsx` imported it statically; it is now `lazy()` inside a `Suspense` whose fallback is the existing `SkeletonDetail`. With cut 1 alone the view already leaves the first load (the overlay rides in the `ObjectView` chunk); this boundary keeps it out of the list route too, so a list that never opens a record never downloads it (probe below: `list` requests no `RecordDetailView` chunk, `list-drawer` does). 3. **`plugin-list` registers lazily.** `apps/console/src/register-plugins.ts` bare-imported five plugins. Measured one at a time by dropping each import: only `@object-ui/plugin-list` moves the closure (−40,068 B, the whole `plugins-views` chunk). It now registers `list-view`, `view:list` (`skipFallback`) and `object-gallery` as `registerLazy` stubs with the namespaces the package itself registers. `plugin-grid`, `plugin-form`, `plugin-view` and `plugin-detail` stay eager imports: each is held by another eager edge (Acceptance notes), so a stub would move nothing; the order's "as far as the measure shows a closure win". `ui/scripts/vite-declared-lazy-views.ts` follows the graph: - `EAGER_WALK_CONTROL`, counter-probe 2's positive control, was `ObjectView.tsx`, which is no longer eager. It is now `packages/app-shell/src/layout/ConsoleLayout.tsx`, imported by the same always-eager block and drawn around every route. - The plugin's `missing` half fired on the cut build for `RecordDetailView.tsx` (pinned, no longer eager), so its line leaves `DECLARED_LAZY_VIEWS_STILL_EAGER`, which is now empty. - Unpinned, `RecordDetailView.tsx` would be declared `moduleSideEffects: false`, and guard 2 rightly refuses that: it bare-imports `./record-approvals-renderer.js`. A new frozen ledger, `DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS`, lists declared-lazy views the plugin weighs like the rest (eager and unpinned still fails the build) but never declares pure. The plugin refuses a stale entry (no bare side-effect import and not named in its package's `sideEffects` array). `RecordDetailView` is lazy without the declaration, measured: nothing in the eager graph reaches it but the package barrel, which the package's own `sideEffects` array already leaves shakeable. Result on the same instrument, head `b5429992` (sources identical to the measured build): **103 eager chunks, 2,060,434 B gzip, −105,287 B (−4.9%)**. The real console build (`pnpm --filter @object-ui/console build`, tsc + vite + manifest) reads 2,165,724 → 2,060,438 on the same two trees; the 3–4 B is build-to-build variance. | chunk (card) | before, B gz | after | status | |:--|--:|--:|:--| | `RecordDetailView` | 27,317 | — | **left the eager closure** | | `plugins-views` (plugin-list + detail group) | 39,465 | — | **left the eager closure** | | `plugin-grid` | 160,144 | 160,137 | eager, held elsewhere (notes) | | `plugin-form` | 44,267 | 44,270 | eager, held elsewhere (notes) | | `plugin-view` | 16,067 | 16,056 | eager, held elsewhere (notes) | | **five-chunk sum** | **287,260** | **220,463** | **−66,797** | Also left: `objectViewTitleSwitcher` (16,825), most of `index` (137,209 → 108,359), `newViewSpec`, `PageHeader`, `createDerive`, `recordDetailSections`, `MetadataInspector`, `useDatasetCatalog`, `deriveRelatedLists` and a few small ones. Seven small chunks appear (largest `studioScope` 12,223, `objectViewChrome` 5,298, `recordDrawerStack` 4,760): modules that were already eager inside `index` and the chunks that left, regrouped by rolldown, ⛔ not new first-load bytes (the total is the measure). The eager-closure gate's ceiling does not move; `BASELINE` is untouched. Changeset `.changeset/33581-console-eager-closure-list-and-record.md`: `@object-ui/console` patch (app-shell is private; the console's `dist` ships it, and `register-plugins.ts` is the console's own). ## Tests - `scripts/__tests__/vite-declared-lazy-views.test.ts` (34 tests, pass): the control is read from AppContent's `ConsoleLayout` import line; `ObjectView.tsx` is a parsed declaration (13 files, was 12); the new ledger is sorted, exists, is declared lazy, and every entry really carries a bare side-effect import and is not also pinned eager; the "every unpinned declared view is pure" pin excludes it; the attached-prose pins cover the new constant; the eager ledger records empty. - Console registry suites read `list-view` from its package now that the console registers a stub: `public-contract.test.ts` lists `list-view` among the tags reached through a pending stub; `registry-inputs-spec-parity.test.ts` and `htmlTierDataSourceInputDeclaration-6678.test.tsx` import `@object-ui/plugin-list` beside `register-plugins`, the remedy `registry-inputs-spec-parity` already uses for kanban, calendar, tree, map, gantt and timeline, and the way `dev/manifest-registry.ts` loads it before writing the published manifest. - Affected suites, from `ui/` under the lock: every `AppContent.*` suite (app-shell and console), every `ObjectView.*` suite (the record drawer opens through the lazy pane in `ObjectView.recordDrawer-27545` and the record-open pins), the four `RecordDetailView` suites that mount the overlay, and all 22 suites that import `register-plugins`: **178 files, 1886 tests**. First run: 175 files passed, 3 failed (the three registry suites above, 8 tests, all reading `list-view` as eagerly loaded); after the fix the three pass (285 tests). - `pnpm --filter @object-ui/app-shell run type-check`: exit 0. ESLint `--no-inline-config` on the eight changed source and test files: 0 errors (53 pre-existing warnings, none on a changed line). **Ablations** (`scripts/ablation-replace.mjs`, each restore proven: blob equal to HEAD, `git diff HEAD` empty): - New control: `EAGER_WALK_CONTROL` pointed back at the lazy `ObjectView.tsx` ⇒ the console build fails, `counter-probe failed: packages/app-shell/src/views/ObjectView.tsx is not in the eager closure`. The probe still fires. - Stale side-effect entry: the ledger line `RecordDetailView.tsx` replaced by the pure `ObjectView.tsx` ⇒ the build fails, `ObjectView.tsx is in DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS but carries no bare side-effect import ...`. - Record pane boundary put back to a static import ⇒ build green, closure 2,059,952 (−482 B against head: regrouping), and the graph shows `RecordDetailView` as a static import of the `ObjectView` chunk. As stated in cut 2: on the first load the record pane boundary is neutral; it is the list route's saving, which the browser probe reads. - Nothing catches the plugin-list import coming back (+40,068 B): `check:eager-closure`'s sensitivity is 695 KiB by ruling, the reading #33580 recorded. No pin is added (a new gate). ## Acceptance notes **What still holds the three remaining chunks** (module graph of the cut build, shortest eager chunk path): - `plugin-grid`: `hooks/sharedUserFeeds.ts` (reached from `ConsoleShell` → `useUserLocale` / `useHomeInbox`) imports `@object-ui/plugin-detail`, which the `plugin-grid` group captures; dropping every bare import in `register-plugins.ts` and the `dev/DevRowActions` edge too still leaves it eager. The eleven `plugin-detail` reach-ins are PR 2's. - `plugin-form`: `providers/MetadataProvider.tsx`, `console/AppContent.tsx` and `apps/console/src/components/FormPage.tsx` import named helpers from the package entry, which keeps the whole registering entry (PR 2's side-effect-free subpaths). - `plugin-view`: `console/AppContent.tsx` imports `deriveRecordSurface` / `deriveRecordFlowSurface` from the entry (PR 2). - `apps/console/src/App.tsx` imports `dev/DevRowActions.tsx` (a dev-only `/dev/row-actions` harness) statically, an `ObjectGrid` edge into `plugin-grid`. Measured inert today (−934 B when cut, because the edges above hold the chunk); it becomes a real edge once PR 2 lands. `carrier: #33581 PR 2`. - A `list-view` / `object-gallery` stub carries only the namespace and category until the package loads, so `ComponentRegistry.getConfig` answers no `inputs` for them before first use, the same as every other lazy plugin (kanban, calendar, dashboard). The published manifest is built by `dev/manifest-registry.ts`, which imports the package eagerly, so `sdui.manifest.json` is unchanged (`node scripts/check-sdui-manifest.mjs` exit 0). - The seat note to use `React.lazy` at the boundary and not a second lazy wrapper is followed: the record pane uses `React.lazy`, the route uses AppContent's own `routeChunk.lazy`; no shared `lazyPage` helper is needed. **A built console in a real browser, before and after.** Showcase built at this tree (`pnpm --filter '@objectstack/example-showcase...' build`), the console built for real (`pnpm --filter @object-ui/console build && pnpm --filter @objectstack/console build:dist`) once with the base sources (`3c0033f9`'s `ui/packages/app-shell/src`, `ui/apps/console/src`, `ui/scripts`) and once at head, each served by `pnpm dev --fresh` from `examples/app-showcase`; headless Chromium, a fresh context (cold cache) per route, signed in as the dev admin. "chunks" = which of the watched chunks the route requested. | route | before: drew · chunks | after: drew · chunks | |:--|:--|:--| | dashboard `showcase_ops_dashboard` | yes · RecordDetailView, plugins-views | yes · **none of** ObjectView, RecordDetailView, plugins-views | | list `showcase_task` | yes (10 rows) · RecordDetailView, plugins-views | yes (10 rows) · ObjectView, plugins-views; **no** RecordDetailView | | list + drawer `?recordId=` | yes, drawer open | yes, drawer open · ObjectView, plugins-views, RecordDetailView | | record page `/record/ID` | yes | yes · RecordDetailView; **no** ObjectView, plugins-views | | saved view `view/cards` (gallery, `object-gallery` stub) | yes | yes · ObjectView, plugins-views | | saved view `view/board` (kanban) | yes | yes · ObjectView, plugins-views | | Studio `/studio` | yes | yes | | Setup → Packages | yes | yes · none of the three | No page error, no console error, no failed request on any route, before or after. The page text length is identical before and after on every route that does not show a record (1638, 2092, 1643, 1812, 1147, 1092 characters); the two record routes show a different record on each run (`--fresh` seeds new ids), so their lengths differ by the record. Screenshots, `routes.json` for both runs, the probe and both `eager-closure.json` files are in the project folder `pm-orders/ui/33581-probe/`. ## Verification All on head `b5429992`. `node scripts/pm/dispatch-gates.mjs --ran` answers: 44 derived families accounted for, 44 run, 0 NOT-MEASURED. - Affected tests: 178 test files, 1886 tests pass (app-shell, console and `ui/scripts` suites touching the changed files). - `pnpm --dir ui exec vitest run scripts/` (under the shared verify lock): 171 files passed, 2 skipped; 5065 tests passed, 2 skipped. - `ui/scripts/__tests__/vite-declared-lazy-views.test.ts`: 34 passed. - app-shell type-check exit 0; ESLint on the changed files: 0 errors. - `pnpm --dir ui check:eager-closure`, `check:side-effects-array`, `check:sdui-registration-pins`, `check:eager-locale-catalogues`, `check:new-line-citations`: exit 0 each. Every derived gate command and its exit code: ```text node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-dts-emitted.mjs --self-test :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-sdui-manifest.mjs :: exit 0 node scripts/check-sdui-manifest.mjs --self-test :: exit 0 node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:dts-closure :: exit 0 pnpm check:dual-build-cjs-loads :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:lean-entry-closure :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:skill-identifier-liveness :: exit 0 pnpm check:sourcemap-no-sources-content :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 pnpm --dir ui check:eager-closure :: exit 0 pnpm --dir ui check:side-effects-array :: exit 0 pnpm --dir ui check:sdui-registration-pins :: exit 0 pnpm --dir ui check:eager-locale-catalogues :: exit 0 pnpm --dir ui check:new-line-citations :: exit 0 pnpm --dir ui exec vitest run scripts/ :: exit 0 ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5mBsWKVFHwHpfLNx3a --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5mBsWKVFHwHpfLNx3a)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent bea3328 commit 68cee82

9 files changed

Lines changed: 176 additions & 53 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/console': patch
3+
---
4+
5+
perf(console): the first load no longer downloads the object list, the record view and the list view package
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Every Console route, a dashboard included, used to download the object list (the default list and a saved list view), the record view its drawer draws, and `@object-ui/plugin-list` (the list view and the gallery) before the app asked for any data. The object list now loads like the other route pages, its download starting as soon as the route is known; the record view loads the first time a record opens in the drawer; and the `list-view`, `view:list` and `object-gallery` registrations are lazy stubs that load the package the first time a schema names one of them. The Console's eager closure (`dist/eager-closure.json`) goes from 2,165,721 to 2,060,434 bytes gzipped (−105,287). What each route draws is unchanged; a record opened in the drawer shows the detail skeleton while its code arrives.

‎ui/apps/console/src/__tests__/htmlTierDataSourceInputDeclaration-6678.test.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ import type { Diagnostic } from '@objectstack/sdui-parser';
7070

7171
// The full registration graph — the same pair `dev/manifest-dump.tsx` builds the
7272
// published artifacts from, and the pair every live-path suite in this directory
73-
// reads. `list-view` and the REAL `object-grid` both arrive through it.
73+
// reads. The REAL `object-grid` arrives through it; `list-view` is a lazy stub
74+
// there, so its package is loaded here too, the way `dev/manifest-registry.ts`
75+
// loads it before reading the published manifest.
7476
import '@object-ui/components';
7577
import '../register-plugins';
78+
import '@object-ui/plugin-list';
7679

7780
const OBJECT = 'opportunity';
7881

‎ui/apps/console/src/__tests__/public-contract.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ const EXPECTED_UNIMPLEMENTED: string[] = [];
144144
* plugins below, move that tag out of this list — it is still covered.
145145
*/
146146
const EXPECTED_LAZY = [
147+
'list-view',
147148
'object-kanban',
148149
'object-calendar',
149150
'object-gantt',

‎ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ import '@object-ui/plugin-tree';
310310
import '@object-ui/plugin-map';
311311
import '@object-ui/plugin-gantt';
312312
import '@object-ui/plugin-timeline';
313+
// The same remedy for `list-view`, which the console registers as a lazy stub
314+
// since its first load stopped carrying `@object-ui/plugin-list`
315+
// (objectstack#33581): without this import the block leaves `covered`.
316+
import '@object-ui/plugin-list';
313317

314318
/** This block's spec props schema, or `undefined` when this pin has none. */
315319
const specSchema = (type: string): unknown => (ComponentPropsMap as Record<string, unknown>)[type];

‎ui/apps/console/src/register-plugins.ts‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626
import { ComponentRegistry } from '@object-ui/core';
2727

28-
// Eager imports — core views needed on most pages. These are cheap (no heavy
29-
// 3rd-party deps) so paying their cost upfront is the right tradeoff.
28+
// Eager imports — core views the console shell itself imports by name today
29+
// (the shell's own helpers and record surfaces reach these four packages'
30+
// entries), so a lazy stub here would move nothing out of the first load.
3031
import '@object-ui/plugin-grid';
3132
import '@object-ui/plugin-form';
3233
import '@object-ui/plugin-view';
33-
import '@object-ui/plugin-list';
3434
import '@object-ui/plugin-detail';
3535

3636
// Lazy plugins — registered as deferred loaders. The first time the
@@ -42,6 +42,23 @@ import '@object-ui/plugin-detail';
4242
// A lazily-registered tag is still a full member of the public contract:
4343
// `getPublicConfigs()` resolves these stubs, so `kind:'react'` pages get them
4444
// in scope before the chunk loads (objectui#2953).
45+
// The list view and the gallery: nothing on the first load imports
46+
// `@object-ui/plugin-list` by name, so each tag it registers is a stub that
47+
// loads the package the first time a schema names it.
48+
ComponentRegistry.registerLazy('list-view', () => import('@object-ui/plugin-list'), {
49+
namespace: 'plugin-list',
50+
category: 'Views',
51+
});
52+
ComponentRegistry.registerLazy('list', () => import('@object-ui/plugin-list'), {
53+
namespace: 'view',
54+
skipFallback: true,
55+
category: 'view',
56+
});
57+
ComponentRegistry.registerLazy('object-gallery', () => import('@object-ui/plugin-list'), {
58+
namespace: 'plugin-list',
59+
category: 'view',
60+
});
61+
4562
ComponentRegistry.registerLazy('object-map', () => import('@object-ui/plugin-map'), {
4663
namespace: 'plugin-map',
4764
category: 'view',

‎ui/packages/app-shell/src/console/AppContent.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ import { ErrorBoundary } from '../chrome/ErrorBoundary.js';
5252
import { LoadingScreen } from '../chrome/LoadingScreen.js';
5353
import { BackToHomeButton, NotFoundState } from '../components/NotFoundState.js';
5454
import { RedirectWithSplash } from '../chrome/RedirectWithSplash.js';
55-
import { ObjectView } from '../views/ObjectView.js';
56-
// objectui#13052 — on its own line: the line above is the eager-walk control
57-
// `scripts/__tests__/vite-declared-lazy-views.test.ts` reads verbatim.
58-
import { ObjectNotFoundState } from '../views/ObjectView.js';
55+
// `ObjectNotFoundState` from its own module, not through `ObjectView`: the
56+
// object list is a lazy route element below, and a by-value import of its
57+
// module here would hold the whole list (and the grid it draws) eager.
58+
import { ObjectNotFoundState } from '../views/objectViewChrome.js';
5959
import { KeyboardShortcutsDialog } from '../chrome/KeyboardShortcutsDialog.js';
6060
import { OnboardingWalkthrough } from '../chrome/OnboardingWalkthrough.js';
6161
import { RouteFader } from '../chrome/RouteFader.js';
@@ -138,6 +138,10 @@ const SearchResultsPage = routeChunk.lazy(() => import('../views/SearchResultsPa
138138
const RecordFormPage = routeChunk.lazy(() => import('../views/RecordFormPage.js').then(m => m.RecordFormPage));
139139
const ComponentNavView = routeChunk.lazy(() => import('../views/ComponentNavView.js').then(m => m.ComponentNavView));
140140
const ObjectDataPage = routeChunk.lazy(() => import('../views/ObjectDataPage.js').then(m => m.ObjectDataPage));
141+
// The object list (the default list and a saved list view): a route element
142+
// like the rest, so a first load that opens a dashboard or a page does not
143+
// download the list, its record pane and the grid they draw.
144+
const ObjectView = routeChunk.lazy(() => import('../views/ObjectView.js').then(m => m.ObjectView));
141145

142146
// Metadata admin — mounted under /apps/:app/metadata for the datasource
143147
// alone (objectstack ADR-0146 D1): every other type's URL there opens Studio's
@@ -165,6 +169,8 @@ const MarketplacePackagePage = routeChunk.lazy(() => import('./marketplace/Marke
165169
* them). A path not listed renders an eagerly bundled element.
166170
*/
167171
const APP_ROUTE_CHUNKS: ReadonlyArray<{ path: string; chunk: { preload: () => Promise<unknown> } }> = [
172+
{ path: ':objectName', chunk: ObjectView },
173+
{ path: ':objectName/view/:viewId', chunk: ObjectView },
168174
{ path: ':objectName/new', chunk: RecordFormPage },
169175
{ path: ':objectName/data', chunk: ObjectDataPage },
170176
{ path: ':objectName/record/:recordId', chunk: RecordDetailView },

‎ui/packages/app-shell/src/views/objectViewRecordOverlay.tsx‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@
1818
* and its counter names the list's view (`stepScope`).
1919
*/
2020

21-
import type { ReactNode } from 'react';
21+
import { lazy, Suspense, type ReactNode } from 'react';
2222
import type { NavigationOverlayMode } from '@object-ui/components';
23-
import { RecordDetailView } from './RecordDetailView.js';
23+
import { SkeletonDetail } from '../skeletons/index.js';
2424
import { RecordStackDrawer, useRecordDrawerStack } from './recordDrawerStack.js';
2525
import type { useObjectViewRecordNavigation } from './objectViewRecordNavigation.js';
2626
import type { ConsoleObjectViewProps } from './ObjectView.js';
2727

2828
type RecordNavigation = ReturnType<typeof useObjectViewRecordNavigation>;
2929

30+
// The record view is fetched the first time a record opens here, not with the
31+
// list: a list that never opens a record never downloads it.
32+
const RecordDetailView = lazy(() => import('./RecordDetailView.js').then((m) => ({ default: m.RecordDetailView })));
33+
3034
export function ObjectViewRecordOverlay({
3135
navOverlay,
3236
mode,
@@ -74,14 +78,16 @@ export function ObjectViewRecordOverlay({
7478
storageKey={`drawer-width:${objectDef.name}`}
7579
objects={objects}
7680
renderRecord={(level) => (
77-
<RecordDetailView
78-
dataSource={dataSource}
79-
objects={objects}
80-
onEdit={onEdit}
81-
objectNameOverride={level.objectName}
82-
recordIdOverride={level.recordId}
83-
embedded
84-
/>
81+
<Suspense fallback={<SkeletonDetail />}>
82+
<RecordDetailView
83+
dataSource={dataSource}
84+
objects={objects}
85+
onEdit={onEdit}
86+
objectNameOverride={level.objectName}
87+
recordIdOverride={level.recordId}
88+
embedded
89+
/>
90+
</Suspense>
8591
)}
8692
/>
8793
);

‎ui/scripts/__tests__/vite-declared-lazy-views.test.ts‎

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { attachedDocs } from './helpers/attached-docs';
55
import {
66
APP_CONTENT_PATH,
77
DECLARED_LAZY_VIEWS_STILL_EAGER,
8+
DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS,
89
EAGER_WALK_CONTROL,
910
bareSideEffectImport,
1011
declaredSideEffectful,
@@ -53,6 +54,28 @@ describe('DECLARED_LAZY_VIEWS_STILL_EAGER', () => {
5354
});
5455
});
5556

57+
describe('DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS', () => {
58+
it('is sorted, free of duplicates, and names declared-lazy files that exist', () => {
59+
const entries = [...DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS];
60+
expect(entries).toEqual([...new Set(entries)]);
61+
expect(entries).toEqual([...entries].sort());
62+
const declared = parseDeclaredLazyViews(read(APP_CONTENT_PATH));
63+
for (const entry of entries) {
64+
expect(fs.existsSync(path.join(REPO_ROOT, entry)), entry).toBe(true);
65+
expect(declared, `${entry} is listed but no longer declared lazy`).toContain(entry);
66+
}
67+
});
68+
69+
it('lists only views that really carry a side effect, and none the eager ledger pins', () => {
70+
// The plugin refuses a stale entry at build time; this is the same claim
71+
// read from the sources, so a pure view cannot sit here undeclared.
72+
for (const entry of DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS) {
73+
expect(bareSideEffectImport(read(entry)), entry).not.toBeNull();
74+
expect(DECLARED_LAZY_VIEWS_STILL_EAGER, entry).not.toContain(entry);
75+
}
76+
});
77+
});
78+
5679
describe('parseDeclaredLazyViews', () => {
5780
it('finds every relative module AppContent declares, resolved to real files', () => {
5881
const declared = parseDeclaredLazyViews(read(APP_CONTENT_PATH));
@@ -61,15 +84,16 @@ describe('parseDeclaredLazyViews', () => {
6184
// vacuously. Eight single-file route views (objectui#6535), the
6285
// metadata-admin directory barrel that six declarations share, and the two
6386
// marketplace pages (objectui#6681 measured three; objectui#12733 retired the
64-
// Installed Apps one), and the app's report index (objectui#13020) = twelve
65-
// distinct files.
66-
expect(declared).toHaveLength(12);
87+
// Installed Apps one), the app's report index (objectui#13020) and the
88+
// object list (objectstack#33581) = thirteen distinct files.
89+
expect(declared).toHaveLength(13);
6790
for (const view of declared) {
6891
expect(fs.existsSync(path.join(REPO_ROOT, view)), view).toBe(true);
6992
}
7093
expect(declared).toContain('packages/app-shell/src/views/ObjectDataPage.tsx');
7194
expect(declared).toContain('packages/app-shell/src/views/ComponentNavView.tsx');
7295
expect(declared).toContain('packages/app-shell/src/views/AppReportIndexView.tsx');
96+
expect(declared).toContain('packages/app-shell/src/views/ObjectView.tsx');
7397
// The three surfaces objectui#6535 deliberately looked away from and
7498
// objectui#6681 measured. Named individually: a bare length assertion goes
7599
// on passing if the widened matcher swaps one surface for another.
@@ -147,8 +171,9 @@ describe('bareSideEffectImport', () => {
147171

148172
it('agrees with the real sources: every unpinned declared view is pure', () => {
149173
// The plugin declares `moduleSideEffects: false` for exactly the declared
150-
// views it has NOT pinned, so this is the claim it makes about this repo.
151-
const pinned = new Set(DECLARED_LAZY_VIEWS_STILL_EAGER);
174+
// views it has neither pinned nor listed as side-effectful, so this is the
175+
// claim it makes about this repo.
176+
const pinned = new Set([...DECLARED_LAZY_VIEWS_STILL_EAGER, ...DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS]);
152177
const declared = parseDeclaredLazyViews(read(APP_CONTENT_PATH));
153178
const unpinned = declared.filter((view) => !pinned.has(view));
154179
expect(unpinned.length).toBeGreaterThan(0);
@@ -254,7 +279,7 @@ describe('EAGER_WALK_CONTROL', () => {
254279
// means anything while AppContent still imports it outside a `lazy()`.
255280
expect(fs.existsSync(path.join(REPO_ROOT, EAGER_WALK_CONTROL))).toBe(true);
256281
const appContent = read(APP_CONTENT_PATH);
257-
expect(appContent).toContain("import { ObjectView } from '../views/ObjectView.js';");
282+
expect(appContent).toContain("import { ConsoleLayout } from '../layout/ConsoleLayout.js';");
258283
expect(parseDeclaredLazyViews(appContent)).not.toContain(EAGER_WALK_CONTROL);
259284
});
260285
});
@@ -366,19 +391,22 @@ describe('the prose attached to the exported constants (objectui#7289)', () => {
366391
APP_CONTENT_PATH,
367392
EAGER_WALK_CONTROL,
368393
DECLARED_LAZY_VIEWS_STILL_EAGER,
394+
DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS,
369395
} as const;
370396

371397
it('locates the block attached to each constant, and only that block', () => {
372398
const appContent = attachedDocs(source, 'APP_CONTENT_PATH');
373399
const control = attachedDocs(source, 'EAGER_WALK_CONTROL');
374400
const ledger = attachedDocs(source, 'DECLARED_LAZY_VIEWS_STILL_EAGER');
401+
const sideEffectful = attachedDocs(source, 'DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS');
375402

376403
// Controls that MUST hit: a phrase verified to be inside each attached
377404
// block. A locator that quietly found the wrong span would pass every pin
378405
// below by scanning prose that says nothing about these constants.
379406
expect(appContent.prose).toContain('declarations are the subject');
380407
expect(control.prose).toContain('The positive control for the eager walk');
381408
expect(ledger.prose).toContain('Deleting a line is a MEASUREMENT');
409+
expect(sideEffectful.prose).toContain('never declares');
382410

383411
// ...and the neighbours are not swept in. These three declarations sit
384412
// consecutively with nothing but their own blocks between them, so an
@@ -388,11 +416,14 @@ describe('the prose attached to the exported constants (objectui#7289)', () => {
388416
expect(control.prose).not.toContain('declarations are the subject');
389417
expect(ledger.prose).not.toContain('The positive control for the eager walk');
390418
expect(ledger.prose).not.toContain('Pull the modules out of');
419+
expect(ledger.prose).not.toContain('never declares');
420+
expect(sideEffectful.prose).not.toContain('Deleting a line is a MEASUREMENT');
421+
expect(sideEffectful.prose).not.toContain('Pull the modules out of');
391422

392423
// The code is not prose. Without this the positive pin below would be
393424
// satisfiable by the ledger's own entry line.
394-
expect(ledger.code).toContain("'packages/app-shell/src/views/RecordDetailView.tsx'");
395-
expect(ledger.prose).not.toContain("'packages/app-shell/src/views/RecordDetailView.tsx'");
425+
expect(sideEffectful.code).toContain("'packages/app-shell/src/views/RecordDetailView.tsx'");
426+
expect(sideEffectful.prose).not.toContain("'packages/app-shell/src/views/RecordDetailView.tsx'");
396427
});
397428

398429
/**
@@ -410,8 +441,8 @@ describe('the prose attached to the exported constants (objectui#7289)', () => {
410441

411442
/**
412443
* What each constant carries AS DATA, recorded so the pin above cannot go
413-
* vacuous in silence. The two controls carry exactly themselves; the ledger
414-
* carries one entry.
444+
* vacuous in silence. The two controls carry exactly themselves; the eager
445+
* ledger is empty and the side-effectful one carries one entry.
415446
*
416447
* ⚠️ The ledger EMPTYING is a win, not a failure — the block above this
417448
* declaration says it in as many words ("Deleting a line is a MEASUREMENT,
@@ -424,6 +455,7 @@ describe('the prose attached to the exported constants (objectui#7289)', () => {
424455
it('records what each constant carries as data, so the pin cannot go vacuous', () => {
425456
expect(pathsCarriedBy(APP_CONTENT_PATH)).toEqual([APP_CONTENT_PATH]);
426457
expect(pathsCarriedBy(EAGER_WALK_CONTROL)).toEqual([EAGER_WALK_CONTROL]);
427-
expect(pathsCarriedBy(DECLARED_LAZY_VIEWS_STILL_EAGER)).toHaveLength(1);
458+
expect(pathsCarriedBy(DECLARED_LAZY_VIEWS_STILL_EAGER)).toEqual([]);
459+
expect(pathsCarriedBy(DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS)).toHaveLength(1);
428460
});
429461
});

0 commit comments

Comments
 (0)