Repository navigation
Commit 0bfb225
perf(app-shell): a packaged app's object route asks its lookup targets without views (#29609)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9Ubb99UApg2HDL6vC7wFG5UA5v)_
Fixes #29551
Clause-②: no
Metadata-protocol: none
Claim: 6586992712
## 维护者速读
- 改了什么:有包的应用里,对象页读取本对象查找字段的目标对象(例如 `owner` 指向的
`sys_user`)时,改为按名读取且不带视图,与无包应用的做法一致。本对象、`requiresObject` 和导航对象仍然带视图。
- 为什么改:目标对象不在应用包(bundle)里时,带视图的读法会为它下载整张 `/meta/view` 列表(app-crm 上 7,014
B),而查找字段只需要目标对象的定义。
-
风险与回滚:查找目标的定义照旧按名到达并并入对象作用域,查找单元格的链接与名称不变;目标对象不再带视图,实测路由上没有读取查找目标视图的地方。回滚方法是
revert 本 PR。注意:在 #29550 落地前,`ObjectView` 的已存视图读取仍会请求同一张 `/meta/view`,所以
app-crm 上线路字节暂时不变;两者都落地后该列表消失(本地探针已实测)。
- 先看:`ui/packages/app-shell/src/console/appObjectScope.ts` 的
`readObjectRouteNames` 末尾(有包分支的查找目标读取),然后是 `appObjectScope-12811`
测试末尾新增的两个用例。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx`,预期
6 个用例全部通过。
- 需要你做的:无,席位落地。
## What changes
In an app whose served item names its package, an object route reads the
route object's lookup targets through `readObjectRouteNames`. On the
packaged branch it asked them with the route's names through the package
scope's with-views read (`read([...names, ...lookups])`). A target
outside the app bundle, such as `sys_user` behind `crm_account.owner`,
then composed its views from the whole `/meta/view` list.
| | Before | Now |
|---|---|---|
| Packaged app, lookup targets | `readObjectScope({ packageId, names:
[...names, ...lookups] })`, with views, returned as the route's scope |
`readObjectScope({ packageId, names: lookups, views: false })`; the
scope returned is the route's names read, which the targets join as they
land (the same package scope entry) |
| Package-less app, lookup targets | `{ names: lookups, views: false }`
| unchanged |
| Route object, `requiresObject` entries, palette nav objects | with
views | unchanged, with views |
Readers of the lookup targets' views on a packaged object route, checked
before the edit: none. A lookup cell links and names its target.
`ObjectView`'s saved-views read, `useServedViewItems` and
`RecordFormPage` read the route object's views only. A record drawer or
form overlay reads the whole registry beside or instead of the scope, as
before. `ready` and the route's failure outcome still come from the
route object's read alone.
## Tests
- `appObjectScope-12811`, two new cases with a ready app bundle that
holds `crm_account` and `crm_contact` with their views:
- `/apps/crm/crm_account` (lookup `owner` to `sys_user`, outside the
bundle): the reads are `object?package=app.crm` and `object/sys_user`,
and no `view` list. The scope reads `crm_account[crm_account.all]`,
`crm_contact[crm_contact.all]`, `sys_user[]`.
- CONTROL `/apps/crm/crm_contact` (lookup to `crm_account`, in the
bundle): only `object?package=app.crm`, and the same composed views as
before.
- Ablation: restoring `return { scope: read([...names, ...lookups]), ...
}` on the packaged branch turns the first case red on the extra `view`
read; the CONTROL stays green.
- `AppContent.objectScope-12811`, `AppContent.packagelessReads-29416`
and the `openPathObjectReaders-12811` census need no change and are
green.
## Acceptance notes
- The bytes on the wire do not drop yet. With this reader gone, the same
`/meta/view` list (7,014 B) is now first asked by `ObjectView`'s
saved-views read (`dataSource.listViews` to the adapter's
`readViewList`), which #29550 is removing. Before this change that read
shared the request this reader started. A local probe with that read
stubbed showed no `/meta/view` request at all on both routes.
- Request counts differ by preference and `security/explain` writes
only; the `meta` and `data` reads are the same set.
## Verification
<details><summary>Production Console, app-crm (<code>objectstack dev
--fresh --seed-admin</code>), base <code>dbca3ef0</code> and fix
<code>cb81f443</code></summary>
Playwright signs in, opens each route, reloads with the cache disabled,
and logs every `/api/` request with its CDP initiator stack (async depth
64). The `crm_app` bundle holds the CRM objects; `crm_account` and
`crm_contact` look up `sys_user`, `sys_organization` and
`sys_business_unit`, which it does not hold.
`/apps/crm_app/crm_account`, en:
- Before: 30 requests, 1,033,677 B. `GET /api/v1/meta/view` (7,014 B),
initiator the packaged lookup read in `readObjectRouteNames`, called
from `useAppObjectScopePrefetch`.
- After: 28 requests, 1,033,049 B. `GET /api/v1/meta/view` (7,014 B),
initiator `ObjectView`'s `listViews` to `readViewList`; nothing from
`appObjectScope`.
- Probe, after plus `ObjectView`'s `listViews` stubbed (not committed):
28 requests, 1,027,054 B, no `/meta/view`.
`/apps/crm_app/crm_contact`, en:
- Before: 28 requests, 1,034,072 B, `/meta/view` from the same packaged
lookup read.
- After: 28 requests, 1,034,072 B, `/meta/view` from `ObjectView`'s
`listViews` only.
- Probe: 27 requests, 1,027,058 B, no `/meta/view`.
Both routes read `meta/object/sys_organization`, `sys_user` and
`sys_business_unit` by name before and after.
</details>
<details><summary>Local runs</summary>
- Ablation through `scripts/ablation-replace.mjs` (anchor 1 to 0,
restored, blob equals HEAD, `git diff HEAD` empty): 1 failed, 5 passed.
- Sweep at `cb81f443` under `os-verify-lock`, `--maxWorkers=2`: 139 test
files naming the scope readers or `AppContent`, 1,092 tests, all passed.
- `turbo run type-check --filter=@object-ui/app-shell`: 65/65 at
`cb81f443` and at `fadf5b2f` (merge of main).
- `eslint` on the changed files: 0 errors.
- Derived gates (`dispatch-gates --commands`) at `cb81f443`: 34
commands, all exit 0, reconciled with `--ran` (34 derived, 34 run, 0
NOT-MEASURED).
- At `fadf5b2f`: the four scope test files (23 tests) pass;
`check-sdui-manifest`, `check-changeset-no-major` and spec
`check:generated` exit 0.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [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_01QsR2jUpBc8NqS3hJsBsz7W
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUpBc8NqS3hJsBsz7W)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent a81b7cb commit 0bfb225
3 files changed
Lines changed: 135 additions & 13 deletions
File tree
- .changeset
- ui/packages/app-shell/src/console
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
23 | | - | |
| 29 | + | |
24 | 30 | | |
25 | | - | |
26 | | - | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
575 | 576 | | |
576 | 577 | | |
577 | 578 | | |
| |||
0 commit comments