From 582bfaee39d44d6bfa781b3a97127a27a77c0d83 Mon Sep 17 00:00:00 2001 From: LofiSu Date: Fri, 6 Feb 2026 16:10:29 +0800 Subject: [PATCH] fix(citations): only citation links in citationMap render as badges Revert streaming logic - only links that are actually in citationMap should render as badges. This prevents project URLs and other regular links from being incorrectly rendered as citation badges. During streaming, links may initially appear as plain links until the citations block is fully parsed, then they will update to badge style. Co-authored-by: Cursor --- .../workspace/messages/message-list-item.tsx | 33 ++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/workspace/messages/message-list-item.tsx b/frontend/src/components/workspace/messages/message-list-item.tsx index 80a5438..1af53c4 100644 --- a/frontend/src/components/workspace/messages/message-list-item.tsx +++ b/frontend/src/components/workspace/messages/message-list-item.tsx @@ -77,43 +77,24 @@ export function MessageListItem({ /** * Custom link component that handles citations and external links - * - During streaming (isLoadingCitations=true): all external links render as badges - * - After streaming: only links in citationMap render as badges - * - Human messages and non-citation links render as plain links + * Only links in citationMap are rendered as CitationLink badges + * Other links (project URLs, regular links) are rendered as plain links */ function MessageLink({ href, children, citationMap, isHuman, - isLoadingCitations, }: React.AnchorHTMLAttributes & { citationMap: Map; isHuman: boolean; - isLoadingCitations: boolean; }) { if (!href) return {children}; - // Human messages always render as plain links - if (isHuman) { - return ( - - {children} - - ); - } - const citation = citationMap.get(href); - const isExternalLink = href.startsWith("http://") || href.startsWith("https://"); - // During streaming: render all external links as badges (citations not yet fully loaded) - // After streaming: only render links in citationMap as badges - if (citation || (isLoadingCitations && isExternalLink)) { + // Only render as CitationLink badge if it's a citation (in citationMap) and not human message + if (citation && !isHuman) { return ( {children} @@ -121,7 +102,7 @@ function MessageLink({ ); } - // Non-citation links render as plain links + // All other links render as plain links return ( ({ a: (props: React.AnchorHTMLAttributes) => ( - + ), img: (props: React.ImgHTMLAttributes) => ( ), - }), [citationMap, thread_id, isHuman, isLoadingCitations]); + }), [citationMap, thread_id, isHuman]); // Render message response // Human messages use humanMessagePlugins (no autolink) to prevent URL bleeding into adjacent text