import type { JSX } from "react"; import { translate } from "../../../../i18n/index"; import { dedupeToolSectionContent, ToolMarkdownBlock, ToolSection, type AgentToolRendererProps } from "./agentToolContentShared"; import { getToolFallbackText, getWebFetchRenderData } from "./render-data/agentToolRenderData"; export function AgentWebFetchContent({ call, onLinkClick }: AgentToolRendererProps): JSX.Element | null { "use memo"; const web = getWebFetchRenderData(call); const urlText = web.url && web.domain && web.domain !== web.url ? `${web.domain}\n\n${web.url}` : web.url; const visibleContent = dedupeToolSectionContent( web.visibleContent, web.url, web.domain, urlText ); const fallbackText = getToolFallbackText(call); const errorText = dedupeToolSectionContent( fallbackText.error, urlText, visibleContent ); if (!web.url && !visibleContent && !errorText) { return null; } return (
{web.url ? ( ) : null} {visibleContent ? ( ) : null} {web.isTruncated ? (
{translate("agentHost.agentTool.details.contentTruncated")}
) : null} {errorText ? ( ) : null}
); }