fix(console): declare type: 'home' on the page preview sample (#3454) - #3473
Merged
Conversation
`PageSchema.type` is `PageTypeSchema.default('record')`, so the page sample
omitting `type` did not mean "unspecified" — it materialised the CRM welcome
screen as a RECORD page bound to no object (`object` is optional, so nothing
complained). The `app` sample in the same file routes that very page as the
CRM's landing entry, so `home` is the kind it is actually used as.
The mismatch was invisible: the gallery renders the UNPARSED draft, so no
test would ever have gone red over it. It matters because these samples are
the worked example authors — increasingly models generating metadata — copy.
Pinned on the PARSED value, since only the parse distinguishes "declared
`home`" from "omitted, therefore `record`".
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
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 #3454
问题
apps/console/src/preview-samples.ts的page样例只声明了name/label/regions,没有声明type。而 spec 的PageSchema.type是PageTypeSchema.default('record')(page.zod.ts:413),所以「不写」并不等于「未指定」——它会落成record页;又因为object是可选的,这个 record 页没有任何对象绑定,校验也不会报错。但同一个文件里的
app样例,正是把这个页面当首页用的:navigation[0]={ id: 'home', type: 'page', pageName: 'crm_welcome' }即:样例演示的语义(首页)与它解析后的语义(无绑定的记录页)是矛盾的。
为什么之前没有任何测试变红
gallery 渲染的是未解析的 draft(
draft.type为 undefined);而preview-samples-registry-resolvable.test.ts只遍历regions[].components,不读根节点的type。这个缺陷正好落在两条既有防线之间。它值得修,是因为这些样例是作者(越来越多是生成元数据的模型)照抄的范例——错误语义会被复制、传播。改动
一行
type: 'home',加一段说明「为什么必须显式声明」的注释。home在PageTypeSchema中(page.zod.ts:232),且已注册渲染器(packages/components/src/renderers/layout/page.tsx:700,与page共用PageRenderer)。这一行有实际作用,不只是「更规范」
运行时
PageView.tsx:129-131会把 spec 的type桥接到渲染器真正读的pageType:该处注释写明:没有这个映射,"every page fell back to
pageType: 'record', so non-record pages got the record max-width, a wrongdata-page-typeand a suppressed header"。也就是说,原样例演示的恰恰是这个映射要避免的坏状态;补上后,它发布到真实应用、从 home 导航打开时,会真正走HomePageLayout。验证
反向验证(先预测方向,再执行):先加 pin、不改样例 → 应当变红,且 received 恰为
'record'。实际输出:补上
type: 'home'后:preview-samples-spec-valid.test.ts+preview-samples-registry-resolvable.test.ts:35 passedapps/console全量:23 files / 212 tests passedtype-check --filter=@object-ui/console:35 tasks successfulcheck-control-bytes:OK浏览器验证(scoped verify skill,gallery
?only=page):改动前后截图 md5 完全一致(8fde30b4...),DOM 采集逐项相同,无 "Unknown component type" 兜底框。零视觉差异的原因比「draft 路径忽略 type」更具体:design 模式下PagePreview走的是PageBlockCanvas,根本不经过PageRenderer(所以 DOM 里没有data-page-type);即便走SchemaRenderer,'home'与原先注入的'page'也都解析到同一个PageRenderer,而布局分支读的是pageType(预览路径并不设置它)。未改动 / 无新 finding
spec 的
type(页面种类)与 objectui 节点pageType的命名冲突,是packages/types/src/zod/layout.zod.ts:296已明确记录的既有取舍,且运行时已由PageView桥接,因此不另开 finding。按 #3453 先例,dev-only 样例不加 changeset。
Generated by Claude Code