Skip to content

Commit cbc29bf

Browse files
committed
feat(ux): modify wrapping behavior of compact tool output
- tool 'name' will not be truncated up to 25 chars - tool invocation 'description' locks to first line of output (and truncates if nec) - result 'summary' will appear on first line if space is available, otherwise can wrap to second line. (no content wrapping expected beyond second line)
1 parent 6af0d45 commit cbc29bf

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

packages/cli/src/ui/components/messages/DenseToolMessage.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,28 @@ describe('DenseToolMessage', () => {
453453
expect(output).toMatchSnapshot();
454454
});
455455

456+
it('truncates long description but preserves tool name (< 25 chars)', async () => {
457+
const longDescription =
458+
'This is a very long description that should definitely be truncated because it exceeds the available terminal width and we want to see how it behaves.';
459+
const toolName = 'tool-name-is-24-chars-!!'; // Exactly 24 chars
460+
const { lastFrame, waitUntilReady } = await renderWithProviders(
461+
<DenseToolMessage
462+
{...defaultProps}
463+
name={toolName}
464+
description={longDescription}
465+
terminalWidth={50} // Narrow width to force truncation
466+
/>,
467+
);
468+
await waitUntilReady();
469+
const output = lastFrame();
470+
471+
// Tool name should be fully present (it plus one space is exactly 25, fitting the maxWidth)
472+
expect(output).toContain(toolName);
473+
// Description should be present but truncated
474+
expect(output).toContain('This is a');
475+
expect(output).toMatchSnapshot();
476+
});
477+
456478
describe('Toggleable Diff View (Alternate Buffer)', () => {
457479
const diffResult: FileDiff = {
458480
fileDiff: '@@ -1,1 +1,1 @@\n-old line\n+new line',

packages/cli/src/ui/components/messages/DenseToolMessage.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,18 @@ export const DenseToolMessage: React.FC<DenseToolMessageProps> = (props) => {
450450
return (
451451
<Box flexDirection="column">
452452
<Box marginLeft={2} flexDirection="row" flexWrap="wrap">
453-
<ToolStatusIndicator status={status} name={name} />
454-
<Box maxWidth={25} flexShrink={1} flexGrow={0}>
455-
<Text color={theme.text.primary} bold wrap="truncate-end">
456-
{name}{' '}
457-
</Text>
458-
</Box>
459-
<Box marginLeft={1} flexShrink={1} flexGrow={0}>
460-
{description}
453+
<Box flexShrink={1}>
454+
<ToolStatusIndicator status={status} name={name} />
455+
<Box maxWidth={25} flexShrink={0} flexGrow={0}>
456+
<Text color={theme.text.primary} bold wrap="truncate-end">
457+
{name}{' '}
458+
</Text>
459+
</Box>
460+
<Box marginLeft={1} flexShrink={1} flexGrow={0}>
461+
{description}
462+
</Box>
461463
</Box>
464+
462465
{summary && (
463466
<Box
464467
key="tool-summary"

packages/cli/src/ui/components/messages/__snapshots__/DenseToolMessage.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ exports[`DenseToolMessage > renders generic output message for unknown object re
9999
"
100100
`;
101101

102+
exports[`DenseToolMessage > truncates long description but preserves tool name (< 25 chars) 1`] = `
103+
" ✓ tool-name-is-24-chars-!! This is a very long description that should definitely be truncated …
104+
→ Success result
105+
"
106+
`;
107+
102108
exports[`DenseToolMessage > truncates long string results 1`] = `
103109
" ✓ test-tool Test description
104110
→ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…

0 commit comments

Comments
 (0)