mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-10 01:39:25 +00:00
fix: always expose the free-text Other option in question prompts (#1003)
The question adapter only set allow_other on the wire when the SDK item carried an otherLabel/otherDescription, but the AskUserQuestion tool never provides those fields. Web clients honor allow_other, so the free-text option silently disappeared in the web UI while the TUI (which renders it unconditionally) kept working. Set allow_other unconditionally to match the tool's 'users always have an Other option' contract.
This commit is contained in:
parent
b84704bff3
commit
e15edfd017
3 changed files with 10 additions and 8 deletions
5
.changeset/fix-web-question-other-option.md
Normal file
5
.changeset/fix-web-question-other-option.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@moonshot-ai/kimi-code": patch
|
||||
---
|
||||
|
||||
Fix the web question prompt missing the free-text Other option.
|
||||
|
|
@ -142,14 +142,8 @@ function buildItem(
|
|||
if (item.header !== undefined) out.header = item.header;
|
||||
if (item.body !== undefined) out.body = item.body;
|
||||
if (item.multiSelect !== undefined) out.multi_select = item.multiSelect;
|
||||
// SDK has no `allowOther` field — `otherLabel` / `otherDescription` exist
|
||||
// and we expose them on the wire alongside an inferred `allow_other: true`
|
||||
// when either tag is set. (SDK semantics: presence of `otherLabel` enables
|
||||
// the "Other" affordance; we surface that explicitly on the wire so client
|
||||
// renderers don't have to infer.)
|
||||
const hasOtherAffordance =
|
||||
item.otherLabel !== undefined || item.otherDescription !== undefined;
|
||||
if (hasOtherAffordance) out.allow_other = true;
|
||||
// SDK has no allowOther field; always advertise the free-text Other option on the wire.
|
||||
out.allow_other = true;
|
||||
if (item.otherLabel !== undefined) out.other_label = item.otherLabel;
|
||||
if (item.otherDescription !== undefined) out.other_description = item.otherDescription;
|
||||
return out;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ describe('question-adapter · toBrokerRequest (in-process → protocol)', () =>
|
|||
expect(protoReq.questions[0]?.header).toBe('Pets');
|
||||
expect(protoReq.questions[0]?.body).toBe('pick one');
|
||||
expect(protoReq.questions[0]?.multi_select).toBe(false);
|
||||
// Other affordance is always on, even when the SDK item has no otherLabel.
|
||||
expect(protoReq.questions[0]?.allow_other).toBe(true);
|
||||
expect(protoReq.questions[0]?.other_label).toBeUndefined();
|
||||
|
||||
expect(protoReq.questions[1]?.id).toBe('q_1');
|
||||
expect(protoReq.questions[1]?.options.map((o) => o.id)).toEqual([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue