feat: show favicons for external chat links
Adds DuckDuckGo favicon lookup for external URLs Shows favicons in markdown and fetch tool link rows Hides missing icons automatically
This commit is contained in:
@@ -22,6 +22,7 @@ import { useSkillsStore } from '@/stores/useSkillsStore';
|
||||
import ReasoningPart from './ReasoningPart';
|
||||
import JustificationBlock from './JustificationBlock';
|
||||
import { areRenderRelevantPartsEqual } from '../renderCompare';
|
||||
import { getExternalFaviconUrl } from '@/lib/url';
|
||||
|
||||
interface ProgressiveGroupProps {
|
||||
parts: TurnActivityPart[];
|
||||
@@ -41,6 +42,27 @@ interface ProgressiveGroupProps {
|
||||
renderJustificationActions?: (activity: TurnActivityPart) => React.ReactNode;
|
||||
}
|
||||
|
||||
const ExternalLinkFavicon: React.FC<{ href: string }> = ({ href }) => {
|
||||
const [failed, setFailed] = React.useState(false);
|
||||
const faviconUrl = React.useMemo(() => getExternalFaviconUrl(href), [href]);
|
||||
|
||||
if (!faviconUrl || failed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<img
|
||||
src={faviconUrl}
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
className="size-4 flex-shrink-0 rounded-sm"
|
||||
onError={() => setFailed(true)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const isActivityRunning = (activity: TurnActivityPart): boolean => {
|
||||
if (activity.kind !== 'tool') return false;
|
||||
const part = activity.part as ToolPartType;
|
||||
@@ -728,13 +750,14 @@ const StaticToolRowInner: React.FC<{
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(
|
||||
'min-w-0 flex-1 underline decoration-[color:var(--status-info)] underline-offset-2 hover:opacity-90',
|
||||
'min-w-0 flex-1 inline-flex items-center gap-1.5 underline decoration-[color:var(--status-info)] underline-offset-2 hover:opacity-90',
|
||||
'truncate whitespace-nowrap typography-meta'
|
||||
)}
|
||||
style={{ color: 'var(--status-info)' }}
|
||||
title={url}
|
||||
>
|
||||
{url}
|
||||
<ExternalLinkFavicon href={url} />
|
||||
<span className="min-w-0 truncate">{url}</span>
|
||||
</a>
|
||||
))
|
||||
: null}
|
||||
|
||||
Reference in New Issue
Block a user