From 8c2146ff26bd9c621eb4acc88cbd65fc74a62b8a Mon Sep 17 00:00:00 2001 From: cmackdev Date: Fri, 15 Aug 2025 21:29:55 -0600 Subject: [PATCH] feat: make external links in markdown open in new tabs - Add custom anchor component to MARKDOWN_COMPONENTS - External links (http/https) now open in new tabs with target='_blank' - Includes rel='noopener noreferrer' for security - Internal links remain unchanged - Improves user experience by preventing navigation away from chat Fixes: Users losing chat context when clicking external links --- .../src/components/markdown/MarkdownContent.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/ui-chat/src/components/markdown/MarkdownContent.tsx b/source/ui-chat/src/components/markdown/MarkdownContent.tsx index 8139fd64..ea5d1502 100644 --- a/source/ui-chat/src/components/markdown/MarkdownContent.tsx +++ b/source/ui-chat/src/components/markdown/MarkdownContent.tsx @@ -96,6 +96,23 @@ const MARKDOWN_COMPONENTS: Components = { */ td({ children }) { return {children}; + }, + /** + * Renders links with external links opening in new tabs + */ + a({ href, children, ...props }) { + const isExternal = href && (href.startsWith('http://') || href.startsWith('https://')); + + return ( + + {children} + + ); } };