🤯 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: slove the group member agents cant set skills problem (#12021)
Shinji-Li2302940079c6
diff --git a/src/features/ChatInput/ActionBar/Tools/KlavisServerItem.tsx b/src/features/ChatInput/ActionBar/Tools/KlavisServerItem.tsxindex cacc4b3306f..c70b5e7700e 100644--- a/src/features/ChatInput/ActionBar/Tools/KlavisServerItem.tsx+++ b/src/features/ChatInput/ActionBar/Tools/KlavisServerItem.tsx@@ -15,6 +15,11 @@ const POLL_INTERVAL_MS = 1000; // 每秒轮询一次const POLL_TIMEOUT_MS = 15_000; // 15 秒超时interface KlavisServerItemProps {+ /**+ * Optional agent ID to use instead of currentAgentConfig+ * Used in group profile to specify which member's plugins to toggle+ */+ agentId?: string;/*** Identifier used for storage (e.g., 'google-calendar')*/@@ -28,7 +33,7 @@ interface KlavisServerItemProps {}const KlavisServerItem = memo<KlavisServerItemProps>(- ({ identifier, label, server, serverName }) => {+ ({ identifier, label, server, serverName, agentId }) => {const { t } = useTranslation('setting');const [isConnecting, setIsConnecting] = useState(false);const [isToggling, setIsToggling] = useState(false);@@ -43,6 +48,10 @@ const KlavisServerItem = memo<KlavisServerItemProps>(const createKlavisServer = useToolStore((s) => s.createKlavisServer);const refreshKlavisServerTools = useToolStore((s) => s.refreshKlavisServerTools);+ // Get effective agent ID (agentId prop or current active agent)+ const activeAgentId = useAgentStore((s) => s.activeAgentId);+ const effectiveAgentId = agentId || activeAgentId || '';+// 清理所有定时器const cleanup = useCallback(() => {if (windowCheckIntervalRef.current) {@@ -162,10 +171,24 @@ const KlavisServerItem = memo<KlavisServerItemProps>(// Get plugin ID for this server (使用 identifier 作为 pluginId)const pluginId = server ? server.identifier : '';- const [checked, togglePlugin] = useAgentStore((s) => [- agentSelectors.currentAgentPlugins(s).includes(pluginId),- s.togglePlugin,- ]);+ const plugins =+ useAgentStore(agentSelectors.getAgentConfigById(effectiveAgentId))?.plugins || [];+ const checked = plugins.includes(pluginId);+ const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);++ // Toggle plugin for the effective agent+ const togglePlugin = useCallback(+ async (pluginIdToToggle: string) => {+ if (!effectiveAgentId) return;+ const currentPlugins = plugins;+ const hasPlugin = currentPlugins.includes(pluginIdToToggle);+ const newPlugins = hasPlugin+ ? currentPlugins.filter((id) => id !== pluginIdToToggle)+ : [...currentPlugins, pluginIdToToggle];+ await updateAgentConfigById(effectiveAgentId, { plugins: newPlugins });+ },+ [effectiveAgentId, plugins, updateAgentConfigById],+ );const handleConnect = async () => {if (!userId) {diff --git a/src/features/ChatInput/ActionBar/Tools/LobehubSkillServerItem.tsx b/src/features/ChatInput/ActionBar/Tools/LobehubSkillServerItem.tsxindex 04e928abeff..7f49aed9bff 100644--- a/src/features/ChatInput/ActionBar/Tools/LobehubSkillServerItem.tsx+++ b/src/features/ChatInput/ActionBar/Tools/LobehubSkillServerItem.tsx@@ -13,6 +13,11 @@ const POLL_INTERVAL_MS = 1000;const POLL_TIMEOUT_MS = 15_000;interface LobehubSkillServerItemProps {+ /**+ * Optional agent ID to use instead of currentAgentConfig+ * Used in group profile to specify which member's plugins to toggle+ */+ agentId?: string;/*** Display label for the provider*/@@ -23,7 +28,7 @@ interface LobehubSkillServerItemProps {provider: string;}-const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, label }) => {+const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, label, agentId }) => {const { t } = useTranslation('setting');const [isConnecting, setIsConnecting] = useState(false);const [isToggling, setIsToggling] = useState(false);@@ -38,6 +43,10 @@ const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, laconst checkStatus = useToolStore((s) => s.checkLobehubSkillStatus);const getAuthorizeUrl = useToolStore((s) => s.getLobehubSkillAuthorizeUrl);+ // Get effective agent ID (agentId prop or current active agent)+ const activeAgentId = useAgentStore((s) => s.activeAgentId);+ const effectiveAgentId = agentId || activeAgentId || '';+const cleanup = useCallback(() => {if (windowCheckIntervalRef.current) {clearInterval(windowCheckIntervalRef.current);@@ -129,10 +138,23 @@ const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, la);const pluginId = server ? server.identifier : '';- const [checked, togglePlugin] = useAgentStore((s) => [- agentSelectors.currentAgentPlugins(s).includes(pluginId),- s.togglePlugin,- ]);+ const plugins = useAgentStore(agentSelectors.getAgentConfigById(effectiveAgentId))?.plugins || [];+ const checked = plugins.includes(pluginId);+ const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);++ // Toggle plugin for the effective agent+ const togglePlugin = useCallback(+ async (pluginIdToToggle: string) => {+ if (!effectiveAgentId) return;+ const currentPlugins = plugins;+ const hasPlugin = currentPlugins.includes(pluginIdToToggle);+ const newPlugins = hasPlugin+ ? currentPlugins.filter((id) => id !== pluginIdToToggle)+ : [...currentPlugins, pluginIdToToggle];+ await updateAgentConfigById(effectiveAgentId, { plugins: newPlugins });+ },+ [effectiveAgentId, plugins, updateAgentConfigById],+ );// Listen for OAuth success message from popup windowuseEffect(() => {@@ -156,9 +178,10 @@ const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, la.lobehubSkillServers?.find((s) => s.identifier === provider);if (latestServer?.status === LobehubSkillStatus.CONNECTED) {const newPluginId = latestServer.identifier;- const isAlreadyEnabled = agentSelectors- .currentAgentPlugins(useAgentStore.getState())- .includes(newPluginId);+ const currentAgentPlugins =+ agentSelectors.getAgentConfigById(effectiveAgentId)(useAgentStore.getState())+ ?.plugins || [];+ const isAlreadyEnabled = currentAgentPlugins.includes(newPluginId);if (!isAlreadyEnabled) {console.log('[LobehubSkill] Auto-enabling plugin:', newPluginId);togglePlugin(newPluginId);@@ -169,7 +192,7 @@ const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, lawindow.addEventListener('message', handleMessage);return () => window.removeEventListener('message', handleMessage);- }, [provider, cleanup, checkStatus, togglePlugin]);+ }, [provider, cleanup, checkStatus, togglePlugin, effectiveAgentId]);const handleConnect = async () => {// 只有已连接状态才阻止重新连接diff --git a/src/features/ChatInput/ActionBar/Tools/useControls.tsx b/src/features/ChatInput/ActionBar/Tools/useControls.tsxindex ed36f14dd95..fd86fd5586e 100644--- a/src/features/ChatInput/ActionBar/Tools/useControls.tsx+++ b/src/features/ChatInput/ActionBar/Tools/useControls.tsx@@ -176,6 +176,7 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean)key: type.identifier,label: (<KlavisServerItem+ agentId={agentId}identifier={type.identifier}label={type.label}server={getServerByName(type.identifier)}@@ -184,7 +185,7 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean)),})): [],- [isKlavisEnabledInEnv, allKlavisServers, installedKlavisIds, recommendedKlavisIds],+ [isKlavisEnabledInEnv, allKlavisServers, installedKlavisIds, recommendedKlavisIds, agentId],);// LobeHub Skill Provider 列表项 - 只展示已安装或推荐的@@ -197,10 +198,22 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean)).map((provider) => ({icon: <LobehubSkillIcon icon={provider.icon} label={provider.label} />,key: provider.id, // 使用 provider.id 作为 key,与 pluginId 保持一致- label: <LobehubSkillServerItem label={provider.label} provider={provider.id} />,+ label: (+ <LobehubSkillServerItem+ agentId={agentId}+ label={provider.label}+ provider={provider.id}+ />+ ),})): [],- [isLobehubSkillEnabled, allLobehubSkillServers, installedLobehubIds, recommendedLobehubIds],+ [+ isLobehubSkillEnabled,+ allLobehubSkillServers,+ installedLobehubIds,+ recommendedLobehubIds,+ agentId,+ ],);// Builtin 工具列表项(不包含 Klavis 和 LobeHub Skill)diff --git a/src/features/ProfileEditor/AgentTool.tsx b/src/features/ProfileEditor/AgentTool.tsxindex 650cf1b169b..d8e275f2949 100644--- a/src/features/ProfileEditor/AgentTool.tsx+++ b/src/features/ProfileEditor/AgentTool.tsx@@ -271,6 +271,7 @@ const AgentTool = memo<AgentToolProps>(key: type.identifier,label: (<KlavisServerItem+ agentId={effectiveAgentId}identifier={type.identifier}label={type.label}server={getServerByName(type.identifier)}@@ -279,7 +280,7 @@ const AgentTool = memo<AgentToolProps>(),})): [],- [isKlavisEnabledInEnv, allKlavisServers],+ [isKlavisEnabledInEnv, allKlavisServers, effectiveAgentId],);// LobeHub Skill Provider 列表项@@ -289,10 +290,16 @@ const AgentTool = memo<AgentToolProps>(? LOBEHUB_SKILL_PROVIDERS.map((provider) => ({icon: <LobehubSkillIcon icon={provider.icon} label={provider.label} />,key: provider.id, // 使用 provider.id 作为 key,与 pluginId 保持一致- label: <LobehubSkillServerItem label={provider.label} provider={provider.id} />,+ label: (+ <LobehubSkillServerItem+ agentId={effectiveAgentId}+ label={provider.label}+ provider={provider.id}+ />+ ),})): [],- [isLobehubSkillEnabled, allLobehubSkillServers],+ [isLobehubSkillEnabled, allLobehubSkillServers, effectiveAgentId],);// Handle plugin remove via Tag close - use byId actions