import React from 'react'
import { marked } from 'marked'
import hljs from 'highlight.js'
import 'highlight.js/styles/github-dark.css'
import ToolCall from './ToolCall'
function ChatView({ messages, toolCalls }) {
const renderMessage = (message) => {
const html = marked(message.content)
return (
{message.agent.toUpperCase()}
{new Date(message.timestamp).toLocaleTimeString()}
)
}
React.useEffect(() => {
// Highlight code blocks after render
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block)
})
}, [messages])
if (messages.length === 0 && toolCalls.length === 0) {
return (
No messages yet
)
}
return (
{messages.map(renderMessage)}
{toolCalls.length > 0 && (
Tool Calls
{toolCalls.map((toolCall) => (
))}
)}
)
}
export default ChatView