Skip to content

Commit d853994

Browse files
committed
Enhance History component: add test for long tool result messages and improve rendering
1 parent 2161a31 commit d853994

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

src/ui/HistoryItemDisplay.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,18 @@ function ToolMessageContent({ content }: { content: ToolContent }) {
105105
typeof toolResult.output === "string"
106106
? toolResult.output
107107
: JSON.stringify(toolResult.output, null, 2);
108+
108109
return (
109-
<Text key={`tool-result-${index}`} color="cyan">
110-
› Tool Result ({toolResult.toolName}):{`\n`}
111-
{resultString}
112-
</Text>
110+
<Box key={`tool-result-${index}`} flexDirection="column">
111+
<Text color="cyan">› Tool Result ({toolResult.toolName}):</Text>
112+
<Box flexDirection="column">
113+
{resultString.split("\n").map((line, i) => (
114+
<Text key={i} color="cyan">
115+
{line}
116+
</Text>
117+
))}
118+
</Box>
119+
</Box>
113120
);
114121
})}
115122
</Box>

tests/ui/History.test.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,30 @@ describe("History", () => {
8484
expect(lastFrame()).toContain("Tool Result (readFile)");
8585
expect(lastFrame()).toContain("hello world");
8686
});
87+
88+
it("should render long tool result messages correctly", () => {
89+
const longOutput = "line 1\nline 2\nline 3";
90+
const history: Message[] = [
91+
{
92+
id: "1",
93+
role: "tool",
94+
content: [
95+
{
96+
type: "tool-result",
97+
toolCallId: "tool-call-456",
98+
toolName: "longTool",
99+
output: longOutput,
100+
},
101+
],
102+
},
103+
];
104+
105+
(useStore as any).mockReturnValue(history);
106+
107+
const { lastFrame } = render(<History />);
108+
expect(lastFrame()).toContain("Tool Result (longTool)");
109+
expect(lastFrame()).toContain("line 1");
110+
expect(lastFrame()).toContain("line 2");
111+
expect(lastFrame()).toContain("line 3");
112+
});
87113
});

0 commit comments

Comments
 (0)