import React from 'react'; import { format } from 'date-fns'; import { Terminal } from 'lucide-react'; import type { SystemGroup } from '@renderer/types/groups'; // Module-level constant - safe because .replace() resets lastIndex on g-flagged regexes const ANSI_ESCAPE_REGEX = new RegExp(String.fromCharCode(27) + '\\[[0-9;]*m', 'g'); interface SystemChatGroupProps { systemGroup: SystemGroup; } /** * SystemChatGroup displays command output (e.g., /model response). * Renders on LEFT side like AI, but with neutral/gray styling. */ const SystemChatGroupInner = ({ systemGroup, }: Readonly): React.JSX.Element => { const { commandOutput, timestamp } = systemGroup; // Clean ANSI escape codes from output const cleanOutput = commandOutput.replace(ANSI_ESCAPE_REGEX, ''); return (
{/* Header - system icon */}
System ยท {format(timestamp, 'h:mm:ss a')}
{/* Content - theme-aware neutral styling */}
            {cleanOutput}
          
); }; export const SystemChatGroup = React.memo(SystemChatGroupInner);