diff options
| author | Jacob Richman <[email protected]> | 2025-06-19 20:17:23 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-19 13:17:23 -0700 |
| commit | b0bc7c3d996d25c9fefdfbcba3ca19fa46ad199f (patch) | |
| tree | c2d89d14b8dade1daf51f835969d9b0e79d4df30 /packages/cli/src/ui/components/messages/ToolGroupMessage.tsx | |
| parent | 10a83a6395b70f21b01da99d0992c78d0354a8dd (diff) | |
Fix flicker issues by ensuring all actively changing content fits in the viewport (#1217)
Diffstat (limited to 'packages/cli/src/ui/components/messages/ToolGroupMessage.tsx')
| -rw-r--r-- | packages/cli/src/ui/components/messages/ToolGroupMessage.tsx | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx b/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx index 8ce40893..445a157c 100644 --- a/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx +++ b/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx @@ -15,7 +15,8 @@ import { Config } from '@gemini-cli/core'; interface ToolGroupMessageProps { groupId: number; toolCalls: IndividualToolCallDisplay[]; - availableTerminalHeight: number; + availableTerminalHeight?: number; + terminalWidth: number; config?: Config; isFocused?: boolean; } @@ -24,6 +25,7 @@ interface ToolGroupMessageProps { export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({ toolCalls, availableTerminalHeight, + terminalWidth, config, isFocused = true, }) => { @@ -33,6 +35,9 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({ const borderColor = hasPending ? Colors.AccentYellow : Colors.Gray; const staticHeight = /* border */ 2 + /* marginBottom */ 1; + // This is a bit of a magic number, but it accounts for the border and + // marginLeft. + const innerWidth = terminalWidth - 4; // only prompt for tool approval on the first 'confirming' tool in the list // note, after the CTA, this automatically moves over to the next 'confirming' tool @@ -41,6 +46,23 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({ [toolCalls], ); + let countToolCallsWithResults = 0; + for (const tool of toolCalls) { + if (tool.resultDisplay !== undefined && tool.resultDisplay !== '') { + countToolCallsWithResults++; + } + } + const countOneLineToolCalls = toolCalls.length - countToolCallsWithResults; + const availableTerminalHeightPerToolMessage = availableTerminalHeight + ? Math.max( + Math.floor( + (availableTerminalHeight - staticHeight - countOneLineToolCalls) / + Math.max(1, countToolCallsWithResults), + ), + 1, + ) + : undefined; + return ( <Box flexDirection="column" @@ -69,7 +91,8 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({ resultDisplay={tool.resultDisplay} status={tool.status} confirmationDetails={tool.confirmationDetails} - availableTerminalHeight={availableTerminalHeight - staticHeight} + availableTerminalHeight={availableTerminalHeightPerToolMessage} + terminalWidth={innerWidth} emphasis={ isConfirming ? 'high' @@ -87,6 +110,10 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({ confirmationDetails={tool.confirmationDetails} config={config} isFocused={isFocused} + availableTerminalHeight={ + availableTerminalHeightPerToolMessage + } + terminalWidth={innerWidth} /> )} </Box> |
