diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx index f1fdb49e952..a5dc59d2132 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx @@ -189,6 +189,14 @@ function SourceReference({ index, children }: SourceReferenceProps) { ) } +/** + * Placeholder URLs Streamdown's streaming parser substitutes for a link or image + * whose URL is still arriving. Neither resolves, so a pending link renders as + * its text and a pending image is withheld until the URL completes. + */ +const INCOMPLETE_LINK_HREF = 'streamdown:incomplete-link' +const INCOMPLETE_IMAGE_SRC = 'streamdown:incomplete-image' + const WORKSPACE_LINK_PREFIX = '#sim-workspace-ref-' const WorkspaceRefsContext = createContext<{ resources: WorkspaceResourceTagData[] @@ -375,6 +383,7 @@ const MARKDOWN_COMPONENTS = { href?: string 'data-footnote-ref'?: boolean }) { + if (href === INCOMPLETE_LINK_HREF) return <>{children} if (href?.startsWith(SOURCE_LINK_PREFIX)) { return ( @@ -488,7 +497,7 @@ const MARKDOWN_COMPONENTS = { return {children} }, img({ src, alt }: ComponentPropsWithoutRef<'img'>) { - if (typeof src !== 'string' || !src) return null + if (typeof src !== 'string' || !src || src === INCOMPLETE_IMAGE_SRC) return null return (