diff --git a/packages/ui/src/hooks/useSearchShortcut.jsx b/packages/ui/src/hooks/useSearchShortcut.jsx
index 2fc598a0fdb..fedff244c54 100644
--- a/packages/ui/src/hooks/useSearchShortcut.jsx
+++ b/packages/ui/src/hooks/useSearchShortcut.jsx
@@ -6,6 +6,9 @@ const isMac = getOS() === 'macos'
const useSearchShorcut = (inputRef) => {
useEffect(() => {
const component = inputRef.current
+
+ if (!component) return // Check if inputRef.current is defined
+
const handleKeyDown = (event) => {
if ((isMac && event.metaKey && event.key === 'f') || (!isMac && event.ctrlKey && event.key === 'f')) {
event.preventDefault()
@@ -17,14 +20,16 @@ const useSearchShorcut = (inputRef) => {
if (event.key === 'Escape') component.blur()
}
- inputRef.current.addEventListener('keydown', handleInputEscape)
+ component.addEventListener('keydown', handleInputEscape)
document.addEventListener('keydown', handleKeyDown)
return () => {
- component.addEventListener('keydown', handleInputEscape)
+ if (component) {
+ component.removeEventListener('keydown', handleInputEscape)
+ }
document.removeEventListener('keydown', handleKeyDown)
}
- })
+ }, [inputRef]) // Add inputRef to the dependency array to ensure the effect is re-applied if inputRef changes
}
export default useSearchShorcut
diff --git a/packages/ui/src/views/assistants/index.jsx b/packages/ui/src/views/assistants/index.jsx
index 85f9fc2aa0f..06694696965 100644
--- a/packages/ui/src/views/assistants/index.jsx
+++ b/packages/ui/src/views/assistants/index.jsx
@@ -43,6 +43,11 @@ const Assistants = () => {
setShowLoadDialog(true)
}
+ const [search, setSearch] = useState('')
+ const onSearchChange = (event) => {
+ setSearch(event.target.value)
+ }
+
const onAssistantSelected = (selectedOpenAIAssistantId, credential) => {
setShowLoadDialog(false)
addNew(selectedOpenAIAssistantId, credential)
@@ -78,6 +83,11 @@ const Assistants = () => {
getAllAssistantsApi.request()
}
+ function filterAssistants(data) {
+ const parsedData = JSON.parse(data.details)
+ return parsedData && parsedData.name && parsedData.name.toLowerCase().indexOf(search.toLowerCase()) > -1
+ }
+
useEffect(() => {
getAllAssistantsApi.request()
@@ -101,7 +111,12 @@ const Assistants = () => {
) : (
-
+