From 19e89a8b2d97b77b6d4630b7b37adc3d0cf0e8a6 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sat, 17 May 2025 12:57:00 -0300 Subject: [PATCH] agent: Scroll to the bottom after sending a new message (#30878) Closes https://github.com/zed-industries/zed/issues/30572 Release Notes: - agent: Improved UX by scrolling to the bottom of the thread after submitting a new message or editing a previous one. --- crates/agent/src/active_thread.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/agent/src/active_thread.rs b/crates/agent/src/active_thread.rs index 737822420fb91329d0199cfc65bde596d96ecb75..11d48a2c3f0afae9cf00177d2768efde01bfc29f 100644 --- a/crates/agent/src/active_thread.rs +++ b/crates/agent/src/active_thread.rs @@ -1014,6 +1014,7 @@ impl ActiveThread { self.push_message(message_id, &message_segments, window, cx); } + self.scroll_to_bottom(cx); self.save_thread(cx); cx.notify(); } @@ -1027,6 +1028,7 @@ impl ActiveThread { self.edited_message(message_id, &message_segments, window, cx); } + self.scroll_to_bottom(cx); self.save_thread(cx); cx.notify(); } @@ -3408,6 +3410,11 @@ impl ActiveThread { .or_insert(true); *is_expanded = !*is_expanded; } + + pub fn scroll_to_bottom(&mut self, cx: &mut Context) { + self.list_state.reset(self.messages.len()); + cx.notify(); + } } pub enum ActiveThreadEvent {