From 159276ad151824f5878eadc417f40b42a8542ce7 Mon Sep 17 00:00:00 2001 From: lancebord Date: Sat, 7 Mar 2026 20:14:24 -0500 Subject: make chatbot fill from bottom --- src/tui/ui.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 4878848..0f552f2 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -88,23 +88,32 @@ fn draw_chat_log(f: &mut Frame, area: Rect, state: &AppState) { .iter() .map(|msg| render_chat_line(msg)) .collect(); - let block = Block::default() .borders(Borders::ALL) .border_type(BorderType::Plain) .border_style(Style::default().fg(Color::Green)) .style(Style::default()); - let inner_width = area.width.saturating_sub(2) as usize; let inner_height = area.height.saturating_sub(2) as usize; - let total_wrapped = count_wrapped_lines(&lines, inner_width); - let scroll = total_wrapped.saturating_sub(inner_height); + + let (padded_lines, scroll) = if total_wrapped < inner_height { + // Pad the top with empty lines to push content to the bottom + let padding = inner_height - total_wrapped; + let mut padded = vec![Line::raw(""); padding]; + padded.extend(lines); + (padded, 0u16) + } else { + // Content overflows — scroll to keep the latest lines visible + let scroll = total_wrapped.saturating_sub(inner_height); + (lines, scroll as u16) + }; + f.render_widget( - Paragraph::new(Text::from(lines)) + Paragraph::new(Text::from(padded_lines)) .block(block) .wrap(Wrap { trim: false }) - .scroll((scroll as u16, 0)), + .scroll((scroll, 0)), area, ); } -- cgit v1.2.3-59-g8ed1b