diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/edit-message.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/edit-message.tsx index ef0e31158..b5826d4a0 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/edit-message.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/edit-message.tsx @@ -13,12 +13,23 @@ type MarkdownFieldProps = { editedFlag: React.ReactNode; }; +// Function to replace tags with a placeholder before markdown processing +const preprocessChatMessage = (text: string): string => { + // Replace tags with `think:` + return text + .replace(//g, "``") + .replace(/<\/think>/g, "``"); +}; + export const MarkdownField = ({ chat, isEmpty, chatMessage, editedFlag, }: MarkdownFieldProps) => { + // Process the chat message to handle tags + const processedChatMessage = preprocessChatMessage(chatMessage); + return (
; } + + // Specifically handle tags that were wrapped in backticks + if (content === "" || content === "") { + return {content}; + } } const match = /language-(\w+)/.exec(className || ""); @@ -74,7 +90,9 @@ export const MarkdownField = ({ }, }} > - {isEmpty && !chat.stream_url ? EMPTY_OUTPUT_SEND_MESSAGE : chatMessage} + {isEmpty && !chat.stream_url + ? EMPTY_OUTPUT_SEND_MESSAGE + : processedChatMessage} {editedFlag}