Repository navigation
Commit de8d549
fix(console, app-shell): discovery starts with the session check; Setup's open reads no whole object registry (#35304)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg48yiCyRmnqoUoHcQ9VbBp6)_
Part of #34211 — this lands asks (1) and (2). The card stays open for
its two acceptance numbers, which this PR does not reach (see Acceptance
notes): the list page is not at 5 serial layers, and Setup still sends
two small object reads (both answer empty), not one.
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:控制台冷加载时,`discovery` 请求现在在 HTML 解析阶段就和 `get-session`
一起发出,不再等主包下载完再单独排一层;打开 Setup 不再读取整份对象注册表(showcase 上约 860
KB),改成只读它导航项需要的对象,已在应用包(bundle)里的对象直接从包里回答。
- 为什么改:卡片实测控制台首屏 7 层串行请求,其中 discovery 独占一层;Setup
先读空的包对象列表,再读整份注册表(服务端最重的一次元数据计算)。
- 风险与回滚:只动控制台启动(`index.html`、`main.tsx`、新的 `lib/early-discovery.ts`)和
app-shell 两处(Setup 根路由的对象范围、存在性读取走 bundle);回滚即 revert 本 PR。`index.html`
不在认领列出的路径里,见 Acceptance notes。
- 先看:`ui/packages/app-shell/src/providers/MetadataProvider.tsx`(存在性读取由
bundle
回答的分支)、`ui/packages/app-shell/src/console/appObjectScope.ts`(删掉根路由读整份注册表的例外)、`ui/apps/console/index.html`(`startEarlyDiscovery`)。
- 两分钟验证:`pnpm --dir ui exec vitest run
apps/console/src/__tests__/sessionCheckBootDedup.test.tsx
packages/app-shell/src/providers/__tests__/MetadataProvider.bundleFirstReads-28645.test.tsx
packages/app-shell/src/console/__tests__/AppContent.emptyPackageScope-13046.test.tsx`,预期
3 个文件全绿。
- 需要你做的:决定卡片剩下的两个验收数字(列表页 5 层以内、Setup 恰好一次 `meta/object`)是否另开后续,或按本 PR
的读数调整验收。
## What changes
Measured first (A1) on a production console build (`pnpm console:build`,
served by `objectstack dev --ui --seed-admin` from
`examples/app-showcase` on a private port), signed in through the login
page (so the Bearer token and the early session check are in play),
headless Chromium 1440x900, one warm-up load, then a fresh page per
load; every `/api/` resource entry from navigation to network idle plus
3 s, start and end times from the Resource Timing API. A request's layer
is 1 + the deepest layer of any request that ENDED before it STARTED, so
the page's count is the longest chain of strictly sequential requests.
On a fast local server this counts the client's own render and chunk
gaps as layers too, so it reads higher than the card's grouping; both
readings are below.
1. **Discovery starts with get-session (ask 1, reproduced).** On
`origin/main` `d6d96450` discovery left at 581–613 ms, after the main
bundle evaluated, while `get-session` left at 19–23 ms. `index.html` now
sends `GET /api/v1/discovery` during parse in a third inline script,
`startEarlyDiscovery`, beside `runtime/config` and `get-session`, and
leaves the pending answer under `Symbol.for('objectui.earlyDiscovery')`.
The console's discovery reader moves out of `languageSeed.ts` into
`src/lib/early-discovery.ts` as `readConsoleDiscovery()`: it takes that
request once (same URL) as the request behind `getSharedDiscovery`, and
`main.tsx` starts it on every boot. Before, a device with a stored
language skipped it, so discovery waited for the data adapter's
`connect()`, after the session. The adapter's `connect()` asks the same
per-origin cache, so it joins the answer. It is one request either way,
and its spelling (`credentials: 'include'`, `Accept: application/json`,
no Bearer) is the one `languageSeed` already sent. A failed or non-OK
early request is not reused.
2. **Setup's open reads no whole object registry (ask 2, reproduced).**
On `origin/main`, Setup sent `meta/object?package=com.objectstack.setup`
(49 B, empty) and then `meta/object` (862,486 B, the whole registry).
The root of an app whose package holds no objects of its own was the one
app route that fell back to the registry. It now reads the way that
app's object routes do: the package list, then the objects its entries
require (`requiresObject`) in the one presence read. The presence read
(the batched names scope, `views: false`) now answers a name the entered
app's bundle holds from the bundle, as a by-name read of it is answered,
so Setup's 14 required objects cost no request. What remains on Setup is
the package list and, after the landing redirects to
`dashboard/system_overview`, that dashboard's widget gate asking for
`sys_package_installation` (49 B, empty: an object this runtime does not
register; the registry used to answer it).
3. **The bundle starts with `meta/app`'s answer already (ask 3, premise
does not reproduce).** `meta/app/APP/bundle` leaves 35–50 ms after
`meta/app` answers, in the same render as `meta/object?package=` and
`me/apps`, and on several loads before `meta/object?package=` has
answered (list run 1: package read 731→758, bundle from 741). The
console root has entered the bundle as soon as the app list names the
app (`useAppObjectScopePrefetch`, since objectstack#28645). It cannot
start earlier without the app's name, which only `meta/app` answers: the
route segment is the package id. No change here.
<details><summary>A1 readings, before (origin/main d6d9645) and after
(b48d967, product files byte-identical to head)</summary>
Chain-depth layers, each run:
| page | before | after |
|:--|:--|:--|
| list `showcase_task` | 13, 12 | 11, 12, 12 |
| Setup open | 13, 12 | 11, 13, 10 |
The card's grouping (requests that run together), list page:
- before: L1 `runtime/config`, `get-session` · L2 `discovery` · L3
permissions, organization, i18n, `auth/config`, `meta/app`,
`sys_user_preference` · L4 `meta/object?package=`, `me/apps`, bundle ·
L5 `meta/object?names=sys_user`, view, packages, `ai/agents` · L6 data
reads · L7 `meta/object/sys_user`, notification receipt (7)
- after: L1 `runtime/config`, `get-session`, `discovery` · then the same
groups (6)
Object list reads on Setup: before `?package=com.objectstack.setup` (49
B) + whole registry (862,486 B); after `?package=com.objectstack.setup`
(49 B) + `?names=sys_package_installation` (49 B). An intermediate build
without the bundle-answered presence read sent a third, `?names=` with
the 14 required objects (111,925 B).
After, list run 1 (ms from navigation, start→end):
```
L1: runtime/config (26→80) · auth/get-session (30→105) · discovery (31→107)
L2: auth/me/permissions (712→757) · i18n/translations/en (723→760) · organization/get-active-member (724→768) · organization/list (724→773) · auth/config (756→776)
L3: meta/app (760→804) · data/sys_user_preference (765→818)
L4: meta/object?package=com.example.showcase (847→882) · me/apps (861→1005) · auth/me/localization (864→900) · meta/app/showcase_app/bundle (864→1002)
L5: meta/object?names=sys_user (1015→1033)
```
Before, list run 1:
```
L1: runtime/config (22→29) · auth/get-session (23→71)
L2: discovery (581→585)
L3: auth/me/permissions (622→646) · i18n/translations/en (630→659) · organization/get-active-member (632→665) · organization/list (632→671)
L4: auth/config (657→674) · meta/app (662→696) · data/sys_user_preference (664→705)
L5: auth/me/localization (716→731) · meta/object?package=com.example.showcase (731→758)
L6: me/apps (739→849) · meta/app/showcase_app/bundle (741→847)
```
Setup's sidebar after the change draws the same 46 entries, every
`requiresObject` entry among them (Business Units, Sharing Rules,
Queues, Webhooks, HTTP Deliveries ...), and the landing dashboard
renders.
</details>
## Tests
- `ui/apps/console/src/__tests__/sessionCheckBootDedup.test.tsx`, new
top-level describe `discovery starts at parse time beside get-session,
and the console reads that request (objectstack#34211)`: the shipped
`index.html` scripts, run in document order, send `runtime/config`,
`get-session` and `discovery` in one parse pass; `main.tsx` starts
`readConsoleDiscovery(SERVER_BASE)`; the reader takes the parse-time
request and an adapter-style `getSharedDiscovery` caller joins it (one
discovery request, its own fetcher never called); a failed early request
is asked again.
-
`ui/packages/app-shell/src/providers/__tests__/MetadataProvider.bundleFirstReads-28645.test.tsx`,
new top-level describe `a presence read is answered from the entered
app's bundle (objectstack#34211)`: a bundled name asks nothing; only the
names the bundle does not hold go in one `?names=` read; CONTROL: with
the bundle still on the wire the names are asked as before. The harness
double now also answers the `?names=` list door.
- `AppContent.emptyPackageScope-13046.test.tsx` and
`AppContent.objectScope-12811.test.tsx`: the two CONTROLs that pinned
the root's `?package=` then whole-registry read are now pins of the new
shape: the package list, then one presence read, and the whole registry
at no point. The 13046 one moved into its own top-level describe, since
it is no longer a control.
- `main.nativeBridgeVersion-29330.test.tsx` mocks the new boot kick
beside the other boot modules it already mocks (it imports `main.tsx`).
<details><summary>Ablations (scripts/ablation-replace.mjs, each
restored: blob == HEAD, git diff HEAD empty)</summary>
- `early-discovery.ts`: `const early = await takeEarlyDiscovery(url);` →
`const early = null as { body: unknown } | null;` — 1 failed / 21
passed: `the console reader takes the parse-time request …` ("expected [
[ …(2) ], [ …(2) ] ] to have a length of 1 but got 2").
- `appObjectScope.ts`: the removed root exception put back (`if
(!route.objectName && !own.served.some(…)) return { candidate, scope:
null, … }`) — 2 failed / 13 passed: both root pins ("expected [ …(2) ]
to include 'object?names=sys_member'" and "…
'object?names=cloud_only'").
- `MetadataProvider.tsx`: `if (bundled.state === 'hit') {` → `if
(bundled.state === 'hit' && false) {` — 2 failed / 18 passed: `answers a
bundled name from the bundle, and asks nothing` and `asks, in one
?names= read, only the names the bundle does not hold`.
</details>
## Acceptance notes
- **The card's two acceptance numbers are not reached.** List page: the
card's grouping goes 7 → 6 layers. The chain counted on the built
console stays at 11–12 layers, because most of what is left is client
render and lazy-chunk gaps between requests, not request-to-request
waits. The waits that are left are real dependencies: `meta/app` and the
permission reads need the mounted tree, the package list and the bundle
need `meta/app`'s answer (the URL holds the package id, the bundle route
takes the app name), and the view and data reads need the object. Setup:
two object reads remain, both 49 B and empty. The second is
`DashboardView`'s widget gate asking for an object this runtime does not
register, which only a server answer settles. The registry used to
answer it, at 862 KB. Getting to one read would need a server-side
signal, such as the app item saying its package holds no objects, or the
bundle answering absence. That is out of this PR (claim: no server
edit).
- `ui/apps/console/index.html` is outside the claim's listed paths
(`ui/apps/console/src/**` boot). Ask (1) cannot be met without it,
because the session check starts there. The change follows its two
sibling parse-time scripts.
- The list page still reads `sys_user` twice:
`meta/object?names=sys_user` (presence) at ~1015 ms and
`meta/object/sys_user` (by name) at ~1571 ms. Noted, not traced here.
- Ask (3) is unchanged: see What changes, item 3.
## Verification
On head `93c21bff` (`origin/main` merged; the incoming commits touch no
file of this diff):
- Scoped re-check after the merge: `cd ui && pnpm exec vitest run` over
the five test files named under Tests plus
`App.listPageBootReadsOnce-28085` and `languageSeed.test.ts`: 7 files,
82 tests passed; `pnpm --filter @object-ui/app-shell run type-check`
exit 0.
- On `998d59a3` (the last product commit): `cd ui && pnpm exec vitest
run packages/app-shell/src/console/ packages/app-shell/src/providers/
packages/app-shell/src/hooks/ packages/app-shell/src/views/__tests__/
apps/console/src/` under the verify lock: Test Files 847 passed, Tests
7836 passed. `pnpm --filter @object-ui/app-shell --filter
@object-ui/console run type-check`: exit 0.
- `node scripts/pm/dispatch-gates.mjs --commands` on `998d59a3`: 39
derived families, 39 run, each exit 0 (`pnpm --dir ui exec vitest run
scripts/`: 171 files passed, 2 skipped). `pnpm check:new-line-citations`
(ui): 0 new citations.
- Dogfood battery: not run (no `!` in the title, no `(narrowing)` arm).
- The CI families (Lint & Repo Gates, Type Check UI, Test UI, Build &
E2E UI and the rest of the required set) are this PR's check-runs.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 17ceb2d commit de8d549
12 files changed
Lines changed: 444 additions & 57 deletions
File tree
- .changeset
- ui
- apps/console
- src
- __tests__
- lib
- packages/app-shell/src
- console
- __tests__
- providers
- __tests__
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 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 | + | |
186 | 248 | | |
187 | 249 | | |
188 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
341 | 344 | | |
342 | 345 | | |
343 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | 103 | | |
105 | 104 | | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | 120 | | |
128 | 121 | | |
129 | 122 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | 123 | | |
153 | 124 | | |
154 | 125 | | |
| |||
196 | 167 | | |
197 | 168 | | |
198 | 169 | | |
199 | | - | |
| 170 | + | |
200 | 171 | | |
201 | 172 | | |
202 | 173 | | |
| |||
0 commit comments