You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9f120af
Browse filesBrowse the repository at this point in the historyBrowse files
fix(app-shell): Home asks for the objects it names instead of loading the whole object registry (#29229)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbBxNE9wTVjSGYnZ9fUpaahr)_Fixes#29121
Clause-②: no
Metadata-protocol: none
Claim: 6572592854 · amendment: 6573209598
## 维护者速读
- 改了什么:租户首页不再读整张对象注册表(`GET
/api/v1/meta/object`)和整张视图表;命令面板第一次打开时才挂载,首页的动态、最近访问、面板最近记录都只按名字读自己用到的对象。
- 为什么改:每次进首页都下载全部对象定义(HotCRM 约 875 KB,app-crm 551
KB),只为一个关着的面板和几行图标、标签;网络慢时首页因此多等。
- 风险与回滚:读法从「一次整表」变成「按名逐个读」,首页请求数多了(app-crm 上 +9 个小请求,合计 70 KB 对 558
KB);进入应用后整表已加载时一律直接用整表,不再发请求。回滚即 revert 本 PR。
- 先看:`ui/packages/app-shell/src/hooks/useObjectPresence.ts`(新的
`readObjectsByName`)、`ui/packages/app-shell/src/console/home/HomeLayout.tsx`(面板首开才挂载)、`ui/packages/app-shell/src/hooks/useNavMemberGates.ts`(首页无应用时的能力门)。
- 两分钟验证:打开首页,开发者工具 Network 过滤 `meta/object`:只见
`meta/object/<名字>`,没有不带名字的 `meta/object`;按 ⌘K 搜 `acme`,结果与改前一致。
- 需要你做的:无,席位落地。
## What changes
On `main`, every visit to `/home` read the whole object registry and the
whole view list. Measured with CDP initiator stacks on a production
Console (app-crm), four readers asked for them unconditionally, each
hidden behind the one before by the provider's cache, and four more once
there is data:
| Reader | Before | Now |
|---|---|---|
| `HomeLayout`: the command palette's `objects` prop (palette closed) |
whole list at mount | palette mounted from its first open; then the host
app's scope over its navigation's objects, `views: false` |
| `useObjectPresence` outside an app (activity feeds' `sys_activity`
check) | whole list | by name, `views: false` |
| `useNavMemberGates` outside an app (the feeds' cross-app roster
capability gate) | whole list | names-only scope over the app list's
`requiresObject` union, `views: false`; the package leg asks without
views too |
| `HomePage`: recent record row icons | whole list at render | the row's
object by name |
| `useNavTargetLabel` object label (Home's recent record rows) | whole
list | `{ byName: true }` option: the object by name; a view target
reads its object with its views |
| `useRecentItemLabel`: recent object / list-view rows | whole list |
the row's object by name (a view row with its views) |
| `ActivityObjectLabel`: activity rows (Home rail, bell) | whole list |
the row's object by name |
| `CommandPalette` recent record rows (palette open) | whole list | the
row's object by name |
`readObjectsByName` (in `useObjectPresence.ts`) is the one helper: while
nothing has loaded the whole list it asks each name through the
names-only scope (objectui#12980); once the list is loaded or loading it
reads the list and asks nothing; a hand-rolled context reads its
`objects`; no name asks nothing (a names-only scope with no names would
be the whole registry). Every in-app leg is unchanged: inside an app the
sidebar, routes and gates read what they read before.
The palette's record search reads only its navigation's objects
(`useRecordSearch` with `objectNames`), so handing it the host app's
scope over those names leaves its results unchanged.
## Tests
Request-count tests over the real `MetadataProvider` and a fake adapter
that records each read:
- `console/home/__tests__/homeObjectReads-29121.test.tsx`: presence
check, roster gate (answers as the whole list did, including an absent
required object), activity label, an empty-names read; CONTROL: with the
whole list loaded each reader asks nothing.
- `console/home/__tests__/HomeLayout.paletteReads-29121.test.tsx`:
closed palette not mounted and no read; opened (click or `?palette=1`)
reads `object?package=…` plus the outside name; a package-less app reads
by name only.
- `console/home/__tests__/HomePage.recentObjectReads-29121.test.tsx`: no
recent row → no read; record rows read their objects by name (icon and
label pinned); an object row by name and a list-view row with its views
(`view`, never `object`).
- `chrome/CommandPalette.recentReadsByName-29121.test.tsx`: the
palette's recent rows read their objects by name.
- Updated pins: `HomeLayout.searchOpensPalette-12601` (the palette probe
exists from the first open), `navGateUnionScope-12980` (its "outside an
app reads the whole registry" control now pins the by-name read),
`openPathObjectReaders-12811` (the census learns `readObjectsByName(…)`
as a spelling and a `byName` kind; HomeLayout, HomePage,
ActivityObjectLabel and useRecentItemLabel reclassified).
## Acceptance notes
- **Files beyond the amendment's seven:** `chrome/CommandPalette.tsx`
(the palette's recent rows, its object source while open; found on the
production re-measure) and the three updated test pins above.
- **Acceptance 1** (no unscoped `GET /api/v1/meta/object` on home): met
on app-crm, see Verification. The home now asks the 8 `requiresObject`
names of the Setup app's navigation by name (the roster gate), plus
`sys_activity` and the objects its recent and activity rows name. That
is more requests than one list (19 → 28 on app-crm) and far fewer bytes
(558 KB → 70 KB). There is no batch by-names read on `/meta/object`
today.
- **Acceptance 2** (palette object search unchanged): the palette's text
for `acme` is byte-identical between main and this branch on the same
server.
- The card's premise named only the palette. Measuring showed it was the
first of four unconditional readers; the claim was amended (6573209598)
to the full shape.
- Not changed: a recent dashboard / page / report row still reads that
type's list (`useRecentItemLabel`), and opening the palette reads
`/meta/report` and `/meta/dataset` (its report entries). Neither is the
object registry.
## Verification
<details><summary>Home requests, production Console, app-crm
(<code>objectstack dev --fresh</code>), recent records and activity rows
present</summary>
main `0a41075a`: 19 `/api/` requests on reload of `/home`, including
`GET /api/v1/meta/object` (551,461 bytes) and `GET /api/v1/meta/view`
(6,643 bytes); the initiator of both is `HomeLayout` (`get objects`).
This branch `5705cea1`: 28 requests; no `GET /api/v1/meta/object`
without a name and no `/meta/view`. By name: `sys_business_unit`,
`sys_notification`, `sys_notification_preference`,
`sys_notification_template`, `sys_queue`, `sys_queue_member`,
`sys_record_share`, `sys_sharing_rule` (Setup's `requiresObject`
entries), `sys_activity`, `crm_contact`, `crm_account` (recent and
activity rows): 70,164 bytes together. Opening the palette and typing
reads `object?package=com.example.crm` (31,636 bytes), `/meta/report`,
`/meta/dataset`.
Same page on both: recent rows' text and icons, activity rows' labels,
and the activity feed's `sys_activity` filter (21 object names) are
identical.
</details>
<details><summary>Ablations (each leg through
<code>scripts/ablation-replace.mjs</code>, restored with <code>git diff
HEAD</code> empty)</summary>
- A1 palette mounted while closed → `HomeLayout.paletteReads` "closed"
red.
- A2 presence check keeps the whole list outside an app →
`homeObjectReads` presence red.
- A3 roster gate keeps the whole list outside an app → `homeObjectReads`
gate red.
- A4 `readObjectsByName` returns the whole list → activity label,
empty-names, both HomePage row cases red (4).
- A5 HomePage icon reads `metadata.objects` → record rows red.
- A6 `useNavTargetLabel` ignores `byName` → both HomePage row cases red.
- A7 `useRecentItemLabel` title reads `metadata.objects` → object/view
row case red.
- A8 palette scope composed with views → both opened cases red.
- A9 / A10 palette recent icon / label read the whole list →
`CommandPalette.recentReadsByName` red.
</details>
<details><summary>Local runs at <code>5705cea1</code></summary>
- 91 test files naming the touched modules (`CommandPalette`,
`useNavTargetLabel`, `readObjectsByName`, the census): 90 files / 802
tests passed (one name listed twice). Earlier heads: 88 files naming the
seven hooks/components (2 expected pins updated, then green) and 151
files naming `sharedUserFeeds`, `InboxPopover`, `RecentApps`,
`HomeRail`, `CommandPalette`, `AppHeader`: 620 + 498 tests passed.
- `turbo run type-check --filter=@object-ui/app-shell`: 65/65 tasks.
- `eslint --no-inline-config` on the changed files: 0 errors.
- Derived gates (`node scripts/pm/dispatch-gates.mjs --commands`) at
`d8b43ffa`: 34 derived, 34 run, all exit 0, reconciled with `--ran` (0
NOT-MEASURED); `check:type-check-debt` under the verify lock; `node
scripts/check-sdui-manifest.mjs` exit 0 among them. The full app-shell
suite is CI's Test UI.
</details>
## 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_01QsR2jSvXnowXjLpyfdKoux
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(app-shell): Home asks for the objects it names instead of loading the whole object registry
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
Every visit to `/home` read `GET /api/v1/meta/object` (the whole registry, the largest metadata payload of the page) and `GET /api/v1/meta/view`, for a few object names. Now:
11
+
12
+
- The command palette is mounted from its first open. Opened, it reads its host app's object scope over the objects its navigation lists, without views: the objects its record search reads.
13
+
- Outside an app, the activity feeds' `sys_activity` check (`useObjectPresence`) and their roster's capability gate (`useNavMemberGates`) ask their names by name, without views.
14
+
- Recent rows (Home's and the palette's) and activity rows read the object each one names, by name (`readObjectsByName`, `useNavTargetLabel({ byName: true })`, `useRecentItemLabel`, `ActivityObjectLabel`). A list-view row reads its object with its views.
15
+
16
+
Once something has loaded the whole list (inside an app, say), every one of these reads it and asks nothing more. What Home and the palette show is unchanged.
why: "an object's presence (the bell's sys_activity feed) is asked by name through the app scope, until something loads the whole registry",
67
+
why: "an object's presence (the bell's and Home's sys_activity feed) is asked by name, through the app scope inside an app, until something loads the whole registry; it also holds readObjectsByName",
'packages/app-shell/src/hooks/useConsoleActionRuntime.tsx': {kind: 'off',why: 'read inside action handlers, when an action runs'},
75
78
'packages/plugin-grid/src/ObjectGrid.tsx': {kind: 'off',why: 'read inside an action handler, when an action runs'},
76
-
'packages/app-shell/src/hooks/useNavTargetLabel.ts': {kind: 'off',why: 'read when a label is resolved for a nav entry without its own label, or a view entry'},
77
-
'packages/app-shell/src/hooks/useRecentItemLabel.ts': {kind: 'off',why: 'read when a recent object or view entry is labelled'},
78
-
'packages/app-shell/src/layout/ActivityObjectLabel.tsx': {kind: 'off',why: "the inbox and the home rail's activity rows"},
why: 'read when a label is resolved for a nav entry without its own label, or a view entry; with { byName: true } (Home, recent rows) the object is read by name',
82
+
},
83
+
'packages/app-shell/src/hooks/useRecentItemLabel.ts': {kind: 'byName',why: "a recent object or view entry's object, by name (objectstack#29121)"},
84
+
'packages/app-shell/src/layout/ActivityObjectLabel.tsx': {kind: 'byName',why: "the inbox's and the home rail's activity rows, each row's object by name (objectstack#29121)"},
79
85
'packages/app-shell/src/chrome/CommandPalette.tsx': {kind: 'off',why: "the Studio scope's object list, read while the palette lists Studio entries"},
80
-
'packages/app-shell/src/console/home/HomeLayout.tsx': {kind: 'off',why: 'the home page, outside any app'},
81
-
'packages/app-shell/src/console/home/HomePage.tsx': {kind: 'off',why: 'the home page, outside any app'},
0 commit comments