Skip to content

fix(app-shell): page block inspector authors visibleWhen, not hidden (#3229) - #3286

Merged
xuyushun441-sys merged 1 commit into
mainfrom
claude/issue-3229-page-block-visible-when
Aug 3, 2026
Merged

fix(app-shell): page block inspector authors visibleWhen, not hidden (#3229)#3286
xuyushun441-sys merged 1 commit into
mainfrom
claude/issue-3229-page-block-visible-when

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Fixes #3229

按 PM 裁定的方案 A 实现(A/B 已与维护者敲定,本 PR 不再重开该讨论)。

缺陷

PageBlockInspector.tsx 给选中 page 块渲染的条件构建器读写的是 block.hidden。而 @objectstack/specPageComponentSchemaui/page.zod.ts)是 .strict() 的,键集合里根本没有 hidden

关键点是方向:这不是「消费端太宽容」,而是生产者在批量产出契约必然拒收的元数据。作者在这个框里填任何东西,保存时都会拿到一个指名了自己从没输入过的键的解析错误 —— 那个键是检查器替他填的。spec 的报错自己就写明了修法(the canonical key is visibleWhen)。

改动

  1. ConditionBuilder 改为读写 visibleWhen(ADR-0089 canonical)。因为 visibleWhenExpressionInputSchema,已持久化的块携带的是 { dialect, source } 信封而非作者输入的字符串,所以走 Hook 检查器把 { dialect, source } 信封形式的 condition 读成空字符串,提交时会清掉它 #3218 落地的共享读写对 expressionSource / writeExpressionSource —— 一次编辑会保留 dialectmeta、丢弃已陈旧的 ast,而不是把信封拍平成裸字符串、悄悄换掉求值引擎。
  2. 语义翻转落在 UI 文案上hiddenvisibleWhen 互为反义,所以标签、i18n key、双语文案一起走 —— engine.inspector.pageBlock.hidden.visibleWhenHidden (CEL)Visible when (CEL),「隐藏条件(CEL)」→「显示条件(CEL)」。
  3. 本地类型 hidden?: stringvisibleWhen?: ExpressionInput

同时补上了原单指出的第三个缺口:一个合法的块(带 visibleWhen)此前在检查器里没有任何控件能编辑它的可见性 —— 屏幕上唯一的可见性控件写的是错键。

两件明确没做的事

没有把旧 hidden 表达式取反塞进 visibleWhen 对任意 CEL 表达式做文本取反不成立(!(a && b) 不是 !a && !b);而且根本不存在需要迁移的存量 —— ADR-0089 D3a 之后 hidden 在保存时就是响亮解析失败,D3a 之前该键在 parse 时被静默剥掉,同样进不了已发布的元数据。让稀有的陈旧草稿走响亮报错(报错本身就是迁移指引),比静默改写作者的谓词安全。

没有只换键名而留下 hidden 语义的文案。 那会让作者把条件写反,产出「能 parse 但语义相反」的元数据 —— 正是 objectui#3276 那一类,而 #3257 的守卫结构上抓不到它(它只问能不能 parse)。

测试:钉住方向,不只是键名

新增 PageBlockInspector.visibleWhen.test.tsx(11 例)。沿用 #3216 的 fixture 纪律:不手写信封,所有 fixture 都是作者输入喂给 PageSchema.parse 的结果。

  • 方向(硬要求):把检查器实际提交的那个块交给 SchemaRenderer(即 PageBlockCanvas 使用的渲染器)—— 谓词为真时块渲染,为假时不渲染。两个方向互为佐证:谓词若失效会 fail-soft 成可见,那样「为假」这条就会红。
  • 提交的键是 visibleWhen不是 hidden;提交后的草稿能 PageSchema.parse 通过(并反向钉住旧 hidden 形状确实会抛错)。
  • 信封写入规则(保留 dialect / meta)、清空回落 undefined、从零新建时提交裸字符串简写。
  • 文案:英文断言出现 Visible when 且不出现 Hidden;中文断言出现「显示条件」且不出现「隐藏条件」。

验证结果

vitest run packages/app-shell/src/views/metadata-admin/inspectors/PageBlockInspector.visibleWhen.test.tsx
 Test Files  1 passed (1)
      Tests  11 passed (11)

vitest run packages/app-shell/src/views/metadata-admin      # 回归整个 metadata-admin
 Test Files  119 passed (119)
      Tests  1056 passed | 1 skipped (1057)

eslint 3 个改动文件  → 0 errors

type-check 在全新 worktree 里因为兄弟包未构建会有 866 条 Cannot find module '@object-ui/*' 级联报错 —— 我用 stash 把改动摘掉跑了同一条命令做基线对比:基线 866 / 本分支 866,逐条 diff 只有行号位移(我加了 import 与注释),本改动零新增类型错误。

范围

严格限定在 views/metadata-admin/inspectors/ + 共享 i18n 语言包。语言包只改了自己的 2 行(每个语种 1 行),没有重排或重新格式化任何既有条目,避免与并行 agent 冲突。未触碰 previews/#3275)与 RecordDetailView.tsx#3268)。

已附 changeset(patch,未声明 major,已过 check-changeset-no-major.mjs)。

🤖 Generated with Claude Code

https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa


Generated by Claude Code

…en` (#3229)

The conditional-visibility `ConditionBuilder` on the selected page block read
and wrote `block.hidden`. `PageComponentSchema` (`ui/page.zod.ts`) is
`.strict()` and has no `hidden` key, so the designer — a PRODUCER — was
emitting drafts guaranteed to fail parse on save, naming a key the author
never typed. The canonical key is `visibleWhen` (ADR-0089).

The control now reads/writes `visibleWhen` through the shared expression
envelope pair (#3218), since `visibleWhen` is `ExpressionInputSchema` and a
persisted block carries `{ dialect, source }` rather than the authored string.

The semantic flip lands in the UI copy too — `hidden` and `visibleWhen` are
inverses, so the label and the i18n key move with it
(`engine.inspector.pageBlock.hidden` → `.visibleWhen`, both language packs:
"Hidden (CEL)" → "Visible when (CEL)", 隐藏条件 → 显示条件). Renaming the key
under hide-flavoured copy would make authors write predicates backwards —
metadata that parses and means the opposite (the #3276 class, which #3257's
parse guard is structurally blind to).

No value is migrated: negating an arbitrary CEL predicate textually is unsound,
and since ADR-0089 D3a no valid stored draft can carry `hidden` anyway.

Tests pin DIRECTION, not just the key name: the block the inspector actually
commits is rendered through SchemaRenderer and must appear when its predicate
is true and be absent when false.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Aug 3, 2026 10:49am

Request Review

@github-actions github-actions Bot added the tests label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Main entry (gzip) 28.1 KB 350 KB
Entry file index-Dr6Eb9OF.js
Status PASS

📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 8.47KB 3.09KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 7.57KB 2.97KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 22.10KB 4.37KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.12KB 3.41KB
auth (LoginForm.js) 17.86KB 5.29KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.43KB 2.09KB
auth (SocialSignInButtons.js) 9.60KB 3.89KB
auth (UserMenu.js) 3.40KB 1.22KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 35.76KB 9.11KB
auth (createAuthenticatedFetch.js) 4.37KB 1.69KB
auth (index.js) 2.35KB 1.07KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 4.91KB 0.87KB
auth (useIsWorkspaceAdmin.js) 1.61KB 0.85KB
collaboration (CommentThread.js) 18.38KB 4.49KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 3.65KB 1.42KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.25KB 0.53KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 476.42KB 104.61KB
core (index.js) 2.25KB 0.80KB
create-plugin (index.js) 9.28KB 2.98KB
data-objectstack (index.js) 136.23KB 34.75KB
fields (index.js) 223.53KB 54.78KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.32KB 1.77KB
i18n (index.js) 2.46KB 0.96KB
i18n (pickLocalized.js) 1.70KB 0.83KB
i18n (provider.js) 5.37KB 1.72KB
i18n (useObjectLabel.js) 26.14KB 6.07KB
i18n (useSafeTranslation.js) 3.26KB 1.44KB
layout (index.js) 37.96KB 10.54KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.74KB
mobile (index.js) 1.50KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.71KB 0.42KB
mobile (useResponsiveConfig.js) 1.36KB 0.63KB
mobile (useSpecGesture.js) 4.05KB 1.53KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 8.75KB 3.06KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 3.67KB 1.12KB
permissions (evaluator.js) 4.41KB 1.44KB
permissions (index.js) 0.91KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.52KB
permissions (usePermissions.js) 1.55KB 0.71KB
plugin-ai (index.js) 15.71KB 3.79KB
plugin-calendar (index.js) 44.98KB 12.37KB
plugin-charts (index.js) 60.54KB 17.13KB
plugin-chatbot (index.js) 180.09KB 42.72KB
plugin-dashboard (index.js) 112.01KB 28.86KB
plugin-designer (index.js) 210.51KB 42.51KB
plugin-detail (index.js) 230.56KB 56.80KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 111.49KB 26.95KB
plugin-gantt (index.js) 162.25KB 39.55KB
plugin-grid (index.js) 185.08KB 49.04KB
plugin-kanban (index.js) 47.89KB 13.18KB
plugin-list (index.js) 104.94KB 25.32KB
plugin-map (index.js) 16.81KB 5.24KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 40.55KB 10.59KB
plugin-timeline (index.js) 25.76KB 7.33KB
plugin-tree (index.js) 8.34KB 2.82KB
plugin-view (index.js) 83.67KB 20.43KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.71KB 3.53KB
providers (index.js) 0.44KB 0.22KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.67KB 2.37KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 19.28KB 6.38KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.02KB 0.55KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 4.09KB 1.74KB
sdui-parser (index.js) 4.47KB 2.03KB
sdui-parser (parse.js) 10.04KB 2.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 4.69KB 1.48KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.87KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-retry.js) 4.32KB 2.02KB
types (index.js) 2.46KB 1.21KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 0.20KB 0.18KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.05KB 1.93KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 3.40KB 1.71KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@xuyushun441-sys
xuyushun441-sys marked this pull request as ready for review August 3, 2026 10:53
@xuyushun441-sys
xuyushun441-sys added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit 8e02ad7 Aug 3, 2026
17 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the claude/issue-3229-page-block-visible-when branch August 3, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page 块检查器提供的 hidden 条件框写的是 spec 不认识的键(canonical 是 visibleWhen)

2 participants