Repository navigation
fix(plugin-form): a create form offers a state_machine select only its initialStates - #27969
Merged
Merged
Conversation
… initialStates A select governed by a blocking state_machine that declares initialStates now keeps only those values on a create form, through the same field gate every layout draws through. The value the form opens with stays offered. @object-ui/core gains stateMachineInitialValues beside stateMachineNextValues. Claude-Session: https://claude.ai/code/session_01Utp6CaJoinvGQSbHeDaWBe Co-authored-by: Claude <noreply@anthropic.com>
…e narrows Claude-Session: https://claude.ai/code/session_01Utp6CaJoinvGQSbHeDaWBe Co-authored-by: Claude <noreply@anthropic.com>
…ate; changeset Claude-Session: https://claude.ai/code/session_01Utp6CaJoinvGQSbHeDaWBe Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbUGFznjxdG6YQZm1Z Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Oct 30, 2026
Contributor
Author
|
domain:ui#3 · os-bill · session_01Utp6CaJoinvGQSbHeDaWBe 席位核对ACCEPT · head
Generated by Claude Code |
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.
domain:ui#3 · os-bill · session_01Utp6CaJoinvGQSbHeDaWBe
Requested by Bill · project thread
维护者速读
state_machine管辖的下拉字段,现在只列出该状态机声明的initialStates(如 showcase 项目只给「Planned」),与编辑表单已有的「只给可达状态」走同一道字段门。initialStates,表单却列出全部选项,用户选别的值点保存才收到invalid_initial_state拒绝;按分诊「先改平台」裁定,在表单层修好,所有应用的新建表单一起受益。initialStates的状态机、warning 级或仅 update 的规则保持全部选项;回滚即 revert 本 PR。ui/packages/plugin-form/src/stateMachineOptions.ts(create 分支与「打开值保留」规则)、ui/packages/core/src/validation/validators/state-machine-next-values.ts(新 helper)、ui/packages/plugin-form/src/ObjectForm.tsx(gateFields 下移以拿到打开值)。pnpm --dir ui exec vitest run packages/plugin-form/src/__tests__/stateMachineCreateSelect-27763.test.tsx,预期 6 条全绿(主从表单、平铺表单、新建对话框都只给planned)。Fixes #27763
Clause-②: no
Metadata-protocol: none
What changes
@object-ui/coregainsstateMachineInitialValues(objectSchema, fieldName)besidestateMachineNextValues: the values a new record may be created in, read from the same servedvalidationswith the same rule reading (blockingseverity: 'error',active,eventscovering the write, absent keys read as the spec default). It returnsnullwhen no applicable rule declaresinitialStates, which is exactly where the server's insert check is a no-op. The two helpers now share one rule predicate, so there is still one reading of a machine.narrowStateMachineOptions(the pass insidegateFormFields, which every form layout draws through) gains a create arm: onmode: 'create'a select governed by such a machine keeps only itsinitialStates. The edit arm is unchanged.openingValues: the seededdefault: trueoption or the caller's pre-fill) stays offered even when it lies outsideinitialStates, so the form never silently drops a value it was handed; the server's refusal stays the one that names it. Every layout passes the values it opens with:ObjectForm(its gate step moves belowfinalDefaultValuesfor that),ModalForm,DrawerForm,TabbedForm,WizardForm.ObjectForm, so it draws through the same gate (measured: the master-detail test below goes red under the ablation with the others).ui/packages/plugin-form/README.mdandcontent/docs/frontend/plugins/plugin-form.mdx(neither described the edit-side narrowing before).Why
showcase_project'sproject_status_flowdeclaresinitialStates: ['planned'], and the server refuses any other initial status withinvalid_initial_state. The "New Project + Tasks" create form offered all five statuses, so four of them were dead ends. The triage ruled platform first: the form stops offering what the server refuses, for every app, and the showcase page stays as it is as the proof.examples/app-showcase/**is untouched.Tests
ui/packages/core/src/validation/__tests__/state-machine-next-values.test.ts:stateMachineInitialValues(package-root export, declared states, absentevents, no or emptyinitialStates, warning / inactive / update-only rules, another field, intersection of two rules).ui/packages/plugin-form/src/stateMachineOptions.test.ts: the create arm on both option carriers, the opening value kept, the persisted record ignored on create, the no-initialStatescontrol, the edit control, aviewform, and throughgateFormFields.ui/packages/plugin-form/src/__tests__/stateMachineCreateSelect-27763.test.tsx(DOM, read off the native select Radix renders): the showcase master-detail create form, the flat in-page create form and the console create dialog each offer onlyplanned; a caller's pre-fill outsideinitialStatesstays offered; CONTROL: noinitialStateskeeps every option; CONTROL: an edit form still narrows from the stored value.ui/e2e/live/master-detail.spec.ts: one new case opens the status select on the live showcase page and assertsplannedis offered and the four refused states are not. The existing cases are unchanged apart from one comment.Ablation (one-shot, on the committed tree)
Via
scripts/ablation-replace.mjsunder the verify lock;@object-ui/coreand the plugin-form sources resolve tosrc/through the ui vitest alias, so no dist rebuild sits in the path.if (mode === 'create') {replaced so it never matches): 8 failed, 16 passed of the two files. Red: the 4 create-arm unit cases and the 4 DOM create cases (master-detail, flat, dialog, pre-fill). Green: both CONTROLs and every edit case. Restored: blob equals HEAD,git diff HEADempty.return initial && opening !== null ? new Set([...initial, opening]) : initial;replaced byreturn initial;): 2 failed, 22 passed. Red: exactly the two pre-fill cases. Restored the same way.Acceptance notes
default: trueoption isplanned, which is insideinitialStates, so the master-detail form opens on a legal value. A seeded default outsideinitialStateswould stay offered (the opening-value rule) and the server would refuse it on save; no showcase object has one today.showcase_task) are not narrowed on create:task_status_flowis update-only and declares noinitialStates, so the server does not police their insert either.gateFormFields. Filed by the seat as Grid inline new row and board quick-create offer every option of a state_machine field that declares initialStates #27976.mode: 'create', the value every create form in the console and the showcase page declares. A form that declares no mode keeps every option, as before.Live E2E UIjob, not locally.Verification
Local readings. Tests and type check ran on
5c360f28; the head54cb3d7dadds only the README and docs-page text on top of it. The gate union ran on54cb3d7d.pnpm --dir ui exec vitest run packages/plugin-form/ packages/core/, Test Files 432 passed (432), Tests 6533 passed, 28 skipped.pnpm --filter @object-ui/core --filter @object-ui/plugin-form run type-check, bothDone, VERDICT command-exit 0.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, 66 families, among themnode scripts/check-sdui-manifest.mjsandpnpm --dir ui exec vitest run scripts/at 169 files passed): every one exit 0.--ranreconciliation: "66 derived famil(ies) accounted for — 66 run, 0 NOT-MEASURED".check:skill-examplesfirst refused with exit 3 (its prerequisite, a built@objectstack/client-react, was missing; nothing measured), then ran exit 0 after that build.pnpm --dir ui run check:new-line-citations: 0 new citations.Human Minimum
packages/specholds no runtime logic. (packages/specuntouched.)pnpm lintis CI's run.main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code