import { CheckIcon, ChevronLeftIcon, PlugIcon, RefreshCwIcon, Loader2Icon, Settings2Icon, } from "lucide-react"; import { useState, type ReactNode } from "react"; import { ConnectionAccountPicker, type ConnectionAccountControls, } from "./capabilities/connection-account-picker"; import type { FirstPartyMcpToolName } from "@opengeni/contracts"; import { CapabilityLogo } from "./capabilities/capability-logo"; import { ConnectorAction } from "../../ui/composer-menu-action"; import { ComposerMenuHeader, ComposerMenuSwitch, ComposerMenuSwitchIndicator, ComposerMenuRowsSkeleton, } from "../../ui/composer-menu"; import { MENU_BACK_BUTTON_CLASS, MENU_CHECK_CLASS, MENU_LABEL_CLASS, MENU_NOTE_CLASS, } from "../../ui/menu-styles"; import { cn } from "../lib/utils"; import type { SessionToolSelection } from "./pickers"; import { isComposerConnector, type McpServerOption } from "../lib/session-tools"; export type SessionConnectorsMenuProps = { presentation?: "menu" | "dialog" | undefined; servers: McpServerOption[]; firstPartyTools: ReadonlyArray<{ id: FirstPartyMcpToolName; name: string }>; selection: SessionToolSelection; onChange: (selection: SessionToolSelection) => void; /** Header switch. Off = read-only workspace list; on = row toggles. */ customizing?: boolean | undefined; onCustomizingChange?: ((customizing: boolean) => void) | undefined; leading?: ReactNode | undefined; onReconnect?: ((serverId: string) => void) | undefined; loading?: boolean | undefined; error?: string | null | undefined; busyId?: string | null | undefined; accountControls?: ConnectionAccountControls | undefined; }; /** Connected apps for one chat. Built-in tools follow the agent's capabilities (+ > Capabilities). */ export function SessionConnectorsMenuBody(props: SessionConnectorsMenuProps) { const connectors = props.servers.filter(isComposerConnector); const customizing = props.customizing === true; const [settingsId, setSettingsId] = useState(null); const settingsServer = connectors.find((server) => server.id === settingsId); const accounts = props.accountControls; const changeConnector = (serverId: string, enabled: boolean) => { const next = new Set(props.selection.mcpServerIds); if (enabled) next.add(serverId); else next.delete(serverId); props.onCustomizingChange?.(true); props.onChange({ mcpServerIds: next, firstPartyToolIds: new Set(props.selection.firstPartyToolIds), }); }; if (settingsServer && accounts) { return ( <> setSettingsId(null)} >