Merge branch 'main' into 0xSage-patch-1
This commit is contained in:
commit
bdfc152916
@ -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'
|
||||
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}, [])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user