From 9d029410e4ff740f0fc5514d74f92cb29575ef91 Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Wed, 8 Apr 2026 14:06:57 -1000 Subject: [PATCH] feat(desktop): render GitHub PR links as inline smart chips GitHub pull request URLs are now displayed as compact inline chips with a pull request icon and owner/repo#number label instead of raw URLs, matching the style of @mention and #channel-link chips. Co-Authored-By: Claude Opus 4.6 (1M context) --- desktop/src/shared/ui/markdown.tsx | 44 ++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/desktop/src/shared/ui/markdown.tsx b/desktop/src/shared/ui/markdown.tsx index 2997f394d..ad980a6b4 100644 --- a/desktop/src/shared/ui/markdown.tsx +++ b/desktop/src/shared/ui/markdown.tsx @@ -1,3 +1,4 @@ +import { GitPullRequest } from "lucide-react"; import * as React from "react"; import ReactMarkdown, { type Components } from "react-markdown"; import remarkBreaks from "remark-breaks"; @@ -11,6 +12,9 @@ import { rewriteRelayUrl } from "@/shared/lib/mediaUrl"; import remarkChannelLinks from "@/shared/lib/remarkChannelLinks"; import remarkMentions from "@/shared/lib/remarkMentions"; +const GITHUB_PR_RE = + /^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)\/?$/; + type MarkdownProps = { channelNames?: string[]; className?: string; @@ -41,17 +45,35 @@ function createMarkdownComponents( : "space-y-1 pl-6 marker:text-muted-foreground"; return { - a: ({ children, href, ...props }) => ( - - {children} - - ), + a: ({ children, href, ...props }) => { + const prMatch = href ? GITHUB_PR_RE.exec(href) : null; + if (prMatch) { + const [, owner, repo, number] = prMatch; + return ( + + + {owner}/{repo}#{number} + + ); + } + return ( + + {children} + + ); + }, blockquote: ({ children }) => (
{children}