agent: Scroll to bottom after submitting a new message (#32819)

This is a follow up to my original attempt
https://github.com/zed-industries/zed/pull/30878 and to the PR that
eventually reverted parts of it because it broke stuff
https://github.com/zed-industries/zed/pull/31295. This new approach
attaches the `scroll_to_bottom` feature to the `chat` function, which is
triggered when the `Chat` action is dispatched by the "send" icon
buttons. With that, and from my testing, the thread doesn't forcefully
scroll as new messages are added, which was the regression I had
introduced.

Release Notes:

- agent: The panel nows scrolls to the bottom after submitting a new
message, allowing to see it more easily.
This commit is contained in:
Danilo Leal 2025-06-16 19:07:29 -03:00 committed by GitHub
parent ffc6218349
commit 69e84c0c48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 5 deletions

View file

@ -301,6 +301,7 @@ impl MessageEditor {
self.set_editor_is_expanded(false, cx);
self.send_to_model(window, cx);
cx.emit(MessageEditorEvent::ScrollThreadToBottom);
cx.notify();
}
@ -906,7 +907,7 @@ impl MessageEditor {
)
}
fn render_changed_buffers(
fn render_edits_bar(
&self,
changed_buffers: &BTreeMap<Entity<Buffer>, Entity<BufferDiff>>,
window: &mut Window,
@ -1510,6 +1511,7 @@ impl EventEmitter<MessageEditorEvent> for MessageEditor {}
pub enum MessageEditorEvent {
EstimatedTokenCount,
Changed,
ScrollThreadToBottom,
}
impl Focusable for MessageEditor {
@ -1537,7 +1539,7 @@ impl Render for MessageEditor {
v_flex()
.size_full()
.when(changed_buffers.len() > 0, |parent| {
parent.child(self.render_changed_buffers(&changed_buffers, window, cx))
parent.child(self.render_edits_bar(&changed_buffers, window, cx))
})
.child(self.render_editor(window, cx))
.children({