diff --git a/.beans/claudbg-6dgc--table-overflows-terminal-truncate-long-columns-and.md b/.beans/claudbg-6dgc--table-overflows-terminal-truncate-long-columns-and.md index 55ae6b2..78b9523 100644 --- a/.beans/claudbg-6dgc--table-overflows-terminal-truncate-long-columns-and.md +++ b/.beans/claudbg-6dgc--table-overflows-terminal-truncate-long-columns-and.md @@ -1,11 +1,11 @@ --- # claudbg-6dgc title: Table overflows terminal — truncate long columns and respect terminal width -status: todo +status: completed type: bug priority: normal created_at: 2026-03-30T04:36:31Z -updated_at: 2026-03-30T04:41:14Z +updated_at: 2026-03-30T05:06:58Z parent: claudbg-tci9 --- @@ -28,3 +28,8 @@ parent: claudbg-tci9 - `src/output/table.rs` — `render_table`, `FALLBACK_WIDTH` constant - `src/commands/sessions.rs` — `list()` function that calls `render_table` + +## Summary of Changes + +- Removed hardcoded FALLBACK_WIDTH=200 from table.rs; table now uses ContentArrangement::Dynamic for automatic terminal width fitting +- In sessions list(), truncate project path to last ~40 chars with ellipsis prefix when longer diff --git a/src/commands/sessions.rs b/src/commands/sessions.rs index 722eda3..e7c2d70 100644 --- a/src/commands/sessions.rs +++ b/src/commands/sessions.rs @@ -189,10 +189,23 @@ pub async fn list(opts: &crate::cli::GlobalOpts) -> Result<()> { crate::util::short_id(&session_id).to_string() }; + const MAX_PATH_LEN: usize = 40; + let display_path = if project_path.len() > MAX_PATH_LEN { + let boundary = project_path + .char_indices() + .rev() + .map(|(i, _)| i) + .nth(MAX_PATH_LEN - 1) + .unwrap_or(0); + format!("…{}", &project_path[boundary..]) + } else { + project_path + }; + rows.push(vec![ display_id, last_msg_at, - project_path, + display_path, model, message_count.to_string(), ]); diff --git a/src/output/table.rs b/src/output/table.rs index a47358b..395c1a6 100644 --- a/src/output/table.rs +++ b/src/output/table.rs @@ -12,12 +12,6 @@ use crate::error::Result; pub fn render_table(headers: &[&str], rows: &[Vec]) -> Result { let mut table = Table::new(); table.set_content_arrangement(ContentArrangement::Dynamic); - // Ensure a sensible minimum width so content is never truncated in non-interactive - // environments (CI, Nix sandbox, pipes) where the terminal may report a very narrow - // width or no width at all. - const FALLBACK_WIDTH: u16 = 200; - let width = table.width().unwrap_or(FALLBACK_WIDTH).max(FALLBACK_WIDTH); - table.set_width(width); table.set_header(headers); for row in rows { table.add_row(row);