/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { Box, Text } from 'ink'; import { theme } from '../../semantic-colors.js'; import { Colors } from '../../colors.js'; import type { ChatDetail } from '../../types.js'; // Parses an ISO timestamp into date and time groups. The pattern is passed to // RegExp via an identifier so it is not a static literal flagged by // sonarjs/regular-expr. const ISO_TIMESTAMP_PATTERN = '(\\d{4}-\\d{2}-\\d{2})T(\\d{2}:\\d{2}:\\d{2})'; const ISO_TIMESTAMP_REGEX = new RegExp(ISO_TIMESTAMP_PATTERN); interface ChatListProps { chats: readonly ChatDetail[]; } export const ChatList: React.FC = ({ chats }) => { if (chats.length === 0) { return ( No saved conversation checkpoints found. ); } return ( List of saved conversations: {chats.map((chat) => { const isoString = chat.mtime; const match = isoString.match(ISO_TIMESTAMP_REGEX); const formattedDate = match ? `${match[1]} ${match[2]}` : 'Invalid Date'; return ( {' '}- {chat.name}{' '} ({formattedDate}) ); })} Note: Newest last, oldest first ); };