Repository navigation
Commit 3eb778d
perf(console): a list page draws its rows once before they paint, and the shell re-renders less during first load (#37883)
Part of #37575
Part of #37444
This is slice 2 of the first-render card. It does not bring the list and
record pages under 2.5 s, so the card stays open. The section "What is
left" below says what still costs the time.
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill or doc page names `appContentLanguages`
(git grep of `skills/`, `content/` and `docs/`; only two changesets do)
**Narrowing (public API of `@object-ui/i18n` and `@object-ui/react`):**
`useObjectTranslation()` and `useI18nContext()` no longer return
`appContentLanguages`, which #36040 added to them and which has shipped.
`@object-ui/react` re-exports both hooks, so the narrowing reaches that
entry too. Read the list with the new `useAppContentLanguages()`
instead; both entries export it. The changeset carries the BREAKING
section and an ADR-0087 disposition. It ships `patch` because the change
is not to the metadata protocol.
## 维护者速读
- 控制台用户打开列表页、记录页时,首屏少做几遍整块重绘,看到的内容和交互不变;同机对照列表页快约 80 毫秒、记录页快约 90
毫秒,首页不变。
- 属于「首屏打开速度」专题,接着上一片侧栏的改动,继续削减首屏前的重复渲染。
- 出错的话,最可能是列表行末按钮、侧栏入口的显隐、或语言菜单的「内容未翻译」提示显示不对;整个提交可以直接撤回。
- 无
## What changes
Between a list's rows' first render and their first paint the grid drew
the whole table three more times, and the shell re-rendered large parts
of the page for answers few components read. Each cut below removes one
such pass; none changes what is drawn.
**Grid (`@object-ui/plugin-grid`)**
1. `ObjectGrid`'s loading face now draws inside the same root element
the loaded table uses (same type, place and ref). React keeps the
element across the swap, so `gridRoot`, and the list page scope answer
read off it, is known when the rows first render. Before, the rows drew
once with row-end controls and the `_actions` column, the root's ref
then answered "list page", and the table drew again without them (plus a
right-shadow flip).
2. `useInlineRowActionFold` watches its host from a stable callback ref
instead of holding the element in state, so mounting the host no longer
re-renders `ObjectGrid` (an 838-component pass).
3. `useRecordCrudVerdicts` publishes a verdict map only when it differs
from the published one. It used to publish a new empty `Map` on every
read before anything was asked, which re-rendered the grid for nothing.
**Shell**
4. `@object-ui/i18n`: the app's own locale list (`appContentLanguages`)
moves to its own context, read with the new `useAppContentLanguages()`.
The list lands late in boot; in the main context it re-rendered every
`useObjectTranslation` reader (about 1,900 components on a list page).
`useObjectTranslation()` and `useI18nContext()` no longer carry the
field; its two readers (`LocaleSwitcher`, the profile page's language
card) use the new hook. `@object-ui/react` re-exports the new hook
beside the two it re-exports already (contract review S1). This removal
narrows the published API: it is declared `Clause-②: yes (narrowing)`
above and in the changeset, with a BREAKING section that names the
replacement hook and the reason (about 1,900 first-load components no
longer re-render when the list lands).
5. `@object-ui/layout`: the row memo from #37722 also compares the
capability checker by what it answers for a leaf row (`requiresObject`,
`requiresService`), as it already did for the three target resolvers.
## Tests
Each pin fails on `main` and passes here; I checked this by running each
one against the `main` version of the source:
- `plugin-grid/src/__tests__/listGridFirstRender-37575.test.tsx`: a list
page grid never puts a row-end control in the DOM, not even for one
commit (a MutationObserver reads added and removed nodes); attaching the
fold's host renders nothing; re-reading verdicts with nothing answered
keeps the same lookup.
- `i18n/src/__tests__/provider-appContentLanguages-37575.test.tsx`: a
memoised translation reader is not re-rendered when the list lands; a
reader of the list is.
- `layout/src/__tests__/NavigationRenderer.rowMemo-37575.test.tsx`: a
new capability checker with the same answers redraws no leaf row, and
one that hides a row removes it.
Two list tests changed. `plugin-list` `ListView.harness` (objectui#6917
block) and `app-shell` `ObjectView.titleViewSwitcher-27594` read the
record-count bar, which a grid does not draw: the grid draws the count
in its resident footer row (`data-table-summary-lead`,
objectstack#35702), and ListView hides the bar once the grid says so.
The tests caught the bar in the frames before that, frames the grid no
longer spends. They now read the grid's footer count. The expected
numbers are unchanged, and both pass on `main` too.
**Taken back out (head 6049056):** a first version mounted each sidebar
row's Radix tooltip only in the icon rail, which saved about 750 mounts.
Folding or docking the sidebar then swapped the row's wrapper, so its
button remounted and keyboard focus was lost
(`UnifiedSidebar.railOverlay-27593`,
`UnifiedSidebar.hiddenCollapse-35062` caught it). The primitive under
`components/src/ui` is not edited here, so that cut needs its own
design.
## Acceptance notes
<details><summary>Readings: Lighthouse 13.6.0 desktop, HTTP/2 TLS front,
10 runs per page, the #37444 method; base and PR built and measured in
the same session, back to back</summary>
Production console build served by `objectstack start`
(`NODE_ENV=production`) behind the local h2 front, signed in, cold
cache, 4-core container.
| Page | `main` 1028438 (median of 10) | this PR at 6049056 (median of
10) | Δ |
|:--|--:|--:|--:|
| Home | 2207 | 2214 | +7 (noise) |
| Object list | 2768 | 2685 | −83 |
| Record page | 2594 | 2504 | −90 |
Sorted runs: main home 2130…2289, list 2583…2964, record 2494…2883; PR
home 2143…2371, list 2516…2835, record 2417…2676.
The machine read about 90 ms slower than the readings at session start
(main list 2662 then, 2755 now), which is why both columns come from the
same hour.
React commit census, list page, on the build that still had the tooltip
cut: components re-rendered before the rows mount went from about 10,300
to about 6,000. Without that cut the mounts stay as on `main`. Between
the rows' DOM insertion and the first paint after it there is no commit
any more (Performance observer + commit hook timestamps).
</details>
<details><summary>What is left: why the list and record pages are still
over 2.5 s</summary>
- Lighthouse's main-thread breakdown on the list page is about 2.0 s of
script evaluation, almost all of it React render work attributed to
`vendor-react`. The main thread is busy from about 600 ms to the paint.
- Of what this PR leaves before the rows, the passes are mostly real
content arriving: translation bundles (the `t` identity), object labels
as the metadata store fills (`MetadataProvider`'s global `version`
counter re-renders every metadata reader on each bump, 6 bumps on a list
page), the app menu. Cutting those needs a selector-style metadata
store, not a memo. That is an L-size change in `app-shell`, the next
lever for this card.
- Each row's ⋯ menu still mounts a Radix `DropdownMenu`, whose Popper
anchor re-renders its trigger once (a ~460 component pass). Mounting the
menu on first pointer or focus would remove it.
- After the rows mount, 4 passes remain after the first paint and do not
delay LCP: the view bar (`ManageViewsDialog`'s view-id array), the
table's right shadow (measured in a layout effect), the object schema
arriving, and the columns reseed.
</details>
## Verification
Read first, by risk:
1. `ui/packages/plugin-grid/src/ObjectGrid.tsx`, the loading branch: the
root element must stay the same type, place and ref as the final return,
or the fix silently stops working (the MutationObserver pin catches
that).
2. `ui/packages/layout/src/NavigationRenderer.tsx`, `sameRowAnswers`:
the capability checker is compared by answers for leaf rows.
3. `ui/packages/i18n/src/provider.tsx`: the new context and
`useAppContentLanguages()`.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/listGridFirstRender-37575.test.tsx
packages/i18n/src/__tests__/provider-appContentLanguages-37575.test.tsx
packages/layout/src/__tests__/NavigationRenderer.rowMemo-37575.test.tsx`.
All the tests should pass.
Local runs: the `plugin-grid` package (317 files, 2,794 tests),
`layout`, `i18n`, the console's `pages/system` tests and the
`LocaleSwitcher` tests all pass. Type checks pass for `i18n`, `layout`,
`plugin-grid`, `app-shell` and the console. `eslint` on the changed
files reports 0 errors. All 39 `dispatch-gates --commands` pass. One of
them, `vitest run scripts/`, was killed for memory in the batch run, and
I re-ran it on its own with 2 workers: 172 files passed.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgTd1y1ncyDVcgVtep5
<!-- signed: repo:objectstack#2 · os-sales ·
session_01L6bhgTd1y1ncyDVcgVtep5 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 43ce731 commit 3eb778d
21 files changed
Lines changed: 367 additions & 67 deletions
File tree
- .changeset
- ui
- apps/console/src/pages/system
- __tests__
- packages
- app-shell/src
- layout
- views
- i18n/src
- __tests__
- layout/src
- __tests__
- plugin-grid/src
- __tests__
- hooks
- plugin-list/src/__tests__
- react/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | | - | |
| 592 | + | |
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
| 610 | + | |
610 | 611 | | |
611 | 612 | | |
612 | 613 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | 105 | | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
170 | 177 | | |
171 | | - | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | 181 | | |
| |||
308 | 315 | | |
309 | 316 | | |
310 | 317 | | |
311 | | - | |
| 318 | + | |
312 | 319 | | |
313 | 320 | | |
314 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
49 | | - | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
181 | | - | |
| 184 | + | |
182 | 185 | | |
183 | 186 | | |
184 | 187 | | |
| |||
272 | 275 | | |
273 | 276 | | |
274 | 277 | | |
275 | | - | |
| 278 | + | |
276 | 279 | | |
277 | 280 | | |
278 | 281 | | |
| |||
297 | 300 | | |
298 | 301 | | |
299 | 302 | | |
300 | | - | |
| 303 | + | |
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| |||
0 commit comments