From e957bbeb7e56a16d946b775b1baae9a8af74d8f8 Mon Sep 17 00:00:00 2001 From: Craig Constable Date: Mon, 9 Mar 2026 16:28:41 +1000 Subject: [PATCH] Fix desktop chat markdown external links --- apps/web/src/components/ChatMarkdown.tsx | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/ChatMarkdown.tsx b/apps/web/src/components/ChatMarkdown.tsx index da44045c98..dc8c1d0275 100644 --- a/apps/web/src/components/ChatMarkdown.tsx +++ b/apps/web/src/components/ChatMarkdown.tsx @@ -20,6 +20,7 @@ import React, { import type { Components } from "react-markdown"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; +import { isElectron } from "../env"; import { resolveDiffThemeName, type DiffThemeName } from "../lib/diffRendering"; import { fnv1a32 } from "../lib/diffRendering"; import { LRUCache } from "../lib/lruCache"; @@ -240,7 +241,31 @@ function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) { a({ node: _node, href, ...props }) { const targetPath = resolveMarkdownFileLinkTarget(href, cwd); if (!targetPath) { - return ; + if (!isElectron) { + return ; + } + + return ( + { + if (!href) { + return; + } + const api = readNativeApi(); + if (api) { + event.preventDefault(); + event.stopPropagation(); + void api.shell.openExternal(href); + } else { + console.warn("Unable to open external link."); + } + }} + /> + ); } return (