({ agent, width }: { agent: AgentState; width: number })
| 77 | } |
| 78 | |
| 79 | function AgentPanel({ agent, width }: { agent: AgentState; width: number }) { |
| 80 | const maxLines = 15; |
| 81 | const contentWidth = width - 4; |
| 82 | |
| 83 | // Build all display lines from activity |
| 84 | const displayLines: { text: string; color?: string; dim?: boolean }[] = []; |
| 85 | |
| 86 | for (const event of agent.activity) { |
| 87 | switch (event.type) { |
| 88 | case 'thinking': { |
| 89 | const wrapped = wrapText(`💭 ${event.text}`, contentWidth); |
| 90 | wrapped.forEach((line) => displayLines.push({ text: line, dim: true })); |
| 91 | break; |
| 92 | } |
| 93 | case 'tool_call': { |
| 94 | const toolText = `🔧 ${event.name}(${event.args})`; |
| 95 | const wrapped = wrapText(toolText, contentWidth); |
| 96 | wrapped.forEach((line) => displayLines.push({ text: line, color: 'cyan' })); |
| 97 | break; |
| 98 | } |
| 99 | case 'tool_result': { |
| 100 | const wrapped = wrapText(` ↪ ${event.preview}`, contentWidth); |
| 101 | wrapped.forEach((line) => displayLines.push({ text: line, color: 'gray' })); |
| 102 | break; |
| 103 | } |
| 104 | case 'response': { |
| 105 | const wrapped = wrapText(event.text, contentWidth); |
| 106 | wrapped.forEach((line) => displayLines.push({ text: line })); |
| 107 | break; |
| 108 | } |
| 109 | case 'error': { |
| 110 | const wrapped = wrapText(`❌ ${event.text}`, contentWidth); |
| 111 | wrapped.forEach((line) => displayLines.push({ text: line, color: 'red' })); |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // Add current streaming text |
| 118 | if (agent.currentText && agent.status === 'running') { |
| 119 | const wrapped = wrapText(`▸ ${agent.currentText}`, contentWidth); |
| 120 | wrapped.forEach((line) => displayLines.push({ text: line, color: 'white' })); |
| 121 | } |
| 122 | |
| 123 | // Take last N lines |
| 124 | const visibleLines = displayLines.slice(-maxLines); |
| 125 | |
| 126 | return ( |
| 127 | <Box |
| 128 | flexDirection="column" |
| 129 | width={width} |
| 130 | borderStyle="round" |
| 131 | borderColor={agent.color} |
| 132 | paddingX={1} |
| 133 | > |
| 134 | {/* Header */} |
| 135 | <Box justifyContent="space-between"> |
| 136 | <Text bold color={agent.color}> |
nothing calls this directly
no test coverage detected