Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion webview-ui/src/components/chat/ChatRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -986,13 +986,21 @@ const Markdown = memo(({ markdown, partial }: { markdown?: string; partial?: boo
const [isHovering, setIsHovering] = useState(false)
const { copyWithFeedback } = useCopyToClipboard(200) // shorter feedback duration for copy button flash

// Remove trailing code delimiters like "```tool_code" or "```xml"
const cleanedMarkdown = useMemo(() => {
if (!markdown) return markdown

// Regex to match trailing code block delimiters at the very end of the string
return markdown.replace(/```[a-zA-Z0-9_-]*\s*$/g, "")
}, [markdown])

return (
<div
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
style={{ position: "relative" }}>
<div style={{ wordBreak: "break-word", overflowWrap: "anywhere", marginBottom: -15, marginTop: -15 }}>
<MarkdownBlock markdown={markdown} />
<MarkdownBlock markdown={cleanedMarkdown} />
</div>
{markdown && !partial && isHovering && (
<div
Expand Down