Skip to content

Commit

Permalink
fix: app picks model automatically edge cases (#4322)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Dec 23, 2024
1 parent 171dad1 commit df1c465
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions web/containers/ModelDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion web/hooks/useDeleteThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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) => {
Expand Down Expand Up @@ -86,7 +89,7 @@ export default function useDeleteThread() {
type: 'success',
})
if (availableThreads.length > 0) {
setActiveThreadId(availableThreads[0].id)
setActiveThread(availableThreads[0])
} else {
setActiveThreadId(undefined)
}
Expand Down
5 changes: 1 addition & 4 deletions web/screens/Thread/ThreadRightPanel/Tools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit df1c465

Please sign in to comment.