🤯 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
🐛 fix: skill store mcp detail crash and optimize skill panel (#11822)
Rdmclin21d34c0e5aa89
diff --git a/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsx b/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsxindex 4ff174f0625..09d1e3cd4c8 100644--- a/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsx+++ b/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsx@@ -58,6 +58,7 @@ const ProfileEditor = memo(() => {<ModelSelectinitialWidthonChange={updateConfig}+ popupWidth={400}value={{model: config.model,provider: config.provider,diff --git a/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsx b/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsxindex 3d3f8297f73..8893e260853 100644--- a/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsx+++ b/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsx@@ -9,7 +9,7 @@ interface ActionsProps {const Actions = memo<ActionsProps>(({ dropdownMenu, isLoading }) => {return (- <DropdownMenu items={dropdownMenu}>+ <DropdownMenu items={dropdownMenu} nativeButton={false}><ActionIconicon={MoreHorizontalIcon}loading={isLoading}diff --git a/src/app/[variants]/(main)/home/features/InputArea/SkillInstallBanner.tsx b/src/app/[variants]/(main)/home/features/InputArea/SkillInstallBanner.tsxindex b8961f0377d..6777c482905 100644--- a/src/app/[variants]/(main)/home/features/InputArea/SkillInstallBanner.tsx+++ b/src/app/[variants]/(main)/home/features/InputArea/SkillInstallBanner.tsx@@ -1,18 +1,30 @@'use client';import { getKlavisServerByServerIdentifier, getLobehubSkillProviderById } from '@lobechat/const';-import { Avatar, Flexbox, Icon } from '@lobehub/ui';+import { Flexbox, Icon } from '@lobehub/ui';import { createStaticStyles } from 'antd-style';import { Blocks } from 'lucide-react';-import { type ReactNode, createElement, memo, useCallback, useMemo } from 'react';+import React, { createElement, memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { createSkillStoreModal } from '@/features/SkillStore';import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';import { useToolStore } from '@/store/tool';+const ICON_SIZE = 16;+const AVATAR_SIZE = 24;+const styles = createStaticStyles(({ css, cssVar }) => ({avatar: css`+ display: flex;+ flex-shrink: 0;+ align-items: center;+ justify-content: center;++ width: ${AVATAR_SIZE}px;+ height: ${AVATAR_SIZE}px;+ border-radius: 50%;+background: ${cssVar.colorBgContainer};box-shadow:0 0 8px -2px rgba(0, 0, 0, 5%),@@ -43,6 +55,10 @@ const styles = createStaticStyles(({ css, cssVar }) => ({icon: css`color: ${cssVar.colorTextSecondary};`,+ iconGroup: css`+ display: flex;+ align-items: center;+ `,text: css`font-size: 13px;color: ${cssVar.colorTextSecondary};@@ -51,10 +67,10 @@ const styles = createStaticStyles(({ css, cssVar }) => ({const BANNER_SKILL_IDS = [{ id: 'gmail', type: 'klavis' },- { id: 'notion', type: 'klavis' },{ id: 'google-drive', type: 'klavis' },{ id: 'google-calendar', type: 'klavis' },{ id: 'slack', type: 'klavis' },+ { id: 'notion', type: 'klavis' },{ id: 'twitter', type: 'lobehub' },{ id: 'github', type: 'klavis' },] as const;@@ -73,38 +89,24 @@ const SkillInstallBanner = memo(() => {useFetchLobehubSkillConnections(isLobehubSkillEnabled);useFetchUserKlavisServers(isKlavisEnabled);- const avatarItems = useMemo(() => {- const items: Array<{ avatar: ReactNode; key: string; title: string }> = [];+ const skillIcons = useMemo(() => {+ const icons: Array<{ icon: string | React.ComponentType<{ size?: number }>; key: string }> = [];for (const skill of BANNER_SKILL_IDS) {if (skill.type === 'lobehub') {const provider = getLobehubSkillProviderById(skill.id);if (provider) {- items.push({- avatar:- typeof provider.icon === 'string'- ? provider.icon- : createElement(provider.icon, { size: 14 }),- key: provider.id,- title: provider.label,- });+ icons.push({ icon: provider.icon, key: provider.id });}} else {const server = getKlavisServerByServerIdentifier(skill.id);if (server) {- items.push({- avatar:- typeof server.icon === 'string'- ? server.icon- : createElement(server.icon, { size: 14 }),- key: server.identifier,- title: server.label,- });+ icons.push({ icon: server.icon, key: server.identifier });}}}- return items;+ return icons;}, []);const handleOpenStore = useCallback(() => {@@ -120,16 +122,22 @@ const SkillInstallBanner = memo(() => {<Icon className={styles.icon} icon={Blocks} size={18} /><span className={styles.text}>{t('skillInstallBanner.title')}</span></Flexbox>- {avatarItems.length > 0 && (- <Avatar.Group- classNames={{- avatar: styles.avatar,- }}- items={avatarItems}- shape="circle"- size={24}- variant={'outlined'}- />+ {skillIcons.length > 0 && (+ <div className={styles.iconGroup}>+ {skillIcons.map(({ icon, key }, index) => (+ <div+ className={styles.avatar}+ key={key}+ style={{ marginLeft: index === 0 ? 0 : -6, zIndex: index }}+ >+ {typeof icon === 'string' ? (+ <img alt={key} height={ICON_SIZE} src={icon} width={ICON_SIZE} />+ ) : (+ createElement(icon, { size: ICON_SIZE })+ )}+ </div>+ ))}+ </div>)}</div>);diff --git a/src/app/[variants]/(main)/settings/skill/features/KlavisSkillItem.tsx b/src/app/[variants]/(main)/settings/skill/features/KlavisSkillItem.tsxindex 65855c11ced..fb874d5293b 100644--- a/src/app/[variants]/(main)/settings/skill/features/KlavisSkillItem.tsx+++ b/src/app/[variants]/(main)/settings/skill/features/KlavisSkillItem.tsx@@ -1,10 +1,10 @@'use client';import { type KlavisServerType } from '@lobechat/const';-import { ActionIcon, Avatar, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';+import { Avatar, DropdownMenu, Flexbox, Icon, Button as LobeButton } from '@lobehub/ui';import { App, Button } from 'antd';import { createStaticStyles, cssVar } from 'antd-style';-import { Loader2, MoreVerticalIcon, SquareArrowOutUpRight, Unplug } from 'lucide-react';+import { Loader2, MoreHorizontalIcon, SquareArrowOutUpRight, Unplug } from 'lucide-react';import { memo, useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -301,7 +301,7 @@ const KlavisSkillItem = memo<KlavisSkillItemProps>(({ serverType, server }) => {]}placement="bottomRight">- <ActionIcon icon={MoreVerticalIcon} />+ <LobeButton icon={MoreHorizontalIcon} /></DropdownMenu>);}@@ -313,35 +313,35 @@ const KlavisSkillItem = memo<KlavisSkillItemProps>(({ serverType, server }) => {return (<Flexbox- align="center"- className={styles.container}- gap={16}- horizontal- justify="space-between"- >- <Flexbox align="center" gap={16} horizontal style={{ flex: 1, overflow: 'hidden' }}>- <div className={styles.icon}>{renderIcon()}</div>- <Flexbox gap={4} style={{ overflow: 'hidden' }}>- <span- className={styles.title}- onClick={() =>- createIntegrationDetailModal({- identifier: serverType.identifier,- serverName: serverType.serverName,- type: 'klavis',- })- }- >- {serverType.label}- </span>- {!isConnected && renderStatus()}- </Flexbox>- </Flexbox>- <Flexbox align="center" gap={12} horizontal>- {isConnected && renderStatus()}- {renderAction()}+ align="center"+ className={styles.container}+ gap={16}+ horizontal+ justify="space-between"+ >+ <Flexbox align="center" gap={16} horizontal style={{ flex: 1, overflow: 'hidden' }}>+ <div className={styles.icon}>{renderIcon()}</div>+ <Flexbox gap={4} style={{ overflow: 'hidden' }}>+ <span+ className={styles.title}+ onClick={() =>+ createIntegrationDetailModal({+ identifier: serverType.identifier,+ serverName: serverType.serverName,+ type: 'klavis',+ })+ }+ >+ {serverType.label}+ </span>+ {!isConnected && renderStatus()}</Flexbox></Flexbox>+ <Flexbox align="center" gap={12} horizontal>+ {isConnected && renderStatus()}+ {renderAction()}+ </Flexbox>+ </Flexbox>);});diff --git a/src/app/[variants]/(main)/settings/skill/features/LobehubSkillItem.tsx b/src/app/[variants]/(main)/settings/skill/features/LobehubSkillItem.tsxindex c2544d8b3fb..1f9832b0941 100644--- a/src/app/[variants]/(main)/settings/skill/features/LobehubSkillItem.tsx+++ b/src/app/[variants]/(main)/settings/skill/features/LobehubSkillItem.tsx@@ -1,10 +1,10 @@'use client';import { type LobehubSkillProviderType } from '@lobechat/const';-import { ActionIcon, Avatar, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';+import { Avatar, DropdownMenu, Flexbox, Icon, Button as LobeButton } from '@lobehub/ui';import { App, Button } from 'antd';import { createStaticStyles, cssVar } from 'antd-style';-import { Loader2, MoreVerticalIcon, SquareArrowOutUpRight, Unplug } from 'lucide-react';+import { Loader2, MoreHorizontalIcon, SquareArrowOutUpRight, Unplug } from 'lucide-react';import { memo, useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -290,7 +290,7 @@ const LobehubSkillItem = memo<LobehubSkillItemProps>(({ provider, server }) => {]}placement="bottomRight">- <ActionIcon icon={MoreVerticalIcon} />+ <LobeButton icon={MoreHorizontalIcon} /></DropdownMenu>);};@@ -299,36 +299,36 @@ const LobehubSkillItem = memo<LobehubSkillItemProps>(({ provider, server }) => {return (<Flexbox- align="center"- className={styles.container}- gap={16}- horizontal- justify="space-between"- >- <Flexbox align="center" gap={16} horizontal style={{ flex: 1, overflow: 'hidden' }}>- <div className={`${styles.icon} ${!isConnected ? styles.disconnectedIcon : ''}`}>- {renderIcon()}- </div>- <Flexbox gap={4} style={{ overflow: 'hidden' }}>- <span- className={`${styles.title} ${!isConnected ? styles.disconnectedTitle : ''}`}- onClick={() =>- createIntegrationDetailModal({- identifier: provider.id,- type: 'lobehub',- })- }- >- {provider.label}- </span>- {!isConnected && renderStatus()}- </Flexbox>- </Flexbox>- <Flexbox align="center" gap={12} horizontal>- {isConnected && renderStatus()}- {renderAction()}+ align="center"+ className={styles.container}+ gap={16}+ horizontal+ justify="space-between"+ >+ <Flexbox align="center" gap={16} horizontal style={{ flex: 1, overflow: 'hidden' }}>+ <div className={`${styles.icon} ${!isConnected ? styles.disconnectedIcon : ''}`}>+ {renderIcon()}+ </div>+ <Flexbox gap={4} style={{ overflow: 'hidden' }}>+ <span+ className={`${styles.title} ${!isConnected ? styles.disconnectedTitle : ''}`}+ onClick={() =>+ createIntegrationDetailModal({+ identifier: provider.id,+ type: 'lobehub',+ })+ }+ >+ {provider.label}+ </span>+ {!isConnected && renderStatus()}</Flexbox></Flexbox>+ <Flexbox align="center" gap={12} horizontal>+ {isConnected && renderStatus()}+ {renderAction()}+ </Flexbox>+ </Flexbox>);});diff --git a/src/app/[variants]/(main)/settings/skill/index.tsx b/src/app/[variants]/(main)/settings/skill/index.tsxindex a76901158ad..14ad807683d 100644--- a/src/app/[variants]/(main)/settings/skill/index.tsx+++ b/src/app/[variants]/(main)/settings/skill/index.tsx@@ -1,7 +1,7 @@'use client';import { Button, Icon } from '@lobehub/ui';-import { PlusIcon } from 'lucide-react';+import { Store } from 'lucide-react';import { useCallback } from 'react';import { useTranslation } from 'react-i18next';@@ -21,7 +21,7 @@ const Page = () => {<><SettingHeaderextra={- <Button icon={<Icon icon={PlusIcon} />} onClick={handleOpenStore}>+ <Button icon={<Icon icon={Store} />} onClick={handleOpenStore}>{t('skillStore.button')}</Button>}diff --git a/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx b/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsxindex 1b5780e743d..f514ec4e3b7 100644--- a/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx+++ b/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx@@ -18,12 +18,11 @@ const styles = createStaticStyles(({ css }) => ({}));interface PopoverContentProps {- enableKlavis: boolean;items: ItemType[];onOpenStore: () => void;}-const PopoverContent = memo<PopoverContentProps>(({ items, enableKlavis, onOpenStore }) => {+const PopoverContent = memo<PopoverContentProps>(({ items, onOpenStore }) => {const { t } = useTranslation('setting');const navigate = useNavigate();@@ -34,7 +33,6 @@ const PopoverContent = memo<PopoverContentProps>(({ items, enableKlavis, onOpenS<divstyle={{maxHeight: 500,- minHeight: enableKlavis ? 500 : undefined,overflowY: 'auto',}}>diff --git a/src/features/ChatInput/ActionBar/Tools/ToolsList.tsx b/src/features/ChatInput/ActionBar/Tools/ToolsList.tsxindex 2430503c096..ec92fd3abaa 100644--- a/src/features/ChatInput/ActionBar/Tools/ToolsList.tsx+++ b/src/features/ChatInput/ActionBar/Tools/ToolsList.tsx@@ -38,6 +38,10 @@ export const toolsListStyles = createStaticStyles(({ css }) => ({width: 24px;height: 24px;++ .ant-avatar {+ margin-inline-end: 0;+ }`,}));diff --git a/src/features/ChatInput/ActionBar/Tools/index.tsx b/src/features/ChatInput/ActionBar/Tools/index.tsxindex 2e4a8e14ad1..400b080ea36 100644--- a/src/features/ChatInput/ActionBar/Tools/index.tsx+++ b/src/features/ChatInput/ActionBar/Tools/index.tsx@@ -6,7 +6,6 @@ import { createSkillStoreModal } from '@/features/SkillStore';import { useModelSupportToolUse } from '@/hooks/useModelSupportToolUse';import { useAgentStore } from '@/store/agent';import { agentByIdSelectors } from '@/store/agent/selectors';-import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';import { useAgentId } from '../../hooks/useAgentId';import Action from '../components/Action';@@ -20,8 +19,6 @@ const Tools = memo(() => {setUpdating,});- const enableKlavis = useServerConfigStore(serverConfigSelectors.enableKlavis);-const agentId = useAgentId();const model = useAgentStore((s) => agentByIdSelectors.getAgentModelById(agentId)(s));const provider = useAgentStore((s) => agentByIdSelectors.getAgentModelProviderById(agentId)(s));@@ -41,13 +38,7 @@ const Tools = memo(() => {icon={Blocks}loading={updating}popover={{- content: (- <PopoverContent- enableKlavis={enableKlavis}- items={marketItems}- onOpenStore={handleOpenStore}- />- ),+ content: <PopoverContent items={marketItems} onOpenStore={handleOpenStore} />,maxWidth: 320,minWidth: 320,styles: {diff --git a/src/features/ChatInput/ActionBar/Tools/useControls.tsx b/src/features/ChatInput/ActionBar/Tools/useControls.tsxindex 08c50fe9826..ed36f14dd95 100644--- a/src/features/ChatInput/ActionBar/Tools/useControls.tsx+++ b/src/features/ChatInput/ActionBar/Tools/useControls.tsx@@ -6,7 +6,7 @@ import {RECOMMENDED_SKILLS,RecommendedSkillType,} from '@lobechat/const';-import { Avatar, Icon, Image, type ItemType } from '@lobehub/ui';+import { Avatar, Icon, type ItemType } from '@lobehub/ui';import { cssVar } from 'antd-style';import isEqual from 'fast-deep-equal';import { ToyBrick } from 'lucide-react';@@ -32,18 +32,25 @@ import KlavisServerItem from './KlavisServerItem';import LobehubSkillServerItem from './LobehubSkillServerItem';import ToolItem from './ToolItem';+const SKILL_ICON_SIZE = 20;+/*** Klavis 服务器图标组件- * 对于 string 类型的 icon,使用 Image 组件渲染- * 对于 IconType 类型的 icon,使用 Icon 组件渲染,并根据主题设置填充色*/const KlavisIcon = memo<Pick<KlavisServerType, 'icon' | 'label'>>(({ icon, label }) => {if (typeof icon === 'string') {- return <Image alt={label} height={18} src={icon} style={{ flex: 'none' }} width={18} />;+ return (+ <Avatar+ alt={label}+ avatar={icon}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />+ );}- // 使用主题色填充,在深色模式下自动适应- return <Icon fill={cssVar.colorText} icon={icon} size={18} />;+ return <Icon fill={cssVar.colorText} icon={icon} size={SKILL_ICON_SIZE} />;});KlavisIcon.displayName = 'KlavisIcon';@@ -54,10 +61,18 @@ KlavisIcon.displayName = 'KlavisIcon';const LobehubSkillIcon = memo<Pick<LobehubSkillProviderType, 'icon' | 'label'>>(({ icon, label }) => {if (typeof icon === 'string') {- return <Image alt={label} height={18} src={icon} style={{ flex: 'none' }} width={18} />;+ return (+ <Avatar+ alt={label}+ avatar={icon}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />+ );}- return <Icon fill={cssVar.colorText} icon={icon} size={18} />;+ return <Icon fill={cssVar.colorText} icon={icon} size={SKILL_ICON_SIZE} />;},);@@ -193,7 +208,12 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean)() =>filteredBuiltinList.map((item) => ({icon: (- <Avatar avatar={item.meta.avatar} shape={'square'} size={20} style={{ flex: 'none' }} />+ <Avatar+ avatar={item.meta.avatar}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />),key: item.identifier,label: (@@ -236,9 +256,9 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean)// 生成插件列表项的函数const mapPluginToItem = (item: (typeof list)[0]) => ({icon: item?.avatar ? (- <PluginAvatar avatar={item.avatar} size={20} />+ <PluginAvatar avatar={item.avatar} size={SKILL_ICON_SIZE} />) : (- <Icon icon={ToyBrick} size={20} />+ <Icon icon={ToyBrick} size={SKILL_ICON_SIZE} />),key: item.identifier,label: (@@ -315,7 +335,12 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean).filter((item) => checked.includes(item.identifier)).map((item) => ({icon: (- <Avatar avatar={item.meta.avatar} shape={'square'} size={20} style={{ flex: 'none' }} />+ <Avatar+ avatar={item.meta.avatar}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />),key: item.identifier,label: (@@ -371,9 +396,9 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean).filter((item) => checked.includes(item.identifier)).map((item) => ({icon: item?.avatar ? (- <PluginAvatar avatar={item.avatar} size={20} />+ <PluginAvatar avatar={item.avatar} size={SKILL_ICON_SIZE} />) : (- <Icon icon={ToyBrick} size={20} />+ <Icon icon={ToyBrick} size={SKILL_ICON_SIZE} />),key: item.identifier,label: (@@ -395,9 +420,9 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean).filter((item) => checked.includes(item.identifier)).map((item) => ({icon: item?.avatar ? (- <PluginAvatar avatar={item.avatar} size={20} />+ <PluginAvatar avatar={item.avatar} size={SKILL_ICON_SIZE} />) : (- <Icon icon={ToyBrick} size={20} />+ <Icon icon={ToyBrick} size={SKILL_ICON_SIZE} />),key: item.identifier,label: (diff --git a/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx b/src/features/ChatInput/ActionBar/components/ActionDropdown.tsxindex b977e4dbcf5..c688928e4d7 100644--- a/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx+++ b/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx@@ -117,8 +117,9 @@ const ActionDropdown = memo<ActionDropdownProps>(return trigger === 'hover';}, [trigger]);const resolvedTriggerProps = useMemo(() => {- if (openOnHover === undefined) return triggerProps;+ if (openOnHover === undefined) return { nativeButton: false, ...triggerProps };return {+ nativeButton: false,...triggerProps,openOnHover,};diff --git a/src/features/ModelSelect/index.tsx b/src/features/ModelSelect/index.tsxindex 607f23c8f3e..10fdb4c09f6 100644--- a/src/features/ModelSelect/index.tsx+++ b/src/features/ModelSelect/index.tsx@@ -1,14 +1,18 @@import { LobeSelect, type LobeSelectProps, TooltipGroup } from '@lobehub/ui';-import { createStaticStyles } from 'antd-style';+import { createStyles } from 'antd-style';import { type ReactNode, memo, useMemo } from 'react';import { ModelItemRender, ProviderItemRender } from '@/components/ModelSelect';import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';import { type EnabledProviderWithModels } from '@/types/aiProvider';-const styles = createStaticStyles(({ css }) => ({+const useStyles = createStyles(({ css }, { popupWidth }: { popupWidth?: number | string }) => ({popup: css`- width: max(360px, var(--anchor-width));+ width: ${popupWidth+ ? typeof popupWidth === 'number'+ ? `${popupWidth}px`+ : popupWidth+ : 'max(360px, var(--anchor-width))'};`,}));@@ -27,6 +31,7 @@ interface ModelSelectProps extends Pick<LobeSelectProps, 'loading' | 'size' | 'sdefaultValue?: { model: string; provider?: string };initialWidth?: boolean;onChange?: (props: { model: string; provider: string }) => void;+ popupWidth?: number | string;requiredAbilities?: (keyof EnabledProviderWithModels['children'][number]['abilities'])[];showAbility?: boolean;@@ -41,10 +46,12 @@ const ModelSelect = memo<ModelSelectProps>(showAbility = true,requiredAbilities,loading,+ popupWidth,size,style,variant,}) => {+ const { styles } = useStyles({ popupWidth });const enabledList = useEnabledChatModels();const options = useMemo<LobeSelectProps['options']>(() => {diff --git a/src/features/ProfileEditor/AgentTool.tsx b/src/features/ProfileEditor/AgentTool.tsxindex 2b3e198cc4c..650cf1b169b 100644--- a/src/features/ProfileEditor/AgentTool.tsx+++ b/src/features/ProfileEditor/AgentTool.tsx@@ -7,7 +7,7 @@ import {type LobehubSkillProviderType,} from '@lobechat/const';import { Avatar, Button, Flexbox, Icon, type ItemType } from '@lobehub/ui';-import { createStaticStyles, cssVar } from 'antd-style';+import { cssVar } from 'antd-style';import isEqual from 'fast-deep-equal';import { PlusIcon, ToyBrick } from 'lucide-react';import React, { Suspense, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';@@ -40,30 +40,25 @@ const WEB_BROWSING_IDENTIFIER = 'lobe-web-browsing';type TabType = 'all' | 'installed';-const styles = createStaticStyles(({ css }) => ({- icon: css`- flex: none;- width: 18px;- height: 18px;- margin-inline-end: ${cssVar.marginXS};- `,- scroller: css`- overflow: hidden auto;- `,-}));+const SKILL_ICON_SIZE = 20;/*** Klavis 服务器图标组件- * 对于 string 类型的 icon,使用 Image 组件渲染- * 对于 IconType 类型的 icon,使用 Icon 组件渲染,并根据主题设置填充色*/const KlavisIcon = memo<Pick<KlavisServerType, 'icon' | 'label'>>(({ icon, label }) => {if (typeof icon === 'string') {- return <img alt={label} className={styles.icon} height={18} src={icon} width={18} />;+ return (+ <Avatar+ alt={label}+ avatar={icon}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />+ );}- // 使用主题色填充,在深色模式下自动适应- return <Icon className={styles.icon} fill={cssVar.colorText} icon={icon} size={18} />;+ return <Icon fill={cssVar.colorText} icon={icon} size={SKILL_ICON_SIZE} />;});/**@@ -72,10 +67,18 @@ const KlavisIcon = memo<Pick<KlavisServerType, 'icon' | 'label'>>(({ icon, labelconst LobehubSkillIcon = memo<Pick<LobehubSkillProviderType, 'icon' | 'label'>>(({ icon, label }) => {if (typeof icon === 'string') {- return <img alt={label} className={styles.icon} height={18} src={icon} width={18} />;+ return (+ <Avatar+ alt={label}+ avatar={icon}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />+ );}- return <Icon className={styles.icon} fill={cssVar.colorText} icon={icon} size={18} />;+ return <Icon fill={cssVar.colorText} icon={icon} size={SKILL_ICON_SIZE} />;},);@@ -315,7 +318,12 @@ const AgentTool = memo<AgentToolProps>(// 原有的 builtin 工具...filteredBuiltinList.map((item) => ({icon: (- <Avatar avatar={item.meta.avatar} size={20} style={{ flex: 'none', marginRight: 0 }} />+ <Avatar+ avatar={item.meta.avatar}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />),key: item.identifier,label: (@@ -347,9 +355,9 @@ const AgentTool = memo<AgentToolProps>(const mapPluginToItem = useCallback((item: (typeof installedPluginList)[0]) => ({icon: item?.avatar ? (- <PluginAvatar avatar={item.avatar} size={20} />+ <PluginAvatar avatar={item.avatar} size={SKILL_ICON_SIZE} />) : (- <Icon icon={ToyBrick} size={20} />+ <Icon icon={ToyBrick} size={SKILL_ICON_SIZE} />),key: item.identifier,label: (@@ -428,7 +436,14 @@ const AgentTool = memo<AgentToolProps>(const enabledBuiltinItems = filteredBuiltinList.filter((item) => isToolEnabled(item.identifier)).map((item) => ({- icon: <Avatar avatar={item.meta.avatar} size={20} style={{ flex: 'none' }} />,+ icon: (+ <Avatar+ avatar={item.meta.avatar}+ shape={'square'}+ size={SKILL_ICON_SIZE}+ style={{ flex: 'none' }}+ />+ ),key: item.identifier,label: (<ToolItem@@ -475,9 +490,9 @@ const AgentTool = memo<AgentToolProps>(.filter((item) => plugins.includes(item.identifier)).map((item) => ({icon: item?.avatar ? (- <PluginAvatar avatar={item.avatar} size={20} />+ <PluginAvatar avatar={item.avatar} size={SKILL_ICON_SIZE} />) : (- <Icon icon={ToyBrick} size={20} />+ <Icon icon={ToyBrick} size={SKILL_ICON_SIZE} />),key: item.identifier,label: (@@ -508,9 +523,9 @@ const AgentTool = memo<AgentToolProps>(.filter((item) => plugins.includes(item.identifier)).map((item) => ({icon: item?.avatar ? (- <PluginAvatar avatar={item.avatar} size={20} />+ <PluginAvatar avatar={item.avatar} size={SKILL_ICON_SIZE} />) : (- <Icon icon={ToyBrick} size={20} />+ <Icon icon={ToyBrick} size={SKILL_ICON_SIZE} />),key: item.identifier,label: (@@ -552,7 +567,6 @@ const AgentTool = memo<AgentToolProps>(// Use effective tab for display (default to all while initializing)const effectiveTab = activeTab ?? 'all';- const currentItems = effectiveTab === 'all' ? allTabItems : installedTabItems;const button = (<Button@@ -581,11 +595,11 @@ const AgentTool = memo<AgentToolProps>({/* Plugin Selector and Tags */}<Flexbox align="center" gap={8} horizontal wrap={'wrap'}><Suspense fallback={button}>- {/* Plugin Selector Dropdown - Using Action component pattern */}+ {/* Plugin Selector Dropdown - Using Action component pattern */}<ActionDropdownmaxWidth={400}menu={{- items: currentItems,+ items: [],style: {// let only the custom scroller scrollmaxHeight: 'unset',@@ -596,15 +610,20 @@ const AgentTool = memo<AgentToolProps>(onOpenChange={setDropdownOpen}open={dropdownOpen}placement={'bottomLeft'}- popupRender={(menu) => (+ popupProps={{+ style: {+ padding: 0,+ },+ }}+ popupRender={() => (<PopoverContentactiveTab={effectiveTab}+ allTabItems={allTabItems}installedTabItems={installedTabItems}- menu={menu}onClose={() => setDropdownOpen(false)}onOpenStore={() => {setDropdownOpen(false);- createSkillStoreModal()+ createSkillStoreModal();}}onTabChange={setActiveTab}/>diff --git a/src/features/ProfileEditor/PopoverContent.tsx b/src/features/ProfileEditor/PopoverContent.tsxindex 21f8b67549e..65270185df6 100644--- a/src/features/ProfileEditor/PopoverContent.tsx+++ b/src/features/ProfileEditor/PopoverContent.tsx@@ -1,56 +1,22 @@import { Flexbox, Icon, type ItemType, Segmented } from '@lobehub/ui';import { createStaticStyles, cssVar } from 'antd-style';-import { ArrowRight, ExternalLink, Settings, Store } from 'lucide-react';-import { type ReactNode, memo } from 'react';+import { ChevronRight, ExternalLink, Settings, Store } from 'lucide-react';+import { memo } from 'react';import { useTranslation } from 'react-i18next';import { useNavigate } from 'react-router-dom';+import ToolsList, { toolsListStyles } from '@/features/ChatInput/ActionBar/Tools/ToolsList';+import Empty from './Empty';type TabType = 'all' | 'installed';-const prefixCls = 'ant';+const SKILL_ICON_SIZE = 20;const styles = createStaticStyles(({ css }) => ({- dropdown: css`- overflow: hidden;- width: 100%;-- .${prefixCls}-dropdown-menu {- border-radius: 0 !important;- background: transparent !important;- box-shadow: none !important;- }- `,- footerItem: css`- cursor: pointer;-- display: flex;- gap: 12px;- align-items: center;-- padding-block: 8px;- padding-inline: 12px;- border-radius: 6px;-- transition: background-color 0.2s;-- &:hover {- background: ${cssVar.colorFillTertiary};- }- `,- footerItemContent: css`- flex: 1;- min-width: 0;- `,- footerItemIcon: css`- display: flex;- flex-shrink: 0;- align-items: center;- justify-content: center;-- width: 24px;- height: 24px;+ footer: css`+ padding: 4px;+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};`,header: css`padding: ${cssVar.paddingXS};@@ -67,20 +33,22 @@ const styles = createStaticStyles(({ css }) => ({interface PopoverContentProps {activeTab: TabType;+ allTabItems: ItemType[];installedTabItems: ItemType[];- menu: ReactNode;onClose?: () => void;onOpenStore: () => void;onTabChange: (tab: TabType) => void;}const PopoverContent = memo<PopoverContentProps>(- ({ menu, activeTab, onTabChange, installedTabItems, onOpenStore, onClose }) => {+ ({ activeTab, onTabChange, allTabItems, installedTabItems, onOpenStore, onClose }) => {const { t } = useTranslation('setting');const navigate = useNavigate();+ const currentItems = activeTab === 'all' ? allTabItems : installedTabItems;+return (- <Flexbox className={styles.dropdown} style={{ maxHeight: 500 }}>+ <Flexbox style={{ maxHeight: 500, width: '100%' }}>{/* stopPropagation prevents dropdown's onClick from calling preventDefault on Segmented */}<div className={styles.header} onClick={(e) => e.stopPropagation()}><Segmented@@ -101,23 +69,22 @@ const PopoverContent = memo<PopoverContentProps>(/></div><div className={styles.scroller} style={{ flex: 1 }}>- {activeTab === 'installed' && installedTabItems.length === 0 ? <Empty /> : menu}+ {activeTab === 'installed' && installedTabItems.length === 0 ? (+ <Empty />+ ) : (+ <ToolsList items={currentItems} />+ )}</div>- <div- style={{- borderBlockStart: `1px solid ${cssVar.colorBorderSecondary}`,- padding: 4,- }}- >- <div className={styles.footerItem} onClick={onOpenStore} role="button" tabIndex={0}>- <div className={styles.footerItemIcon}>- <Icon icon={Store} size={20} />+ <div className={styles.footer}>+ <div className={toolsListStyles.item} onClick={onOpenStore} role="button" tabIndex={0}>+ <div className={toolsListStyles.itemIcon}>+ <Icon icon={Store} size={SKILL_ICON_SIZE} /></div>- <div className={styles.footerItemContent}>{t('skillStore.title')}</div>- <Icon className={styles.trailingIcon} icon={ArrowRight} size={16} />+ <div className={toolsListStyles.itemContent}>{t('skillStore.title')}</div>+ <Icon className={styles.trailingIcon} icon={ChevronRight} size={16} /></div><div- className={styles.footerItem}+ className={toolsListStyles.item}onClick={() => {onClose?.();navigate('/settings/skill');@@ -125,10 +92,10 @@ const PopoverContent = memo<PopoverContentProps>(role="button"tabIndex={0}>- <div className={styles.footerItemIcon}>- <Icon icon={Settings} size={20} />+ <div className={toolsListStyles.itemIcon}>+ <Icon icon={Settings} size={SKILL_ICON_SIZE} /></div>- <div className={styles.footerItemContent}>{t('tools.plugins.management')}</div>+ <div className={toolsListStyles.itemContent}>{t('tools.plugins.management')}</div><Icon className={styles.trailingIcon} icon={ExternalLink} size={16} /></div></div>diff --git a/src/features/SkillStore/CommunityList/Item.tsx b/src/features/SkillStore/CommunityList/Item.tsxindex 95a5f73a1cd..776a34147f4 100644--- a/src/features/SkillStore/CommunityList/Item.tsx+++ b/src/features/SkillStore/CommunityList/Item.tsx@@ -9,8 +9,8 @@ import { useTranslation } from 'react-i18next';import PluginAvatar from '@/components/Plugins/PluginAvatar';import McpDetail from '@/features/MCP/MCPDetail';-import MCPInstallProgress from '@/features/MCP/MCPInstallProgress';import McpDetailLoading from '@/features/MCP/MCPDetail/Loading';+import MCPInstallProgress from '@/features/MCP/MCPInstallProgress';import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';@@ -95,6 +95,7 @@ const Item = memo<DiscoverMcpItem>(({ name, description, icon, identifier }) =>},},]}+ nativeButton={false}placement="bottomRight"><ActionIcon icon={MoreVerticalIcon} />diff --git a/src/features/SkillStore/CommunityList/index.tsx b/src/features/SkillStore/CommunityList/index.tsxindex 4a9308711e2..35581d33e71 100644--- a/src/features/SkillStore/CommunityList/index.tsx+++ b/src/features/SkillStore/CommunityList/index.tsx@@ -1,16 +1,17 @@'use client';-import { Center, Flexbox, Icon, Text } from '@lobehub/ui';+import { Center, Icon, Text } from '@lobehub/ui';import { ServerCrash } from 'lucide-react';-import { memo, useEffect } from 'react';+import { memo, useEffect, useRef } from 'react';import { useTranslation } from 'react-i18next';-import { Virtuoso } from 'react-virtuoso';+import { VirtuosoGrid } from 'react-virtuoso';import { useToolStore } from '@/store/tool';import Empty from '../Empty';import Loading from '../Loading';import VirtuosoLoading from '../VirtuosoLoading';+import { virtuosoGridStyles } from '../style';import Item from './Item';export const CommunityList = memo(() => {@@ -20,7 +21,6 @@ export const CommunityList = memo(() => {keywords,isMcpListInit,allItems,- totalCount,currentPage,searchLoading,useFetchMCPPluginList,@@ -30,7 +30,6 @@ export const CommunityList = memo(() => {s.mcpSearchKeywords,s.isMcpListInit,s.mcpPluginItems,- s.totalCount,s.currentPage,s.searchLoading,s.useFetchMCPPluginList,@@ -38,8 +37,14 @@ export const CommunityList = memo(() => {s.resetMCPPluginList,]);+ const prevKeywordsRef = useRef(keywords);+useEffect(() => {- resetMCPPluginList(keywords);+ // Only reset when keywords actually change, not on initial mount+ if (prevKeywordsRef.current !== keywords) {+ prevKeywordsRef.current = keywords;+ resetMCPPluginList(keywords);+ }}, [keywords, resetMCPPluginList]);const { isLoading, error } = useFetchMCPPluginList({@@ -66,29 +71,18 @@ export const CommunityList = memo(() => {if (allItems.length === 0) return <Empty search={hasSearchKeywords} />;return (- <Virtuoso+ <VirtuosoGridcomponents={{- Footer: isLoading ? VirtuosoLoading : undefined,+ Footer: isLoading ? VirtuosoLoading : () => <div style={{ height: 16 }} />,}}data={allItems}endReached={loadMoreMCPPlugins}increaseViewportBy={typeof window !== 'undefined' ? window.innerHeight : 0}- itemContent={(index) => {- const item = allItems[index];- // Render two items per row- if (index % 2 !== 0) return null;-- const nextItem = allItems[index + 1];- return (- <Flexbox gap={12} horizontal paddingInline={16} style={{ paddingBottom: 12 }}>- <Item {...item} />- {nextItem && <Item {...nextItem} />}- </Flexbox>- );- }}+ itemClassName={virtuosoGridStyles.item}+ itemContent={(_, item) => <Item {...item} />}+ listClassName={virtuosoGridStyles.list}overscan={24}style={{ height: '60vh', width: '100%' }}- totalCount={Math.ceil((totalCount || 0) / 2)}/>);};diff --git a/src/features/SkillStore/CustomList/Item.tsx b/src/features/SkillStore/CustomList/Item.tsxindex db2a0da3cde..6294f3d35ae 100644--- a/src/features/SkillStore/CustomList/Item.tsx+++ b/src/features/SkillStore/CustomList/Item.tsx@@ -84,7 +84,7 @@ const Item = memo<ItemProps>(({ identifier, title, description, avatar }) => {horizontalpaddingBlock={12}paddingInline={12}- variant={'filled'}+ variant={'outlined'}><PluginAvatar avatar={avatar} size={40} /><Flexbox flex={1} gap={4} style={{ minWidth: 0, overflow: 'hidden' }}>@@ -109,6 +109,7 @@ const Item = memo<ItemProps>(({ identifier, title, description, avatar }) => {onClick: handleDelete,},]}+ nativeButton={false}placement="bottomRight"><ActionIcon icon={MoreVerticalIcon} />diff --git a/src/features/SkillStore/CustomList/index.tsx b/src/features/SkillStore/CustomList/index.tsxindex 5b578ff955f..2dbf3e6488c 100644--- a/src/features/SkillStore/CustomList/index.tsx+++ b/src/features/SkillStore/CustomList/index.tsx@@ -1,6 +1,5 @@'use client';-import { createStaticStyles, responsive } from 'antd-style';import isEqual from 'fast-deep-equal';import { memo, useMemo } from 'react';@@ -8,26 +7,9 @@ import { useToolStore } from '@/store/tool';import { pluginSelectors } from '@/store/tool/selectors';import Empty from '../Empty';+import { gridStyles } from '../style';import Item from './Item';-const styles = createStaticStyles(({ css }) => ({- container: css`- min-height: 50vh;- `,- grid: css`- display: grid;- grid-template-columns: repeat(2, 1fr);- gap: 12px;-- padding-block-end: 16px;- padding-inline: 16px;-- ${responsive.sm} {- grid-template-columns: 1fr;- }- `,-}));-export const CustomList = memo(() => {const customPlugins = useToolStore(pluginSelectors.installedCustomPluginMetaList, isEqual);const searchKeywords = useToolStore((s) => s.customPluginSearchKeywords || '');@@ -50,18 +32,16 @@ export const CustomList = memo(() => {}return (- <div className={styles.container}>- <div className={styles.grid}>- {filteredItems.map((plugin) => (- <Item- avatar={plugin.avatar}- description={plugin.description}- identifier={plugin.identifier}- key={plugin.identifier}- title={plugin.title}- />- ))}- </div>+ <div className={gridStyles.grid}>+ {filteredItems.map((plugin) => (+ <Item+ avatar={plugin.avatar}+ description={plugin.description}+ identifier={plugin.identifier}+ key={plugin.identifier}+ title={plugin.title}+ />+ ))}</div>);});diff --git a/src/features/SkillStore/LobeHubList/Item.tsx b/src/features/SkillStore/LobeHubList/Item.tsxindex 15bdfe99b42..732e903f415 100644--- a/src/features/SkillStore/LobeHubList/Item.tsx+++ b/src/features/SkillStore/LobeHubList/Item.tsx@@ -1,6 +1,6 @@'use client';-import { ActionIcon, Block, DropdownMenu, Flexbox, Icon, Image } from '@lobehub/ui';+import { ActionIcon, Block, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';import { App } from 'antd';import { cssVar } from 'antd-style';import type { Klavis } from 'klavis';@@ -55,7 +55,7 @@ const Item = memo<ItemProps>(const renderIcon = () => {if (typeof icon === 'string') {- return <Image alt={label} height={40} src={icon} width={40} />;+ return <img alt={label} height={40} src={icon} width={40} />;}return <Icon fill={cssVar.colorText} icon={icon as any} size={40} />;};@@ -76,6 +76,7 @@ const Item = memo<ItemProps>(onClick: confirmDisconnect,},]}+ nativeButton={false}placement="bottomRight"><ActionIcon icon={MoreVerticalIcon} />@@ -98,7 +99,7 @@ const Item = memo<ItemProps>(paddingBlock={12}paddingInline={12}style={{ cursor: 'pointer' }}- variant={'filled'}+ variant={'outlined'}>{renderIcon()}<Flexbox flex={1} gap={4} style={{ minWidth: 0, overflow: 'hidden' }}>diff --git a/src/features/SkillStore/LobeHubList/index.tsx b/src/features/SkillStore/LobeHubList/index.tsxindex 40e3c835585..59247caf770 100644--- a/src/features/SkillStore/LobeHubList/index.tsx+++ b/src/features/SkillStore/LobeHubList/index.tsx@@ -1,7 +1,6 @@'use client';import { KLAVIS_SERVER_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';-import { createStaticStyles } from 'antd-style';import isEqual from 'fast-deep-equal';import { memo, useCallback, useMemo } from 'react';@@ -13,29 +12,14 @@ import { KlavisServerStatus } from '@/store/tool/slices/klavisStore';import { LobehubSkillStatus } from '@/store/tool/slices/lobehubSkillStore/types';import Empty from '../Empty';+import { gridStyles } from '../style';import Item from './Item';-const styles = createStaticStyles(({ css }) => ({- grid: css`- display: grid;- grid-template-columns: repeat(2, 1fr);- gap: 12px;-- padding-block-end: 16px;- padding-inline: 16px;-- @media (max-width: 768px) {- grid-template-columns: 1fr;- }- `,-}));-interface LobeHubListProps {keywords: string;}export const LobeHubList = memo<LobeHubListProps>(({ keywords }) => {-const isLobehubSkillEnabled = useServerConfigStore(serverConfigSelectors.enableLobehubSkill);const isKlavisEnabled = useServerConfigStore(serverConfigSelectors.enableKlavis);const allLobehubSkillServers = useToolStore(lobehubSkillStoreSelectors.getServers, isEqual);@@ -98,7 +82,7 @@ export const LobeHubList = memo<LobeHubListProps>(({ keywords }) => {if (filteredItems.length === 0) return <Empty search={hasSearchKeywords} />;return (- <div className={styles.grid}>+ <div className={gridStyles.grid}>{filteredItems.map((item) => {if (item.type === 'lobehub') {const server = getLobehubSkillServerByProvider(item.provider.id);diff --git a/src/features/SkillStore/Search/index.tsx b/src/features/SkillStore/Search/index.tsxindex 9e3c8518aa1..5888d334158 100644--- a/src/features/SkillStore/Search/index.tsx+++ b/src/features/SkillStore/Search/index.tsx@@ -37,7 +37,7 @@ export const Search = memo<SearchProps>(({ activeTab, onLobeHubSearch }) => {}}}placeholder={t('skillStore.search')}- variant="filled"+ variant="outlined"/></Flexbox></Flexbox>diff --git a/src/features/SkillStore/index.tsx b/src/features/SkillStore/index.tsxindex fcdc8b7e100..3e6ab6903d8 100644--- a/src/features/SkillStore/index.tsx+++ b/src/features/SkillStore/index.tsx@@ -2,6 +2,7 @@import { createModal } from '@lobehub/ui';import { t } from 'i18next';+import { MemoryRouter } from 'react-router-dom';import { isDesktop } from '@/const/version';import { MarketAuthProvider } from '@/layout/AuthProvider/MarketAuth';@@ -12,9 +13,11 @@ export const createSkillStoreModal = () =>createModal({allowFullscreen: true,children: (- <MarketAuthProvider isDesktop={isDesktop}>- <SkillStoreContent />- </MarketAuthProvider>+ <MemoryRouter>+ <MarketAuthProvider isDesktop={isDesktop}>+ <SkillStoreContent />+ </MarketAuthProvider>+ </MemoryRouter>),destroyOnHidden: false,footer: null,diff --git a/src/features/SkillStore/style.ts b/src/features/SkillStore/style.tsindex 17f3196cebe..b6b44d3ed5a 100644--- a/src/features/SkillStore/style.ts+++ b/src/features/SkillStore/style.ts@@ -1,4 +1,37 @@-import { createStaticStyles } from 'antd-style';+import { createStaticStyles, responsive } from 'antd-style';++export const gridStyles = createStaticStyles(({ css }) => ({+ grid: css`+ display: grid;+ grid-template-columns: repeat(2, 1fr);+ gap: 12px;++ padding-block-end: 16px;+ padding-inline: 16px;++ ${responsive.sm} {+ grid-template-columns: 1fr;+ }+ `,+}));++export const virtuosoGridStyles = createStaticStyles(({ css }) => ({+ item: css`+ width: calc(50% - 6px);++ ${responsive.sm} {+ width: 100%;+ }+ `,+ list: css`+ display: flex;+ flex-wrap: wrap;+ gap: 12px;++ padding-block-end: 16px;+ padding-inline: 16px;+ `,+}));export const itemStyles = createStaticStyles(({ css, cssVar }) => ({container: css`