fix(tui): clip legacy bash fallback output path (#1433)
Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Box } from "ink";
|
||||
import { memo } from "react";
|
||||
import { INTERRUPTED_BY_USER } from "../../constants";
|
||||
import { clipToolReturn } from "../../tools/manager";
|
||||
import type { StreamingState } from "../helpers/accumulator";
|
||||
import { useTerminalWidth } from "../hooks/useTerminalWidth";
|
||||
import { BlinkDot } from "./BlinkDot.js";
|
||||
@@ -90,7 +91,9 @@ export const BashCommandMessage = memo(
|
||||
<Text>{" ⎿ "}</Text>
|
||||
</Box>
|
||||
<Box flexGrow={1} width={Math.max(0, columns - 5)}>
|
||||
<MarkdownDisplay text={line.output.replace(/\n+$/, "")} />
|
||||
<MarkdownDisplay
|
||||
text={clipToolReturn(line.output).replace(/\n+$/, "")}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
30
src/tests/tools/clip-tool-return.test.ts
Normal file
30
src/tests/tools/clip-tool-return.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { clipToolReturn } from "../../tools/manager";
|
||||
|
||||
describe("clipToolReturn", () => {
|
||||
test("clips long single-line output and appends ellipsis", () => {
|
||||
const long = "A".repeat(1200);
|
||||
const clipped = clipToolReturn(long);
|
||||
|
||||
expect(clipped.length).toBeLessThan(400);
|
||||
expect(clipped.endsWith("…")).toBe(true);
|
||||
});
|
||||
|
||||
test("clips by line count for multiline output", () => {
|
||||
const text = "line1\nline2\nline3\nline4\nline5";
|
||||
const clipped = clipToolReturn(text, 3, 10_000);
|
||||
|
||||
expect(clipped).toContain("line1");
|
||||
expect(clipped).toContain("line2");
|
||||
expect(clipped).toContain("line3");
|
||||
expect(clipped).not.toContain("line4");
|
||||
expect(clipped.endsWith("…")).toBe(true);
|
||||
});
|
||||
|
||||
test("does not clip user-denial reasons", () => {
|
||||
const denial = `Error: request to call tool denied. User reason: ${"B".repeat(800)}`;
|
||||
const clipped = clipToolReturn(denial);
|
||||
|
||||
expect(clipped).toBe(denial);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user