Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ pub struct App {
/// Kill confirmation: (selected_index, timestamp). Expires after 2s.
kill_confirm: Option<(usize, Instant)>,
pub theme: Theme,
/// Agent CLIs hidden by config; their quota columns are hidden too.
pub hidden_agents: Vec<String>,
pub show_context: bool,
pub show_quota: bool,
pub show_tokens: bool,
Expand Down Expand Up @@ -190,6 +192,7 @@ impl App {
status_msg: None,
kill_confirm: None,
theme,
hidden_agents: hidden_agents.to_vec(),
show_context: panels.context,
show_quota: panels.quota,
show_tokens: panels.tokens,
Expand Down
12 changes: 10 additions & 2 deletions src/ui/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ pub(crate) fn draw_quota_panel_active(
// Split into side-by-side columns: one per known source (CLAUDE | CODEX).
// Columns are always rendered so the panel layout stays stable even when a
// source has no data yet.
let num_sources = SOURCES.len() as u16;
let mut sources: Vec<&str> = SOURCES
.iter()
.copied()
.filter(|s| !app.hidden_agents.iter().any(|h| h.eq_ignore_ascii_case(s)))
.collect();
if sources.is_empty() {
sources = SOURCES.to_vec();
}
let num_sources = sources.len() as u16;
let col_w = inner.width / num_sources;
let content_h = inner.height.saturating_sub(1); // reserve last row for totals

for (i, source) in SOURCES.iter().enumerate() {
for (i, source) in sources.iter().enumerate() {
let col_x = inner.x + (i as u16) * col_w;
let this_w = if i as u16 == num_sources - 1 {
inner.width - (i as u16) * col_w
Expand Down
66 changes: 60 additions & 6 deletions src/ui/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ pub(crate) fn draw_sessions_panel_active(
let show_tokens = w >= 86;
let show_memory = w >= 110;
let show_turn = w >= 110;
// The AI column only tells sessions apart when more than one agent, or an App/IDE session, runs.
let show_agent = app.sessions.iter().any(|s| {
s.agent_cli != app.sessions[0].agent_cli || !s.launch_surface.label_suffix().is_empty()
});

let project_w: u16 = if w >= 120 {
14
Expand Down Expand Up @@ -255,11 +259,19 @@ pub(crate) fn draw_sessions_panel_active(
)));
}

if !show_agent {
cells.remove(1);
}
rows.push(Row::new(cells).style(row_style).height(1));

// 2nd line: task text in Summary column
let summary_idx = 3 + show_pid as usize + show_session_id as usize + show_config as usize;
let total_cols = 6
let summary_idx = 2
+ show_agent as usize
+ show_pid as usize
+ show_session_id as usize
+ show_config as usize;
let total_cols = 5
+ show_agent as usize
+ show_pid as usize
+ show_session_id as usize
+ show_config as usize
Expand Down Expand Up @@ -308,8 +320,16 @@ pub(crate) fn draw_sessions_panel_active(
if show_pid {
sa_cells.push(Cell::from(""));
}
if !show_agent {
sa_cells.remove(1);
}
let sa_name = if show_agent {
sa.name.clone()
} else {
format!("{prefix}{}", sa.name)
};
sa_cells.push(Cell::from(Span::styled(
truncate_str(&sa.name, project_w as usize),
truncate_str(&sa_name, project_w as usize),
Style::default().fg(theme.graph_text),
)));
if show_session_id {
Expand Down Expand Up @@ -377,6 +397,9 @@ pub(crate) fn draw_sessions_panel_active(
if show_turn {
header_cells.push(Cell::from(Span::styled(t("col.turn"), header_style)));
}
if !show_agent {
header_cells.remove(1);
}
let header = Row::new(header_cells).height(1);

let mut widths_vec: Vec<Constraint> = vec![
Expand Down Expand Up @@ -408,6 +431,9 @@ pub(crate) fn draw_sessions_panel_active(
if show_turn {
widths_vec.push(Constraint::Length(4)); // turn
}
if !show_agent {
widths_vec.remove(1);
}

// Scroll: rows vary per session in tree view; use the built row list as the source of truth.
let visible_sessions = app.visible_indices();
Expand Down Expand Up @@ -1377,10 +1403,9 @@ mod tests {

let cli_text = render(LaunchSurface::Cli);
assert!(
cli_text.contains("*CC "),
"plain CLI session should render the unsuffixed label\n{cli_text}"
!cli_text.contains("*CC") && !cli_text.contains(" AI "),
"sessions from one agent CLI should hide the AI column\n{cli_text}"
);
assert!(!cli_text.contains("*CCa") && !cli_text.contains("*CCi"));

let app_text = render(LaunchSurface::App);
assert!(
Expand All @@ -1395,6 +1420,35 @@ mod tests {
);
}

#[test]
fn agent_column_shows_only_for_mixed_agent_clis() {
let render = |agents: &[&'static str]| {
let mut app = App::new_with_config(Theme::default(), &[], PanelVisibility::default());
for (i, agent) in agents.iter().enumerate() {
let mut session = test_session(&format!("sid{i}"), "proj");
session.agent_cli = agent;
app.sessions.push(session);
}
let mut terminal = Terminal::new(TestBackend::new(120, 20)).unwrap();
terminal
.draw(|f| draw_sessions_panel(f, &app, Rect::new(0, 0, 120, 20), &app.theme))
.unwrap();
format!("{}", terminal.backend())
};

let codex_only = render(&["codex", "codex"]);
assert!(
!codex_only.contains(">CD"),
"codex-only sessions should hide the AI column\n{codex_only}"
);

let mixed = render(&["claude", "codex"]);
assert!(
mixed.contains("*CC") && mixed.contains(">CD"),
"mixed agent CLIs should show the AI column\n{mixed}"
);
}

#[test]
fn task_row_text_respects_terminal_display_width() {
assert_eq!(task_row_text("ABCD", 6), "└─ A…");
Expand Down