import { Box, Text } from "ink" import * as theme from "../../theme.js" import type { ToolRendererProps } from "./types.js" import { truncateText, sanitizeContent } from "./utils.js" const MAX_CONTENT_LINES = 15 export function CompletionTool({ toolData }: ToolRendererProps) { const result = toolData.result ? sanitizeContent(toolData.result) : "" const question = toolData.question ? sanitizeContent(toolData.question) : "" const content = toolData.content ? sanitizeContent(toolData.content) : "" const isQuestion = toolData.tool.includes("question") || toolData.tool.includes("Question") const displayContent = result || question || content const { text: previewContent, truncated, hiddenLines } = truncateText(displayContent, MAX_CONTENT_LINES) return previewContent ? ( {isQuestion ? ( {previewContent} ) : ( {previewContent.split("\n").map((line, i) => ( {line} ))} )} {truncated && ( ... ({hiddenLines} more lines) )} ) : null }