Skip to content

fix(ui): a stored field carrying an expression is read-only on every write surface - #31803

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-ktuwe5
Nov 9, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-ktuwe5

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #31759

Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 改了什么: 声明了 expression 的存储字段(例如示例应用发票行的 amount = 数量 × 单价,以及发票的「含税总额」)现在和公式字段一样,在所有可写入口都只读:自动布局的新建表单不再显示它;编辑表单和手写分区表单显示格式化后的值,不再是输入框;列表行内编辑、记录页行内编辑(详情、高亮条、路径阶段)不再提供编辑器;导入向导只把它作为匹配键,AI 表格导入不再提供它。判断集中在 @object-ui/core 新导出的 isExpressionComputedField 一处。
  • 为什么改: spec 规定这类字段「由引擎在每次写入时计算并存储,客户端传来的值永远不会生效」。之前表单照样给出输入框,用户输入的值保存时被静默替换(卡片实测: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 文本,没有输入框。
  • 需要你做的: 无,席位落地(落地前欠一次 Clause-② 声明复审)。

What changes

@objectstack/spec's FieldSchema.expression: on a non-formula field 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 read expression. 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 expression is computed exactly as a formula is.

  • @object-ui/core: isExpressionComputedField(def) (new export). It reads expression the way the spec's own isComputed (packages/spec/src/data/inline-grid-columns.ts) and deriveMasterDetail read it: a non-empty bare string, or the source of the { dialect, source } envelope. It takes an untyped bag because every caller holds served JSON.
  • @object-ui/plugin-form.
    • filterAutoGeneratedFields and filterCreateModeFields (autoLayout.ts): the auto-layout create form drops the field, as it drops a formula. This covers the flat and grouped arms of ObjectForm, ModalForm and DrawerForm, which all call it.
    • The two FormField producers, ObjectForm.tsx generateField and sectionFields.ts fromObjectSchema, stamp readonly: 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 is readonly, not disabled: disabled draws a greyed input, while readonly draws the plain value and is omitted from the edit submit (readonlyFieldNames in form.tsx).
    • deriveMasterDetail.ts: its two inline reads of expression switch to the predicate. Behaviour is unchanged, since the line grid already treated such a column as computed.
  • @object-ui/plugin-grid: isFieldInlineEditable answers false, so the column's cells are read-only.
  • @object-ui/plugin-detail: a new module-private helper, isComputedDetailField(viewType, objectDefField), beside isComputedFieldType. 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): importTargetFields keeps the field as a match key only, the disposition a readonly field gets (it has a real column; a formula has 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 ObjectForm render.

  • 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, real ObjectForm render): 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 plain currency field is an editable input on every form; a formula is drawn read-only as before.
  • plugin-form/src/__tests__/autoLayout.test.ts: applyAutoLayout and filterCreateModeFields drop 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 no dist is involved): isExpressionComputedField made to return false, mutation proven on disk (anchor 1 → 0, blob f6b07e05 → 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 HEAD empty.

Acceptance notes

  • Should the engine refuse a client-written value for a stored-expression field instead of replacing it? Not built. The spec declares the replace (packages/spec/src/data/field.zod.ts, expression), so a refusal would narrow a published contract. carrier: maintainer (a spec ruling on FieldSchema.expression).
  • What the user loses: an input, inline editor or import column whose typed value the save always replaced. Nothing that ever persisted is lost; the engine computed the value before and still does.
  • Edit submit: the edit form already writes only the fields that differ from the record it read, so an untouched value was never sent. What changes is that the user can no longer type one.
  • Live grid cell: NOT MEASURED live, reason: the live run did not open a list grid in inline-edit mode. The gate is pinned at isFieldInlineEditable, the one predicate objectGridPersistedColumns.ts reads.
  • The invoice record page (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 merges origin/main at e253f3ab (the merge included #31757, so invoice.amount was 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.
  • app-shell: views/importTargetFields.test.ts + console/ai/ (51 files, 293 tests) and views/ObjectView.importPredicates.test.tsx + views/__tests__/ (92 files, 774 tests), all passed.
  • The eight pin files on the final head: 146 tests passed.
  • Examples censuses (found with git grep -l of every touched source path over ui/examples/**/test/** and ui/e2e/**): catalog-gallery-render.test.tsx and form-field-channel-census-12130.test.tsx, 613 tests passed. ui/e2e/record-flow-phone-targets.spec.ts reads DetailSection and HeaderHighlight and is left to Build & E2E UI.
  • pnpm --dir ui exec vitest run scripts/: 170 files passed, 2 skipped; 5027 tests passed.
  • turbo run type-check for core, plugin-form, plugin-grid, plugin-detail and app-shell: 73/73 tasks. eslint over 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) and check-changeset-no-major. pnpm --dir ui exec vitest run scripts/ exited 0 (above). The body-reading gates check-closing-keyword-parity and check-adr-0087-registration --base origin/main ran on this body through GITHUB_EVENT_PATH and exited 0. --ran reconciliation is in the os-dev report on the card.

Live run

pnpm dev --fresh showcase on a random port, the Console from source under Vite, signed in as the seeded admin, 1280×900 at deviceScaleFactor 2.

  • Invoice line INV-1004 · Consulting hours (showcase_invoice_line.amount, quantity 3 × 150): the Edit dialog draws Amount as the text $450.00, with no input[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).
  • Invoice 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.
  • Screenshots: project files, folder 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

…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
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 9, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 405ec10952e496303975c77262151d435c279435
Local-runs: none

This is the lane seat's own review of record. It is owed only because of the Clause-②: yes declaration (face declaration). No path in the diff is a published schema or a governed path: packages/spec/** and the server are untouched, and check-governed-merges --pr 31803 reads NOT governed (534 lines).

① Derived judgments

  • @object-ui/core is published and only widens. It exports one new function, isExpressionComputedField(def: unknown): boolean, through the root barrel. Nothing is removed, renamed or retyped.
    • It answers true for a non-empty bare expression string, or for a non-empty source on the { dialect, source } envelope.
    • It answers false for an empty string, for an envelope with no source, and for null or a non-object.
    • That is the spec's own reading (isComputed, packages/spec/src/data/inline-grid-columns.ts), and it matches the two inline reads in deriveMasterDetail that it replaces, so the master-detail grid behaves as before.
  • @object-ui/plugin-detail: isComputedDetailField is new in fieldEnrichment.ts, but the package's only exports entry (. → src/index.tsx) does not re-export it, so it is not published surface. The details body, the highlight strip and the path stage all call this one helper, which ORs the existing type union with the predicate. It can only lock a field, never unlock one.
  • @object-ui/plugin-form and @object-ui/plugin-grid: no export changes. Each gate adds && !isExpressionComputedField(...) or an early return false, so a surface can only offer less, never more:
    • filterCreateModeFields and filterAutoGeneratedFields;
    • the readonly: true stamps in ObjectForm generateField and sectionFields fromObjectSchema;
    • isFieldInlineEditable.
  • app-shell (private): importTargetFields keeps such a field as a match key only, and ExcelImportBar drops it from the write fields. The seat added the latter to the surface in amendment 6731512111.
  • Read face, not disabled. The form stamps readonly, not disabled, so the field draws its type's read face, and the form's existing read-only strip keeps it out of the save.
  • Metadata-protocol: none is RIGHT. FieldSchema.expression already means "a client-sent value never stands" (field.zod.ts ~L2143). The ui now draws what the spec declares, and no author-written key, value or meaning changes.
  • Accept sets: none change.

② Semver level

  • .changeset/31759-expression-computed-read-only.md marks @object-ui/core, plugin-form, plugin-grid and plugin-detail as patch, and app-shell is private. Both declaration lines sit at line start, in the changeset and in the PR body. That is RIGHT: a widening ships as patch.

③ Boundary flags

  • Nit N1: the live run did not measure the grid inline cell. It is pinned at isFieldInlineEditable, and the dev declared it as a deviation. Accepted.
  • Nit N2: no pin asserts that the save omits the field. Its omission rests on the form's existing read-only strip, which an existing pin already covers, plus the new readonly stamp, which is pinned. Accepted.
  • The ui/e2e/record-flow-phone-targets.spec.ts census runs in CI (Build & E2E UI), and the seat reads it at ACCEPT.
  • The Acceptance note on server refusal names carrier: maintainer, as amended.
  • open_questions: none.

Implemented-by: claude/project-thread-ktuwe5
Reviewed-by: session_01QsR2jVEjiYrK7onirxUGyo

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo

席位核对 · ACCEPT · 2026-11-09T05:04Z · head 405ec10952e496303975c77262151d435c279435

Seat domain:ui#3 reviewed the diff of its own dispatch for #31759. The card thread is session_01QsR2jRozMk42iSKSwHdNts, and the os-dev-report is 6732463276. I checked against GitHub, not against the report.

  1. Shape: 22 files, +507 / -27, draft on main, Fixes #31759. This is option A as amended (6731512111).
    • One reading: isExpressionComputedField(def) is exported from @object-ui/core. It is the spec's isComputed reading: a non-empty bare expression, or the envelope's source.
    • Seven existing gates ask it, plus ExcelImportBar:
      • auto-layout create drops the field;
      • the auto-layout edit form and authored sections stamp readonly (its read face, not disabled);
      • isFieldInlineEditable returns false;
      • the record page's body, highlight strip and path stage go through one isComputedDetailField, which plugin-detail's index does not export;
      • import keeps the field as a match key only;
      • the AI import bar drops it.
    • deriveMasterDetail's two inline reads now use the predicate, with no change in behaviour.
  2. Premise: on origin/main, a stored-expression currency was an editable input, grid cell, inline row and import column. The save then replaced what the user typed: PATCH amount 999 read back 323.94. The step-1 census is 6731488444.
  3. Gates / check-runs:
    • 57 runs on this head: 44 success, 13 skipped, 0 red. That includes Test UI, Type Check UI, Build & E2E UI (the record-flow-phone-targets census) and Live E2E UI. mergeable_state is clean.
    • Dev: 36/36 derived gates exit 0, with --ran reconciled, and the body gates pass.
    • Ablation (predicate → false): 16 failed / 130 passed, and every failure is a new pin.
    • Live: showcase_invoice_line.amount, and invoice.amount from feat(showcase): make the invoice the live multi-currency example #31757, now merged, both draw as text with no input.
  4. Declaration review: TIER_DEFAULT PASS, record 6732511495, on this head.
  5. Tests read:
    • The create form draws neither the stored-expression field nor the formula.
    • The edit form shows the stored value with no input, for both a bare string and an envelope.
    • Authored sections behave the same on create and edit.
    • The grid, the record body, the highlight and the path stage offer no editor.
    • Import offers the field as a match key only, and the import bar leaves it out.
    • CONTROL: a plain currency of the same shape stays editable on every surface, and a formula answers as before.
  6. Accepted deviations:
    • Review nit N1: the live run did not measure the grid inline cell, which is pinned at isFieldInlineEditable.
    • Review nit N2: no pin asserts that the save omits the field. The omission rests on the existing read-only strip plus the pinned readonly stamp.
    • Server refusal goes to Acceptance notes as carrier: maintainer. The spec declares that the value is replaced (field.zod.ts L2143).
  7. Landing:
    • check-governed-merges --pr 31803: NOT governed, 534 changed lines.
    • Clause-②: yes (widening), reviewed above. Metadata-protocol: none.
    • Serial: feat(ui): undo a business-record delete from its toast through the recycle bin #31795 (in the queue) shares @object-ui/core but no file, and the queue's merge group tests the combination.
    • Landing on the maintainer's standing rule that the pm-dispatch skill reviews and lands fleet PRs (2026-11-03T04:52Z), in this project. Relay pr_ready, then automerge_enable.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 9, 2026 05:05
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 9, 2026 05:05
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 6be71ab Nov 9, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-ktuwe5 branch November 9, 2026 05:23
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/l tests 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.

Auto-layout form draws a currency field with a stored expression as an editable input, and save silently replaces the typed value

1 participant