Skip to content

A field typed autonumber (the spec spelling) is inline-editable on the detail page, so a user can overwrite a machine-generated value #4219

Description

@yinlianghui

Found during the fall-through sweep for #4216; filed unassigned per Prime Directive #10. Separate file, separate defect — #4216 is the input-widget routing, this is the editability gate.

What happens

packages/plugin-detail/src/fieldEnrichment.ts gates computed fields out of inline edit with one set:

export const TEXTUAL_REF_FALLBACK_TYPES = new Set([
  'formula',
  'summary',
  'rollup',
  'auto_number',
]);

isComputedFieldType() reads that set, and both hosts (DetailSection, HeaderHighlight) gate on it: fieldEditable = !isReadonly && !isComputedField && !isSystemField.

The set carries only auto_number. @objectstack/spec spells the type autonumber — stated in this repo's own alias table (packages/fields/src/field-type-alias.ts):

// `@objectstack/spec` spells this `autonumber`; the widget map key is
// `auto_number`. Map both spellings so a spec-typed field/param doesn't
// fall through to the plain text input.
autonumber: 'field:auto_number',
auto_number: 'field:auto_number',

So a field declared type: 'autonumber' is not recognised as computed, fieldEditable is true, the pencil / double-click affordance appears, and InlineFieldInput renders it as a plain text box the user can type over and save.

Why the spelling is the live one

autonumber is what the designer and the rest of the stack emit — packages/types/src/designer.ts:718, plugin-designer/src/DataModelDesigner.tsx:33, FieldDesigner.tsx:116, app-shell/src/views/importTargetFields.ts:48, app-shell/.../SchemaForm.tsx:228.

@object-ui/plugin-form guards both spellings in each of its non-input sets, which is the shape this one is missing:

packages/plugin-form/src/deriveMasterDetail.ts:40
  'formula', 'summary', 'rollup', 'autonumber', 'auto_number',
packages/plugin-form/src/deriveMasterDetail.ts:305
  const NON_INPUT_TYPES = new Set(['formula', 'summary', 'rollup', 'autonumber', 'auto_number']);

Why it matters

This is the objectui#3355 failure mode again, and that file's own doc comment records what it cost: a computed field that became inline-editable had its value overwritten by hand and stayed corrupted until an unrelated child-row touch re-fired the recomputation (objectstack#5077, downstream yinlianghui/hotcrm-heimao#61). An auto-number is the identity a user quotes back — a hand-edited one collides or gaps silently, and nothing recomputes it.

Note the set is also the input-side TEXTUAL_REF_FALLBACK_TYPES, so the same gap makes an autonumber carrying a reference_to eligible for the lookup-picker branch.

Likely shape of a fix

Add 'autonumber' to TEXTUAL_REF_FALLBACK_TYPES, matching plugin-form's both-spellings convention, with a pin asserting isComputedFieldType('autonumber', undefined) is true and that the field renders non-editable in DetailSection / HeaderHighlight. Worth checking rollup for the same treatment in the other direction (it is in this set but absent from the form alias table).


Generated by Claude Code

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions