MCPcopy Create free account
hub / github.com/anus-dev/ANUS / ToolMessage

Function ToolMessage

packages/cli/src/ui/components/messages/ToolMessage.tsx:34–111  ·  view source on GitHub ↗
({
  name,
  description,
  resultDisplay,
  status,
  availableTerminalHeight,
  terminalWidth,
  emphasis = 'medium',
  renderOutputAsMarkdown = true,
})

Source from the content-addressed store, hash-verified

32}
33
34export const ToolMessage: React.FC<ToolMessageProps> = ({
35 name,
36 description,
37 resultDisplay,
38 status,
39 availableTerminalHeight,
40 terminalWidth,
41 emphasis = 'medium',
42 renderOutputAsMarkdown = true,
43}) => {
44 const availableHeight = availableTerminalHeight
45 ? Math.max(
46 availableTerminalHeight - STATIC_HEIGHT - RESERVED_LINE_COUNT,
47 MIN_LINES_SHOWN + 1, // enforce minimum lines shown
48 )
49 : undefined;
50
51 // Long tool call response in MarkdownDisplay doesn't respect availableTerminalHeight properly,
52 // we're forcing it to not render as markdown when the response is too long, it will fallback
53 // to render as plain text, which is contained within the terminal using MaxSizedBox
54 if (availableHeight) {
55 renderOutputAsMarkdown = false;
56 }
57
58 const childWidth = terminalWidth - 3; // account for padding.
59 if (typeof resultDisplay === 'string') {
60 if (resultDisplay.length > MAXIMUM_RESULT_DISPLAY_CHARACTERS) {
61 // Truncate the result display to fit within the available width.
62 resultDisplay =
63 '...' + resultDisplay.slice(-MAXIMUM_RESULT_DISPLAY_CHARACTERS);
64 }
65 }
66 return (
67 <Box paddingX={1} paddingY={0} flexDirection="column">
68 <Box minHeight={1}>
69 <ToolStatusIndicator status={status} />
70 <ToolInfo
71 name={name}
72 status={status}
73 description={description}
74 emphasis={emphasis}
75 />
76 {emphasis === 'high' && <TrailingIndicator />}
77 </Box>
78 {resultDisplay && (
79 <Box paddingLeft={STATUS_INDICATOR_WIDTH} width="100%" marginTop={1}>
80 <Box flexDirection="column">
81 {typeof resultDisplay === 'string' && renderOutputAsMarkdown && (
82 <Box flexDirection="column">
83 <MarkdownDisplay
84 text={resultDisplay}
85 isPending={false}
86 availableTerminalHeight={availableHeight}
87 terminalWidth={childWidth}
88 />
89 </Box>
90 )}
91 {typeof resultDisplay === 'string' && !renderOutputAsMarkdown && (

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected