diff --git a/packages/types/src/followup.ts b/packages/types/src/followup.ts index dc21fc26dd..4d7047665f 100644 --- a/packages/types/src/followup.ts +++ b/packages/types/src/followup.ts @@ -9,7 +9,7 @@ export interface FollowUpData { /** The question being asked by the LLM */ question?: string /** Array of questions being asked by the LLM */ - questions?: string[] + questions?: FollowUpQuestion[] /** Array of suggested answers that the user can select */ suggest?: Array } @@ -24,6 +24,12 @@ export interface SuggestionItem { mode?: string } +/** + * Type definition for a follow-up question + * Can be a simple string or an object with text and options + */ +export type FollowUpQuestion = string | { text: string; options?: string[] } + /** * Zod schema for SuggestionItem */ @@ -32,12 +38,23 @@ export const suggestionItemSchema = z.object({ mode: z.string().optional(), }) +/** + * Zod schema for FollowUpQuestion + */ +export const followUpQuestionSchema = z.union([ + z.string(), + z.object({ + text: z.string(), + options: z.array(z.string()).optional(), + }), +]) + /** * Zod schema for FollowUpData */ export const followUpDataSchema = z.object({ question: z.string().optional(), - questions: z.array(z.string()).optional(), + questions: z.array(followUpQuestionSchema).optional(), suggest: z.array(suggestionItemSchema).optional(), }) diff --git a/src/shared/tools.ts b/src/shared/tools.ts index 8d8064d9d1..e9c94e72bf 100644 --- a/src/shared/tools.ts +++ b/src/shared/tools.ts @@ -7,6 +7,7 @@ import type { ToolName, BrowserActionParams, GenerateImageParams, + FollowUpQuestion, } from "@roo-code/types" export type ToolResponse = string | Array @@ -110,7 +111,7 @@ export type NativeToolArgs = { list_files: { path: string; recursive?: boolean } new_task: { mode: string; message: string; todos?: string } ask_followup_question: { - questions: Array + questions: FollowUpQuestion[] follow_up: Array<{ text: string; mode?: string }> } browser_action: BrowserActionParams @@ -237,7 +238,7 @@ export interface AccessMcpResourceToolUse extends ToolUse<"access_mcp_resource"> export interface AskFollowupQuestionToolUse extends ToolUse<"ask_followup_question"> { name: "ask_followup_question" - params: Partial, "question" | "follow_up">> + params: Partial, "question" | "follow_up" | "questions">> } export interface AttemptCompletionToolUse extends ToolUse<"attempt_completion"> { diff --git a/webview-ui/src/components/chat/MultiQuestionHandler.tsx b/webview-ui/src/components/chat/MultiQuestionHandler.tsx index 7f1c21a945..dea9da65d0 100644 --- a/webview-ui/src/components/chat/MultiQuestionHandler.tsx +++ b/webview-ui/src/components/chat/MultiQuestionHandler.tsx @@ -2,19 +2,15 @@ import { useState, useEffect } from "react" import { Button, AutosizeTextarea } from "@/components/ui" import { useAppTranslation } from "@src/i18n/TranslationContext" import { useExtensionState } from "@src/context/ExtensionStateContext" - -interface Question { - text: string - options?: string[] -} +import { FollowUpQuestion } from "@roo-code/types" interface MultiQuestionHandlerProps { - questions: Array + questions: FollowUpQuestion[] onSendResponse: (response: string) => void } interface QuestionItemProps { - question: string | Question + question: FollowUpQuestion title: string textValue: string selectedOption?: string diff --git a/webview-ui/src/i18n/locales/en/settings.json b/webview-ui/src/i18n/locales/en/settings.json index de76ba4c67..f6cf71670f 100644 --- a/webview-ui/src/i18n/locales/en/settings.json +++ b/webview-ui/src/i18n/locales/en/settings.json @@ -126,6 +126,10 @@ "requireCtrlEnterToSend": { "label": "Require {{primaryMod}}+Enter to send messages", "description": "When enabled, you must press {{primaryMod}}+Enter to send messages instead of just Enter" + }, + "showQuestionsOneByOne": { + "label": "Show questions one by one", + "description": "When enabled, questions from the model will be displayed one at a time." } }, "prompts": {