'use client';
import { useEffect, useRef, useState } from 'react';
import { useStore } from '@/lib/store';
import { renderMarkdown } from '@/lib/markdown';
function CopyRow({ content, sources }: { content: string; sources: string[] }) {
const [copied, setCopied] = useState(false);
function copy() {
navigator.clipboard.writeText(content).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
});
}
return (
{sources && sources.length > 0 && (
Sources: {[...new Set(sources)].join(', ')}
)}
);
}
export default function MessageList() {
const { messages, isLoading } = useStore();
const bottomRef = useRef(null);
useEffect(() => {
bottomRef.current?.scrollIntoView({ behavior: 'smooth' });
}, [messages, isLoading]);
if (!messages.length && !isLoading) {
return (
What are you working on?
Ask about your documents, projects, research, or anything else.
Your entire corpus is available.
);
}
return (
{messages.map((m, i) => (
{m.role === 'user' ? 'you' : 'aaron ai'}
{m.role === 'assistant' ? (
) : (
{m.content}
)}
))}
{isLoading && (
)}
);
}