Skip to content

fix(app-shell): an unset metadata-form switch shows its declared default - #38459

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-38420-default-true-switch
Nov 29, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-38420-default-true-switch

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #38420

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:管理员在 Studio 打开元数据表单(知识源、智能体、技能、应用、邮件模板、对象能力、仪表盘页眉等)时,未填写且默认开启的开关,编辑与只读两种模式下都显示为「开」,与实际运行一致。
  • 为什么做:修复 Studio 知识源表单把默认开启的「可被 AI 智能体搜索」「随记录变更同步」显示成关闭、与帮助文字和实际行为相反的缺陷。
  • 出错会怎样:只影响开关的显示,不写入任何值;未改动的条目保存后仍不存这个键,出问题时撤回本次改动即可恢复原显示。
  • 要你做什么:无

What changes

The metadata-form Switch in SchemaForm drew every unset boolean as !!value, so a key whose served schema says default: true read OFF while the runtime treats it as on. It now draws the value in effect: an unset key (the shared isUnsetFieldValue definition) draws the schema's declared default, a stored boolean draws itself. This is the flow node inspector's existing "show, do not write" boolean rule applied to the generic form: nothing is written until the author toggles, so an untouched item still saves without the key and keeps following the default (the ruling's display-only constraint).

The default is read off the served JSON Schema, which already carries it: aiExposed and refresh.onRecordChange are z.boolean().default(true).optional(), and z.toJSONSchema emits default: true for both. The form declares no default of its own and needs none, so packages/spec is untouched.

Every boolean row a registered metadata form declares whose derived schema defaults to true shares this one Switch; the new test enumerates them from METADATA_FORM_REGISTRY and the registered type schemas rather than listing them. At the head of this PR the walk finds rows on nine forms: knowledge source (aiExposed, refresh.onRecordChange), skill, agent, app and email template (active), object (enable.searchable, enable.apiEnabled, enable.feeds, enable.activities, enable.clone), field (sortable), report (drilldown, dateRange.allowCustomRange) and dashboard (header.showTitle, header.showDescription, dateRange.allowCustomRange). That list is a reading taken once; the test is the instrument that re-derives it.

Read first, by risk:

  1. ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx, the boolean branch of FieldControl (the declaredDefault line and the checked expression): the only behaviour change.
  2. ui/packages/app-shell/src/views/metadata-admin/SchemaForm.declaredBooleanDefault-38420.test.tsx, the defaultTrueRows walker: what "every default-true switch" means here (top-level rows and composite sub-rows).

Two-minute check: pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/SchemaForm.declaredBooleanDefault-38420.test.tsx, expect 6 passed.

Tests

New SchemaForm.declaredBooleanDefault-38420.test.tsx, all against the real spec (the served form and z.toJSONSchema(getMetadataTypeSchema(type)), as the /meta/types row carries them):

  • knowledge-source form, edit and read-only: both unset switches report aria-checked="true";
  • explicit false reports "false", explicit true reports "true";
  • an untouched form calls onChange zero times; the first click writes aiExposed: false and adds no refresh key;
  • every enumerated default-true row renders ON when unset, with a floor (knowledge_source.aiExposed, knowledge_source.refresh.onRecordChange, skill.active) so the walk cannot pass by finding nothing;
  • CONTROL: a boolean with no declared default, unset, reports "false".

Ablation (fix reverted on disk by scripts/ablation-replace.mjs, checked={!!value}; app-shell is a vitest source alias, so no build sits between): 4 failed, 2 passed, exactly the four unset cases red and the explicit-value and control cases green; restore verified blob equal to HEAD and git diff HEAD empty.

Readings
  • Final head 03896dd, the new file plus the neighbouring suites (SchemaForm.optionalEnumUnset-29733, SchemaForm.requiredMarker-10367, SchemaForm.widgetLabelling, ResourceEditPage.formBoundObject-37309): Test Files 5 passed (5), Tests 104 passed (104).
  • Ablated: Tests 4 failed | 2 passed (6); ablation-replace: ok restored: blob == HEAD (3095ad68c426) and git diff HEAD is empty.
  • pnpm --dir ui exec vitest run scripts/ (derived family): Test Files 1 failed | 171 passed | 2 skipped (174); the one failure was js-comment-mask-returns-interpolation-9424.test.ts timing out at 15000ms on a contended box (unrelated to this diff); rerun alone: Tests 8 passed (8).

Acceptance notes

  • Local type-check of @object-ui/app-shell was not measured: it needs every @object-ui/* dist built (the run reported Cannot find module '@object-ui/components' and its siblings before reaching any check of this diff). NOT MEASURED locally, reason: closure not built; Type Check UI in CI carries it. The change types against JsonSchema, which that file declares as a string-keyed record of any value.
  • Not verified in a running Studio; the component test drives the real served form and derived schema through SchemaForm.
  • The walker covers top-level rows and composite sub-rows. Boolean columns inside repeaters (an object's fields rows, for one) render through the same FieldControl Switch, so they take the fix, but the pin does not enumerate them.
  • dynamic-config's schema-driven boolean (DynamicConfigWidget in widgets.tsx) has the same Boolean(cur) shape, but nothing in the tree populates WidgetContext.dynamicSchemas, so it has no reachable default-true input today. Noted, not changed.
  • The dispatch's file surface named ui/.changeset/*.md; ui/AGENTS.md says new changesets go to the root .changeset/ and none are added under ui/.changeset/, so the changeset is .changeset/38420-unset-switch-shows-default.md.

Verification

Local derived gate list (node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack): 38 families, run at 862c74b, all exit 0 except two. check:test-source-alias was red on the new test (it reached @objectstack/lint and @object-ui/plugin-detail through dynamic imports with no module-top import); 03896dd adds the two imports, and the gate is green there. vitest run scripts/ had one timeout, which passed when rerun alone. On 03896dd, the families that read the changed test file were rerun, all exit 0: check:test-source-alias, check:undeclared-dep-imports, check:cross-package-test-inputs, check:nul-bytes, check:gitlink-declared, and ui check:new-line-citations (0 new citations). --ran reconciliation: 38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero). Every family CI runs is read from this PR's check-runs.


Generated by Claude Code

The metadata-form Switch drew every unset boolean OFF, so a key whose
schema declares default(true) read as off. It now draws the declared
default for an unset key and writes nothing until the author toggles.

Claude-Session: https://claude.ai/code/session_016WV4d13AraSmVmgVtCvkWk
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m 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 29, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4d13AraSmVmgVtCvkWk

席位核对

ACCEPT at head 03896dd (L1, repo:objectstack#1, read by the dispatching seat).

  • Shape: l1-face.mjs --pr 38459: draft, base main, first line Fixes #38420, no other card bound, one non-empty changeset (@object-ui/app-shell, @objectstack/console patch), Clause-②: no · Metadata-protocol: none, dogfood not owed.
  • Diff read by the seat: one line of behaviour in SchemaForm.tsx FieldControl — checked is the schema's declared default === true when the value is unset (isUnsetFieldValue), else !!value; onCheckedChange unchanged, so nothing is written until the author toggles (the dispatch's display-only ruling). packages/spec untouched: the served JSON schema already carries default: true.
  • Changeset read sentence by sentence against the diff: "an unset switch … shows the default its schema declares", "Nothing is written for it", "A boolean with no declared default still draws off when unset, and a stored false draws off" — each matches the one-line change and a test case. The list of other default-true rows matches the test's walker (17 rows, 9 forms).
  • Evidence: new test runs the real registry forms; unset → aria-checked="true" in edit and read-only, explicit false/true honoured, zero onChange on an untouched form, control (no declared default) reads false. Ablation (checked={!!value}): 4 failed / 2 passed, restore blob-identical.
  • Accepted deviations: the changeset is in root .changeset/ (ui/AGENTS.md: root config does not read ui/.changeset/); local @object-ui/app-shell type-check NOT MEASURED, CI Type Check UI read at landing.
  • Out of scope: DynamicConfigWidget draws Boolean(cur) the same way but nothing populates WidgetContext.dynamicSchemas (zero pull) — Acceptance notes.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4d13AraSmVmgVtCvkWk

Landing · ACCEPT → PR #38459 comment 7249953581

reading at head 03896dd
pr-state.mjs --pr 38459 38 success · 13 expected skip · 0 unexpected skip · 0 failed · 0 pending · mergeable clean (Type Check UI, Lint UI, Build & E2E UI green)
check-governed-merges.mjs --pr 38459 NOT governed · 206 lines; landing-k.mjs no reading (a UI-only diff runs no Test Core shard, so no affected-set base is printed)

State: ready + auto-merge now; on MERGED #38420 closes by Fixes and leaves pm:dispatched.

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/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio knowledge-source form shows "Searchable by AI agents" and "Sync on record changes" OFF when unset, though both default ON

2 participants