/** * TaskCoordinationItem - Single task coordination injection with expandable breakdown. */ import React, { useState } from 'react'; import { COLOR_TEXT_MUTED, COLOR_TEXT_SECONDARY } from '@renderer/constants/cssVariables'; import { ChevronRight, Users } from 'lucide-react'; import { formatTokens } from '../utils/formatting'; import type { TaskCoordinationInjection } from '@renderer/types/contextInjection'; interface TaskCoordinationItemProps { injection: TaskCoordinationInjection; onNavigateToTurn?: (turnIndex: number) => void; } export const TaskCoordinationItem = ({ injection, onNavigateToTurn, }: Readonly): React.ReactElement => { const [expanded, setExpanded] = useState(false); const turnIndex = injection.turnIndex; const isClickable = onNavigateToTurn && turnIndex >= 0; const hasBreakdown = injection.breakdown.length > 0; const containerContent = ( <> {hasBreakdown && ( )} {isClickable ? ( { e.stopPropagation(); onNavigateToTurn(turnIndex); }} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.stopPropagation(); onNavigateToTurn(turnIndex); } }} > @Turn {turnIndex + 1} ) : ( @Turn {turnIndex + 1} )} ~{formatTokens(injection.estimatedTokens)} tokens {injection.breakdown.length} item{injection.breakdown.length !== 1 ? 's' : ''} ); return (
{hasBreakdown ? ( ) : (
{containerContent}
)} {expanded && hasBreakdown && (
{injection.breakdown.map((item, idx) => (
{item.label} ~{formatTokens(item.tokenCount)}
))}
)}
); };