Skip to content

🀯 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.

πŸ› fix: stop agent-scoped connectors double-showing as "uninstalled" in base tools list (#17255)

LiJian86d0c7b8a8e5
diff --git a/src/features/ProfileEditor/AgentTool.tsx b/src/features/ProfileEditor/AgentTool.tsx
index 5ed35ddcb86..67f2e25ae9b 100644
--- a/src/features/ProfileEditor/AgentTool.tsx
+++ b/src/features/ProfileEditor/AgentTool.tsx
@@ -53,6 +53,17 @@ export interface AgentToolProps {
* Used in group profile to specify which member's plugins to display
*/
agentId?: string;
+ /**
+ * Hide identifiers that are agent-owned/linked connectors from the rendered
+ * chips. ONLY the two-section agent profile sets this (it renders those
+ * connectors in a separate "Agent Tools" section above, so showing them here
+ * too would duplicate them β€” as an "uninstalled" chip lacking a base manifest).
+ * Consumers that render `AgentTool` as the SOLE tool list (e.g. the group
+ * member profile) MUST leave this off, otherwise the enabled agent tool would
+ * disappear entirely with no way to see or remove it.
+ * @default false
+ */
+ excludeAgentConnectors?: boolean;
/**
* Whether to filter tools by availableInWeb property
* @default false
@@ -71,7 +82,13 @@ export interface AgentToolProps {
}
const AgentTool = memo<AgentToolProps>(
- ({ agentId, showWebBrowsing = false, filterAvailableInWeb = false, useAllMetaList = false }) => {
+ ({
+ agentId,
+ showWebBrowsing = false,
+ filterAvailableInWeb = false,
+ useAllMetaList = false,
+ excludeAgentConnectors = false,
+ }) => {
const { t } = useTranslation('setting');
const { allowed: canEdit } = usePermission('edit_own_content');
const activeAgentId = useAgentStore((s) => s.activeAgentId);
@@ -144,6 +161,22 @@ const AgentTool = memo<AgentToolProps>(
// Custom connectors (user-added OAuth MCP servers) from the connector store
const customConnectors = useToolStore(connectorSelectors.customConnectors, isEqual);
+ // Agent-owned / linked connectors: when `excludeAgentConnectors` is set (the
+ // two-section agent profile), these are rendered in the dedicated "Agent
+ // Tools" section above, so they must be dropped from THIS base/user list β€”
+ // otherwise the identifier, pinned into `config.plugins` for runtime gating,
+ // would surface here too and, lacking a base-dimension manifest, render as an
+ // "uninstalled" chip. When the prop is off (e.g. the group member profile,
+ // where AgentTool is the only tool list) they are kept, so the enabled tool
+ // stays visible and removable. Display-only either way; the pin is untouched.
+ const agentConnectors = useToolStore(
+ connectorSelectors.agentConnectors(effectiveAgentId),
+ isEqual,
+ );
+ const agentConnectorIdentifiers = useMemo(
+ () => (excludeAgentConnectors ? new Set(agentConnectors.map((c) => c.identifier)) : null),
+ [agentConnectors, excludeAgentConnectors],
+ );
const isConnectorsInit = useToolStore((s) => s.isConnectorsInit);
const fetchConnectors = useToolStore((s) => s.fetchConnectors);
useEffect(() => {
@@ -776,8 +809,11 @@ const AgentTool = memo<AgentToolProps>(
if (showWebBrowsing && isSearchEnabled && !tools.includes(WEB_BROWSING_IDENTIFIER)) {
tools.unshift(WEB_BROWSING_IDENTIFIER);
}
- return tools.filter((toolId) => !USER_HIDDEN_BUILTIN_SKILLS.has(toolId));
- }, [plugins, isSearchEnabled, showWebBrowsing]);
+ return tools.filter(
+ (toolId) =>
+ !USER_HIDDEN_BUILTIN_SKILLS.has(toolId) && !agentConnectorIdentifiers?.has(toolId),
+ );
+ }, [plugins, isSearchEnabled, showWebBrowsing, agentConnectorIdentifiers]);
return (
<>
diff --git a/src/features/ProfileEditor/AgentUserTools/UserToolsSection.test.tsx b/src/features/ProfileEditor/AgentUserTools/UserToolsSection.test.tsx
new file mode 100644
index 00000000000..79b80829214
--- /dev/null
+++ b/src/features/ProfileEditor/AgentUserTools/UserToolsSection.test.tsx
@@ -0,0 +1,112 @@
+/**
+ * @vitest-environment happy-dom
+ */
+import { render, screen } from '@testing-library/react';
+import type { ReactNode } from 'react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import UserToolsSection from './UserToolsSection';
+
+// Regression for the profile "double display" bug: an agent-scoped connector
+// (e.g. a Composio account bound to this agent) is pinned into `config.plugins`
+// for runtime gating. It is rendered in the "Agent Tools" section above; it must
+// NOT also be counted/shown in this base ("Workspace/User") section β€” where,
+// lacking a base-dimension manifest, it rendered as an extra "uninstalled" chip
+// and inflated the header count.
+
+const mocks = vi.hoisted(() => ({
+ toolState: {
+ // connectorSelectors.agentConnectors(agentId) reads s.agentConnectors[agentId]
+ agentConnectors: {} as Record<
+ string,
+ Array<{ agentId: string; id: string; identifier: string }>
+ >,
+ connectors: [] as unknown[],
+ },
+ agentConfig: { plugins: [] as unknown[] },
+}));
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+// Personal vs workspace only changes the label, not the count under test.
+vi.mock('@/business/client/hooks/useActiveWorkspaceId', () => ({
+ useActiveWorkspaceId: () => 'ws-1',
+}));
+
+// The chips themselves are rendered by AgentTool (covered separately); stub it
+// so this test isolates the header count wiring.
+vi.mock('@/features/ProfileEditor/AgentTool', () => ({ default: () => null }));
+vi.mock('@/features/ProfileEditor/PluginTag', () => ({ default: () => null }));
+
+vi.mock('@lobehub/ui', () => ({
+ Flexbox: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ Text: ({ children }: { children: ReactNode }) => <span data-testid="label">{children}</span>,
+}));
+vi.mock('@lobehub/ui/base-ui', () => ({
+ Button: ({ children }: { children: ReactNode }) => <button type="button">{children}</button>,
+}));
+
+// Apply the real selectors against the mock state.
+vi.mock('@/store/tool', () => ({
+ useToolStore: (sel: (s: unknown) => unknown) => sel(mocks.toolState),
+}));
+vi.mock('@/store/agent', () => ({
+ useAgentStore: (sel: (s: unknown) => unknown) => sel(undefined),
+}));
+vi.mock('@/store/agent/selectors', () => ({
+ agentSelectors: { getAgentConfigById: () => () => mocks.agentConfig },
+}));
+
+const renderSection = () =>
+ render(
+ <UserToolsSection
+ agentId="agent-1"
+ copyMode={false}
+ copying={false}
+ selected={new Set()}
+ toggleSelected={() => {}}
+ onCancelCopy={() => {}}
+ onConfirmCopy={() => {}}
+ />,
+ );
+
+const labelText = () => screen.getByTestId('label').textContent;
+
+describe('UserToolsSection β€” base tool count excludes agent-owned connectors', () => {
+ beforeEach(() => {
+ mocks.toolState.agentConnectors = {};
+ mocks.toolState.connectors = [];
+ mocks.agentConfig = { plugins: [] };
+ });
+
+ it('does not count an agent-owned connector identifier pinned in config.plugins', () => {
+ // google-drive is pinned for the agent AND is an agent-owned connector row β†’
+ // it belongs to the Agent Tools section, so this section's count must be 0.
+ mocks.agentConfig = { plugins: [{ identifier: 'google-drive', mode: 'pinned' }] };
+ mocks.toolState.agentConnectors = {
+ 'agent-1': [{ agentId: 'agent-1', id: 'c1', identifier: 'google-drive' }],
+ };
+
+ renderSection();
+
+ expect(labelText()).toContain('Β· 0');
+ });
+
+ it('still counts a genuine base pinned tool that is not an agent connector', () => {
+ mocks.agentConfig = {
+ plugins: [
+ { identifier: 'google-drive', mode: 'pinned' }, // agent-owned β†’ excluded
+ { identifier: 'some-user-plugin', mode: 'pinned' }, // base β†’ counted
+ ],
+ };
+ mocks.toolState.agentConnectors = {
+ 'agent-1': [{ agentId: 'agent-1', id: 'c1', identifier: 'google-drive' }],
+ };
+
+ renderSection();
+
+ expect(labelText()).toContain('Β· 1');
+ });
+});
diff --git a/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsx b/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsx
index 5615843695f..063be40848b 100644
--- a/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsx
+++ b/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsx
@@ -4,7 +4,7 @@ import { getActivePluginIds } from '@lobechat/types';
import { Flexbox, Text } from '@lobehub/ui';
import { Button } from '@lobehub/ui/base-ui';
import isEqual from 'fast-deep-equal';
-import { memo } from 'react';
+import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
@@ -44,7 +44,18 @@ const UserToolsSection = memo<Props>(
const { t } = useTranslation('setting');
const userConnectors = useToolStore(connectorSelectors.connectorList, isEqual);
const config = useAgentStore(agentSelectors.getAgentConfigById(agentId), isEqual);
- const userToolCount = getActivePluginIds(config?.plugins).length;
+ // Agent-owned/linked connector identifiers are shown in the Agent Tools
+ // section above (and excluded from this section's chips in `AgentTool`), so
+ // exclude them from the count too β€” otherwise the header would count a tool
+ // that renders in the section above, not here.
+ const agentConnectors = useToolStore(connectorSelectors.agentConnectors(agentId), isEqual);
+ const agentConnectorIdentifiers = useMemo(
+ () => new Set(agentConnectors.map((c) => c.identifier)),
+ [agentConnectors],
+ );
+ const userToolCount = getActivePluginIds(config?.plugins).filter(
+ (id) => !agentConnectorIdentifiers.has(id),
+ ).length;
// In a workspace, this section's base tools are the WORKSPACE dimension
// (`connector.list` is workspace-scoped), not the caller's personal tools β€”
// label it so the user knows the tools are shared workspace-scoped, not
@@ -104,7 +115,7 @@ const UserToolsSection = memo<Props>(
<Text style={{ fontSize: 12, fontWeight: 500 }} type={'secondary'}>
{baseToolsLabel} Β· {userToolCount}
</Text>
- <SharedAgentTool {...toolProps} agentId={agentId} />
+ <SharedAgentTool {...toolProps} excludeAgentConnectors agentId={agentId} />
</Flexbox>
);
},