fix(app-shell): 默认列表视图的身份改向组装器查询,译文键 _views.default 不再落空 (#3770) - #3776
Merged
Conversation
… `list.name || 'list'` (#3770) A `defineView` container declares its default list under the `list` key. That key is a slot in the authoring document, not the view's identity: the composer `expandViewContainer` — the same one the framework loader and the i18n extractor call — registers an unnamed default list as `<object>.default`. This renderer derived `list.name || 'list'`, a third spelling no producer emits, so a default-list-only object probed `_views.list.label` and missed the published `_views.default.label` (objectstack#5164 ruling A, migrated in objectstack#6124), falling back to English for the view's label, description and empty state alike. - `mergeViewsIntoObjects` expands a stack-packaged container through the composer and routes the result through the same path as first-class ViewItems, so both gates key by `<object>.<key>` and the container inherits the composer's folding and collision renaming. - `ObjectView` derives the primary view id through one shared `defaultListViewId` helper (override lookup + switcher promotion), with no literal fallback left behind. Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3770
结论
容器(
defineView)把默认列表放在list这个键下面。list是授权文档里的一个槽位,不是视图的身份:组装器expandViewContainer(框架 loader 与 i18n 提取器调用的同一个函数)给未命名的默认列表分配的身份是{object}.default,给具名的分配{object}.{list.name}。objectui 这一侧自己推了第三种拼法
list.name || 'list'—— 没有任何生产者会产出它。于是只声明默认list的对象在 objectui 上探测objects.{object}._views.list.label,而译文包里(objectstack#5164 裁 A,objectstack#6124 迁移)是_views.default.label,命不中 → 标签、description、emptyState 一起回落英文。修法按卡内 contract-first 方向:不在
viewSuffixes加 list→default 双读,也不写?? 'default'字面量,而是向组装器要身份。改了什么
MetadataProvider.mergeViewsIntoObjects的容器分支改为跑expandViewContainer(objName, view),再把结果喂给与 ViewItem(记录闸门)同一段路由代码(抽出的applyViewItem)。两个闸门因此产出同一套{object}.{key}身份,容器还白拿了组装器的两条规则:listViews里某项与list结构相同时,组装器把默认列表折进那一项的身份(本地推导永远做不到这件事,只会多出一个重复 tab);_2重命名。ObjectView两处primary.name || 'list'收敛成一个共享 helperdefaultListViewId(packages/app-shell/src/utils/viewIdentity.ts),override 查询与视图切换器提升共用同一次推导,不留任何字面量兜底。已带上组装器限定名的条目直接原样返回(否则会得到crm_lead.crm_lead.default的双前缀)。AppHeader未改:那里是按 URL 段去listViews里查,本身没有这条推导,id 修正后它自动跟着对。metadata-admin/inspectors/ViewInspector的?? 'list'也未改 —— 那是设计器编辑的容器槽位 storeKey,属另一条轴。存量数据测量(派发要求的门控,先测后改)
键面与写入位置。 override 的持久化键就是 view id:
ObjectView.persistViewPatch(view.id)→dataSource.updateViewConfig(objectName, viewId, cfg)→data-objectstack:client.meta.saveItem('view', viewId, { ...cfg, object, name: viewId })→PUT /api/v1/meta/view/{viewId}→ 一行sys_metadata(type='view',name=该 id)。不落 localStorage;defaultViewId是每次渲染由views.find(v => v.isDefault)现算的,从不持久化,自身没有存量。结论:改名不会让任何存量数据静默失联。 三条证据:
objectql/engine.ts对每个从 manifest 注册的容器同时注册容器本身与expandViewContainer展开出的 ViewItem;objectui 的 merge 见到 ViewItem 就跳过容器。framework 的packages/objectql/src/protocol-view-identity-overlay.test.ts里那行「从 3777 repro 的 sys_metadata 行捕获」的真实个性化 PUT,存的正是name: 'showcase_task.default'。也就是说 showcase 默认列表的 override 早就写在showcase_task.default下 —— 本 PR 不动这条路径的 id(helper 对已限定名原样返回)。'list'根本不是一个可表示的视图身份,因此不存在「需要迁移到新 id」的合法存量行:ViewItemNameSchema=/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/,裸名一律拒。(已实测:ViewItemSchema/ViewItemWireSchema对'list'、'default'均 REJECT,对showcase_contact.default通过。)resolveViewId双向解析裸名与限定名;旧的/view/list链接现在解析不到,回落到defaultViewId—— 而那正是它本来指的那个视图。顺带记录一条本 PR 不修的相邻观察(已另立 #3774):
data-objectstack.listViewOverrides(objectName)读的是client.meta.getItems(objectName),即GET /api/v1/meta/{objectName}(把对象名当成 metadata type),而写入走的是type='view',两边键空间不相交;且它失败时返回{},ObjectView.loadBatch见到「是对象」就不再回落逐视图getView。测试
新增
packages/app-shell/src/views/ObjectView.defaultViewIdentity.test.tsx,钉住整条链路(两仓此前都没有的那条):服务端 TranslationData(键
_views.default)→transformSpecTranslations(consoleloadLanguage用的真实变换)→mergeViewsIntoObjects→defaultListViewId→useObjectLabel().viewLabel(objectName, view.name || view.id, fallback),断言 label / description / emptyState 三个都命中中文;具名视图仍按自己的裸键解析;记录闸门那条(本来就对的)一并钉住;ViewItemNameSchema钉住「推出来的 id 是可表示的持久化键、'list'不是」,以及重复推导幂等(否则每次渲染都会换名字、把上一次的 override 孤立掉)。MetadataProvider.merge.test.ts的容器用例做了逐条分诊而非批量改拼写:未命名默认列表 →{object}.default;作者写了list.name→ 用作者的键;新增折叠用例(listViews复述list时只出一个视图);form 家族路由。原「跳过容器」用例的注释改写为它现在真正的理由(容器展开后会多出第三个default列表 tab 并把formViews.default挤成_2,且 ViewItem 行才是运行时把个性化 heal 上去的那一份)。反向验证(先预测方向再跑,两个方向都出现了):把退休推导装回去(
primary.name || 'list'+bucket.listViews[view.list.name || 'list'])后 ——第二条是反向红:退回去以后那个本该永远命不中的
_views.list反而解析出来了。两个方向都断言,所以只回退其中一处调用点也无法保持绿。跑过的命令(worktree
objectui-3770,仓根,均在flock /tmp/os-heavy-verify.lock下):消费半径已按「规则被谁消费」而不是「改了哪个包」清扫:全仓
mergeViewsIntoObjects的调用方只有 app-shell 这一处(@object-ui/core里另有一个同名 adapter,但仓内零消费者,已作为观察类 finding 另立 #3775);plugin-view / apps/console 的listViewsfixture 由 schema 作者提供,不经此 merge。Changeset
.changeset/default-list-view-identity-3770.md(@object-ui/app-shell: patch,用户可见的标签解析行为)。Generated by Claude Code