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 {
|
||||||
|
EventName,
|
||||||
import { ConversationalExtension } from '@janhq/core'
|
ExtensionType,
|
||||||
|
Thread,
|
||||||
|
events,
|
||||||
|
ConversationalExtension,
|
||||||
|
} from '@janhq/core'
|
||||||
|
|
||||||
import { useAtomValue, useSetAtom } from 'jotai'
|
import { useAtomValue, useSetAtom } from 'jotai'
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,13 @@ import {
|
|||||||
ModelRuntimeParams,
|
ModelRuntimeParams,
|
||||||
Thread,
|
Thread,
|
||||||
ThreadState,
|
ThreadState,
|
||||||
|
ConversationalExtension,
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
import { ConversationalExtension } from '@janhq/core'
|
|
||||||
import { useAtom } from 'jotai'
|
import { useAtom } from 'jotai'
|
||||||
|
|
||||||
|
import useSetActiveThread from './useSetActiveThread'
|
||||||
|
|
||||||
import { extensionManager } from '@/extension/ExtensionManager'
|
import { extensionManager } from '@/extension/ExtensionManager'
|
||||||
import {
|
import {
|
||||||
threadModelRuntimeParamsAtom,
|
threadModelRuntimeParamsAtom,
|
||||||
@ -20,6 +23,7 @@ const useThreads = () => {
|
|||||||
const [threadModelRuntimeParams, setThreadModelRuntimeParams] = useAtom(
|
const [threadModelRuntimeParams, setThreadModelRuntimeParams] = useAtom(
|
||||||
threadModelRuntimeParamsAtom
|
threadModelRuntimeParamsAtom
|
||||||
)
|
)
|
||||||
|
const { setActiveThread } = useSetActiveThread()
|
||||||
|
|
||||||
const getThreads = async () => {
|
const getThreads = async () => {
|
||||||
try {
|
try {
|
||||||
@ -77,13 +81,16 @@ const useThreads = () => {
|
|||||||
setThreadStates(localThreadStates)
|
setThreadStates(localThreadStates)
|
||||||
setThreads(allThreads)
|
setThreads(allThreads)
|
||||||
setThreadModelRuntimeParams(threadModelParams)
|
setThreadModelRuntimeParams(threadModelParams)
|
||||||
|
if (allThreads.length > 0) {
|
||||||
|
setActiveThread(allThreads[0])
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getAllThreads: getThreads,
|
getThreads,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ import {
|
|||||||
export default function ThreadList() {
|
export default function ThreadList() {
|
||||||
const threads = useAtomValue(threadsAtom)
|
const threads = useAtomValue(threadsAtom)
|
||||||
const threadStates = useAtomValue(threadStatesAtom)
|
const threadStates = useAtomValue(threadStatesAtom)
|
||||||
const { getAllThreads } = useThreads()
|
const { getThreads } = useThreads()
|
||||||
const { assistants } = useGetAssistants()
|
const { assistants } = useGetAssistants()
|
||||||
const { requestCreateNewThread } = useCreateNewThread()
|
const { requestCreateNewThread } = useCreateNewThread()
|
||||||
const activeThread = useAtomValue(activeThreadAtom)
|
const activeThread = useAtomValue(activeThreadAtom)
|
||||||
@ -53,7 +53,7 @@ export default function ThreadList() {
|
|||||||
useSetActiveThread()
|
useSetActiveThread()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getAllThreads()
|
getThreads()
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user