feat(chat): add conversation selection and enhance message rendering

- Add currentConversationId prop to ChatContainer for loading selected conversations
- Implement logic to load messages when conversation is selected and clear when deselected
- Improve user message rendering with proper whitespace handling
- Enhance MarkdownRenderer with content normalization and adjusted spacing for better readability
- Add paragraph styling to markdown output for improved layout

This enables users to switch between conversations seamlessly and provides cleaner message display.
This commit is contained in:
Evandro Fonseca Junior committed 2025-10-28 14:40:34 -03:00
1 parent 0cc7a81319
commit d5dd3a9f09
11 files changed
+54 -13

No files matched your search

+13
View File
@@ -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<Message[]>([]);
@@ -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);
+2 -2
View File
@@ -34,9 +34,9 @@ export function ChatMessage({
: "bg-[var(--surface)] text-[var(--foreground)]"
}`}
>
<div className="whitespace-pre-wrap break-words">
<div className="break-words">
{isUser ? (
message.content
<div className="whitespace-pre-wrap">{message.content}</div>
) : (
<MarkdownRenderer content={message.content} />
)}