From 830f45e56abf4f78e62253f2f0f658b5ba4a4dca Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Mon, 13 Jan 2025 17:03:45 -0500 Subject: [PATCH] assistant2: Add floating indicator when a response is streaming (#23096) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds a separate indicator at the bottom of the thread that shows when a response is being streamed (as well as how to cancel it): Screenshot 2025-01-13 at 4 19 07 PM Release Notes: - N/A --- crates/assistant2/src/active_thread.rs | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/assistant2/src/active_thread.rs b/crates/assistant2/src/active_thread.rs index 5ef33c9352c73e084d567c0fbc6742a39e795d9d..86a1eb50fec4902ca8b6e58b5892ddb634343e2b 100644 --- a/crates/assistant2/src/active_thread.rs +++ b/crates/assistant2/src/active_thread.rs @@ -344,7 +344,30 @@ impl ActiveThread { } impl Render for ActiveThread { - fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { - list(self.list_state.clone()).flex_1().py_1() + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { + let is_streaming_completion = self.thread.read(cx).is_streaming(); + + v_flex() + .size_full() + .child(list(self.list_state.clone()).flex_grow()) + .child( + h_flex() + .absolute() + .bottom_1() + .flex_shrink() + .justify_center() + .w_full() + .when(is_streaming_completion, |parent| { + parent.child( + h_flex() + .gap_2() + .p_1p5() + .rounded_md() + .bg(cx.theme().colors().elevated_surface_background) + .child(Label::new("Generating…").size(LabelSize::Small)) + .child(Label::new("esc to cancel").size(LabelSize::Small)), + ) + }), + ) } }