diff --git a/packages/cli/src/ui/components/__snapshots__/MainContent.test.tsx.snap b/packages/cli/src/ui/components/__snapshots__/MainContent.test.tsx.snap
index 6af974bb89..785dc6b6f0 100644
--- a/packages/cli/src/ui/components/__snapshots__/MainContent.test.tsx.snap
+++ b/packages/cli/src/ui/components/__snapshots__/MainContent.test.tsx.snap
@@ -6,14 +6,11 @@ AppHeader(full)
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
│ ⊶ Shell Command Running a long command... │
│ │
-│ Line 6 │
-│ Line 7 │
-│ Line 8 │
-│ Line 9 ▄ │
-│ Line 10 █ │
-│ Line 11 █ │
-│ Line 12 █ │
-│ Line 13 █ │
+│ Line 9 │
+│ Line 10 │
+│ Line 11 │
+│ Line 12 │
+│ Line 13 │
│ Line 14 █ │
│ Line 15 █ │
│ Line 16 █ │
@@ -31,14 +28,11 @@ AppHeader(full)
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
│ ⊶ Shell Command Running a long command... │
│ │
-│ Line 6 │
-│ Line 7 │
-│ Line 8 │
-│ Line 9 ▄ │
-│ Line 10 █ │
-│ Line 11 █ │
-│ Line 12 █ │
-│ Line 13 █ │
+│ Line 9 │
+│ Line 10 │
+│ Line 11 │
+│ Line 12 │
+│ Line 13 │
│ Line 14 █ │
│ Line 15 █ │
│ Line 16 █ │
@@ -55,10 +49,7 @@ exports[`MainContent > MainContent Tool Output Height Logic > 'Normal mode - Con
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
│ ⊶ Shell Command Running a long command... │
│ │
-│ ... first 6 lines hidden (Ctrl+O to show) ... │
-│ Line 7 │
-│ Line 8 │
-│ Line 9 │
+│ ... first 9 lines hidden (Ctrl+O to show) ... │
│ Line 10 │
│ Line 11 │
│ Line 12 │
diff --git a/packages/cli/src/ui/components/messages/ShellToolMessage.test.tsx b/packages/cli/src/ui/components/messages/ShellToolMessage.test.tsx
index 7607f9e4b1..061b8baeaf 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,
- 10,
+ 8,
false,
true,
],
@@ -203,7 +203,7 @@ describe('', () => {
[
'uses full availableTerminalHeight when focused in alternate buffer mode',
100,
- 100,
+ 98,
true,
false,
],
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 b45753d6d0..1847b8ce67 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
@@ -130,8 +130,6 @@ exports[` > Height Constraints > respects availableTerminalH
"╭──────────────────────────────────────────────────────────────────────────────╮
│ ⊶ Shell Command A shell command │
│ │
-│ Line 91 │
-│ Line 92 │
│ Line 93 │
│ Line 94 │
│ Line 95 │
@@ -185,106 +183,104 @@ 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 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 █ │
"
`;
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 292a0093b2..311492591e 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,9 +37,7 @@ exports[`ToolResultDisplay > renders string result as plain text when renderOutp
`;
exports[`ToolResultDisplay > truncates very long string results 1`] = `
-"... 245 hidden (Ctrl+O) ...
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+"... 247 hidden (Ctrl+O) ...
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
diff --git a/packages/cli/src/ui/utils/toolLayoutUtils.test.ts b/packages/cli/src/ui/utils/toolLayoutUtils.test.ts
index b0c0a54916..e93b5e56d0 100644
--- a/packages/cli/src/ui/utils/toolLayoutUtils.test.ts
+++ b/packages/cli/src/ui/utils/toolLayoutUtils.test.ts
@@ -8,6 +8,7 @@ import { describe, it, expect } from 'vitest';
import {
calculateToolContentMaxLines,
calculateShellMaxLines,
+ SHELL_CONTENT_OVERHEAD,
} from './toolLayoutUtils.js';
import { CoreToolCallStatus } from '@google/gemini-cli-core';
import {
@@ -41,8 +42,8 @@ describe('toolLayoutUtils', () => {
isAlternateBuffer: false,
});
- // Math.max(0, 2) = 2
- expect(result).toBe(2);
+ // Math.max(0, 2 - 2) = 0
+ expect(result).toBe(0);
});
it('returns available space directly in constrained terminal (ASB mode)', () => {
@@ -52,8 +53,8 @@ describe('toolLayoutUtils', () => {
isAlternateBuffer: true,
});
- // Math.max(0, 4) = 4
- expect(result).toBe(4);
+ // Math.max(0, 4 - 2) = 2
+ expect(result).toBe(2);
});
it('returns remaining space if sufficient space exists (Standard mode)', () => {
@@ -63,8 +64,8 @@ describe('toolLayoutUtils', () => {
isAlternateBuffer: false,
});
- // Math.max(0, 20) = 20
- expect(result).toBe(20);
+ // Math.max(0, 20 - 2) = 18
+ expect(result).toBe(18);
});
it('returns remaining space if sufficient space exists (ASB mode)', () => {
@@ -74,8 +75,8 @@ describe('toolLayoutUtils', () => {
isAlternateBuffer: true,
});
- // Math.max(0, 20) = 20
- expect(result).toBe(20);
+ // Math.max(0, 20 - 2) = 18
+ expect(result).toBe(18);
});
});
@@ -92,7 +93,7 @@ describe('toolLayoutUtils', () => {
expect(result).toBeUndefined();
});
- it('returns ACTIVE_SHELL_MAX_LINES for ASB mode when availableTerminalHeight is undefined', () => {
+ it('returns ACTIVE_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD for ASB mode when availableTerminalHeight is undefined', () => {
const result = calculateShellMaxLines({
status: CoreToolCallStatus.Executing,
isAlternateBuffer: true,
@@ -101,7 +102,7 @@ describe('toolLayoutUtils', () => {
constrainHeight: true,
isExpandable: false,
});
- expect(result).toBe(ACTIVE_SHELL_MAX_LINES);
+ expect(result).toBe(ACTIVE_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD);
});
it('returns undefined for Standard mode when availableTerminalHeight is undefined', () => {
@@ -126,8 +127,8 @@ describe('toolLayoutUtils', () => {
isExpandable: false,
});
- // Math.max(0, 2) = 2
- expect(result).toBe(2);
+ // Math.max(0, 2 - 2) = 0
+ expect(result).toBe(0);
});
it('handles small availableTerminalHeight gracefully without overflow in ASB mode', () => {
@@ -140,8 +141,8 @@ describe('toolLayoutUtils', () => {
isExpandable: false,
});
- // Math.max(0, 6) = 6
- expect(result).toBe(6);
+ // Math.max(0, 6 - 2) = 4
+ expect(result).toBe(4);
});
it('handles negative availableTerminalHeight gracefully', () => {
@@ -167,11 +168,11 @@ describe('toolLayoutUtils', () => {
isExpandable: false,
});
- // 30
- expect(result).toBe(30);
+ // 30 - 2 = 28
+ expect(result).toBe(28);
});
- it('falls back to COMPLETED_SHELL_MAX_LINES for completed shells if space allows', () => {
+ it('falls back to COMPLETED_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD for completed shells if space allows', () => {
const result = calculateShellMaxLines({
status: CoreToolCallStatus.Success,
isAlternateBuffer: false,
@@ -181,10 +182,10 @@ describe('toolLayoutUtils', () => {
isExpandable: false,
});
- expect(result).toBe(COMPLETED_SHELL_MAX_LINES);
+ expect(result).toBe(COMPLETED_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD);
});
- it('falls back to ACTIVE_SHELL_MAX_LINES for executing shells if space allows', () => {
+ it('falls back to ACTIVE_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD for executing shells if space allows', () => {
const result = calculateShellMaxLines({
status: CoreToolCallStatus.Executing,
isAlternateBuffer: false,
@@ -194,7 +195,7 @@ describe('toolLayoutUtils', () => {
isExpandable: false,
});
- expect(result).toBe(ACTIVE_SHELL_MAX_LINES);
+ expect(result).toBe(ACTIVE_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD);
});
});
});
diff --git a/packages/cli/src/ui/utils/toolLayoutUtils.ts b/packages/cli/src/ui/utils/toolLayoutUtils.ts
index c254734bdb..398eca6f16 100644
--- a/packages/cli/src/ui/utils/toolLayoutUtils.ts
+++ b/packages/cli/src/ui/utils/toolLayoutUtils.ts
@@ -15,7 +15,7 @@ import { CoreToolCallStatus } from '@google/gemini-cli-core';
* These MUST be kept in sync between ToolGroupMessage (for overflow detection)
* and ToolResultDisplay (for actual truncation).
*/
-export const TOOL_RESULT_ASB_RESERVED_LINE_COUNT = 6;
+export const TOOL_RESULT_STATIC_HEIGHT = 1;
export const TOOL_RESULT_STANDARD_RESERVED_LINE_COUNT = 2;
export const TOOL_RESULT_MIN_LINES_SHOWN = 2;
@@ -43,7 +43,10 @@ export function calculateToolContentMaxLines(options: {
let contentHeight =
availableTerminalHeight !== undefined
- ? Math.max(0, availableTerminalHeight)
+ ? Math.max(
+ 0,
+ availableTerminalHeight - TOOL_RESULT_STANDARD_RESERVED_LINE_COUNT,
+ )
: undefined;
if (maxLinesLimit !== undefined) {
@@ -93,7 +96,10 @@ export function calculateShellMaxLines(options: {
: undefined;
}
- const maxLinesBasedOnHeight = Math.max(0, availableTerminalHeight);
+ const maxLinesBasedOnHeight = Math.max(
+ 0,
+ availableTerminalHeight - TOOL_RESULT_STANDARD_RESERVED_LINE_COUNT,
+ );
// 3. Handle ASB mode focus expansion.
// We allow a focused shell in ASB mode to take up the full available height,