Skip to content

Commit 9e6fdf8

Browse files
authored
fix/no-assistant-available-fresh-install (#876)
1 parent efdc776 commit 9e6fdf8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

web/containers/Layout/TopBar/index.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CommandSearch from '@/containers/Layout/TopBar/CommandSearch'
77
import { MainViewState } from '@/constants/screens'
88

99
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
10-
import useGetAssistants from '@/hooks/useGetAssistants'
10+
import useGetAssistants, { getAssistants } from '@/hooks/useGetAssistants'
1111
import { useMainViewState } from '@/hooks/useMainViewState'
1212

1313
import { showRightSideBarAtom } from '@/screens/Chat/Sidebar'
@@ -33,10 +33,18 @@ const TopBar = () => {
3333

3434
const onCreateConversationClick = async () => {
3535
if (assistants.length === 0) {
36-
alert('No assistant available')
37-
return
36+
await getAssistants().then((res) => {
37+
if (res) {
38+
if (res.length === 0) {
39+
alert('No assistant available')
40+
return
41+
}
42+
requestCreateNewThread(res[0])
43+
}
44+
})
45+
} else {
46+
requestCreateNewThread(assistants[0])
3847
}
39-
requestCreateNewThread(assistants[0])
4048
}
4149

4250
return (

web/hooks/useGetAssistants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Assistant, ExtensionType, AssistantExtension } from '@janhq/core'
44

55
import { extensionManager } from '@/extension/ExtensionManager'
66

7-
const getAssistants = async (): Promise<Assistant[]> => {
7+
export const getAssistants = async (): Promise<Assistant[]> => {
88
return (
99
extensionManager
1010
.get<AssistantExtension>(ExtensionType.Assistant)

0 commit comments

Comments
 (0)