From c87f176fac5368ea14e67bf8217cb613d8652e1e Mon Sep 17 00:00:00 2001 From: ruitanglin Date: Fri, 6 Feb 2026 15:06:51 +0800 Subject: [PATCH] fix(citations): use markdown link text as fallback for display When citation data is not available, use the markdown link text (children) as display text instead of just the domain. This ensures that links like [OpenJudge](github.com/...) show 'OpenJudge' instead of just 'github.com'. Co-authored-by: Cursor --- .../src/components/ai-elements/inline-citation.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ai-elements/inline-citation.tsx b/frontend/src/components/ai-elements/inline-citation.tsx index b9e206e..dde6e31 100644 --- a/frontend/src/components/ai-elements/inline-citation.tsx +++ b/frontend/src/components/ai-elements/inline-citation.tsx @@ -310,10 +310,14 @@ export const CitationLink = ({ }: CitationLinkProps) => { const domain = extractDomainFromUrl(href); - // Priority: citation.title > domain - // When citation has title, use it for consistent display - // This ensures correct title shows even during streaming when children might be generic - const displayText = citation?.title || domain; + // Priority: citation.title > children (if meaningful) > domain + // - citation.title: from parsed block, most accurate + // - children: from markdown link text [Text](url), used when no citation data + // - domain: fallback when both above are unavailable + // Skip children if it's a generic placeholder like "Source" + const childrenText = typeof children === "string" ? children : null; + const isGenericText = childrenText === "Source" || childrenText === "来源"; + const displayText = citation?.title || (!isGenericText && childrenText) || domain; return (