Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ› fix: render intervention fallback avatar as image (#14271)

Coooolfan35edca5531a2
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.test.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.test.tsx
index be45ed5e1e8..174de6cbc1b 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.test.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.test.tsx
@@ -17,6 +17,9 @@ vi.mock('@lobehub/ui', () => ({
ActionIcon: ({ children, ...props }: { children?: ReactNode; [key: string]: unknown }) => (
<button {...props}>{children}</button>
),
+ Avatar: ({ avatar, title }: { avatar?: string; title?: string }) => (
+ <img alt={title} src={avatar} />
+ ),
Flexbox: ({ children, ...props }: { children?: ReactNode; [key: string]: unknown }) => (
<div {...props}>{children}</div>
),
@@ -97,4 +100,23 @@ describe('FallbackIntervention', () => {
screen.getByText('Tools & Skills Activator β†’ Activate Tools (Web Search, Calculator)'),
).toBeInTheDocument();
});
+
+ it('renders URL avatars as images instead of visible text', () => {
+ const iconUrl = 'https://example.com/icon.png';
+ metaMap.search.avatar = iconUrl;
+
+ render(
+ <FallbackIntervention
+ apiName="search"
+ assistantGroupId="assistant-group-1"
+ id="message-1"
+ identifier="search"
+ requestArgs="{}"
+ toolCallId="tool-call-1"
+ />,
+ );
+
+ expect(screen.queryByText(iconUrl)).not.toBeInTheDocument();
+ expect(screen.getByRole('img', { name: 'Web Search' })).toHaveAttribute('src', iconUrl);
+ });
});
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.tsx
index 0785af5a73f..0bfe9b7c506 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/Fallback.tsx
@@ -5,7 +5,7 @@ import {
} from '@lobechat/builtin-tool-activator';
import { builtinToolIdentifiers } from '@lobechat/builtin-tools/identifiers';
import { safeParseJSON } from '@lobechat/utils';
-import { ActionIcon, Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Avatar, Flexbox, Icon } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
import isEqual from 'fast-deep-equal';
import { ChevronDown, ChevronRight, Edit3Icon } from 'lucide-react';
@@ -38,10 +38,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
color: ${cssVar.colorTextSecondary};
}
`,
- avatar: css`
- font-size: 16px;
- line-height: 1;
- `,
description: css`
padding-block: 8px;
padding-inline: 16px;
@@ -153,7 +149,15 @@ const FallbackIntervention = memo<FallbackInterventionProps>(
return (
<Flexbox gap={4}>
<Flexbox horizontal align="center" className={styles.description} gap={6}>
- {pluginMeta?.avatar && <span className={styles.avatar}>{pluginMeta.avatar}</span>}
+ {pluginMeta?.avatar && (
+ <Avatar
+ avatar={pluginMeta.avatar}
+ shape={'square'}
+ size={16}
+ style={{ flex: 'none' }}
+ title={toolTitle}
+ />
+ )}
<span>
{toolTitle} β†’ {actionTitle}
{actionTitleSuffix}