/** * @license * Copyright 2025 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, UserShellMessage, AssistantMessage, AssistantMessageContent, ThinkMessage, ThinkMessageContent, } from './messages/ConversationMessages.js'; import { ToolGroupMessage } from './messages/ToolGroupMessage.js'; import { CompressionMessage } from './messages/CompressionMessage.js'; import { SummaryMessage } from './messages/SummaryMessage.js'; import { InfoMessage, WarningMessage, ErrorMessage, RetryCountdownMessage, SuccessMessage, } from './messages/StatusMessages.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 '@qwen-code/qwen-code-core'; import { SkillsList } from './views/SkillsList.js'; import { ToolsList } from './views/ToolsList.js'; import { McpStatus } from './views/McpStatus.js'; import { ContextUsage } from './views/ContextUsage.js'; import { ArenaAgentCard, ArenaSessionCard } from './arena/ArenaCards.js'; import { InsightProgressMessage } from './messages/InsightProgressMessage.js'; interface HistoryItemDisplayProps { item: HistoryItem; availableTerminalHeight?: number; terminalWidth: number; mainAreaWidth?: number; isPending: boolean; isFocused?: boolean; commands?: readonly SlashCommand[]; activeShellPtyId?: number | null; embeddedShellFocused?: boolean; availableTerminalHeightGemini?: number; } const HistoryItemDisplayComponent: React.FC = ({ item, availableTerminalHeight, terminalWidth, mainAreaWidth, isPending, commands, isFocused = true, activeShellPtyId, embeddedShellFocused, availableTerminalHeightGemini, }) => { const marginTop = item.type === 'gemini_content' || item.type === 'gemini_thought_content' ? 0 : 1; const itemForDisplay = useMemo(() => escapeAnsiCtrlCodes(item), [item]); const contentWidth = terminalWidth - 4; const boxWidth = mainAreaWidth || contentWidth; return ( {/* Render standard message types */} {itemForDisplay.type === 'user' && ( )} {itemForDisplay.type === 'user_shell' && ( )} {itemForDisplay.type === 'gemini' && ( )} {itemForDisplay.type === 'gemini_content' && ( )} {itemForDisplay.type === 'gemini_thought' && ( )} {itemForDisplay.type === 'gemini_thought_content' && ( )} {itemForDisplay.type === 'info' && ( )} {itemForDisplay.type === 'success' && ( )} {itemForDisplay.type === 'warning' && ( )} {itemForDisplay.type === 'error' && ( )} {itemForDisplay.type === 'retry_countdown' && ( )} {itemForDisplay.type === 'about' && ( )} {itemForDisplay.type === 'help' && commands && ( )} {itemForDisplay.type === 'stats' && ( )} {itemForDisplay.type === 'model_stats' && ( )} {itemForDisplay.type === 'tool_stats' && ( )} {itemForDisplay.type === 'quit' && ( )} {itemForDisplay.type === 'tool_group' && ( )} {itemForDisplay.type === 'compression' && ( )} {item.type === 'summary' && } {itemForDisplay.type === 'extensions_list' && } {itemForDisplay.type === 'tools_list' && ( )} {itemForDisplay.type === 'skills_list' && ( )} {itemForDisplay.type === 'mcp_status' && ( )} {itemForDisplay.type === 'context_usage' && ( )} {itemForDisplay.type === 'arena_agent_complete' && ( )} {itemForDisplay.type === 'arena_session_complete' && ( )} {itemForDisplay.type === 'insight_progress' && ( )} ); }; // Export alias for backward compatibility export { HistoryItemDisplayComponent as HistoryItemDisplay };