show feedback message after /Compact command (#2162)

This PR updates ChatWidget to ensure that when AgentMessage,
AgentReasoning, or AgentReasoningRawContent events arrive without any
streamed deltas, the final text from the event is rendered before the
stream is finalized. Previously, these handlers ignored the event text
in such cases, relying solely on prior deltas.

<img width="603" height="189" alt="image"
src="https://github.com/user-attachments/assets/868516f2-7963-4603-9af4-adb1b1eda61e"
/>
This commit is contained in:
aibrahim-oai
2025-08-11 10:41:23 -07:00
committed by GitHub
parent 0aa7efe05b
commit fa0a879444

View File

@@ -311,10 +311,12 @@ impl ChatWidget<'_> {
self.request_redraw();
}
EventMsg::AgentMessage(AgentMessageEvent { message: _ }) => {
// Final assistant answer: commit all remaining rows and close with
// a blank line. Use the final text if provided, otherwise rely on
// streamed deltas already in the builder.
EventMsg::AgentMessage(AgentMessageEvent { message }) => {
// AgentMessage: if no deltas were streamed, render the final text.
if self.current_stream != Some(StreamKind::Answer) && !message.is_empty() {
self.begin_stream(StreamKind::Answer);
self.stream_push_and_maybe_commit(&message);
}
self.finalize_stream(StreamKind::Answer);
self.request_redraw();
}
@@ -332,8 +334,12 @@ impl ChatWidget<'_> {
self.stream_push_and_maybe_commit(&delta);
self.request_redraw();
}
EventMsg::AgentReasoning(AgentReasoningEvent { text: _ }) => {
// Final reasoning: commit remaining rows and close with a blank.
EventMsg::AgentReasoning(AgentReasoningEvent { text }) => {
// Final reasoning: if no deltas were streamed, render the final text.
if self.current_stream != Some(StreamKind::Reasoning) && !text.is_empty() {
self.begin_stream(StreamKind::Reasoning);
self.stream_push_and_maybe_commit(&text);
}
self.finalize_stream(StreamKind::Reasoning);
self.request_redraw();
}
@@ -346,8 +352,12 @@ impl ChatWidget<'_> {
self.stream_push_and_maybe_commit(&delta);
self.request_redraw();
}
EventMsg::AgentReasoningRawContent(AgentReasoningRawContentEvent { text: _ }) => {
// Finalize the raw reasoning stream just like the summarized reasoning event.
EventMsg::AgentReasoningRawContent(AgentReasoningRawContentEvent { text }) => {
// Final raw reasoning content: if no deltas were streamed, render the final text.
if self.current_stream != Some(StreamKind::Reasoning) && !text.is_empty() {
self.begin_stream(StreamKind::Reasoning);
self.stream_push_and_maybe_commit(&text);
}
self.finalize_stream(StreamKind::Reasoning);
self.request_redraw();
}