Skip to content

Commit

Permalink
fix stop streaming when user delete or clean thread
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 5, 2024
1 parent 9cf1701 commit 51f8d01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion web/screens/Chat/ThreadList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect } from 'react'

import { MessageStatus } from '@janhq/core'
import {
Modal,
ModalTrigger,
Expand Down Expand Up @@ -33,6 +34,7 @@ import useThreads from '@/hooks/useThreads'

import { displayDate } from '@/utils/datetime'

import { getCurrentChatMessagesAtom } from '@/helpers/atoms/ChatMessage.atom'
import {
activeThreadAtom,
threadStatesAtom,
Expand All @@ -48,6 +50,7 @@ export default function ThreadList() {
const activeThread = useAtomValue(activeThreadAtom)
const { deleteThread, cleanThread } = useDeleteThread()
const { downloadedModels } = useGetDownloadedModels()
const messages = useAtomValue(getCurrentChatMessagesAtom)

const { activeThreadId, setActiveThread: onThreadClick } =
useSetActiveThread()
Expand Down Expand Up @@ -89,7 +92,14 @@ export default function ThreadList() {
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`
)}
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="flex justify-between">
Expand Down

0 comments on commit 51f8d01

Please sign in to comment.