import type { JSX } from "react"; import { MessageSquareMoreIcon } from "../../../../app/renderer/components/icons/MessageSquareMoreIcon"; import { translate } from "../../../../i18n/index"; import { ToolMarkdownBlock, ToolSection, type AgentToolRendererProps } from "./agentToolContentShared"; export function AgentAskUserQuestionContent({ call, onLinkClick }: AgentToolRendererProps): JSX.Element | null { "use memo"; const questions = call.askUserQuestion?.questions ?? []; const outputText = stringValue(call.output?.text); if (questions.length === 0) { return null; } return (
{questions.map((question) => { const body = question.question || question.header || translate("agentHost.agentTool.details.questionFallback"); const answer = formatAnswer(question.answer); const questionKey = question.id.trim() || `${question.header}:${question.question}:${question.options.map((option) => option.label).join("|")}`; return (
{body}
{question.options.length > 0 ? (
{question.options.map((option) => (
{option.label}
{option.description ? (
{option.description}
) : null}
))}
) : null} {answer ? (
{translate("agentHost.agentTool.details.answerPrefix", { answer })}
) : (
)}
); })}
{outputText ? ( ) : null}
); } function formatAnswer( answer: string | string[] | null | undefined ): string | null { if (Array.isArray(answer)) { return answer.filter((value) => value.trim()).join(", ") || null; } return typeof answer === "string" && answer.trim() ? answer.trim() : null; } function stringValue(value: unknown): string | null { return typeof value === "string" && value.trim() ? value.trim() : null; }