fix stop streaming when user delete or clean thread
This commit is contained in:
parent
9cf1701471
commit
51f8d011fb
@ -1,5 +1,6 @@
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
|
|
||||||
|
import { MessageStatus } from '@janhq/core'
|
||||||
import {
|
import {
|
||||||
Modal,
|
Modal,
|
||||||
ModalTrigger,
|
ModalTrigger,
|
||||||
@ -33,6 +34,7 @@ import useThreads from '@/hooks/useThreads'
|
|||||||
|
|
||||||
import { displayDate } from '@/utils/datetime'
|
import { displayDate } from '@/utils/datetime'
|
||||||
|
|
||||||
|
import { getCurrentChatMessagesAtom } from '@/helpers/atoms/ChatMessage.atom'
|
||||||
import {
|
import {
|
||||||
activeThreadAtom,
|
activeThreadAtom,
|
||||||
threadStatesAtom,
|
threadStatesAtom,
|
||||||
@ -48,6 +50,7 @@ export default function ThreadList() {
|
|||||||
const activeThread = useAtomValue(activeThreadAtom)
|
const activeThread = useAtomValue(activeThreadAtom)
|
||||||
const { deleteThread, cleanThread } = useDeleteThread()
|
const { deleteThread, cleanThread } = useDeleteThread()
|
||||||
const { downloadedModels } = useGetDownloadedModels()
|
const { downloadedModels } = useGetDownloadedModels()
|
||||||
|
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
||||||
|
|
||||||
const { activeThreadId, setActiveThread: onThreadClick } =
|
const { activeThreadId, setActiveThread: onThreadClick } =
|
||||||
useSetActiveThread()
|
useSetActiveThread()
|
||||||
@ -89,7 +92,14 @@ export default function ThreadList() {
|
|||||||
className={twMerge(
|
className={twMerge(
|
||||||
`group/message relative mb-1 flex cursor-pointer flex-col transition-all hover:rounded-lg hover:bg-gray-100 hover:dark:bg-secondary/50`
|
`group/message relative mb-1 flex cursor-pointer flex-col transition-all hover:rounded-lg hover:bg-gray-100 hover:dark:bg-secondary/50`
|
||||||
)}
|
)}
|
||||||
onClick={() => onThreadClick(thread)}
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
messages[messages.length - 1]?.status !==
|
||||||
|
MessageStatus.Pending
|
||||||
|
) {
|
||||||
|
onThreadClick(thread)
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div className="relative z-10 p-4 py-4">
|
<div className="relative z-10 p-4 py-4">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user