/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { Box } from 'ink'; import type { IndividualToolCallDisplay } from '../../types.js'; import { StickyHeader } from '../StickyHeader.js'; import { ToolResultDisplay } from './ToolResultDisplay.js'; import { ToolStatusIndicator, ToolInfo, TrailingIndicator, type TextEmphasis, STATUS_INDICATOR_WIDTH, isThisShellFocusable as checkIsShellFocusable, isThisShellFocused as checkIsShellFocused, useFocusHint, FocusHint, } from './ToolShared.js'; import { type Config } from '@google/gemini-cli-core'; import { ShellInputPrompt } from '../ShellInputPrompt.js'; export type { TextEmphasis }; export interface ToolMessageProps extends IndividualToolCallDisplay { availableTerminalHeight?: number; terminalWidth: number; emphasis?: TextEmphasis; renderOutputAsMarkdown?: boolean; isFirst: boolean; borderColor: string; borderDimColor: boolean; activeShellPtyId?: number | null; embeddedShellFocused?: boolean; ptyId?: number; config?: Config; } export const ToolMessage: React.FC = ({ name, description, resultDisplay, status, availableTerminalHeight, terminalWidth, emphasis = 'medium', renderOutputAsMarkdown = true, isFirst, borderColor, borderDimColor, activeShellPtyId, embeddedShellFocused, ptyId, config, }) => { const isThisShellFocused = checkIsShellFocused( name, status, ptyId, activeShellPtyId, embeddedShellFocused, ); const isThisShellFocusable = checkIsShellFocusable(name, status, config); const { shouldShowFocusHint } = useFocusHint( isThisShellFocusable, isThisShellFocused, resultDisplay, ); return ( // It is crucial we don't replace this <> with a Box because otherwise the // sticky header inside it would be sticky to that box rather than to the // parent component of this ToolMessage. <> {emphasis === 'high' && } {isThisShellFocused && config && ( )} ); };