fix(tui): show full /resume popup rows

Closes #542
This commit is contained in:
James Peter
2026-02-13 10:34:45 +10:00
parent 9f9c418c4e
commit 99425efe0f
@@ -135,10 +135,11 @@ impl BottomPaneView<'_> for ResumeSelectionView {
fn desired_height(&self, _width: u16) -> u16 {
// Include block borders (+2), optional subtitle (+1), table header (+1),
// clamped rows, spacer (+1), footer (+1)
// clamped rows, spacer (+1), footer (+1).
// The spacer row is reserved between the table and the footer.
let rows = self.rows.len().min(RESUME_POPUP_ROWS).max(1) as u16;
let subtitle = if self.subtitle.is_empty() { 0 } else { 1 };
2 + subtitle + 1 + rows + 1 + 1
2 + subtitle + 1 + rows + 1 + 2
}
fn render(&self, area: Rect, buf: &mut Buffer) {
@@ -242,3 +243,63 @@ impl BottomPaneView<'_> for ResumeSelectionView {
.render(footer, buf);
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::app_event::AppEvent;
use crate::app_event_sender::AppEventSender;
use ratatui::layout::Rect;
use std::sync::mpsc;
#[test]
fn resume_selection_shows_max_rows_for_capacity() {
let rows = (0..14)
.map(|i| ResumeRow {
modified: "m".to_string(),
created: "c".to_string(),
user_msgs: "1".to_string(),
branch: "main".to_string(),
last_user_message: format!("row-{i}"),
path: std::path::PathBuf::from(format!("/tmp/sess-{i}")),
})
.collect();
let (tx, _rx) = mpsc::channel::<AppEvent>();
let view = ResumeSelectionView::new(
"Resume".to_string(),
String::new(),
rows,
AppEventSender::new(tx),
);
let width = 120;
let height = view.desired_height(width);
let mut buf = ratatui::buffer::Buffer::empty(Rect {
x: 0,
y: 0,
width,
height,
});
view.render(Rect { x: 0, y: 0, width, height }, &mut buf);
let inner_width = width.saturating_sub(2);
let mut row_lines = 0;
for y in 1..height.saturating_sub(1) {
let line: String = (0..inner_width)
.map(|x| {
buf[(x.saturating_add(1), y)]
.symbol()
.to_string()
})
.collect::<Vec<_>>()
.concat();
if line.contains("row-") {
row_lines += 1;
}
}
assert_eq!(row_lines, 14);
}
}