feat(issues): add @ mention for issues in comments

Support mentioning issues via @ in the rich text editor with fuzzy
search on identifier and title. Issue mentions render as clickable
links that navigate to the issue detail page.
This commit is contained in:
Jiang Bohan 2026-03-31 15:38:24 +08:00
parent 3b6f64ba8e
commit 7df140bcda
3 changed files with 58 additions and 9 deletions

View file

@ -1,4 +1,5 @@
import * as React from 'react'
import Link from 'next/link'
import ReactMarkdown, { type Components } from 'react-markdown'
import rehypeRaw from 'rehype-raw'
import remarkGfm from 'remark-gfm'
@ -58,8 +59,21 @@ function createComponents(
const baseComponents: Partial<Components> = {
// Links: Make clickable with callbacks, or render as mention
a: ({ href, children }) => {
// Mention links: mention://member/id or mention://agent/id
// Mention links: mention://member/id, mention://agent/id, mention://issue/id
if (href?.startsWith('mention://')) {
const mentionMatch = href.match(/^mention:\/\/(member|agent|issue)\/(.+)$/)
if (mentionMatch?.[1] === 'issue') {
const issueId = mentionMatch[2]
return (
<Link
href={`/issues/${issueId}`}
className="text-primary font-medium cursor-pointer hover:underline"
style={{ background: 'color-mix(in srgb, var(--primary) 8%, transparent)', padding: '0 0.2em', borderRadius: 'calc(var(--radius) * 0.5)' }}
>
{children}
</Link>
)
}
return (
<span
className="text-primary font-medium"