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.

1.1 KB
Raw Blame
import { useTranslation } from 'react-i18next';

import {
  isEntryOfTab,
  parseMcpEntryTab,
  selectMcpAppEntrypoints,
} from '@/features/MCPApp/entrypoints';
import { useToolStore } from '@/store/tool';

import { LazyPluginAvatar } from './LazyPluginAvatar';

export const McpEntryTabLabel = ({ tab, agentId }: { tab: string; agentId?: string }) => {
  const parsed = parseMcpEntryTab(tab);
  const { t } = useTranslation('plugin');
  const title = useToolStore((s) => {
    const entry = selectMcpAppEntrypoints(s, true, agentId).find((item) =>
      isEntryOfTab(item, parsed),
    );
    return entry?.accountName ? `${entry.title} · ${entry.accountName}` : entry?.title;
  });
  return <>{title ?? parsed?.toolName ?? t('mcpApp.entrypoints')}</>;
};

export const McpEntryTabIcon = ({ tab, agentId }: { tab: string; agentId?: string }) => {
  const parsed = parseMcpEntryTab(tab);
  const icon = useToolStore(
    (s) =>
      selectMcpAppEntrypoints(s, true, agentId).find((entry) => isEntryOfTab(entry, parsed))?.icon,
  );
  return <LazyPluginAvatar avatar={icon || 'MCP_AVATAR'} size={14} />;
};