Skip to content

Commit 8d5e5ea

Browse files
committed
Truncate long project paths and widen cost columns
- Limit project path display to last 3 components - Widen cost and average columns for better readability
1 parent 41daaec commit 8d5e5ea

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/tui/widgets/panels/project.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use super::super::bar::make_bar;
2424
use super::super::panel::{column_header, panel};
2525
use super::super::theme::{COL_COST, COL_PROJECT};
2626

27+
const MAX_PATH_COMPONENTS: usize = 3;
28+
2729
fn shorten_project(path: &str) -> String {
2830
let home = dirs::home_dir()
2931
.map(|h| h.to_string_lossy().to_string())
@@ -33,14 +35,20 @@ fn shorten_project(path: &str) -> String {
3335
} else {
3436
path
3537
};
36-
stripped.trim_start_matches('/').to_string()
38+
let cleaned = stripped.trim_start_matches('/');
39+
let parts: Vec<&str> = cleaned.split('/').filter(|s| !s.is_empty()).collect();
40+
if parts.len() <= MAX_PATH_COMPONENTS {
41+
parts.join("/")
42+
} else {
43+
parts[parts.len() - MAX_PATH_COMPONENTS..].join("/")
44+
}
3745
}
3846

3947
pub fn render(buf: &mut Buffer, area: Rect, bw: u16, projects: &[ProjectSummary]) {
4048
let max_cost = projects.iter().map(|p| p.total_cost_usd).fold(0.0f64, f64::max);
4149
let inner = area.width.saturating_sub(4) as usize;
42-
const COL_COST_W: usize = 8;
43-
const COL_AVG_W: usize = 7;
50+
const COL_COST_W: usize = 10;
51+
const COL_AVG_W: usize = 8;
4452
const COL_SESS_W: usize = 6;
4553
let name_width = inner
4654
.saturating_sub(bw as usize + 1 + COL_COST_W + COL_AVG_W + COL_SESS_W)

0 commit comments

Comments
 (0)