From e444817c5dca4e65afaeabf03a0a47263b40565c Mon Sep 17 00:00:00 2001 From: ruitanglin Date: Fri, 6 Feb 2026 16:09:03 +0800 Subject: [PATCH] fix(citations): render external links as badges during streaming During streaming when citations are still loading (isLoadingCitations=true), all external links should be rendered as badges since we don't know yet which links are citations. After streaming completes, only links in citationMap are rendered as badges. Co-authored-by: Cursor --- .../workspace/messages/message-list-item.tsx | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/workspace/messages/message-list-item.tsx b/frontend/src/components/workspace/messages/message-list-item.tsx index 333b42a..80a5438 100644 --- a/frontend/src/components/workspace/messages/message-list-item.tsx +++ b/frontend/src/components/workspace/messages/message-list-item.tsx @@ -77,25 +77,43 @@ export function MessageListItem({ /** * Custom link component that handles citations and external links - * Only links that are in citationMap are rendered as CitationLink badges - * Other links (project URLs, regular links) are rendered as plain 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 */ 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://"); - // Only render as CitationLink badge if it's a citation (in citationMap) - // This ensures project URLs and regular links are not rendered as badges - if (citation && !isHuman) { + // 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)) { return ( {children} @@ -103,7 +121,7 @@ function MessageLink({ ); } - // All other links (including project URLs) render as plain links + // Non-citation links render as plain links return ( ({ a: (props: React.AnchorHTMLAttributes) => ( - + ), img: (props: React.ImgHTMLAttributes) => ( ), - }), [citationMap, thread_id, isHuman]); + }), [citationMap, thread_id, isHuman, isLoadingCitations]); // Render message response // Human messages use humanMessagePlugins (no autolink) to prevent URL bleeding into adjacent text