fix: app picks model automatically edge cases (#4322)

This commit is contained in:
Louis 2024-12-23 15:52:18 +07:00 committed by GitHub
parent 171dad1eca
commit df1c465fd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 9 deletions

View File

@ -183,10 +183,7 @@ const ModelDropdown = ({
if (!activeThread) return
const modelId = activeAssistant?.model?.id
let model = downloadedModels.find((model) => model.id === modelId)
if (!model) {
model = undefined
}
const model = downloadedModels.find((model) => model.id === modelId)
setSelectedModel(model)
}, [
recommendedModel,

View File

@ -8,6 +8,8 @@ import { currentPromptAtom } from '@/containers/Providers/Jotai'
import { toaster } from '@/containers/Toast'
import useSetActiveThread from './useSetActiveThread'
import { extensionManager } from '@/extension/ExtensionManager'
import { deleteChatMessageAtom as deleteChatMessagesAtom } from '@/helpers/atoms/ChatMessage.atom'
@ -27,6 +29,7 @@ export default function useDeleteThread() {
const deleteMessages = useSetAtom(deleteChatMessagesAtom)
const deleteThreadState = useSetAtom(deleteThreadStateAtom)
const { setActiveThread } = useSetActiveThread()
const cleanThread = useCallback(
async (threadId: string) => {
@ -86,7 +89,7 @@ export default function useDeleteThread() {
type: 'success',
})
if (availableThreads.length > 0) {
setActiveThreadId(availableThreads[0].id)
setActiveThread(availableThreads[0])
} else {
setActiveThreadId(undefined)
}

View File

@ -32,12 +32,9 @@ const Tools = () => {
useEffect(() => {
if (!activeThread) return
let model = downloadedModels.find(
const model = downloadedModels.find(
(model) => model.id === activeAssistant?.model.id
)
if (!model) {
model = recommendedModel
}
setSelectedModel(model)
}, [
recommendedModel,