🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat: use skill-specific icons in slash menu instead of generic wrench icon (#13401)
Innei6402656ec741
diff --git a/src/features/ChatInput/InputEditor/ActionTag/useEnabledSkills.ts b/src/features/ChatInput/InputEditor/ActionTag/useEnabledSkills.tsindex 6eb160acc73..e84928635cb 100644--- a/src/features/ChatInput/InputEditor/ActionTag/useEnabledSkills.ts+++ b/src/features/ChatInput/InputEditor/ActionTag/useEnabledSkills.ts@@ -30,21 +30,29 @@ export const useEnabledSkills = (): ActionTagData[] => {const skillNameMap = new Map<string, string>();const toolNameMap = new Map<string, string>();+ const skillIconMap = new Map<string, string | undefined>();+ const toolIconMap = new Map<string, string | undefined>();+for (const item of builtinList) {toolNameMap.set(item.identifier, item.meta?.title || item.identifier);+ toolIconMap.set(item.identifier, item.meta?.avatar);}for (const item of installedPlugins) {toolNameMap.set(item.identifier, item.title || item.identifier);+ toolIconMap.set(item.identifier, item.avatar);}for (const item of klavisServers) {toolNameMap.set(item.identifier, item.serverName || item.identifier);+ toolIconMap.set(item.identifier, item.icon);}for (const item of lobehubSkillServers) {toolNameMap.set(item.identifier, item.name || item.identifier);+ toolIconMap.set(item.identifier, item.icon);}for (const item of builtinSkills) {skillNameMap.set(item.identifier, item.name || item.identifier);+ skillIconMap.set(item.identifier, item.avatar);}for (const item of marketAgentSkills) {skillNameMap.set(item.identifier, item.name || item.identifier);@@ -54,11 +62,11 @@ export const useEnabledSkills = (): ActionTagData[] => {}for (const [id, label] of skillNameMap) {- items.push({ category: 'skill', label, type: id });+ items.push({ category: 'skill', icon: skillIconMap.get(id), label, type: id });}for (const [id, label] of toolNameMap) {- items.push({ category: 'tool', label, type: id });+ items.push({ category: 'tool', icon: toolIconMap.get(id), label, type: id });}return items;diff --git a/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts b/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.tsindex c9a1e08f553..f228ab8f94b 100644--- a/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts+++ b/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts@@ -1,8 +1,9 @@import type { IEditor, SlashOptions } from '@lobehub/editor';+import { SkillsIcon } from '@lobehub/ui/icons';import Fuse from 'fuse.js';import { $getSelection, $isRangeSelection } from 'lexical';-import { ArchiveIcon, MessageSquarePlusIcon, WrenchIcon } from 'lucide-react';-import { useCallback } from 'react';+import { ArchiveIcon, MessageSquarePlusIcon } from 'lucide-react';+import { createElement, type FC, useCallback } from 'react';import { useTranslation } from 'react-i18next';import { useChatStore } from '@/store/chat';@@ -27,6 +28,40 @@ const COMMAND_ICONS: Record<string, any> = {newTopic: MessageSquarePlusIcon,};+/** Remote/object URLs and data-URI images (plugin/skill avatars); not plain text. */+const shouldRenderIconAsImage = (str: string) =>+ str.startsWith('http://') ||+ str.startsWith('https://') ||+ str.startsWith('blob:') ||+ /^data:image\//i.test(str);++const iconCache = new Map<string, FC>();++const getIconComponent = (avatar: string | undefined): any => {+ if (!avatar) return SkillsIcon;++ const cached = iconCache.get(avatar);+ if (cached) return cached;++ let IconComp: FC;++ if (shouldRenderIconAsImage(avatar)) {+ IconComp = () =>+ createElement('img', {+ alt: '',+ height: 16,+ src: avatar,+ style: { flexShrink: 0, objectFit: 'contain' },+ width: 16,+ });+ } else {+ IconComp = () => createElement('span', { style: { fontSize: 16, lineHeight: 1 } }, avatar);+ }++ iconCache.set(avatar, IconComp);+ return IconComp;+};+export const useSlashActionItems = (): SlashOptions['items'] => {const { t } = useTranslation('editor');const editorInstance = useChatInputStore((s) => s.editor);@@ -55,7 +90,7 @@ export const useSlashActionItems = (): SlashOptions['items'] => {});const makeActionItem = (item: ActionTagData): SlashMenuOption => ({- icon: WrenchIcon,+ icon: getIconComponent(item.icon),key: `${item.category}-${item.type}`,label: item.label,metadata: { category: item.category, type: item.type },diff --git a/src/features/ChatInput/InputEditor/MentionMenu/MenuItem.tsx b/src/features/ChatInput/InputEditor/MentionMenu/MenuItem.tsxindex 0beb358b638..bfafc502072 100644--- a/src/features/ChatInput/InputEditor/MentionMenu/MenuItem.tsx+++ b/src/features/ChatInput/InputEditor/MentionMenu/MenuItem.tsx@@ -20,10 +20,14 @@ const MenuItem = memo<MenuItemProps>(({ item, active, extra, onClick }) => {return (<divaria-selected={active}- className={cx(styles.item, active && styles.itemActive)}data-key={item.key}id={`mention-item-${item.key}`}role="option"+ className={cx(+ styles.item,+ active ? styles.itemActive : undefined,+ extra ? styles.itemWithCategoryExtra : undefined,+ )}onClick={() => onClick(item)}onMouseDown={handleMouseDown}>diff --git a/src/features/ChatInput/InputEditor/MentionMenu/style.ts b/src/features/ChatInput/InputEditor/MentionMenu/style.tsindex 983604adb33..f1bf5d21d33 100644--- a/src/features/ChatInput/InputEditor/MentionMenu/style.ts+++ b/src/features/ChatInput/InputEditor/MentionMenu/style.ts@@ -78,6 +78,9 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({background: ${cssVar.colorFillTertiary};}`,+ itemWithCategoryExtra: css`+ padding-inline-end: 6px;+ `,itemActive: css`background: ${cssVar.colorFillSecondary};`,