fix: address Copilot review round 18 — empty-string constants, nested branch reset

- TUI missingRequiredFields treats an empty string as supplied when the
  property's own `const` pins it there. The one-option control cannot produce
  anything else, so reporting the seeded value as missing made such a branch
  permanently uncallable.
- A nested SchemaForm is reset by the branch-aware key too. Two outer
  alternatives can both carry the same nested object field, and a nested form
  left mounted across an outer switch kept displaying the inner branch chosen
  for the other one while the newly seeded values described another shape.

Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-26 06:55:20 -04:00
commit 36cf58fe6c

View file

@ -837,6 +837,24 @@ describe("schemaToForm", () => {
expect(missingRequiredFields(nullable, { a: null })).toEqual([]);
});
it("accepts an empty string a const pins the field to", () => {
// The one-option control cannot produce anything else, so reporting the
// seeded value as missing would make the branch permanently uncallable.
const pinnedEmpty = {
type: "object",
properties: { kind: { type: "string", const: "" } },
required: ["kind"],
};
expect(missingRequiredFields(pinnedEmpty, { kind: "" })).toEqual([]);
// An ordinary required string is still missing when left blank.
const ordinary = {
type: "object",
properties: { kind: { type: "string" } },
required: ["kind"],
};
expect(missingRequiredFields(ordinary, { kind: "" })).toEqual(["kind"]);
});
it("checks the root's own required fields when there is no union", () => {
const schema = {
type: "object",