import React, { useState } from 'react'; import ReactMarkdown from 'react-markdown'; import { CODE_BG, CODE_BORDER, COLOR_TEXT_MUTED, COLOR_TEXT_SECONDARY, TOOL_CALL_TEXT, } from '@renderer/constants/cssVariables'; import { REHYPE_PLUGINS } from '@renderer/utils/markdownPlugins'; import { formatTokensCompact as formatTokens } from '@shared/utils/tokenFormatting'; import { format } from 'date-fns'; import { ChevronRight, Layers } from 'lucide-react'; import remarkGfm from 'remark-gfm'; import { CopyButton } from '../common/CopyButton'; import { markdownComponents } from './markdownComponents'; import type { CompactGroup } from '@renderer/types/groups'; interface CompactBoundaryProps { compactGroup: CompactGroup; } /** * CompactBoundary displays a horizontal divider indicating where * the conversation was compacted. Click to expand the compacted summary. */ export const CompactBoundary = ({ compactGroup, }: Readonly): React.JSX.Element => { const { timestamp, message } = compactGroup; const [isExpanded, setIsExpanded] = useState(false); // Extract content from message const getCompactContent = (): string => { if (!message?.content) return ''; if (typeof message.content === 'string') { return message.content; } // If it's an array of content blocks, extract text if (Array.isArray(message.content)) { return message.content .filter((block: { type: string; text?: string }) => block.type === 'text') .map((block: { type: string; text?: string }) => block.text ?? '') .join('\n\n'); } return ''; }; const compactContent = getCompactContent(); return (
{/* Divider with centered label */} {/* Expanded Content */} {isExpanded && (
{compactContent && } {/* Content - scrollable with left accent bar */}
{compactContent ? ( {compactContent} ) : (

Conversation Compacted

Previous messages were summarized to save context. The full conversation history is preserved in the session file.

)}
)}
); };