fix(tui): clear chat content area to prevent stuck characters when scrolling

- Clear content_area with spaces before rendering cells each frame
- Preserves theme background color while clearing
- Minimal performance impact (only clears chat viewport, not full terminal)
- Fixes artifacts that remained when scrolling to shorter lines
This commit is contained in:
James Peter
2025-08-23 18:33:23 +10:00
parent 663d1adfc4
commit 2317707b59
+12
View File
@@ -5567,6 +5567,18 @@ impl WidgetRef for &ChatWidget<'_> {
// Record current viewport height for the next frame
self.last_history_viewport_height.set(content_area.height);
// Clear the content area to prevent stale characters from previous frames
// This fixes the "stuck characters" issue when scrolling through chat history
// We fill with spaces while preserving the theme background color
let clear_style = Style::default()
.bg(crate::colors::background())
.fg(crate::colors::text());
for y in content_area.y..(content_area.y + content_area.height) {
for x in content_area.x..(content_area.x + content_area.width) {
buf[(x, y)].set_char(' ').set_style(clear_style);
}
}
// Render the scrollable content with spacing using prefix sums
let mut screen_y = start_y; // Position on screen
let spacing = 1u16; // Spacing between cells