From 3583229c7e0a264765df12c6eaedee166ad5111b Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Wed, 5 Nov 2025 08:48:19 +0000 Subject: [PATCH] Render user messages without markdown formatting --- src/components/message-part.tsx | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/message-part.tsx b/src/components/message-part.tsx index faf52a29..5bbe4465 100644 --- a/src/components/message-part.tsx +++ b/src/components/message-part.tsx @@ -18,6 +18,27 @@ export default function MessagePart(props: MessagePartProps) { const isAssistantMessage = () => props.messageType === "assistant" const textContainerClass = () => (isAssistantMessage() ? "message-text message-text-assistant" : "message-text") + const plainTextContent = () => { + const part = props.part + + if (typeof part?.text === "string") { + return part.text + } + + const segments: string[] = [] + const contentArray = Array.isArray(part?.content) ? part.content : [] + + for (const item of contentArray) { + if (typeof item === "string") { + segments.push(item) + } else if (item && typeof item === "object" && typeof (item as { text?: unknown }).text === "string") { + segments.push((item as { text: string }).text) + } + } + + return segments.join("\n") + } + function handleReasoningClick(e: Event) { e.preventDefault() toggleItemExpanded(reasoningId()) @@ -28,7 +49,12 @@ export default function MessagePart(props: MessagePartProps) {
- + {plainTextContent()}} + > + +