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 (