Download src/hooks/useMergedClients.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 745 Bytes
-
https://huggingface.co/chenbhao/codev/resolve/e91c8197c9918ff9e5df3140e8c36282bb30e9a2/src/hooks/useMergedClients.ts
- Command line
-
hf download hf://chenbhao/codev@e91c8197c9918ff9e5df3140e8c36282bb30e9a2/src/hooks/useMergedClients.ts
-
curl -L -o useMergedClients.ts https://huggingface.co/chenbhao/codev/resolve/e91c8197c9918ff9e5df3140e8c36282bb30e9a2/src/hooks/useMergedClients.ts
745 Bytes
| import uniqBy from 'lodash-es/uniqBy.js' | |
| import { useMemo } from 'react' | |
| import type { MCPServerConnection } from '../services/mcp/types.js' | |
| export function mergeClients( | |
| initialClients: MCPServerConnection[] | undefined, | |
| mcpClients: readonly MCPServerConnection[] | undefined, | |
| ): MCPServerConnection[] { | |
| if (initialClients && mcpClients && mcpClients.length > 0) { | |
| return uniqBy([...initialClients, ...mcpClients], 'name') | |
| } | |
| return initialClients || [] | |
| } | |
| export function useMergedClients( | |
| initialClients: MCPServerConnection[] | undefined, | |
| mcpClients: MCPServerConnection[] | undefined, | |
| ): MCPServerConnection[] { | |
| return useMemo( | |
| () => mergeClients(initialClients, mcpClients), | |
| [initialClients, mcpClients], | |
| ) | |
| } | |