Skip to content

Commit f2e2bcf

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 d1f1d5c commit f2e2bcf

3 files changed

Lines changed: 39 additions & 8 deletions

File tree

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

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

478+
it('truncates long description but preserves tool name (< 25 chars)', async () => {
479+
const longDescription =
480+
'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.';
481+
const toolName = 'tool-name-is-24-chars-!!'; // Exactly 24 chars
482+
const { lastFrame, waitUntilReady } = await renderWithProviders(
483+
<DenseToolMessage
484+
{...defaultProps}
485+
name={toolName}
486+
description={longDescription}
487+
terminalWidth={50} // Narrow width to force truncation
488+
/>,
489+
);
490+
await waitUntilReady();
491+
const output = lastFrame();
492+
493+
// Tool name should be fully present (it plus one space is exactly 25, fitting the maxWidth)
494+
expect(output).toContain(toolName);
495+
// Description should be present but truncated
496+
expect(output).toContain('This is a');
497+
expect(output).toMatchSnapshot();
498+
});
499+
478500
describe('Toggleable Diff View (Alternate Buffer)', () => {
479501
const diffResult: FileDiff = {
480502
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 flexDirection="row" 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
@@ -129,6 +129,12 @@ exports[`DenseToolMessage > renders generic output message for unknown object re
129129
"
130130
`;
131131

132+
exports[`DenseToolMessage > truncates long description but preserves tool name (< 25 chars) 1`] = `
133+
" ✓ tool-name-is-24-chars-!! This is a very long description that should definitely be truncated …
134+
→ Success result
135+
"
136+
`;
137+
132138
exports[`DenseToolMessage > truncates long string results 1`] = `
133139
" ✓ test-tool Test description
134140
→ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…

0 commit comments

Comments
 (0)