Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion extensions/ask-user-choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ export default function askUserChoice(pi: ExtensionAPI): void {
if (details?.selection) {
return new Text(theme.fg("success", `✓ ${details.selection.index}. ${details.selection.label}`), 0, 0);
}
if (details?.customResponse !== undefined) return new Text(theme.fg("success", "✓ Custom response"), 0, 0);
if (details?.customResponse !== undefined) {
return new Text(theme.fg("success", `✓ Custom response — ${details.customResponse}`), 0, 0);
}
return new Text(theme.fg("warning", "Cancelled"), 0, 0);
},
});
Expand Down
14 changes: 14 additions & 0 deletions tests/ask-user-choice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,17 @@ test("ask_user_choice is offered on an interactive rpc host and withdrawn once t
for (const hook of registration.hooks) await hook({}, { mode: "rpc" });
assert.deepEqual(registration.activeTools(), ["read"]);
});

test("ask_user_choice transcript shows the custom response text the user typed", () => {
const { tool } = registerChoiceTool();
const renderResult = (tool as unknown as {
renderResult: (result: unknown, options: unknown, theme: ChoiceTheme) => { render(width: number): string[] };
}).renderResult;
const theme: ChoiceTheme = { fg: (_color, text) => text, bg: (_color, text) => text, bold: (text) => text };
const rendered = renderResult(
{ content: [], details: { question: "Explain?", options, customResponse: "use the staging bucket" } },
{},
theme,
).render(100).join("\n");
assert.equal(stripTerminalSequences(rendered).trimEnd(), "✓ Custom response — use the staging bucket");
});