Repository navigation
fix(ui): a stored field carrying an expression is read-only on every write surface - #31803
Conversation
…rface A stored field with an `expression` is computed by the engine on every write, so a client-sent value never stands. The edit gates decided "computed" from type lists alone and offered such a field as an editable input, grid cell, record-page row and import column. One predicate, isExpressionComputedField in @object-ui/core, now joins every gate. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jRozMk42iSKSwHdNts
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jRozMk42iSKSwHdNts
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jRozMk42iSKSwHdNts
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jRozMk42iSKSwHdNts
|
domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo Contract reviewServed-tier: This is the lane seat's own review of record. It is owed only because of the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo 席位核对 · ACCEPT · 2026-11-09T05:04Z · head
|
Requested by Steedos · project thread
Fixes #31759
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
expression的存储字段(例如示例应用发票行的amount= 数量 × 单价,以及发票的「含税总额」)现在和公式字段一样,在所有可写入口都只读:自动布局的新建表单不再显示它;编辑表单和手写分区表单显示格式化后的值,不再是输入框;列表行内编辑、记录页行内编辑(详情、高亮条、路径阶段)不再提供编辑器;导入向导只把它作为匹配键,AI 表格导入不再提供它。判断集中在@object-ui/core新导出的isExpressionComputedField一处。PATCH amount 999返回 200,读回323.94)。Clause-②: yes (widening),需要声明复审。服务端、spec 都没有改动。回滚即 revert 本 PR。ui/packages/core/src/utils/expression-computed-field.ts(规则本身),然后看ui/packages/plugin-form/src/ObjectForm.tsx和sectionFields.ts里打readonly: true的两处。cd ui && pnpm exec vitest run packages/plugin-form/src/__tests__/objectFormExpressionComputed-31759.test.tsx,预期 6 例全绿;或者pnpm dev --fresh后打开任意发票行点「Edit」,Amount 显示为$450.00文本,没有输入框。What changes
@objectstack/spec'sFieldSchema.expression: on a non-formulafield the engine computes the value from the row the write stores and stores it, "so a client-sent value never stands". The ui decided "computed" from type lists alone (formula,summary,auto_number, …), and none of them readexpression. Such a field was an editable input, grid cell, record row and import column, and the save replaced what the user typed without a word.The rule, stated once: a field carrying a non-empty
expressionis computed exactly as aformulais.@object-ui/core:isExpressionComputedField(def)(new export). It readsexpressionthe way the spec's ownisComputed(packages/spec/src/data/inline-grid-columns.ts) andderiveMasterDetailread it: a non-empty bare string, or thesourceof the{ dialect, source }envelope. It takes an untyped bag because every caller holds served JSON.@object-ui/plugin-form.filterAutoGeneratedFieldsandfilterCreateModeFields(autoLayout.ts): the auto-layout create form drops the field, as it drops aformula. This covers the flat and grouped arms ofObjectForm,ModalFormandDrawerForm, which all call it.ObjectForm.tsxgenerateFieldandsectionFields.tsfromObjectSchema, stampreadonly: true. The form then draws the type's read face (for a currency, the formatted amount) instead of an input, on the auto-layout edit form and in authored sections on create or edit. It isreadonly, notdisabled:disableddraws a greyed input, whilereadonlydraws the plain value and is omitted from the edit submit (readonlyFieldNamesinform.tsx).deriveMasterDetail.ts: its two inline reads ofexpressionswitch to the predicate. Behaviour is unchanged, since the line grid already treated such a column as computed.@object-ui/plugin-grid:isFieldInlineEditableanswersfalse, so the column's cells are read-only.@object-ui/plugin-detail: a new module-private helper,isComputedDetailField(viewType, objectDefField), besideisComputedFieldType. It returns the type union OR the predicate. The details body (DetailSection), the highlight strip (HeaderHighlight) and the path stage (recordPathStageChange) all call it, so the three cannot drift.@object-ui/app-shell(private):importTargetFieldskeeps the field as a match key only, the disposition areadonlyfield gets (it has a real column; aformulahas none and stays absent). The AI spreadsheet import bar (ExcelImportBar.tsx) does not offer it; the seat added this file to the surface in its amendment.Tests
Pins extend the existing harness files; one new file for the
ObjectFormrender.core/src/utils/__tests__/expression-computed-field.test.ts(new): bare string, envelope, formula; CONTROL: absent, empty, sourceless envelope, null, non-string, no field; exported from the package entry.plugin-form/src/__tests__/objectFormExpressionComputed-31759.test.tsx(new, realObjectFormrender): auto-layout create drops a bare-string and an envelope field; auto-layout edit draws no input and shows the stored value; authored sections on create and edit draw no input. CONTROL: a plaincurrencyfield is an editable input on every form; aformulais drawn read-only as before.plugin-form/src/__tests__/autoLayout.test.ts:applyAutoLayoutandfilterCreateModeFieldsdrop it on create and keep it on edit; CONTROL: a plain currency stays.plugin-grid/src/inline-edit-options.test.ts: not inline-editable for a bare string, an envelope, or no type; CONTROL: a plain and an empty-expression currency stay editable, a formula stays locked.plugin-detail/src/__tests__/inlineEditTypeNarrowing.test.tsx: the highlight strip offers no editor; the details body offers no pencil and no input in edit mode, and still shows the value; an envelope locks too; CONTROL: the same currency without an expression is editable on both; the helper is the union.plugin-detail/src/renderers/__tests__/record-path.stageChange-28199.test.tsx: a status field carrying an expression is never pressable.app-shell/src/views/importTargetFields.test.ts: match key only; CONTROL: a plain currency stays a write column, a formula stays absent.app-shell/src/console/ai/__tests__/ExcelImportBar.importGrant-12082.test.tsx: the wizard is handed['title', 'price'], without the expression field and without the formula.Ablation (
node scripts/ablation-replace.mjs; the subject resolves through the vitest source alias@object-ui/core→packages/core/src, so nodistis involved):isExpressionComputedFieldmade to returnfalse, mutation proven on disk (anchor 1 → 0, blobf6b07e05→738b1b68). The eight files gave 16 failed, 130 passed. Every failure is a new pin; every CONTROL row and every pre-existing test stayed green. The restore was proven: blob equal to HEAD,git diff HEADempty.Acceptance notes
packages/spec/src/data/field.zod.ts,expression), so a refusal would narrow a published contract.carrier: maintainer(a spec ruling onFieldSchema.expression).isFieldInlineEditable, the one predicateobjectGridPersistedColumns.tsreads.invoice-document.page.ts) is an authored page with no inline-editable rows, so its record-page check was not meaningful (a plain field there had no editor either). The record-page check was made on the line's default page.Verification
Head
405ec109, which mergesorigin/mainate253f3ab(the merge included #31757, soinvoice.amountwas checked live too). 22 files, +507 / −27.Suites (locked, two workers, run from the ui root)
packages/plugin-form/ packages/core/: 461 files passed, 6857 tests passed, 28 skipped.packages/plugin-grid/ packages/plugin-detail/: 652 files passed, 1 skipped; 5759 tests passed, 18 skipped.views/importTargetFields.test.ts+console/ai/(51 files, 293 tests) andviews/ObjectView.importPredicates.test.tsx+views/__tests__/(92 files, 774 tests), all passed.git grep -lof every touched source path overui/examples/**/test/**andui/e2e/**):catalog-gallery-render.test.tsxandform-field-channel-census-12130.test.tsx, 613 tests passed.ui/e2e/record-flow-phone-targets.spec.tsreadsDetailSectionandHeaderHighlightand is left toBuild & E2E UI.pnpm --dir ui exec vitest run scripts/: 170 files passed, 2 skipped; 5027 tests passed.turbo run type-checkfor core, plugin-form, plugin-grid, plugin-detail and app-shell: 73/73 tasks.eslintover the touched ui files: 0 errors.Gates (dispatch-gates at the merged tree)
36 derived. All 33 run unlocked exited 0, including
check-sdui-manifest.mjs(no widget or registry name changed) andcheck-changeset-no-major.pnpm --dir ui exec vitest run scripts/exited 0 (above). The body-reading gatescheck-closing-keyword-parityandcheck-adr-0087-registration --base origin/mainran on this body throughGITHUB_EVENT_PATHand exited 0.--ranreconciliation is in the os-dev report on the card.Live run
pnpm dev --freshshowcase on a random port, the Console from source under Vite, signed in as the seeded admin, 1280×900 at deviceScaleFactor 2.INV-1004 · Consulting hours(showcase_invoice_line.amount, quantity 3 × 150): the Edit dialog drawsAmountas the text$450.00, with noinput[name="amount"]; Qty and Unit Price stay inputs. On the record page, double-clicking Amount opens nothing and it has no pencil; double-clicking Qty opens its editor (control).INV-1001(showcase_invoice.amount, "Total incl. Tax", from feat(showcase): make the invoice the live multi-currency example #31757): the Edit dialog draws it as the text$1,749.56, with no input; Tax Rate stays an input.issue-31759/live/shots(line-edit-form.png,line-record-page.png,line-record-dblclick-Amount.png,invoice-edit-form.png,invoice-record-page.png).🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jRozMk42iSKSwHdNts
Generated by Claude Code