Merge branch 'main' into 0xSage-patch-1

This commit is contained in:
Hieu 2023-12-21 02:18:47 +09:00 committed by GitHub
commit bdfc152916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 7 deletions

View File

@ -1,6 +1,10 @@
import { EventName, ExtensionType, Thread, events } from '@janhq/core'
import { ConversationalExtension } from '@janhq/core'
import {
EventName,
ExtensionType,
Thread,
events,
ConversationalExtension,
} from '@janhq/core'
import { useAtomValue, useSetAtom } from 'jotai'

View File

@ -3,10 +3,13 @@ import {
ModelRuntimeParams,
Thread,
ThreadState,
ConversationalExtension,
} from '@janhq/core'
import { ConversationalExtension } from '@janhq/core'
import { useAtom } from 'jotai'
import useSetActiveThread from './useSetActiveThread'
import { extensionManager } from '@/extension/ExtensionManager'
import {
threadModelRuntimeParamsAtom,
@ -20,6 +23,7 @@ const useThreads = () => {
const [threadModelRuntimeParams, setThreadModelRuntimeParams] = useAtom(
threadModelRuntimeParamsAtom
)
const { setActiveThread } = useSetActiveThread()
const getThreads = async () => {
try {
@ -77,13 +81,16 @@ const useThreads = () => {
setThreadStates(localThreadStates)
setThreads(allThreads)
setThreadModelRuntimeParams(threadModelParams)
if (allThreads.length > 0) {
setActiveThread(allThreads[0])
}
} catch (error) {
console.error(error)
}
}
return {
getAllThreads: getThreads,
getThreads,
}
}

View File

@ -42,7 +42,7 @@ import {
export default function ThreadList() {
const threads = useAtomValue(threadsAtom)
const threadStates = useAtomValue(threadStatesAtom)
const { getAllThreads } = useThreads()
const { getThreads } = useThreads()
const { assistants } = useGetAssistants()
const { requestCreateNewThread } = useCreateNewThread()
const activeThread = useAtomValue(activeThreadAtom)
@ -53,7 +53,7 @@ export default function ThreadList() {
useSetActiveThread()
useEffect(() => {
getAllThreads()
getThreads()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])