fix: preserve focused thread when navigating in jan app (#1814)
* fix: preserve focused thread when navigating in jan app Signed-off-by: James <james@jan.ai> * Update web/hooks/useThreads.ts Co-authored-by: Louis <louis@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> Co-authored-by: Louis <louis@jan.ai>
This commit is contained in:
parent
bb47d6869d
commit
7b1337aee7
@ -5,13 +5,14 @@ import {
|
|||||||
ConversationalExtension,
|
ConversationalExtension,
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
|
|
||||||
import { useAtom } from 'jotai'
|
import { useAtom, useAtomValue } from 'jotai'
|
||||||
|
|
||||||
import useSetActiveThread from './useSetActiveThread'
|
import useSetActiveThread from './useSetActiveThread'
|
||||||
|
|
||||||
import { extensionManager } from '@/extension/ExtensionManager'
|
import { extensionManager } from '@/extension/ExtensionManager'
|
||||||
import {
|
import {
|
||||||
ModelParams,
|
ModelParams,
|
||||||
|
activeThreadAtom,
|
||||||
threadModelParamsAtom,
|
threadModelParamsAtom,
|
||||||
threadStatesAtom,
|
threadStatesAtom,
|
||||||
threadsAtom,
|
threadsAtom,
|
||||||
@ -23,6 +24,7 @@ const useThreads = () => {
|
|||||||
const [threadModelRuntimeParams, setThreadModelRuntimeParams] = useAtom(
|
const [threadModelRuntimeParams, setThreadModelRuntimeParams] = useAtom(
|
||||||
threadModelParamsAtom
|
threadModelParamsAtom
|
||||||
)
|
)
|
||||||
|
const activeThread = useAtomValue(activeThreadAtom)
|
||||||
const { setActiveThread } = useSetActiveThread()
|
const { setActiveThread } = useSetActiveThread()
|
||||||
|
|
||||||
const getThreads = async () => {
|
const getThreads = async () => {
|
||||||
@ -84,7 +86,7 @@ const useThreads = () => {
|
|||||||
setThreadStates(localThreadStates)
|
setThreadStates(localThreadStates)
|
||||||
setThreads(allThreads)
|
setThreads(allThreads)
|
||||||
setThreadModelRuntimeParams(threadModelParams)
|
setThreadModelRuntimeParams(threadModelParams)
|
||||||
if (allThreads.length > 0) {
|
if (allThreads.length && !activeThread) {
|
||||||
setActiveThread(allThreads[0])
|
setActiveThread(allThreads[0])
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user