diff --git a/components/ClientHome.tsx b/components/ClientHome.tsx index c16c185..0e6b80c 100644 --- a/components/ClientHome.tsx +++ b/components/ClientHome.tsx @@ -62,6 +62,7 @@ export function ClientHome({ offline, models }: ClientHomeProps) { models={models} offline={offline} onConversationCreated={handleConversationCreated} + currentConversationId={currentConversationId} /> diff --git a/components/chat/ChatContainer.tsx b/components/chat/ChatContainer.tsx index 7c00e2a..ce6a595 100644 --- a/components/chat/ChatContainer.tsx +++ b/components/chat/ChatContainer.tsx @@ -15,12 +15,14 @@ interface ChatContainerProps { models: ModelInfo[]; offline: boolean; onConversationCreated?: () => void; + currentConversationId?: string | null; } export function ChatContainer({ models, offline, onConversationCreated, + currentConversationId: propCurrentConversationId, }: ChatContainerProps) { const { prefs, ready, update } = useUserPrefs(); const [messages, setMessages] = useState([]); @@ -42,6 +44,17 @@ export function ChatContainer({ } }, [ready, prefs.selectedModel]); + // Carregar mensagens quando uma conversa é selecionada + useEffect(() => { + if (propCurrentConversationId) { + loadConversation(propCurrentConversationId); + } else { + // Limpar mensagens quando nenhuma conversa está selecionada + setMessages([]); + setConversationId(null); + } + }, [propCurrentConversationId]); + // Salvar modelo quando selecionado const handleModelChange = (modelName: string) => { setSelectedModel(modelName); diff --git a/components/chat/ChatMessage.tsx b/components/chat/ChatMessage.tsx index 0027a95..61c92d1 100644 --- a/components/chat/ChatMessage.tsx +++ b/components/chat/ChatMessage.tsx @@ -34,9 +34,9 @@ export function ChatMessage({ : "bg-[var(--surface)] text-[var(--foreground)]" }`} > -
+
{isUser ? ( - message.content +
{message.content}
) : ( )} diff --git a/components/message/MarkdownRenderer.tsx b/components/message/MarkdownRenderer.tsx index 5ba4494..f94f193 100644 --- a/components/message/MarkdownRenderer.tsx +++ b/components/message/MarkdownRenderer.tsx @@ -12,6 +12,12 @@ type MarkdownRendererProps = { }; export function MarkdownRenderer({ content }: MarkdownRendererProps) { + // Normalizar quebras de linha e espaços + const normalizedContent = content + .replace(/\n{3,}/g, "\n\n") // Máximo 2 quebras consecutivas + .replace(/[ \t]+$/gm, "") // Remover espaços no final das linhas + .trim(); + return ( +