Skip to content

fix(console): ask a requiresObject and a packaged app's off-package lookup target by name only once the host serves it - #34299

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-1gc824
Nov 16, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-1gc824

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

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
Raw request sequences
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.

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, Console: a packaged app's object route reads the whole /meta/view list when a lookup target is outside its bundle #29551 bundled, health reports the wrong version, and the member record page logs meta/object 404s for sys_business_unit and sys_comment_reaction #33343 hidden lookup); the Console: a packaged app's object route reads the whole /meta/view list when a lookup target is outside its bundle #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 Console: a page's lookup targets are asked one name at a time, and a target the host does not register answers 404 #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 Console: a page's lookup targets are asked one name at a time, and a target the host does not register answers 404 #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).


Generated by Claude Code

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 16, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi

维护者速读

  • 卡:Console: a packaged app's off-package lookup target, and a page's requiresObject, are still read by name and answer 404 when the host does not register them #34244(p2,cloud#4300 预发环境 meta/object/sys_approval_request 404 的来源):带包应用里指向包外对象的 lookup,以及导航项的 requiresObject,在宿主没注册该对象时仍按名字读,每次打开都 404。
  • 改了什么:appObjectScope.ts 新增一个共享的存在性读取 readObjectPresence:包自己的对象由包列表回答,其余名字合并成一次 GET /meta/object?names=,只有回答「存在」的才会再按名字读。路由、侧栏能力门(useNavMemberGates)、已服务视图项(useServedViewItems)、nav:menu 和命令面板都走这一条规则,不再各写一份。
  • 请求数(真实 provider 测试框架实测):无包应用的记录页 5→5 次请求、404 从 1→0;带包应用的对象路由和页面路由 3→3 次、404 从 1→0。同一页面上 lookup + requiresObject + nav:menu 共两次存在性读取(必需名字一次、路由对象的 lookup 目标一次,后者要等对象定义回来才知道),没有按读者各发一次。
  • 钉子:未注册的包外 lookup 不再按名读;未注册的 requiresObject 不再按名读;对照组已注册的仍正常解析;12811 的对照用例按声明翻转。消融 5 条全红并还原。派生门禁 38/38 exit 0,受影响测试 375 文件 / 3344 例全绿。
  • CI:head c9f6b80 — success 38 · skipped 13 · 无失败;main 领先 13。Clause-② no,Metadata-protocol none。

席位意见

一个存在性读取供所有读者共享,是根修,不是给每个读者各补一次判断。nav:menu 的读取键改成和侧栏一样的 { packageId, views: false },两者共用一次请求。已声明的偏差:抽屉深链里的 lookup 链接现在等注册表读完再出现,测试已按声明更新;nav:menu 共用请求是按构造和假上下文测试证明的,没在真实 provider 上量。两者都可以接受。同意落地。

席位核对 — ACCEPT · domain:ui#2 · head c9f6b80 · 2026-11-16T05:03Z

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 16, 2026 05:03
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit f9120b8 Nov 16, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-1gc824 branch November 16, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants