Skip to content

Commit 0993149

Browse files
committed
optimize rendering chat bubble
1 parent 95c0ee3 commit 0993149

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

AgentCrew/modules/chat/message/handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ async def get_assistant_response(
196196
if chunk_text:
197197
# End thinking when chunk_text start
198198
if not end_thinking and start_thinking:
199-
self._notify("thinking_completed")
199+
self._notify("thinking_completed", thinking_content)
200200
end_thinking = True
201201
# Notify about response progress
202202
if not self.agent.is_streaming():
@@ -232,7 +232,7 @@ async def get_assistant_response(
232232
},
233233
)
234234
self._messages_append(assistant_message)
235-
self._notify("assistant_message_added", assistant_message)
235+
self._notify("assistant_message_added", assistant_response)
236236

237237
# This should allows YOLO can be configured on-the-fly without recalled to config too many times
238238
config_management = ConfigManagement()

AgentCrew/modules/gui/components/message_handlers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def handle_user_message_created(self, data):
5151

5252
def handle_response_completed(self, data):
5353
"""Handle response completion."""
54+
self.chat_window.chunk_buffer = data
5455
if self.chat_window.current_response_bubble:
5556
self.chat_window.current_response_bubble.message_index = (
5657
len(self.chat_window.message_handler.streamline_messages) - 1
@@ -105,6 +106,8 @@ def _render_buffered_chunks(self):
105106
self.chat_window.chat_components.display_response_chunk(
106107
self.chat_window.chunk_buffer
107108
)
109+
# Release the buffer after rendering
110+
self.chat_window.chunk_buffer = ""
108111

109112
def _render_buffered_thinking(self):
110113
"""Render the latest buffered thinking chunk."""
@@ -116,3 +119,4 @@ def _render_buffered_thinking(self):
116119
self.chat_window.chat_components.display_thinking_chunk(
117120
self.chat_window.thinking_buffer
118121
)
122+
self.chat_window.thinking_buffer = "" # Clear the buffer after rendering

0 commit comments

Comments
 (0)