/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { useMemo } from 'react'; import { escapeAnsiCtrlCodes } from '../utils/textUtils.js'; import type { HistoryItem } from '../types.js'; import { UserMessage } from './messages/UserMessage.js'; import { UserShellMessage } from './messages/UserShellMessage.js'; import { GeminiMessage } from './messages/GeminiMessage.js'; import { InfoMessage } from './messages/InfoMessage.js'; import { ErrorMessage } from './messages/ErrorMessage.js'; import { ToolGroupMessage } from './messages/ToolGroupMessage.js'; import { GeminiMessageContent } from './messages/GeminiMessageContent.js'; import { CompressionMessage } from './messages/CompressionMessage.js'; import { WarningMessage } from './messages/WarningMessage.js'; import { Box } from 'ink'; import { AboutBox } from './AboutBox.js'; import { StatsDisplay } from './StatsDisplay.js'; import { ModelStatsDisplay } from './ModelStatsDisplay.js'; import { ToolStatsDisplay } from './ToolStatsDisplay.js'; import { SessionSummaryDisplay } from './SessionSummaryDisplay.js'; import { Help } from './Help.js'; import type { SlashCommand } from '../commands/types.js'; import { ExtensionsList } from './views/ExtensionsList.js'; import { getMCPServerStatus } from '@google/gemini-cli-core'; import { ToolsList } from './views/ToolsList.js'; import { SkillsList } from './views/SkillsList.js'; import { AgentsStatus } from './views/AgentsStatus.js'; import { McpStatus } from './views/McpStatus.js'; import { ChatList } from './views/ChatList.js'; import { HooksList } from './views/HooksList.js'; import { ModelMessage } from './messages/ModelMessage.js'; import { ThinkingMessage } from './messages/ThinkingMessage.js'; import { HintMessage } from './messages/HintMessage.js'; import { getInlineThinkingMode } from '../utils/inlineThinkingMode.js'; import { useSettings } from '../contexts/SettingsContext.js'; interface HistoryItemDisplayProps { item: HistoryItem; availableTerminalHeight?: number; terminalWidth: number; isPending: boolean; commands?: readonly SlashCommand[]; availableTerminalHeightGemini?: number; isExpandable?: boolean; } export const HistoryItemDisplay: React.FC = ({ item, availableTerminalHeight, terminalWidth, isPending, commands, availableTerminalHeightGemini, isExpandable, }) => { const settings = useSettings(); const inlineThinkingMode = getInlineThinkingMode(settings); const itemForDisplay = useMemo(() => escapeAnsiCtrlCodes(item), [item]); return ( {/* Render standard message types */} {itemForDisplay.type === 'thinking' && inlineThinkingMode !== 'off' && ( )} {itemForDisplay.type === 'hint' && ( )} {itemForDisplay.type === 'user' && ( )} {itemForDisplay.type === 'user_shell' && ( )} {itemForDisplay.type === 'gemini' && ( )} {itemForDisplay.type === 'gemini_content' && ( )} {itemForDisplay.type === 'info' && ( )} {itemForDisplay.type === 'warning' && ( )} {itemForDisplay.type === 'error' && ( )} {itemForDisplay.type === 'about' && ( )} {itemForDisplay.type === 'help' && commands && ( )} {itemForDisplay.type === 'stats' && ( )} {itemForDisplay.type === 'model_stats' && ( )} {itemForDisplay.type === 'tool_stats' && } {itemForDisplay.type === 'model' && ( )} {itemForDisplay.type === 'quit' && ( )} {itemForDisplay.type === 'tool_group' && ( )} {itemForDisplay.type === 'compression' && ( )} {itemForDisplay.type === 'extensions_list' && ( )} {itemForDisplay.type === 'tools_list' && ( )} {itemForDisplay.type === 'skills_list' && ( )} {itemForDisplay.type === 'agents_list' && ( )} {itemForDisplay.type === 'mcp_status' && ( )} {itemForDisplay.type === 'chat_list' && ( )} {itemForDisplay.type === 'hooks_list' && ( )} ); };