Skip to content
Closed
Changes from all commits
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
27 changes: 26 additions & 1 deletion apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -240,7 +241,31 @@ function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) {
a({ node: _node, href, ...props }) {
const targetPath = resolveMarkdownFileLinkTarget(href, cwd);
if (!targetPath) {
return <a {...props} href={href} target="_blank" rel="noreferrer" />;
if (!isElectron) {
return <a {...props} href={href} target="_blank" rel="noreferrer" />;
}

return (
<a
{...props}
href={href}
target="_blank"
rel="noreferrer"
onClick={(event) => {
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 (
Expand Down