Skip to content

Commit

Permalink
fix: #1612 fill empty message with a placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa committed May 18, 2023
1 parent 1a8cb87 commit 6cf2fa0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLTextAreaElement>) => {
Expand Down

0 comments on commit 6cf2fa0

Please sign in to comment.