diff --git a/web/app/components/base/chat/chat/answer/basic-content.tsx b/web/app/components/base/chat/chat/answer/basic-content.tsx index ed8f83d6a9..cda2dd6ffb 100644 --- a/web/app/components/base/chat/chat/answer/basic-content.tsx +++ b/web/app/components/base/chat/chat/answer/basic-content.tsx @@ -18,12 +18,19 @@ const BasicContent: FC = ({ if (annotation?.logAnnotation) return + // Preserve Windows UNC paths and similar backslash-heavy strings by + // wrapping them in inline code so Markdown renders backslashes verbatim. + let displayContent = content + if (typeof content === 'string' && /^\\\\\S.*/.test(content) && !/^`.*`$/.test(content)) { + displayContent = `\`${content}\`` + } + return ( ) } diff --git a/web/app/components/base/chat/chat/answer/index.tsx b/web/app/components/base/chat/chat/answer/index.tsx index 04b884388e..7420b84ede 100644 --- a/web/app/components/base/chat/chat/answer/index.tsx +++ b/web/app/components/base/chat/chat/answer/index.tsx @@ -111,7 +111,7 @@ const Answer: FC = ({ } }, [switchSibling, item.prevSibling, item.nextSibling]) - const contentIsEmpty = content.trim() === '' + const contentIsEmpty = typeof content === 'string' && content.trim() === '' return (