Skip to content

TUI: array-of-enum form requires a redundant top-level enum to render as a select #1751

Description

@cliffhall

Split off from the review of #1691 (PR #1750).

Problem

In clients/tui/src/utils/schemaToForm.ts, the array-of-enum branch is nested under the outer if (property.enum) guard:

if (property.enum) {
  if (property.type === "array" && property.items?.enum) {
    // ...select from items.enum
  } else {
    // ...single select from property.enum
  }
}

So a standard array-of-enums schema — { type: "array", items: { enum: [...] } } with no top-level enum — never reaches the array branch and falls through to the string default field. To get a select today the schema must redundantly carry a top-level enum too (the existing schemaToForm.test.ts array test sets both to work around this).

The web side already guards correctly on fieldSchema.items?.enum alone (SchemaForm.tsx), so the two clients diverge on which array shapes they recognize.

Fix

Restructure the branch so an array with items.enum is detected independently of a top-level enum (match the web guard). Then update schemaToForm.test.ts to drop the redundant top-level enum from the array-of-enum case and add a test for the standard items.enum-only shape.

Acceptance criteria

Notes

Pre-existing behavior, not introduced by #1691 — surfaced during that review.

Metadata

Metadata

Assignees

Labels

v2Issues and PRs for v2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions