diff --git a/web/src/components/chat/AssistantMessage.tsx b/web/src/components/chat/AssistantMessage.tsx deleted file mode 100644 index 17d697b65..000000000 --- a/web/src/components/chat/AssistantMessage.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ReactMarkdown from "react-markdown"; - -type AssistantMessageProps = { - content: string; -}; - -export function AssistantMessage({ content }: AssistantMessageProps) { - return {content}; -} diff --git a/web/src/components/chat/ChatMessage.tsx b/web/src/components/chat/ChatMessage.tsx new file mode 100644 index 000000000..48117221f --- /dev/null +++ b/web/src/components/chat/ChatMessage.tsx @@ -0,0 +1,24 @@ +import ReactMarkdown from "react-markdown"; +import { cn } from "@/lib/utils"; + +type MessageBubbleProps = { + role: "user" | "assistant"; + content: string; +}; + +export function MessageBubble({ role, content }: MessageBubbleProps) { + const isUser = role === "user"; + + return ( +
+ {isUser ? content : {content}} +
+ ); +} diff --git a/web/src/pages/Chat.tsx b/web/src/pages/Chat.tsx index 7a0dde930..74e396721 100644 --- a/web/src/pages/Chat.tsx +++ b/web/src/pages/Chat.tsx @@ -4,7 +4,7 @@ import { FaArrowUpLong } from "react-icons/fa6"; import { useTranslation } from "react-i18next"; import { useState, useCallback } from "react"; import axios from "axios"; -import { AssistantMessage } from "@/components/chat/AssistantMessage"; +import { MessageBubble } from "@/components/chat/ChatMessage"; import { ToolCallBubble } from "@/components/chat/ToolCallBubble"; import type { ChatMessage, ToolCall } from "@/types/chat"; @@ -52,63 +52,53 @@ export default function ChatPage() { }, [input, isLoading, messages, t]); return ( -
-
- {messages.map((msg, i) => ( -
- {msg.role === "assistant" && msg.toolCalls && ( - <> - {msg.toolCalls.map((tc, tcIdx) => ( -
- - {tc.response && ( +
+
+
+ {messages.map((msg, i) => ( +
+ {msg.role === "assistant" && msg.toolCalls && ( + <> + {msg.toolCalls.map((tc, tcIdx) => ( +
- )} -
- ))} - - )} -
- {msg.role === "assistant" ? ( - - ) : ( - msg.content + {tc.response && ( + + )} +
+ ))} + )} +
-
- ))} - {isLoading && ( -
- {t("processing")} -
- )} - {error && ( -

- {error} -

- )} + ))} + {isLoading && ( +
+ {t("processing")} +
+ )} + {error && ( +

+ {error} +

+ )} +
+
-
); } @@ -136,7 +126,7 @@ function ChatEntry({ }; return ( -
+