diff --git a/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx b/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx index 0f141822ff..540fba1cb9 100644 --- a/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx @@ -1,8 +1,8 @@ import { useAvailablePlugins, useInstalledPlugins, usePluginActions } from '@renderer/hooks/usePlugins' import type { GetAgentResponse, GetAgentSessionResponse, UpdateAgentFunctionUnion } from '@renderer/types/agent' -import { Card, Tabs } from 'antd' +import { Card, Segmented } from 'antd' import type { FC } from 'react' -import { useMemo } from 'react' +import { useMemo, useState } from 'react' import { useCallback } from 'react' import { useTranslation } from 'react-i18next' @@ -17,6 +17,7 @@ interface PluginSettingsProps { const PluginSettings: FC = ({ agentBase }) => { const { t } = useTranslation() + const [activeTab, setActiveTab] = useState('available') // Fetch available plugins const { agents, commands, skills, loading: loadingAvailable, error: errorAvailable } = useAvailablePlugins() @@ -55,57 +56,64 @@ const PluginSettings: FC = ({ agentBase }) => { [uninstall, t] ) - const tabItems = useMemo(() => { + const segmentOptions = useMemo(() => { return [ { - key: 'available', - label: t('agent.settings.plugins.available.title'), - children: ( -
- {errorAvailable ? ( - -

- {t('agent.settings.plugins.error.load')}: {errorAvailable} -

-
- ) : ( - - )} -
- ) + value: 'available', + label: t('agent.settings.plugins.available.title') }, { - key: 'installed', - label: t('agent.settings.plugins.installed.title'), - children: ( -
- {errorInstalled ? ( - -

- {t('agent.settings.plugins.error.load')}: {errorInstalled} -

-
- ) : ( - - )} -
- ) + value: 'installed', + label: t('agent.settings.plugins.installed.title') } ] + }, [t]) + + const renderContent = useMemo(() => { + if (activeTab === 'available') { + return ( +
+ {errorAvailable ? ( + +

+ {t('agent.settings.plugins.error.load')}: {errorAvailable} +

+
+ ) : ( + + )} +
+ ) + } + + return ( +
+ {errorInstalled ? ( + +

+ {t('agent.settings.plugins.error.load')}: {errorInstalled} +

+
+ ) : ( + + )} +
+ ) }, [ + activeTab, agentBase.id, agents, commands, @@ -123,8 +131,13 @@ const PluginSettings: FC = ({ agentBase }) => { ]) return ( - - + +
+
+ setActiveTab(value as string)} /> +
+ {renderContent} +
) } diff --git a/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx b/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx index 3fdbb1074f..59725f0787 100644 --- a/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx @@ -243,7 +243,6 @@ export const PluginBrowser: FC = ({ value={searchQuery} onChange={(e) => handleSearchChange(e.target.value)} prefix={} - size="large" suffix={ 0 ? 'filled' : 'text'} @@ -267,9 +266,7 @@ export const PluginBrowser: FC = ({ menu={{ items: pluginCategoryMenuItems }} trigger={['click']} open={filterDropdownOpen} - onOpenChange={(nextOpen) => { - setFilterDropdownOpen(nextOpen) - }}> + onOpenChange={setFilterDropdownOpen}> 0 ? 'filled' : 'text'} color={selectedCategories.length > 0 ? 'primary' : 'default'} @@ -296,7 +293,6 @@ export const PluginBrowser: FC = ({ items={pluginTypeTabItems} className="w-full" size="small" - centered /> diff --git a/src/renderer/src/pages/settings/AgentSettings/components/PluginCard.tsx b/src/renderer/src/pages/settings/AgentSettings/components/PluginCard.tsx index 992a724d08..853890e818 100644 --- a/src/renderer/src/pages/settings/AgentSettings/components/PluginCard.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/components/PluginCard.tsx @@ -27,7 +27,6 @@ export const PluginCard: FC = ({ plugin, installed, onInstall,