Commit 3119a444 authored by Joel's avatar Joel

fix: message error happend title show error

parent 26866fbf
...@@ -78,7 +78,7 @@ const Plugins: FC<IPluginsProps> = ({ ...@@ -78,7 +78,7 @@ const Plugins: FC<IPluginsProps> = ({
> >
{isLoading {isLoading
? ( ? (
<div className='flex items-center h-[200px]'> <div className='flex items-center h-[166px]'>
<Loading type='area' /> <Loading type='area' />
</div> </div>
) )
......
...@@ -235,11 +235,14 @@ const Main: FC<IMainProps> = () => { ...@@ -235,11 +235,14 @@ const Main: FC<IMainProps> = () => {
}) })
}) })
setChatList(newChatList) setChatList(newChatList)
setErrorHappened(false)
}) })
} }
if (isNewConversation) if (isNewConversation) {
setChatList(generateNewChatListWithOpenstatement()) setChatList(generateNewChatListWithOpenstatement())
setErrorHappened(false)
}
setControlFocus(Date.now()) setControlFocus(Date.now())
} }
...@@ -405,7 +408,7 @@ const Main: FC<IMainProps> = () => { ...@@ -405,7 +408,7 @@ const Main: FC<IMainProps> = () => {
const [suggestQuestions, setSuggestQuestions] = useState<string[]>([]) const [suggestQuestions, setSuggestQuestions] = useState<string[]>([])
const [messageTaskId, setMessageTaskId] = useState('') const [messageTaskId, setMessageTaskId] = useState('')
const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false) const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false)
const [errorHappened, setErrorHappened] = useState(false)
const handleSend = async (message: string) => { const handleSend = async (message: string) => {
if (isResponsing) { if (isResponsing) {
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') }) notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
...@@ -462,6 +465,7 @@ const Main: FC<IMainProps> = () => { ...@@ -462,6 +465,7 @@ const Main: FC<IMainProps> = () => {
setHasStopResponded(false) setHasStopResponded(false)
setResponsingTrue() setResponsingTrue()
setErrorHappened(false)
setIsShowSuggestion(false) setIsShowSuggestion(false)
sendChatMessage(data, { sendChatMessage(data, {
...@@ -521,7 +525,9 @@ const Main: FC<IMainProps> = () => { ...@@ -521,7 +525,9 @@ const Main: FC<IMainProps> = () => {
setChatList(newListWithAnswer) setChatList(newListWithAnswer)
}, },
onError() { onError() {
setErrorHappened(true)
setResponsingFalse() setResponsingFalse()
// role back placeholder answer // role back placeholder answer
setChatList(produce(getChatList(), (draft) => { setChatList(produce(getChatList(), (draft) => {
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1) draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
...@@ -625,7 +631,7 @@ const Main: FC<IMainProps> = () => { ...@@ -625,7 +631,7 @@ const Main: FC<IMainProps> = () => {
) )
}> }>
<div className={cn(doShowSuggestion ? 'pb-[140px]' : (isResponsing ? 'pb-[113px]' : 'pb-[76px]'), 'relative grow h-[200px] mb-3.5 overflow-hidden')}> <div className={cn(doShowSuggestion ? 'pb-[140px]' : (isResponsing ? 'pb-[113px]' : 'pb-[76px]'), 'relative grow h-[200px] mb-3.5 overflow-hidden')}>
{(!isNewConversation || isResponsing) && ( {(!isNewConversation || isResponsing || errorHappened) && (
<div className='absolute z-10 top-0 left-0 right-0 flex items-center justify-between border-b border-gray-100 mobile:h-12 tablet:h-16 px-8 bg-white'> <div className='absolute z-10 top-0 left-0 right-0 flex items-center justify-between border-b border-gray-100 mobile:h-12 tablet:h-16 px-8 bg-white'>
<div className='text-gray-900'>{conversationName}</div> <div className='text-gray-900'>{conversationName}</div>
<div className='flex items-center shrink-0 ml-2 space-x-2'> <div className='flex items-center shrink-0 ml-2 space-x-2'>
...@@ -637,7 +643,7 @@ const Main: FC<IMainProps> = () => { ...@@ -637,7 +643,7 @@ const Main: FC<IMainProps> = () => {
)} )}
<div className={cn((!isNewConversation || isResponsing) && 'pt-[90px]', 'pc:w-[794px] max-w-full mobile:w-full mx-auto h-full overflow-y-auto')} ref={chatListDomRef}> <div className={cn((!isNewConversation || isResponsing) && 'pt-[90px]', 'pc:w-[794px] max-w-full mobile:w-full mx-auto h-full overflow-y-auto')} ref={chatListDomRef}>
<Chat <Chat
isShowConfigElem={isNewConversation && !chatList.some(item => item.isAnswer)} isShowConfigElem={isNewConversation && chatList.length === 0}
configElem={<Init configElem={<Init
modelId={modelId} modelId={modelId}
onModelChange={setModeId} onModelChange={setModeId}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment