From 45006e8fbe89309339134b9208d10bb49c438153 Mon Sep 17 00:00:00 2001 From: Guocork Date: Fri, 6 Sep 2024 11:28:22 +0800 Subject: [PATCH 1/2] fix-issue-206 --- src/data/chats/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/chats/mod.rs b/src/data/chats/mod.rs index 26efe676..e935220b 100644 --- a/src/data/chats/mod.rs +++ b/src/data/chats/mod.rs @@ -107,6 +107,8 @@ impl Chats { pub fn cancel_chat_streaming(&mut self) { if let Some(chat) = self.get_current_chat() { chat.borrow_mut().cancel_streaming(self.backend.as_ref()); + let mut chat = self.get_current_chat().unwrap().borrow_mut(); + chat.messages.pop(); } } From c47bab2afac24fb59831eca07d583865d585cb32 Mon Sep 17 00:00:00 2001 From: Guocork Date: Mon, 9 Sep 2024 15:26:18 +0800 Subject: [PATCH 2/2] add logic --- src/data/chats/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/data/chats/mod.rs b/src/data/chats/mod.rs index e935220b..eff312c9 100644 --- a/src/data/chats/mod.rs +++ b/src/data/chats/mod.rs @@ -108,7 +108,10 @@ impl Chats { if let Some(chat) = self.get_current_chat() { chat.borrow_mut().cancel_streaming(self.backend.as_ref()); let mut chat = self.get_current_chat().unwrap().borrow_mut(); - chat.messages.pop(); + let message = chat.messages.last_mut().unwrap(); + if message.content.trim().is_empty() { + chat.messages.pop(); + } } }