Skip to content

Commit 7d5452e

Browse files
author
User
committed
fix(tui): incorrect scroll to the latest message in history view
1 parent 1b5a91a commit 7d5452e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/tui/widgets.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ impl Widget for &mut App<'_> {
184184
}
185185
let chat_len = messages.len();
186186

187+
if self
188+
.ui
189+
.history_state
190+
.selected
191+
.is_some_and(|idx| idx >= chat_len)
192+
&& chat_len >= 1
193+
{
194+
self.ui.history_state.selected = Some(chat_len - 1);
195+
} else if chat_len == 0 {
196+
self.ui.history_state.selected = None;
197+
}
198+
187199
let builder = ListBuilder::new(|context| {
188200
if let Some(mut item) = messages.get(context.index).cloned() {
189201
item.is_selected = context.is_selected;
@@ -204,7 +216,7 @@ impl Widget for &mut App<'_> {
204216
.thumb_symbol("▐"),
205217
)
206218
.infinite_scrolling(false)
207-
.scroll_padding(2);
219+
.scroll_padding(0);
208220

209221
list.render(layout.chat_area, buf, &mut self.ui.history_state);
210222

0 commit comments

Comments
 (0)