/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { Box, Text } from 'ink'; import type { AnsiLine, AnsiOutput, AnsiToken } from '@google/gemini-cli-core'; const DEFAULT_HEIGHT = 24; interface AnsiOutputProps { data: AnsiOutput; availableTerminalHeight?: number; width: number; } export const AnsiOutputText: React.FC = ({ data, availableTerminalHeight, width, }) => { const lastLines = data.slice( -(availableTerminalHeight && availableTerminalHeight > 0 ? availableTerminalHeight : DEFAULT_HEIGHT), ); return ( {lastLines.map((line: AnsiLine, lineIndex: number) => ( {line.length > 0 ? line.map((token: AnsiToken, tokenIndex: number) => ( {token.text} )) : null} ))} ); };