diff --git a/src/chat/chat_line.rs b/src/chat/chat_line.rs index 73261660..9f84fcd4 100644 --- a/src/chat/chat_line.rs +++ b/src/chat/chat_line.rs @@ -415,16 +415,24 @@ impl ChatLineRef { inner.label(id!(avatar_label)).set_text(text); } - pub fn set_message_text(&mut self, cx: &mut Cx, text: &str) { + pub fn set_message_text(&mut self, cx: &mut Cx, text: &str, is_streaming: bool) { let Some(mut inner) = self.borrow_mut() else { return; }; match inner.edition_state { + ChatLineState::Editable | ChatLineState::NotEditable => { - inner.text_input(id!(input)).set_text(text.trim()); - inner.label(id!(plain_text_message)).set_text(text.trim()); - inner.markdown(id!(markdown_message)).set_text(text.trim()); + if is_streaming && !text.is_empty() { + let output = format!("{}{}", text, "●"); + inner.text_input(id!(input)).set_text(&output.trim()); + inner.label(id!(plain_text_message)).set_text(&output.trim()); + inner.markdown(id!(markdown_message)).set_text(&output.trim()); + } else { + inner.text_input(id!(input)).set_text(text.trim()); + inner.label(id!(plain_text_message)).set_text(text.trim()); + inner.markdown(id!(markdown_message)).set_text(text.trim()); + } // We know only AI assistant messages could be empty, so it is never // displayed in user's chat lines. diff --git a/src/chat/chat_panel.rs b/src/chat/chat_panel.rs index facc0d9a..fe08f462 100644 --- a/src/chat/chat_panel.rs +++ b/src/chat/chat_panel.rs @@ -882,7 +882,6 @@ impl ChatPanel { chat_line_item.set_regenerate_button_visible(true); }; - chat_line_item.set_message_text(cx, &chat_line_data.content); chat_line_item.set_message_id(chat_line_data.id); // Disable actions for the last chat line when model is streaming @@ -894,8 +893,10 @@ impl ChatPanel { } ) && item_id == messages_count - 1 { + chat_line_item.set_message_text(cx, &chat_line_data.content, true); chat_line_item.set_actions_enabled(cx, false); } else { + chat_line_item.set_message_text(cx, &chat_line_data.content, false); chat_line_item.set_actions_enabled(cx, true); }