Skip to content

Commit 12eded7

Browse files
fix(acp): keep multi-select free text alongside selected options
Only fold a single-choice field with its `__other` companion. A multi-select answer can carry options and free text together, which the folded question could not express. AI-assisted; verified with the tests and tools listed above.
1 parent 6cab423 commit 12eded7

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎packages/provider-acp/src/server/elicitationForm.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,22 @@ describe("parseElicitationForm", () => {
7979
q0: "Yes",
8080
q1__other: "Only on Fridays",
8181
});
82+
83+
// A multi-select answer can carry options and free text together, so both fields stay.
84+
const multi = parseElicitationForm(
85+
{
86+
type: "object",
87+
properties: {
88+
q0: { type: "array", title: "Databases?", items: { anyOf: [{ const: "Postgres" }] } },
89+
q0__other: { type: "string", title: "Other (type your own)" },
90+
},
91+
},
92+
"Databases?",
93+
);
94+
assert(multi !== undefined);
95+
assert.deepStrictEqual(multi.content({ q0: ["Postgres"], q0__other: "SQLite" }), {
96+
q0: ["Postgres"],
97+
q0__other: "SQLite",
98+
});
8299
});
83100
});

‎packages/provider-acp/src/server/elicitationForm.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,13 @@ export function parseElicitationForm(
202202
parsedFields.push({ id, property, options: parsed.options });
203203
}
204204
// An optional `<id>__other` text field (OMP's ask dialog) is the free-text answer to
205-
// optional choice `<id>`: ask them as one question and send custom text to the companion.
205+
// optional single choice `<id>`: ask them as one question and send custom text to the
206+
// companion. Multi-select keeps both fields, since it can answer with options and text.
206207
const companions = new Map<string, string>();
207208
for (const [id, field] of fields) {
208209
const companionId = `${id}__other`;
209210
if (
210-
(field.kind === "choice" || field.kind === "multiChoice") &&
211+
field.kind === "choice" &&
211212
fields.get(companionId)?.kind === "text" &&
212213
!required.has(id) &&
213214
!required.has(companionId)

0 commit comments

Comments
 (0)