From 6cf2fa02e59b776bf91039b821d557296e9bc0aa Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Fri, 19 May 2023 00:24:25 +0800 Subject: [PATCH] fix: #1612 fill empty message with a placeholder --- app/components/chat.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 49244ccb..758900a9 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -487,18 +487,26 @@ export function Chat() { // stop response const onUserStop = (messageId: number) => { + ChatControllerPool.stop(sessionIndex, messageId); + }; + + useEffect(() => { chatStore.updateCurrentSession((session) => { const stopTiming = Date.now() - REQUEST_TIMEOUT_MS; session.messages.forEach((m) => { // check if should stop all stale messages - if (m.streaming && new Date(m.date).getTime() < stopTiming) { - m.isError = false; - m.streaming = false; + if (new Date(m.date).getTime() < stopTiming) { + if (m.streaming) { + m.streaming = false; + } + + if (m.content.length === 0) { + m.content = "No content in this message."; + } } }); }); - ChatControllerPool.stop(sessionIndex, messageId); - }; + }, []); // check if should send message const onInputKeyDown = (e: React.KeyboardEvent) => {