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.
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 outerif (property.enum)guard:So a standard array-of-enums schema —
{ type: "array", items: { enum: [...] } }with no top-levelenum— never reaches the array branch and falls through to thestringdefault field. To get a select today the schema must redundantly carry a top-levelenumtoo (the existingschemaToForm.test.tsarray test sets both to work around this).The web side already guards correctly on
fieldSchema.items?.enumalone (SchemaForm.tsx), so the two clients diverge on which array shapes they recognize.Fix
Restructure the branch so an array with
items.enumis detected independently of a top-levelenum(match the web guard). Then updateschemaToForm.test.tsto drop the redundant top-levelenumfrom the array-of-enum case and add a test for the standarditems.enum-only shape.Acceptance criteria
{ type: "array", items: { enum: [...] } }(no top-levelenum) renders as a select in the TUI.enumNames/items.enumNameslabeling (from web+tui: Enum forms ignore enumNames (legacy titled enum renders raw values) #1691) still applies.items.enum-only shape without a redundant top-levelenum.Notes
Pre-existing behavior, not introduced by #1691 — surfaced during that review.