diff --git a/web/src/app/chat/components/research-activities-block.tsx b/web/src/app/chat/components/research-activities-block.tsx index 239bea4..d54e01b 100644 --- a/web/src/app/chat/components/research-activities-block.tsx +++ b/web/src/app/chat/components/research-activities-block.tsx @@ -75,7 +75,9 @@ function ActivityMessage({ messageId }: { messageId: string }) { if (message.agent !== "reporter" && message.agent !== "planner") { return (
- {message.content} + + {message.content} +
); } diff --git a/web/src/app/chat/components/research-report-block.tsx b/web/src/app/chat/components/research-report-block.tsx index cad2941..f0a7c83 100644 --- a/web/src/app/chat/components/research-report-block.tsx +++ b/web/src/app/chat/components/research-report-block.tsx @@ -64,7 +64,9 @@ export function ResearchReportBlock({ /> ) : ( <> - {message?.content} + + {message?.content} + {message?.isStreaming && } )} diff --git a/web/src/components/deer-flow/link.tsx b/web/src/components/deer-flow/link.tsx index 8e03291..3e81f0d 100644 --- a/web/src/components/deer-flow/link.tsx +++ b/web/src/components/deer-flow/link.tsx @@ -1,18 +1,24 @@ -import { useEffect, useMemo } from "react"; -import { useToolCalls } from "~/core/store"; -import { cn } from "~/lib/utils"; +import { useMemo } from "react"; +import { useStore, useToolCalls } from "~/core/store"; import { Tooltip } from "./tooltip"; +import { WarningFilled } from "@ant-design/icons"; export const Link = ({ href, children, + checkLinkCredibility = false, }: { href: string | undefined; children: React.ReactNode; + checkLinkCredibility: boolean; }) => { const toolCalls = useToolCalls(); + const responding = useStore((state) => state.responding); + const credibleLinks = useMemo(() => { const links = new Set(); + if (!checkLinkCredibility) return links; + (toolCalls || []).forEach((call) => { if (call && call.name === "web_search" && call.result) { const result = JSON.parse(call.result) as Array<{ url: string }>; @@ -23,28 +29,26 @@ export const Link = ({ }); return links; }, [toolCalls]); - const isCredible = useMemo(() => { - return href ? credibleLinks.has(href) : true; - }, [credibleLinks, href]); - if (!isCredible) { - return ( - - - {children} - - - ); - } + const isCredible = useMemo(() => { + return checkLinkCredibility && href && !responding + ? credibleLinks.has(href) + : true; + }, [credibleLinks, href, responding, checkLinkCredibility]); return ( - - {children} - + + + {children} + + {!isCredible && ( + + + + )} + ); }; diff --git a/web/src/components/deer-flow/markdown.tsx b/web/src/components/deer-flow/markdown.tsx index 947dfae..5f7e253 100644 --- a/web/src/components/deer-flow/markdown.tsx +++ b/web/src/components/deer-flow/markdown.tsx @@ -20,28 +20,36 @@ import Image from "./image"; import { Tooltip } from "./tooltip"; import { Link } from "./link"; -const components: ReactMarkdownOptions["components"] = { - a: ({ href, children }) => {children}, - img: ({ src, alt }) => ( - - {alt - - ), -}; - export function Markdown({ className, children, style, enableCopy, animated = false, + checkLinkCredibility = false, ...props }: ReactMarkdownOptions & { className?: string; enableCopy?: boolean; style?: React.CSSProperties; animated?: boolean; + checkLinkCredibility?: boolean; }) { + const components: ReactMarkdownOptions["components"] = useMemo(() => { + return { + a: ({ href, children }) => ( + + {children} + + ), + img: ({ src, alt }) => ( + + {alt + + ), + }; + }, [checkLinkCredibility]); + const rehypePlugins = useMemo(() => { if (animated) { return [rehypeKatex, rehypeSplitWordsIntoSpans]; diff --git a/web/src/components/deer-flow/tooltip.tsx b/web/src/components/deer-flow/tooltip.tsx index e8a8065..6cfa631 100644 --- a/web/src/components/deer-flow/tooltip.tsx +++ b/web/src/components/deer-flow/tooltip.tsx @@ -19,6 +19,7 @@ export function Tooltip({ open, side, sideOffset, + delayDuration = 750, }: { className?: string; style?: CSSProperties; @@ -27,10 +28,11 @@ export function Tooltip({ open?: boolean; side?: "left" | "right" | "top" | "bottom"; sideOffset?: number; + delayDuration?: number; }) { return ( - + {children}