Skip to content

Commit 090c16f

Browse files
Merge pull request #380 from ryanhopperlowe/fix/tool-catalog-enhancement-fixes
fix: Tool catalog enhancement bugfixes
2 parents 4021926 + 71a3407 commit 090c16f

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

components/chat/chatBar/commands.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ import { useFilePicker } from 'use-file-picker';
6161

6262
const Command = {
6363
Restart: 'restart',
64-
ToolCatalog: 'catalog',
65-
AddExternalTools: 'add',
64+
ToolCatalog: 'addToolFromCatalog',
65+
AddExternalTools: 'addToolFromUrl',
6666
Workspace: 'workspace',
6767
Knowledge: 'knowledge',
6868
} as const;
@@ -269,6 +269,7 @@ export default forwardRef<ChatCommandsRef, CommandsProps>(
269269

270270
setLoadingTool(null);
271271
urlToolModal.onClose();
272+
setIsCatalogOpen(false);
272273

273274
getToolDisplayName(loadingToolRef.current).then((name) => {
274275
setMessages((prev) => [

components/chat/chatBar/search/catalog.tsx

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useDebouncedValue } from '@/hooks/useDebounce';
2-
import { useFetch } from '@/hooks/useFetch';
3-
import { FeaturedTools, ToolsApiResponse } from '@/model/tools';
2+
import { FeaturedTools } from '@/model/tools';
43
import {
54
Card,
65
Listbox,
@@ -58,12 +57,6 @@ export default forwardRef<ToolCatalogRef, CatalogListboxProps>(
5857

5958
const debouncedQuery = useDebouncedValue(query, 250);
6059

61-
const fetchTools = useFetch<ToolsApiResponse>(
62-
'https://tools.gptscript.ai/api/search?q=' + debouncedQuery,
63-
{ disabled: !debouncedQuery, clearOnDisabled: true }
64-
);
65-
const { tools: toolsFromQuery = {} } = fetchTools.data ?? {};
66-
6760
const featuredResults = useMemo(() => {
6861
const flattened = (featuredTools: FeaturedTools) =>
6962
Object.entries(featuredTools).flatMap(([category, tools]) =>
@@ -107,27 +100,6 @@ export default forwardRef<ToolCatalogRef, CatalogListboxProps>(
107100
const { resultsWithIndexes, lastIndex } = useMemo(() => {
108101
let index = 0;
109102
const featuredCategories = Object.entries(featuredResults);
110-
111-
if (Object.keys(toolsFromQuery).length !== 0) {
112-
featuredCategories.push([
113-
'Community Tools',
114-
Object.entries(toolsFromQuery)
115-
.filter(
116-
([name]) =>
117-
!Object.values(featuredResults)
118-
.flat()
119-
.some((tool) => tool.url === name)
120-
)
121-
.map(([toolName, tools]) => ({
122-
url: toolName,
123-
name: toolName.split('/').pop()?.replace(/-/g, ' ') ?? '',
124-
description: tools[0]?.description ?? '',
125-
tags: [],
126-
icon: <></>,
127-
})),
128-
]);
129-
}
130-
131103
const resultsWithIndexes = featuredCategories.map(
132104
([category, tools]) =>
133105
[
@@ -151,7 +123,7 @@ export default forwardRef<ToolCatalogRef, CatalogListboxProps>(
151123
resultsWithIndexes,
152124
lastIndex,
153125
};
154-
}, [featuredResults, toolsFromQuery]);
126+
}, [featuredResults]);
155127

156128
const [focusedItem, setFocusedItem] = useState<number | null>(null);
157129

0 commit comments

Comments
 (0)