diff --git a/components/chat/chatBar/commands.tsx b/components/chat/chatBar/commands.tsx index 3dbd1cf2..dc2774c2 100644 --- a/components/chat/chatBar/commands.tsx +++ b/components/chat/chatBar/commands.tsx @@ -61,8 +61,8 @@ import { useFilePicker } from 'use-file-picker'; const Command = { Restart: 'restart', - ToolCatalog: 'catalog', - AddExternalTools: 'add', + ToolCatalog: 'addToolFromCatalog', + AddExternalTools: 'addToolFromUrl', Workspace: 'workspace', Knowledge: 'knowledge', } as const; @@ -269,6 +269,7 @@ export default forwardRef( setLoadingTool(null); urlToolModal.onClose(); + setIsCatalogOpen(false); getToolDisplayName(loadingToolRef.current).then((name) => { setMessages((prev) => [ diff --git a/components/chat/chatBar/search/catalog.tsx b/components/chat/chatBar/search/catalog.tsx index 3ce42117..9db01e26 100644 --- a/components/chat/chatBar/search/catalog.tsx +++ b/components/chat/chatBar/search/catalog.tsx @@ -1,6 +1,5 @@ import { useDebouncedValue } from '@/hooks/useDebounce'; -import { useFetch } from '@/hooks/useFetch'; -import { FeaturedTools, ToolsApiResponse } from '@/model/tools'; +import { FeaturedTools } from '@/model/tools'; import { Card, Listbox, @@ -58,12 +57,6 @@ export default forwardRef( const debouncedQuery = useDebouncedValue(query, 250); - const fetchTools = useFetch( - 'https://tools.gptscript.ai/api/search?q=' + debouncedQuery, - { disabled: !debouncedQuery, clearOnDisabled: true } - ); - const { tools: toolsFromQuery = {} } = fetchTools.data ?? {}; - const featuredResults = useMemo(() => { const flattened = (featuredTools: FeaturedTools) => Object.entries(featuredTools).flatMap(([category, tools]) => @@ -107,27 +100,6 @@ export default forwardRef( const { resultsWithIndexes, lastIndex } = useMemo(() => { let index = 0; const featuredCategories = Object.entries(featuredResults); - - if (Object.keys(toolsFromQuery).length !== 0) { - featuredCategories.push([ - 'Community Tools', - Object.entries(toolsFromQuery) - .filter( - ([name]) => - !Object.values(featuredResults) - .flat() - .some((tool) => tool.url === name) - ) - .map(([toolName, tools]) => ({ - url: toolName, - name: toolName.split('/').pop()?.replace(/-/g, ' ') ?? '', - description: tools[0]?.description ?? '', - tags: [], - icon: <>, - })), - ]); - } - const resultsWithIndexes = featuredCategories.map( ([category, tools]) => [ @@ -151,7 +123,7 @@ export default forwardRef( resultsWithIndexes, lastIndex, }; - }, [featuredResults, toolsFromQuery]); + }, [featuredResults]); const [focusedItem, setFocusedItem] = useState(null);