From 34f8bb246a04ec262dd6f2cd842ade54f8440b8a Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 27 Dec 2024 13:54:35 -0300 Subject: [PATCH] assistant2: Scroll to the bottom when you submit a new message (#22451) Up until now, in the assistant 2, if you scrolled up either while a message was being generated or after it's been generated, then submitted a new message, you'd keep your scroll position. Now, with this PR, if your scroll position is somewhere else that's not the bottom, as you submit a new message, you'll be back at the bottom. https://github.com/user-attachments/assets/8b111c10-27ff-4d7b-9b10-4c31093c6457 Release Notes: - N/A Co-authored-by: Agus Zubiaga --- crates/assistant2/src/active_thread.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/assistant2/src/active_thread.rs b/crates/assistant2/src/active_thread.rs index 59e1604c3ac189fcf38405bd9f8ee0205667dec1..9c5dc6a8a177d9ebca14020b6d490783d9c83ff5 100644 --- a/crates/assistant2/src/active_thread.rs +++ b/crates/assistant2/src/active_thread.rs @@ -4,8 +4,8 @@ use assistant_tool::ToolWorkingSet; use collections::HashMap; use gpui::{ list, AbsoluteLength, AnyElement, AppContext, DefiniteLength, EdgesRefinement, Empty, Length, - ListAlignment, ListState, Model, StyleRefinement, Subscription, TextStyleRefinement, View, - WeakView, + ListAlignment, ListOffset, ListState, Model, StyleRefinement, Subscription, + TextStyleRefinement, View, WeakView, }; use language::LanguageRegistry; use language_model::Role; @@ -153,6 +153,10 @@ impl ActiveThread { ) }); self.rendered_messages_by_id.insert(*id, markdown); + self.list_state.scroll_to(ListOffset { + item_ix: old_len, + offset_in_item: Pixels(0.0), + }); } fn handle_thread_event(