Repository navigation
Commit 2a86e51
perf(console): the first load stops downloading the Setup pages, the package form and the view config panel (#33580)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X1jBgfsH7uDVYbZzMpqyqUL)_
Fixes #33293
Clause-②: no
Metadata-protocol: none
Seat `domain:ui#2` · os-project-manager · card thread
`session_01FEkQ5mmCUzPNeT1C9cHRtT` · claim 6886542738
## 维护者速读
- 改了什么:控制台首次加载不再预先下载 Setup
里的几个页面(软件包、软件包表单、权限集矩阵编辑器、打包动作、连接器凭据与连接、岗位成员、权限集分配、回收站)和列表视图的「视图配置」侧栏;它们改为第一次打开时才下载。仪表盘等任何路由的首屏脚本从
2,293,387 字节(gzip)降到 2,163,689 字节,少了约 130 KB(5.7%)。
- 为什么改:#33293 测得慢网络冷缓存下仪表盘要等 2.29 MB 首屏脚本下完才开始取数;其中有不少是仪表盘根本不画的代码。卡上点名的
`PackageFormDialog` 块已整块离开首屏。
- 风险与回滚:只改加载时机,不改任何页面画什么。Setup 页面首次打开时多一行「Loading
…」提示,视图配置侧栏在列表挂载时才下载(管理员打开它之前已到)。卡上另外点名的
`plugin-grid`、`plugin-form`、`RecordDetailView`、Studio 英文语言包仍在首屏,原因与拆分建议见
Acceptance notes。回滚即还原本 PR。
- 先看:ui/packages/app-shell/src/services/builtinComponents.tsx(新增
`lazyPage`,八个页面改成按需加载)、ui/packages/app-shell/src/views/ObjectView.tsx(`ViewConfigPanel`
改为 `lazy()` 加 `Suspense`)。
- 两分钟验证:`pnpm --filter '@object-ui/console^...' build` 后在
`ui/apps/console` 跑 `CI=true pnpm exec vite build`,读
`dist/eager-closure.json` 的 `eagerGzipBytes`,应为约 2,163,689;打开
`/apps/setup/component/developer/packages`,页面正常画出。
- 需要你做的:无,席位落地。
## What changes
Measured first, on `origin/main` `e3f0cfd4`: `CI=true pnpm exec vite
build` in `ui/apps/console` wrote `dist/eager-closure.json` = **105
eager chunks of 2427, 2,293,387 B gzip** (7,730,755 raw). The card's
2,286,732 B is the published 18.4.0 Console; same shape. The import edge
that makes each named chunk eager was read from the build's own module
graph (the console's `vite.config.ts` run through Vite's `build()` with
one read-only plugin that dumps `getModuleInfo()` and each chunk's
module list; that build wrote the same `eager-closure.json` to the
byte). The edges are tabled under Acceptance notes.
Two edges are cut here, both by `lazy()` with the `Suspense` boundary
inside what is rendered:
- **`services/builtinComponents.tsx`**, the app-shell module the package
entry bare-imports for its registrations, imported eight pages BY VALUE:
`PackagesPage`, `PermissionMatrixEditPage`, `PackagedActionsPage`,
`ConnectorCredentialsPage`, `ConnectorConnectionsPage`,
`PositionHoldersPage`, `PermissionSetAssignmentPage`, `RecycleBinPage`.
Each, with everything it imports, sat in the eager closure;
`PackagesPage → PackageFormDialog` is the card's `PackageFormDialog`
edge, and `PositionHoldersPage → PositionHoldersSection` held a 25.8 KB
chunk. A new `lazyPage(label, load)` returns a component that renders
the page behind `lazy()` + `Suspense`, the shape the file's two
metadata-admin registrations already use, so `registerAppComponent` and
`registerMetadataResource` still receive a component and no render site
changes. The fallback is the file's existing `MetadataAdminFallback`
("Loading packages…").
- **`views/ObjectView.tsx`** imported `ViewConfigPanel` statically.
`ObjectView` is in AppContent's always-eager block, so the panel held
`ViewVariantInspector`, `SchemaForm`, the Studio form widgets
(`widgets.tsx`, `ConditionBuilder`, `CelPredicateField`) and
`RuntimeDraftBar` eager. It is now `lazy()` inside a `Suspense` boundary
whose fallback is `null`, in the same wrapper div. The panel draws
nothing while closed, so the list draws exactly as before; its chunk is
requested as the list mounts.
Result, `30cbab20` (same instrument): **107 eager chunks of 2487,
2,163,689 B gzip** (7,271,631 raw), **−129,698 B (−5.7%)**. Two builds
of this tree read 2,163,688 and 2,163,689; the 1 B is build-to-build
variance, not attributed.
| named chunk (card) | before, B gz | after | status |
|:--|--:|--:|:--|
| `PackageFormDialog` | 43,854 | — | **left the eager closure** (its
`SchemaForm` / `CelPredicateField` co-tenants left too;
`object-fields-io`, 1,575 B, and `json-schema-to-fields`, 1,882 B, stay,
see notes) |
| `plugin-grid` | 159,651 | 159,637 | eager, see notes |
| `plugin-form` | 44,269 | 44,270 | eager, see notes |
| `RecordDetailView` | 27,273 | 27,291 | eager, see notes |
| `i18n-ns-studio-en` | 64,259 | 64,259 | eager, see notes |
Also left: `PositionHoldersSection` (25,809), most of `src` (69,042 →
38,197), `field-types` (13,030), `view-schema` (5,292),
`MarketplaceLanguages` (5,234), `dist` (4,845), `ViewVariantInspector`,
`ViewColumnPanes`, `RuntimeDraftBar`, `_shared` and four small chunks.
Sixteen small eager chunks appear (largest `metadata-form-i18n` 11,364
and `marketplaceApi` 4,065): modules that were already eager inside the
chunks that left, regrouped by rolldown, ⛔ not new first-load bytes.
The eager-closure gate's ceiling does not move. `pnpm
check:eager-closure` on `30cbab20`: aggregate 2113.0 KB / 2431.6 KB,
headroom 318.6 KB = **0.46x** the 695.0 KB regression, so
`evaluateHeadroomSensitivity`'s one predicate (headroom ≥ 1x) does not
fire and the gate's rules ask for no re-pin. `BASELINE` is untouched.
Changeset `.changeset/33293-console-eager-closure-setup-pages.md`:
`@object-ui/console` patch (app-shell is private; the console's `dist`
ships it).
## Tests
- No test pins the eager set for these modules, so none is updated.
`vite-declared-lazy-views` (build plugin) and the
`ineffective-dynamic-import` ledger both pass on the new build (exit 0,
"41 ineffective dynamic imports, all pinned"), so no new `import()` is
defeated by a static edge elsewhere.
- **Ablation, one edge put back** (`scripts/ablation-replace.mjs` on
`builtinComponents.tsx`: the `PackagesPage` registration re-imported
statically), rebuilt and weighed under the lock: eager closure
**2,223,296 B, 112 chunks**, `PackageFormDialog` eager again; `pnpm
check:eager-closure` **exit 0** (2171.2 KB, headroom 260.4 KB). Restore:
blob equal to HEAD `ec73e832`, `git diff HEAD` empty. ⇒ Nothing catches
an edge coming back: the gate's sensitivity is 695 KiB by ruling
(objectui#12653), and a 60 KB regression is inside it. Adding a pin
would be a new gate; none is added.
- Existing suites through the rendered `ObjectView` and the
registrations, from `ui/` under the lock: every
`packages/app-shell/src/views/ObjectView*.test.tsx`, the four Setup
`*.navContribution.test.tsx` (each mounts its page through
`ComponentNavView`, now through the lazy wrapper),
`ResourceListPage.positionGrants-25333`,
`PermissionMatrixEditor.saveSurface-12725`,
`PackagesPage.installedApps-13356`: **85 files, 662 tests passed**.
`ObjectView.viewConfigSaveWiring-10210`,
`ObjectView.viewWriteRefusal-11583` and
`ObjectView.createViewRefusal-11578` drive the panel through the real
`ObjectView`, so the lazy panel opens and saves through the input
pipeline in those pins.
## Acceptance notes
**Acceptance 1, per chunk.** Edges read from the module graph of the
`30cbab20` build; "eager" = reachable from the entry chunk through
static imports only.
- `plugin-grid` (159.6 KB; 73 of its modules are `plugin-detail`, which
the `plugin-grid` group captures recursively because `ObjectGrid`
imports it). Held by `apps/console/src/register-plugins.ts` (bare
`import '@object-ui/plugin-grid'` and `plugin-detail`, the SDUI
registration of the core views), `apps/console/src/App.tsx` →
`dev/DevRowActions.tsx`, `@object-ui/plugin-view`'s `ObjectView` and
`@object-ui/plugin-list`'s `ListView` (both eager the same way), and
through `plugin-detail` by eleven eager app-shell modules
(`sharedUserFeeds`, `deriveRelatedLists`, `workspacePreference`,
`recordPagePayload`, `recordDetailSections`, `RecordPreviewCard`, …).
- `plugin-form` (44.3 KB). Held by `register-plugins.ts`,
`providers/MetadataProvider.tsx` (`resolveInlineMode`),
`console/AppContent.tsx` and `hooks/useActionModal.tsx` (`ModalForm`),
`utils/editFormLockedByState.ts` (`filterSystemFields`,
`isAutoGeneratedFieldType`), `views/ActionParamDialog.tsx`
(`useInitialFieldFocus`), `views/ScreenView.tsx`,
`apps/console/src/components/FormPage.tsx`, and `plugin-view`'s
`ObjectView`. `plugin-form` declares only its entry side-effectful, so a
named helper import keeps the whole registering entry.
- `RecordDetailView` (27.3 KB). A real static edge:
`views/objectViewRecordOverlay.tsx` imports it and `ObjectView` sits in
AppContent's always-eager block, the reason
`ui/scripts/vite-declared-lazy-views.ts` already pins it in
`DECLARED_LAZY_VIEWS_STILL_EAGER`. The chunk also carries
`NotFoundState`, `recordDrawerStack` and `useObjectActions`, which
`AppContent` imports directly.
- `i18n-ns-studio-en` (64.3 KB). `namespaces/studio/index.ts` imports
`en.ts` statically by design (the synchronous `en` fallback,
objectstack#25922), and `index.ts` is eager twice over: the
`i18n-runtime` group (`/packages/i18n/`) captures it into an eager
chunk, and four eager modules import app-shell's
`metadata-admin/i18n.ts`: `studio-design/studio-canvas-preview.tsx`
(bare-imported by the package entry for its load-time
`registerStudioCanvasPreview('object', …)`),
`metadata-admin/datasource/register.ts` (`DatasourceResourcePage` by
value), `PositionGrantCells` (by value, from `builtinComponents.tsx`),
and `CreateViewDialog` → `objectDatasets` → `useDatasetCatalog`.
**Why this PR stops here (the order's split clause).** The seat filed
the two remaining cuts as their own cards, #33581 (grid / form /
RecordDetailView) and #33582 (the Studio `en` strings). Each remaining
chunk needs a cut this card's bounds do not hold:
- **grid / form / RecordDetailView** need, together: a lazy boundary on
`ObjectView` in AppContent (it is also `EAGER_WALK_CONTROL`, the
positive control of `vite-declared-lazy-views`, so that plugin's
counter-probe needs a new control); `register-plugins.ts`'s five eager
plugins turned into `registerLazy` per tag; and side-effect-free
subpaths for the helpers app-shell imports from `@object-ui/plugin-form`
and `@object-ui/plugin-view` (`deriveRecordSurface`,
`deriveRecordFlowSurface`) — a shared-package API change (new `exports`
entries). Upper bound of the win: 286.7 KB gz (the five chunks' sum,
part of `plugin-detail` likely staying).
- **Studio `en`** needs the default canvas preview in
`studio-canvas-preview.tsx` moved to a module of its own and registered
lazily (a file split of about 400 lines in a `sideEffects`-array
module), `DatasourceResourcePage` and the two position cells registered
lazily, `CreateViewDialog` lazy in `ObjectView`, and an `i18n-ns-studio`
group in `vite.config.ts` like `i18n-ns-marketplace`. The synchronous
`en` fallback stays (`en` remains a static import of the namespace
module; the module itself moves out). Win: 64.3 KB gz plus
`metadata-form-i18n` and the modules only those four reach.
- Two stragglers of the old `PackageFormDialog` chunk stay eager:
`object-fields-io` (1,575 B, imported by
`preview/DraftChangesPanel.tsx`) and `json-schema-to-fields` (1,882 B,
via `DatasourceResourcePage`, the Studio `en` edge above).
**Acceptance 3, a built console in a real browser.** Showcase at this
tree (`pnpm --filter '@objectstack/example-showcase...' build`, `turbo
run build:dist --filter=@objectstack/console`, then `objectstack dev
--ui --seed-admin` from `examples/app-showcase`), headless Chromium, a
fresh context (cold cache) per route, signed in as the dev admin:
| route | drew | lazy chunks seen |
|:--|:--|:--|
| dashboard `showcase_ops_dashboard` | metrics and charts, no page error
| none of `ViewConfigPanel`, `PackagesPage`, `PermissionMatrixEditor`,
`PackageFormDialog`, `SchemaForm` requested |
| list `showcase_task` | 10 rows | `ViewConfigPanel` requested on mount
|
| record `showcase_task/record/…` | header, path, sections | — |
| Studio `/studio` | App Builder home | `PackagesPage`, `SchemaForm`
fetched on demand |
| Setup → Packages | page drew | `PackagesPage`, `PackageFormDialog`
fetched on demand |
| Setup → Position holders | page drew | `PositionHoldersPage` fetched
on demand |
| permission set `member_default` (redirects to Studio) | matrix drew,
126 objects | `PermissionMatrixEditor` fetched on demand |
No page error, no console error, no failed request on any route.
Screenshots, the probe and both `eager-closure.json` files are in the
project folder `pm-orders/ui/33293-probe/`. The record and Studio rows
timed out on the probe's own wait selector (a hidden first match; `main`
not visible) and drew, per their screenshots. Opening the view config
panel by hand needs a saved view the showcase does not seed; the
rendered pins above open it. Cold/warm timing was not re-measured.
## Verification
<details><summary>Local gates, type-check, lint (head
30cbab2)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 30 families for this diff. All 30 exit 0 on
`30cbab20`; `--ran`: 30 derived, 30 run, 0 NOT-MEASURED, 0 UNRUN. `pnpm
--dir ui exec vitest run scripts/` read on its rerun: the first run
(beside the showcase build, `dist/` mid-rebuild) had 4 files fail on
unresolvable workspace imports; alone under the lock with
`--maxWorkers=2`: 171 files passed, 2 skipped, 5062 tests passed, exit
0.
- `pnpm check:eager-closure` exit 0 (above). `pnpm
check:side-effects-array`, `pnpm check:sdui-registration-pins` (71
registrations present, 2492 chunks weighed), `pnpm
check:eager-locale-catalogues`, `pnpm check:new-line-citations` (0 new):
exit 0.
- `pnpm --filter @object-ui/app-shell run type-check`: exit 0. ESLint
`--no-inline-config` on the two changed source files: 0 errors (61
pre-existing warnings).
- The full app-shell suite and the rest of the farm are CI's.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5mmCUzPNeT1C9cHRtT
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5mmCUzPNeT1C9cHRtT)_
<!-- signed: domain:ui#2 · os-project-manager ·
session_01FEkQ5oF8GgTHN2jBZoDwz8 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 9d1f6e2 commit 2a86e51
3 files changed
Lines changed: 92 additions & 24 deletions
File tree
- .changeset
- ui/packages/app-shell/src
- services
- views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | 21 | | |
24 | | - | |
25 | | - | |
26 | 22 | | |
27 | | - | |
28 | 23 | | |
29 | | - | |
30 | | - | |
31 | 24 | | |
32 | | - | |
33 | 25 | | |
34 | 26 | | |
35 | 27 | | |
| |||
106 | 98 | | |
107 | 99 | | |
108 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
109 | 158 | | |
110 | 159 | | |
111 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
1372 | 1379 | | |
1373 | 1380 | | |
1374 | 1381 | | |
1375 | | - | |
1376 | | - | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
1389 | 1398 | | |
1390 | 1399 | | |
1391 | 1400 | | |
| |||
0 commit comments