From d2e5ae77506b4a6f6c8164425d961b26e7e1affc Mon Sep 17 00:00:00 2001 From: Dev Randalpura Date: Thu, 12 Mar 2026 13:05:56 -0500 Subject: [PATCH] Made tool calls take the entire terminal height --- .../messages/ShellToolMessage.test.tsx | 4 +- .../components/messages/ToolGroupMessage.tsx | 2 +- .../components/messages/ToolResultDisplay.tsx | 20 +- .../ShellToolMessage.test.tsx.snap | 188 ++++++++++-------- .../ToolResultDisplay.test.tsx.snap | 5 +- packages/cli/src/ui/utils/toolLayoutUtils.ts | 20 +- 6 files changed, 117 insertions(+), 122 deletions(-) diff --git a/packages/cli/src/ui/components/messages/ShellToolMessage.test.tsx b/packages/cli/src/ui/components/messages/ShellToolMessage.test.tsx index d124ebe929..b9c076d687 100644 --- a/packages/cli/src/ui/components/messages/ShellToolMessage.test.tsx +++ b/packages/cli/src/ui/components/messages/ShellToolMessage.test.tsx @@ -189,7 +189,7 @@ describe('', () => { [ 'respects availableTerminalHeight when it is smaller than ACTIVE_SHELL_MAX_LINES', 10, - 3, // 10 - 1 (static) - 6 (ASB reserved) = 3 + 10, false, ], [ @@ -201,7 +201,7 @@ describe('', () => { [ 'uses full availableTerminalHeight when focused in alternate buffer mode', 100, - 93, // 100 - 1 (static) - 6 (ASB reserved) = 93 + 100, true, ], [ diff --git a/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx b/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx index 752aed35c9..5ec2a18e06 100644 --- a/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx +++ b/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx @@ -191,7 +191,7 @@ export const ToolGroupMessage: React.FC = ({ maxLinesLimit: maxLines, }); - if (contentMaxLines === undefined) return false; + if (!contentMaxLines) return false; if (typeof tool.resultDisplay === 'string') { const text = tool.resultDisplay; diff --git a/packages/cli/src/ui/components/messages/ToolResultDisplay.tsx b/packages/cli/src/ui/components/messages/ToolResultDisplay.tsx index 09dee9cd31..1c29407e91 100644 --- a/packages/cli/src/ui/components/messages/ToolResultDisplay.tsx +++ b/packages/cli/src/ui/components/messages/ToolResultDisplay.tsx @@ -23,10 +23,7 @@ import { Scrollable } from '../shared/Scrollable.js'; import { ScrollableList } from '../shared/ScrollableList.js'; import { SCROLL_TO_ITEM_END } from '../shared/VirtualizedList.js'; import { ACTIVE_SHELL_MAX_LINES } from '../../constants.js'; -import { - calculateToolContentMaxLines, - TOOL_RESULT_MIN_LINES_SHOWN, -} from '../../utils/toolLayoutUtils.js'; +import { calculateToolContentMaxLines } from '../../utils/toolLayoutUtils.js'; import { SubagentProgressDisplay } from './SubagentProgressDisplay.js'; // Large threshold to ensure we don't cause performance issues for very large @@ -64,11 +61,6 @@ export const ToolResultDisplay: React.FC = ({ maxLinesLimit: maxLines, }); - const effectiveMaxHeight = - availableHeight !== undefined - ? Math.max(TOOL_RESULT_MIN_LINES_SHOWN, availableHeight) - : undefined; - const combinedPaddingAndBorderWidth = 4; const childWidth = terminalWidth - combinedPaddingAndBorderWidth; @@ -140,7 +132,7 @@ export const ToolResultDisplay: React.FC = ({ if (isAlternateBuffer && Array.isArray(truncatedResultDisplay)) { // If availableHeight is undefined, fallback to a safe default to prevents infinite loop // where Container grows -> List renders more -> Container grows. - const limit = maxLines ?? effectiveMaxHeight ?? ACTIVE_SHELL_MAX_LINES; + const limit = maxLines ?? availableHeight ?? ACTIVE_SHELL_MAX_LINES; const listHeight = Math.min( // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion (truncatedResultDisplay as AnsiOutput).length, @@ -213,7 +205,7 @@ export const ToolResultDisplay: React.FC = ({ diffContent={(truncatedResultDisplay as FileDiffResult).fileDiff} // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion filename={(truncatedResultDisplay as FileDiffResult).fileName} - availableTerminalHeight={effectiveMaxHeight} + availableTerminalHeight={availableHeight} terminalWidth={childWidth} /> ); @@ -227,7 +219,7 @@ export const ToolResultDisplay: React.FC = ({ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion data={truncatedResultDisplay as AnsiOutput} availableTerminalHeight={ - isAlternateBuffer ? undefined : effectiveMaxHeight + isAlternateBuffer ? undefined : availableHeight } width={childWidth} maxLines={isAlternateBuffer ? undefined : maxLines} @@ -241,7 +233,7 @@ export const ToolResultDisplay: React.FC = ({ return ( @@ -253,7 +245,7 @@ export const ToolResultDisplay: React.FC = ({ return ( diff --git a/packages/cli/src/ui/components/messages/__snapshots__/ShellToolMessage.test.tsx.snap b/packages/cli/src/ui/components/messages/__snapshots__/ShellToolMessage.test.tsx.snap index 9d636ab1c4..23aae9c40a 100644 --- a/packages/cli/src/ui/components/messages/__snapshots__/ShellToolMessage.test.tsx.snap +++ b/packages/cli/src/ui/components/messages/__snapshots__/ShellToolMessage.test.tsx.snap @@ -133,6 +133,13 @@ exports[` > Height Constraints > respects availableTerminalH "╭──────────────────────────────────────────────────────────────────────────────╮ │ ⊶ Shell Command A shell command │ │ │ +│ Line 91 │ +│ Line 92 │ +│ Line 93 │ +│ Line 94 │ +│ Line 95 │ +│ Line 96 │ +│ Line 97 │ │ Line 98 │ │ Line 99 │ │ Line 100 █ │ @@ -187,99 +194,106 @@ exports[` > Height Constraints > uses full availableTerminal "╭──────────────────────────────────────────────────────────────────────────────╮ │ ⊶ Shell Command A shell command (Shift+Tab to unfocus) │ │ │ +│ Line 1 │ +│ Line 2 │ +│ Line 3 │ +│ Line 4 │ +│ Line 5 │ +│ Line 6 │ +│ Line 7 │ │ Line 8 │ │ Line 9 │ │ Line 10 │ │ Line 11 │ │ Line 12 │ │ Line 13 │ -│ Line 14 ▄ │ -│ Line 15 █ │ -│ Line 16 █ │ -│ Line 17 █ │ -│ Line 18 █ │ -│ Line 19 █ │ -│ Line 20 █ │ -│ Line 21 █ │ -│ Line 22 █ │ -│ Line 23 █ │ -│ Line 24 █ │ -│ Line 25 █ │ -│ Line 26 █ │ -│ Line 27 █ │ -│ Line 28 █ │ -│ Line 29 █ │ -│ Line 30 █ │ -│ Line 31 █ │ -│ Line 32 █ │ -│ Line 33 █ │ -│ Line 34 █ │ -│ Line 35 █ │ -│ Line 36 █ │ -│ Line 37 █ │ -│ Line 38 █ │ -│ Line 39 █ │ -│ Line 40 █ │ -│ Line 41 █ │ -│ Line 42 █ │ -│ Line 43 █ │ -│ Line 44 █ │ -│ Line 45 █ │ -│ Line 46 █ │ -│ Line 47 █ │ -│ Line 48 █ │ -│ Line 49 █ │ -│ Line 50 █ │ -│ Line 51 █ │ -│ Line 52 █ │ -│ Line 53 █ │ -│ Line 54 █ │ -│ Line 55 █ │ -│ Line 56 █ │ -│ Line 57 █ │ -│ Line 58 █ │ -│ Line 59 █ │ -│ Line 60 █ │ -│ Line 61 █ │ -│ Line 62 █ │ -│ Line 63 █ │ -│ Line 64 █ │ -│ Line 65 █ │ -│ Line 66 █ │ -│ Line 67 █ │ -│ Line 68 █ │ -│ Line 69 █ │ -│ Line 70 █ │ -│ Line 71 █ │ -│ Line 72 █ │ -│ Line 73 █ │ -│ Line 74 █ │ -│ Line 75 █ │ -│ Line 76 █ │ -│ Line 77 █ │ -│ Line 78 █ │ -│ Line 79 █ │ -│ Line 80 █ │ -│ Line 81 █ │ -│ Line 82 █ │ -│ Line 83 █ │ -│ Line 84 █ │ -│ Line 85 █ │ -│ Line 86 █ │ -│ Line 87 █ │ -│ Line 88 █ │ -│ Line 89 █ │ -│ Line 90 █ │ -│ Line 91 █ │ -│ Line 92 █ │ -│ Line 93 █ │ -│ Line 94 █ │ -│ Line 95 █ │ -│ Line 96 █ │ -│ Line 97 █ │ -│ Line 98 █ │ -│ Line 99 █ │ -│ Line 100 █ │ +│ Line 14 │ +│ Line 15 │ +│ Line 16 │ +│ Line 17 │ +│ Line 18 │ +│ Line 19 │ +│ Line 20 │ +│ Line 21 │ +│ Line 22 │ +│ Line 23 │ +│ Line 24 │ +│ Line 25 │ +│ Line 26 │ +│ Line 27 │ +│ Line 28 │ +│ Line 29 │ +│ Line 30 │ +│ Line 31 │ +│ Line 32 │ +│ Line 33 │ +│ Line 34 │ +│ Line 35 │ +│ Line 36 │ +│ Line 37 │ +│ Line 38 │ +│ Line 39 │ +│ Line 40 │ +│ Line 41 │ +│ Line 42 │ +│ Line 43 │ +│ Line 44 │ +│ Line 45 │ +│ Line 46 │ +│ Line 47 │ +│ Line 48 │ +│ Line 49 │ +│ Line 50 │ +│ Line 51 │ +│ Line 52 │ +│ Line 53 │ +│ Line 54 │ +│ Line 55 │ +│ Line 56 │ +│ Line 57 │ +│ Line 58 │ +│ Line 59 │ +│ Line 60 │ +│ Line 61 │ +│ Line 62 │ +│ Line 63 │ +│ Line 64 │ +│ Line 65 │ +│ Line 66 │ +│ Line 67 │ +│ Line 68 │ +│ Line 69 │ +│ Line 70 │ +│ Line 71 │ +│ Line 72 │ +│ Line 73 │ +│ Line 74 │ +│ Line 75 │ +│ Line 76 │ +│ Line 77 │ +│ Line 78 │ +│ Line 79 │ +│ Line 80 │ +│ Line 81 │ +│ Line 82 │ +│ Line 83 │ +│ Line 84 │ +│ Line 85 │ +│ Line 86 │ +│ Line 87 │ +│ Line 88 │ +│ Line 89 │ +│ Line 90 │ +│ Line 91 │ +│ Line 92 │ +│ Line 93 │ +│ Line 94 │ +│ Line 95 │ +│ Line 96 │ +│ Line 97 │ +│ Line 98 │ +│ Line 99 │ +│ Line 100 │ " `; diff --git a/packages/cli/src/ui/components/messages/__snapshots__/ToolResultDisplay.test.tsx.snap b/packages/cli/src/ui/components/messages/__snapshots__/ToolResultDisplay.test.tsx.snap index 5e5c7ea2b0..292a0093b2 100644 --- a/packages/cli/src/ui/components/messages/__snapshots__/ToolResultDisplay.test.tsx.snap +++ b/packages/cli/src/ui/components/messages/__snapshots__/ToolResultDisplay.test.tsx.snap @@ -37,7 +37,10 @@ exports[`ToolResultDisplay > renders string result as plain text when renderOutp `; exports[`ToolResultDisplay > truncates very long string results 1`] = ` -"... 248 hidden (Ctrl+O) ... +"... 245 hidden (Ctrl+O) ... +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/packages/cli/src/ui/utils/toolLayoutUtils.ts b/packages/cli/src/ui/utils/toolLayoutUtils.ts index 26a10773d4..a99bd8a7b0 100644 --- a/packages/cli/src/ui/utils/toolLayoutUtils.ts +++ b/packages/cli/src/ui/utils/toolLayoutUtils.ts @@ -33,17 +33,10 @@ export function calculateToolContentMaxLines(options: { isAlternateBuffer: boolean; maxLinesLimit?: number; }): number | undefined { - const { availableTerminalHeight, isAlternateBuffer, maxLinesLimit } = options; - - const reservedLines = isAlternateBuffer - ? TOOL_RESULT_ASB_RESERVED_LINE_COUNT - : TOOL_RESULT_STANDARD_RESERVED_LINE_COUNT; + const { availableTerminalHeight, maxLinesLimit } = options; let contentHeight = availableTerminalHeight - ? Math.max( - 0, - availableTerminalHeight - TOOL_RESULT_STATIC_HEIGHT - reservedLines, - ) + ? Math.max(TOOL_RESULT_STATIC_HEIGHT, availableTerminalHeight) : undefined; if (maxLinesLimit) { @@ -91,14 +84,7 @@ export function calculateShellMaxLines(options: { return isAlternateBuffer ? ACTIVE_SHELL_MAX_LINES : undefined; } - const reservedLines = isAlternateBuffer - ? TOOL_RESULT_ASB_RESERVED_LINE_COUNT - : TOOL_RESULT_STANDARD_RESERVED_LINE_COUNT; - - const maxLinesBasedOnHeight = Math.max( - 0, - availableTerminalHeight - TOOL_RESULT_STATIC_HEIGHT - reservedLines, - ); + const maxLinesBasedOnHeight = Math.max(1, availableTerminalHeight); // 3. Handle ASB mode focus expansion. // We allow a focused shell in ASB mode to take up the full available height,