Skip to content

Commit 6610be7

Browse files
committed
fix(chat): correct scroll position when switching conversations
Reset scroll tracking before updating message list so that set_messages sees stick_to_bottom = true and properly scrolls to the bottom when loading a different conversation.
1 parent bb20c94 commit 6610be7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/chat_view.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ impl ChatView {
131131
.push(Arc::new(Message::system("You are a helpful assistant.")));
132132
self.current_conversation_id = None;
133133
self.clear_streaming_ui_buffer();
134-
self.update_message_list(cx);
134+
// Reset scroll tracking BEFORE updating message list
135135
self.message_list
136136
.update(cx, |list, _cx| list.reset_scroll_tracking());
137+
self.update_message_list(cx);
137138
}
138139

139140
/// Load an existing conversation
@@ -217,9 +218,11 @@ impl ChatView {
217218
thinking_duration_ms: None,
218219
}));
219220
}
220-
this.update_message_list(cx);
221+
// Reset scroll tracking BEFORE updating message list
222+
// so that set_messages sees stick_to_bottom = true
221223
this.message_list
222224
.update(cx, |list, _cx| list.reset_scroll_tracking());
225+
this.update_message_list(cx);
223226
});
224227
});
225228
}

0 commit comments

Comments
 (0)