/ hooks / useMergedCommands.ts
useMergedCommands.ts
 1  import uniqBy from 'lodash-es/uniqBy.js'
 2  import { useMemo } from 'react'
 3  import type { Command } from '../commands.js'
 4  
 5  export function useMergedCommands(
 6    initialCommands: Command[],
 7    mcpCommands: Command[],
 8  ): Command[] {
 9    return useMemo(() => {
10      if (mcpCommands.length > 0) {
11        return uniqBy([...initialCommands, ...mcpCommands], 'name')
12      }
13      return initialCommands
14    }, [initialCommands, mcpCommands])
15  }