Repository navigation
Commit f9120b8
fix(console): ask a requiresObject and a packaged app's off-package lookup target by name only once the host serves it (#34299)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9MVfcuum36AeADC9kpjLcCN)_
Fixes #34244
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:控制台对「带包应用里不在本包的查找目标」和「导航条目的
`requiresObject`」不再直接按名字读对象定义,而是先用一次 `GET /meta/object?names=`
问服务端有没有,只有存在的才按名字读。路由、侧栏闸门、视图项读取、命令面板和 `nav:menu` 积木共用同一个判断函数。
- **为什么改**:宿主没注册的对象(如免费环境的 `sys_approval_request`)按名字读,每次打开页面都会
404,cloud#4300 的 staging 噪音多半就是这个。
-
**风险与回滚**:只改控制台读取顺序,不改协议。带包应用有包外目标时每个路由多一次批量请求;记录抽屉深链时包外查找目标要等整表落地才出现链接(见
Acceptance notes)。回滚即 revert 本 PR。
-
**先看**:`ui/packages/app-shell/src/console/appObjectScope.ts`(`readObjectPresence`、`servedByName`)、`ui/packages/app-shell/src/hooks/useNavMemberGates.ts`(侧栏闸门改读存在性答案)、`ui/packages/app-shell/src/views/nav-menu-renderer.tsx`。
- **两分钟验证**:`cd ui && pnpm exec vitest run
packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx
packages/app-shell/src/console/__tests__/AppContent.packagelessReads-29416.test.tsx`,预期全部用例通过,且没有任何
`object/gone_obj`、`object/cloud_billing` 请求。
- **需要你做的**:无,席位落地。
## What changes
One rule for both app arms, in one exported helper, `readObjectPresence`
(`ui/packages/app-shell/src/console/appObjectScope.ts`): a name a reader
would otherwise ask by name is asked first in ONE `GET
/meta/object?names=` read, which leaves an absent name out. In a
packaged app the names the package list holds are registered and asked
nothing more. A name joins a by-name scope only once that read answers
it served (`servedByName`, the generalisation of #34188's
`servedLookupTargets`, which skipped the package arm).
- **Off-package lookup targets** (package arm of `readPageObjectScope` /
`readObjectRouteNames`): now go through the presence read; package-held
targets read as before.
- **`requiresObject`** had several by-name readers, not one, so the
claim's surface was amended on the card by the seat:
- the route's scope (`appObjectScope.ts`, object, page, record and
dashboard arms) asks only the served required names
(`servedRequiredObjectNames`), and the command palette's navigation
objects drop an entry object that is required and not served
(`paletteObjectNames`);
- the sidebar gate (`hooks/useNavMemberGates.ts`): a package-less app
asks its `requiresObject` union in the one `?names=` read inside an app
too (it asked by name there); a packaged app reads the same presence
answer as the route for its own required names, so it still hides an
entry the answer leaves out;
- the served view items (`hooks/useServedViewItems.ts`, package-less
arm): a required object, including an entry that opens the object it
requires, is asked by name only once served;
- the `nav:menu` block (`views/nav-menu-renderer.tsx`): reads the
package list plus the same presence answer, never by name.
- Route, gate, served view items and `nav:menu` pass the same names to
the helper, so the provider's batched names scope asks them once.
### Request counts (measured, `AppContent.packagelessReads-29416`
harness: real provider, `AppContent` and sidebar gate)
| Route | Before (main 43dd565) | After |
|:--|:--|:--|
| package-less `/apps/notes/note` | 5 requests, 1 × 404
(`object/gone_obj`) | 5 requests, 0 × 404 |
| packaged `/apps/app.crm/crm_account` | 3 requests, 1 × 404 | 3
requests, 0 × 404 |
| packaged page `/apps/app.crm/page/crm_only` | 3 requests, 1 × 404 | 3
requests, 0 × 404 |
<details><summary>Raw request sequences</summary>
```text
BEFORE /apps/notes/note object/note, object/gone_obj, object?names=sys_user, object/crm_account, object/sys_user
AFTER /apps/notes/note object/note, object?names=gone_obj, object?names=sys_user, object?names=crm_account, object/sys_user
BEFORE /apps/app.crm/crm_account object?package=app.crm, object/sys_user, object/gone_obj
AFTER /apps/app.crm/crm_account object?package=app.crm, object?names=sys_user,gone_obj, object/sys_user
BEFORE /apps/app.crm/page/crm_only object?package=app.crm, object/sys_user, object/gone_obj
AFTER /apps/app.crm/page/crm_only object?package=app.crm, object?names=sys_user,gone_obj, object/sys_user
```
Fixture: the harness's `CRM_APP` with the two `requiresObject` entries
this PR adds (`sys_user`, `gone_obj`), both runs.
</details>
**One presence read or one per reader?** For one set of names, one: the
route, the sidebar gate, the served view items and `nav:menu` all ask
the same required names through `readObjectPresence`, and the provider
asks a name of the batched scope once (the packaged rows above: one
`?names=sys_user,gone_obj` serves the route and the gate). A packaged
page with an off-package lookup AND an off-package `requiresObject`
makes **two** presence reads (pinned in `appObjectScope-12811`): the
app's required names as the package list lands, then the route object's
lookup targets once its definition lands. Folding them into one would
hold the sidebar gate's answer until the page's bound object answers;
not done. In the package-less arm the gate asks the app list's whole
`requiresObject` union (the bell's cross-app roster) while the route
asks its own app's names, so the rest of the union is a separate
`?names=` read (the `?names=crm_account` above). `nav:menu` sharing the
request: by construction and by the fake-context pin in
`pageObjectReads-12980`; NOT MEASURED against the real provider
(mounting `nav:menu` needs the page renderer).
## Tests
- New pins (top-level describes in existing harnesses):
- `appObjectScope-12811`: "objectstack#34244 — a packaged app asks an
off-package lookup target or a requiresObject by name only once it is
served" (page and object route arms: no `object/sys_approval_request`,
no `object/cloud_billing`, the exact two presence reads; the command
palette open asks no unregistered entry object by name) + CONTROL
(registered off-package `sys_user` still asked by name and in scope).
- `AppContent.packagelessReads-29416` (e): in a package-less and a
packaged app, `gone_obj` only in a `?names=` read and its entry hidden
by the real sidebar gate; CONTROL: a registered off-package
`requiresObject` is shown and asked by name.
- `packagelessChromeScope-12980`: the served view items ask an entry's
required object the host lacks only in the presence read.
- Ablations (each mutation through `scripts/ablation-replace.mjs`,
restore verified `blob == HEAD`, `git diff HEAD` empty; ui vitest reads
`@object-ui/*` from `src/`, no build leg):
1. `servedByName` returns every candidate: 7 red (both 34188 pins, both
new 12811 pins, 29416 (a) and both (e)).
2. gate drops the presence answer's `missing` (`useNavMemberGates.ts`):
2 red (29416 (e) packaged + its CONTROL, which waits on the hidden
entry).
3. `paletteObjectNames` returns every opened object: 2 red (both palette
pins).
4. served view items keep required nav objects by name
(`useServedViewItems.ts`): 1 red (new chrome pin).
5. `nav:menu` drops the presence answer's `missing`: 1 red
(`pageObjectReads-12980` nav:menu pin).
- **Forced test edits** (declared; each is a call-sequence pin that now
sees the presence read):
- `appObjectScope-12811`: the card's named CONTROL `the same lookups
drawn ask every target by name` flipped to `… ask every registered
target by name, once one presence read has answered them`; four
package-arm sequences gain `object?names=sys_user` (root prefetch,
record drawer, #29551 bundled, #33343 hidden lookup); the #29551 bundled
adapter double learns `options.names` (it answered a `?names=` ask as
the whole list).
- `AppContent.packagelessReads-29416` (a): `object/crm_account` and
`object/gone_obj` no longer by-name calls (the card's flip); the
ConsoleLayout mock adds a `user-entry` probe; `CRM_APP` gains two
`requiresObject` entries for (e).
- `AppContent.emptyPackageScope-13046` (a), (b), CONTROL;
`AppContent.objectScope-12811` (2);
`AppContent.packagelessRecordRelated-29552` (3);
`AppContent.pageRouteObjects-12980` (b): the expected sequences gain the
presence reads, and `cloud_only` moves from by-name to `?names=`.
- `navGateUnionScope-12980`: (a) the union is asked in `?names=` reads,
each name once, none by name; (b) rewritten from "a by-name read that
fails" to "a presence read that fails leaves its entries shown" (new
`failNamesRead` behaviour on the double); (c) and CONTROL (d): the
off-package name in the presence read.
- `packagelessChromeScope-12980` (a), `packagelessServedViews-29416`:
the presence read of the required names appears in the call list.
- `pageObjectReads-12980` nav:menu: the gate reads `{ packageId, views:
false }` plus `{ names: ['cloud_only'], views: false, batch: true }`,
never `cloud_only` by name.
- `AppContent.recordDrawerKeepsScope-27626` deep link: before the held
registry lands the list draws `crm_account,crm_contact`; `sys_user`
joins once it lands (see Acceptance notes).
- Six adapter doubles (`13046`, `packagelessRoot-29552`,
`pageRouteObjects-12980`, `recordDrawerKeepsScope-27626`,
`packagelessChromeScope-12980`, `packagelessServedViews-29416`) learn
`options.names`, as #34188's doubles did; without it a `?names=` ask
read as the whole list.
- Four `AppContent.*` harnesses gain the module-top `import
'@objectstack/lint';` that `check:test-source-alias` requires of an
edited file reaching `AppContent`.
## Acceptance notes
- **Record drawer deep link:** the provider's batched names scope waits
for a whole object list already in flight rather than asking twice
(`MetadataProvider.readObjectScope`). On a deep link to a drawer, the
drawer starts the registry before the presence read, so a packaged
list's off-package lookup target (its link in a lookup cell) now appears
when the registry lands, not before; the list itself still draws on its
scope before the registry. A package-less app's lookups have waited the
same way since #34188. Not changed here: asking during an in-flight
registry read would add a request beside it.
- The package-less gate's union read moved from by-name to the one
`?names=` read inside an app as well. Its old comment kept the in-app
union by name so the route object's by-name read was shared with the
record form (objectui#13044); the route still reads its object by name,
so that sharing is unchanged.
- A package-less app whose entries require the objects they open now
makes one presence read for those names beside their by-name reads
(`packagelessChromeScope-12980` (a): `object?names=note`).
## Verification
Final head `c9f6b80b` (main `01598d93` merged in; no overlap with this
diff).
- Affected-test run: the 375 test files under
`ui/packages/app-shell/src` and `ui/apps/console/src` that name a
changed module, `requiresObject`, `readObjectScope`, `AppContent`,
`ConsoleLayout`, `UnifiedSidebar`, `ObjectView` or `AppHeader`: `Test
Files 375 passed (375)`, `Tests 3344 passed (3344)`, lock VERDICT
command-exit 0. Narrowed from the whole package (CI's Test UI shards run
it).
- `@object-ui/app-shell` type-check and the 37 derived gates
(`dispatch-gates --commands`, reconciled with `--ran`): verdicts in the
os-dev-report on #34244.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRxEQg2W4PJKcnZzTr)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 9346353 commit f9120b8
17 files changed
Lines changed: 499 additions & 116 deletions
File tree
- .changeset
- ui/packages/app-shell/src
- console
- __tests__
- hooks
- __tests__
- views
- __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 | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
148 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
149 | 159 | | |
150 | 160 | | |
151 | 161 | | |
| |||
227 | 237 | | |
228 | 238 | | |
229 | 239 | | |
| 240 | + | |
| 241 | + | |
230 | 242 | | |
231 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
232 | 252 | | |
233 | 253 | | |
234 | 254 | | |
| |||
258 | 278 | | |
259 | 279 | | |
260 | 280 | | |
| 281 | + | |
| 282 | + | |
261 | 283 | | |
262 | 284 | | |
263 | 285 | | |
| |||
291 | 313 | | |
292 | 314 | | |
293 | 315 | | |
294 | | - | |
| 316 | + | |
| 317 | + | |
295 | 318 | | |
296 | 319 | | |
297 | 320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
242 | 247 | | |
243 | 248 | | |
244 | 249 | | |
| |||
250 | 255 | | |
251 | 256 | | |
252 | 257 | | |
253 | | - | |
254 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
255 | 262 | | |
256 | 263 | | |
257 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| |||
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
142 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
| |||
264 | 276 | | |
265 | 277 | | |
266 | 278 | | |
267 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
268 | 283 | | |
269 | 284 | | |
270 | 285 | | |
| |||
324 | 339 | | |
325 | 340 | | |
326 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
| 473 | + | |
473 | 474 | | |
474 | 475 | | |
475 | 476 | | |
| |||
504 | 505 | | |
505 | 506 | | |
506 | 507 | | |
507 | | - | |
| 508 | + | |
508 | 509 | | |
509 | 510 | | |
510 | 511 | | |
| |||
562 | 563 | | |
563 | 564 | | |
564 | 565 | | |
565 | | - | |
| 566 | + | |
566 | 567 | | |
567 | 568 | | |
568 | 569 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
176 | 180 | | |
177 | 181 | | |
178 | 182 | | |
179 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
180 | 190 | | |
181 | 191 | | |
182 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| |||
168 | 172 | | |
169 | 173 | | |
170 | 174 | | |
171 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
172 | 182 | | |
173 | 183 | | |
174 | 184 | | |
| |||
286 | 296 | | |
287 | 297 | | |
288 | 298 | | |
289 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
290 | 304 | | |
291 | 305 | | |
292 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
| |||
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
149 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
150 | 160 | | |
151 | 161 | | |
152 | 162 | | |
| |||
288 | 298 | | |
289 | 299 | | |
290 | 300 | | |
291 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
292 | 307 | | |
293 | 308 | | |
294 | 309 | | |
| |||
0 commit comments