Repository navigation
Commit a260556
fix(types,plugin-form)!: close FormField's open index signature; a form-view field's immutable locks the control on edit (#28363)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoGLEEchZXiDquUn9Vikz3oJ)_
Fixes #25923
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no `skills/**` page or docs page teaches `FormField`
or its index signature (`grep -rn FormField skills/` is empty); the
closed-face rule `skills/objectui/rules/protocol.md` already states for
node types now holds for `FormField` too, and the spec's own `immutable`
description ("editable on create, locked once the record exists") is
what the renderer now does.
## 维护者速读
- 改了什么:`@object-ui/types` 的 `FormField` 去掉了 `[key: string]: any`
开放索引签名,拼错或未声明的键在 TS 里直接报错;表单视图字段的 `immutable: true`
现在真的生效:编辑已有记录时该控件锁定,新建时仍可编辑。
- 为什么改:开放签名让拼写错误和宿主私写的键(如 `group`)都能静默通过;`immutable`
以前只是被抄到运行时字段上,没有任何渲染器读它,编辑表单里照样能改。这是本卡最后两项(席位裁决 A 与 immutable 跟进)。
- 风险与回滚:仅编译期收窄,运行时只多了一处行为(编辑模式下 immutable 字段禁用);zod 镜像和严格授权面不变,spec
的接受集合不变。回滚即 revert 本 PR。
- 先看:`ui/packages/plugin-form/src/sectionFields.ts`(immutable
那一行)、`ui/packages/plugin-form/src/fieldGroups.ts`(两个本地交接类型)、`ui/packages/types/src/form.ts`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/plugin-form/src/sectionFields.spec-parity.test.ts
packages/types/src/__tests__/form-field-closed-face-25923.test.ts`,预期全绿。
- 需要你做的:无,席位落地。
## What changes
**`FormField` is a closed authoring face** (seat ruling 6412606977,
letter A). `ui/packages/types/src/form.ts` drops `[key: string]: any`
from `FormField`. Every declared member is unchanged. The zod mirror
`FormFieldSchema` and the strict face `StrictAnyComponentSchema` are
unchanged: they already refused undeclared keys. The readers the drop
broke are fixed by declaring each key where its producer and reader live
(ui `AGENTS.md` #0.1), never with a cast to `any` or `Record<string,
unknown>`:
- **`@object-ui/core`** `FieldWithDeclaredDefault` (the parameter type
of `isServerOwnedValue`) drops its own `[key: string]: unknown`. An
interface without an index signature is not assignable to a type that
has one, so every `FormField` call site of `isServerOwnedValue` broke on
it: the 5 in components `form.tsx` and the 1 in plugin-form
`WizardForm.tsx` measured on 2026-10-26 clear with this one change. The
2 plugin-grid errors measured then do not reproduce: `ObjectGrid.tsx` no
longer imports `FormField` on today's `main`. Its test's bare `{ name:
'title' }` literal is now a typed `FormField` value.
- **`@object-ui/components`** `form.tsx`: the field's raw metadata
carrier is typed `Record<string, unknown> | FormField` (the stashed
object field, else the field config itself, which is what the code
already did) on `RenderFieldProps.field`, `nativeNumberStep` and
`dependentLookupParents`, instead of converting the config through the
signature.
- **`@object-ui/plugin-form`**: `group`, which the host copies from the
object field and `deriveFieldGroupSections` reads back, is typed on a
package-local `FormFieldWithGroup` (`fieldGroups.ts`). `ObjectForm`'s
generated field and `buildFlatFields` write it through that type. The
section-divider row's `collapsible` / `collapsed` / `onToggle` are typed
on a module-local `SectionDividerRow`, which replaces a `Record<string,
unknown>` row cast to `FormField` and an `as unknown as FormField` gate
row. `SectionDividerSource.visibleWhen` is `FormField['visibleWhen']`,
not `unknown`.
**The immutable follow-up** (the work-item-4 landing record 6448239783:
"`immutable` is declared on the mirror but not rendered by objectui
(declared ≠ enforced). Render it, or record a refusal."). It is
rendered. `normalizeSectionField` writes a form-view field's `immutable:
true` as `disabled` when the form edits an existing record
(`isCreateFormMode` false, the same create-mode question `required` asks
there). A create form leaves it editable. The old pass-through copy to a
runtime `immutable` key that no renderer read is gone. The
`zod-mirror-parity` census row moves from `carried, not rendered` to
`translated`.
**Spec accept sets:** none moves. The diff touches no `packages/spec`
path and no `*.zod.ts`. The objectui zod faces are byte-identical, so
`objectui validate` and the strict face judge every document as before.
Only TypeScript consumers that wrote an undeclared key on a fresh
`FormField` literal see a change, from their own compiler.
## Tests
- New
`ui/packages/types/src/__tests__/form-field-closed-face-25923.test.ts`:
fresh-literal `@ts-expect-error` rows for a misspelled key (`labell`)
and a host-written key (`group`), plus the declared spelling compiling.
Reverse check: with the signature put back, `tsc -p tsconfig.test.json`
reds both rows with TS2578 (unused directive); restored from `HEAD`,
empty `git diff HEAD`.
- `sectionFields.spec-parity.test.ts` `immutable` row: an edit form
(`mode: 'edit'`, `recordId`) draws it disabled with no `immutable` key
carried; a create form leaves it enabled.
- `flatFields.test.ts` parity pin spreads both producers into plain
records instead of casting a `FormField` to `Record<string, unknown>`.
## Acceptance notes
- `keyField`, `disclosure` and `precision` are still copied by
`normalizeSectionField` onto the runtime field through its `any`-typed
base, with no reader (the census rows say so). They are not on
`FormField` and this PR does not put them there, since declaring keys no
renderer reads would advertise them. The copy is a deliberate ADR-0007
pass-through in the mapper's own comment. Whether to keep carrying them
or drop the copy is left to the seat.
- The section-divider branch of `form.tsx` reads its row through
`fieldProps as any`, as before. This PR types the producer side only.
## Verification
<details><summary>ui type-check, all dependents of @object-ui/types
(head 43cf87a)</summary>
`bash scripts/pm/os-verify-lock.sh -c "cd ui && pnpm exec turbo run
type-check --filter='...@object-ui/types' --concurrency=2 --continue"`
gave `Tasks: 105 successful, 105 total` and `VERDICT command-exit 0`.
The first measurement, with only the signature dropped, failed in
`@object-ui/components` (`form.tsx` 824, 1946, 2021, 2117, 2257, 3359,
3824), then `@object-ui/plugin-form` (`fieldGroups.ts` 369) once
components was fixed. The new pin's own `tsc -p tsconfig.test.json` in
`@object-ui/types` exited 0 on the next head.
</details>
<details><summary>ui vitest (head 6692b1a)</summary>
`pnpm exec vitest run --maxWorkers=2 packages/plugin-form/
packages/core/src/validation/ packages/components/src/renderers/form/
packages/types/src/__tests__/form-field-closed-face-25923.test.ts
packages/types/src/__tests__/zod-mirror-parity.test.ts` under the lock
gave `Test Files 310 passed (310)`, `Tests 3186 passed | 18 skipped
(3204)`, `VERDICT command-exit 0`. `pnpm --dir ui exec vitest run
scripts/` gave `169 passed | 2 skipped`, `4901 passed | 2 skipped`, exit
0.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 34 commands, all exit 0 (codes
captured before any pipe). The changeset gates were re-run after the
last changeset edit. `--ran` reconciliation: 34 derived, 34 run, 0
NOT-MEASURED, 0 UNRUN. `check-adr-0087-registration`: `not-required
(runtime-interface-only)`, verified on both interfaces.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibxnmxDxesWCZGKX6jW)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1edceb1 commit a260556
13 files changed
Lines changed: 127 additions & 27 deletions
File tree
- .changeset
- ui/packages
- components/src/renderers/form
- core/src/validation
- __tests__
- plugin-form/src
- types/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
824 | | - | |
| 824 | + | |
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
| |||
4369 | 4369 | | |
4370 | 4370 | | |
4371 | 4371 | | |
4372 | | - | |
| 4372 | + | |
4373 | 4373 | | |
4374 | 4374 | | |
4375 | 4375 | | |
| |||
4729 | 4729 | | |
4730 | 4730 | | |
4731 | 4731 | | |
4732 | | - | |
| 4732 | + | |
4733 | 4733 | | |
4734 | 4734 | | |
4735 | 4735 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
93 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
958 | 958 | | |
959 | 959 | | |
960 | 960 | | |
961 | | - | |
| 961 | + | |
962 | 962 | | |
963 | 963 | | |
964 | 964 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
24 | 48 | | |
25 | 49 | | |
26 | 50 | | |
| |||
49 | 73 | | |
50 | 74 | | |
51 | 75 | | |
52 | | - | |
| 76 | + | |
53 | 77 | | |
54 | 78 | | |
55 | 79 | | |
| |||
135 | 159 | | |
136 | 160 | | |
137 | 161 | | |
138 | | - | |
| 162 | + | |
139 | 163 | | |
140 | 164 | | |
141 | 165 | | |
| |||
335 | 359 | | |
336 | 360 | | |
337 | 361 | | |
338 | | - | |
| 362 | + | |
339 | 363 | | |
340 | 364 | | |
341 | 365 | | |
342 | | - | |
| 366 | + | |
343 | 367 | | |
344 | 368 | | |
345 | 369 | | |
| |||
355 | 379 | | |
356 | 380 | | |
357 | 381 | | |
358 | | - | |
| 382 | + | |
359 | 383 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
110 | 117 | | |
111 | 118 | | |
112 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
418 | 425 | | |
419 | 426 | | |
420 | 427 | | |
| |||
0 commit comments