From 6ae5f6916389a3b0d8c79da9e0eb70233c97df54 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Wed, 5 Nov 2025 18:44:13 +0800 Subject: [PATCH] refactor: update PluginSettings and ToolingSettings for improved layout and functionality --- .../settings/AgentSettings/PluginSettings.tsx | 6 +- .../AgentSettings/ToolingSettings.tsx | 99 ++++++++----------- .../components/PluginBrowser.tsx | 40 +------- 3 files changed, 51 insertions(+), 94 deletions(-) diff --git a/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx b/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx index 540fba1cb..7d6c10241 100644 --- a/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/PluginSettings.tsx @@ -1,3 +1,4 @@ +import Scrollbar from '@renderer/components/Scrollbar' import { useAvailablePlugins, useInstalledPlugins, usePluginActions } from '@renderer/hooks/usePlugins' import type { GetAgentResponse, GetAgentSessionResponse, UpdateAgentFunctionUnion } from '@renderer/types/agent' import { Card, Segmented } from 'antd' @@ -8,7 +9,6 @@ import { useTranslation } from 'react-i18next' import { InstalledPluginsList } from './components/InstalledPluginsList' import { PluginBrowser } from './components/PluginBrowser' -import { SettingsContainer } from './shared' interface PluginSettingsProps { agentBase: GetAgentResponse | GetAgentSessionResponse @@ -131,14 +131,14 @@ const PluginSettings: FC = ({ agentBase }) => { ]) return ( - +
setActiveTab(value as string)} />
{renderContent}
-
+ ) } diff --git a/src/renderer/src/pages/settings/AgentSettings/ToolingSettings.tsx b/src/renderer/src/pages/settings/AgentSettings/ToolingSettings.tsx index bbe50aaec..e353799c5 100644 --- a/src/renderer/src/pages/settings/AgentSettings/ToolingSettings.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/ToolingSettings.tsx @@ -14,7 +14,7 @@ import type { import { AgentConfigurationSchema } from '@renderer/types' import { Modal, Tag } from 'antd' import { Alert, Card, Input, Switch } from 'antd' -import { ShieldAlert, ShieldCheck, Wrench } from 'lucide-react' +import { ShieldAlert, Wrench } from 'lucide-react' import type { FC } from 'react' import { useCallback, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -274,60 +274,47 @@ export const ToolingSettings: FC = ({ agentBase, upda return (
handleSelectPermissionMode(card.mode)}> - -
- - {t(card.titleKey, card.titleFallback)} - - - {t(card.descriptionKey, card.descriptionFallback)} - -
- {disabled ? ( - {t('common.coming_soon', 'Coming soon')} - ) : isSelected ? ( - -
- - {t('common.selected', 'Selected')} -
-
- ) : null} -
- } - styles={{ - header: { - paddingLeft: '12px', - paddingRight: '12px', - borderBottom: 'none' - }, - body: { - paddingLeft: '12px', - paddingRight: '12px' - } - }}> -
- {t(card.behaviorKey, card.behaviorFallback)} - {showCaution ? ( -
- - - {t( - 'agent.settings.tooling.permissionMode.bypassPermissions.warning', - 'Use with caution — all tools will run without asking for approval.' - )} - -
- ) : null} + className={`flex flex-col gap-3 overflow-hidden rounded-lg border p-4 transition-colors ${ + isSelected + ? 'border-primary bg-primary-50/30 dark:bg-primary-950/20' + : 'border-default-200 hover:bg-default-50 dark:hover:bg-default-900/20' + } ${disabled ? 'cursor-not-allowed opacity-60' : 'cursor-pointer'}`} + onClick={() => !disabled && handleSelectPermissionMode(card.mode)}> + {/* Header */} +
+
+ + {t(card.titleKey, card.titleFallback)} + + + {t(card.descriptionKey, card.descriptionFallback)} +
- + {disabled && {t('common.coming_soon', 'Coming soon')}} + {isSelected && !disabled && ( + +
+ {t('common.selected', 'Selected')} +
+
+ )} +
+ + {/* Body */} +
+ {t(card.behaviorKey, card.behaviorFallback)} + {showCaution && ( +
+ + + {t( + 'agent.settings.tooling.permissionMode.bypassPermissions.warning', + 'Use with caution — all tools will run without asking for approval.' + )} + +
+ )} +
) })} @@ -414,7 +401,7 @@ export const ToolingSettings: FC = ({ agentBase, upda })} checked={isApproved} disabled={isAuto || isUpdatingTools} - size="default" + size="small" onChange={(checked) => handleToggleTool(tool.id, checked)} /> @@ -485,7 +472,7 @@ export const ToolingSettings: FC = ({ agentBase, upda name: server.name })} checked={isSelected} - size="default" + size="small" disabled={!server.isActive || isUpdatingMcp} onChange={(checked) => handleToggleMcp(server.id, checked)} /> diff --git a/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx b/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx index 59725f078..9251a47ae 100644 --- a/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/components/PluginBrowser.tsx @@ -230,57 +230,27 @@ export const PluginBrowser: FC = ({ setSelectedPlugin(null) } - const handleOpenFilterDropdown = () => { - setFilterDropdownOpen(!filterDropdownOpen) - } - return (
{/* Search and Filter */} -
+
handleSearchChange(e.target.value)} prefix={} - suffix={ - 0 ? 'filled' : 'text'} - color={selectedCategories.length > 0 ? 'primary' : 'default'} - size="small" - style={{ - position: 'absolute', - top: '50%', - right: '8px', - transform: 'translateY(-50%)', - padding: '4px', - minWidth: '32px', - borderRadius: '4px' - }} - icon={} - onClick={handleOpenFilterDropdown} - /> - } /> 0 ? 'filled' : 'text'} + variant={selectedCategories.length > 0 ? 'filled' : 'outlined'} color={selectedCategories.length > 0 ? 'primary' : 'default'} - size="small" - style={{ - position: 'absolute', - top: '50%', - right: '8px', - transform: 'translateY(-50%)', - padding: '4px', - minWidth: '32px', - borderRadius: '4px' - }} - icon={} + size="middle" + icon={} />