diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_error_wraps_long_backend_message.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_error_wraps_long_backend_message.snap index a8e1a7a496..88ab2ce044 100644 --- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_error_wraps_long_backend_message.snap +++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_error_wraps_long_backend_message.snap @@ -4,10 +4,8 @@ expression: rendered --- /usage -╭──────────────────────────────────────────────────────────╮ -│ Usage by token share │ -│ Percent of consumed tokens in this selected range │ -│ │ -│ Failed to load usage: sqlite state database could not │ -│ be opened because the configured path is unavailable │ -╰──────────────────────────────────────────────────────────╯ +Usage by token share +Percent of consumed tokens in this selected range + + Failed to load usage: sqlite state database could not be + opened because the configured path is unavailable diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output.snap index 56b5d4d1cf..580fd313b2 100644 --- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output.snap +++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output.snap @@ -4,27 +4,25 @@ expression: rendered --- /usage -╭─────────────────────────────────────────────────────╮ -│ Daily usage by token share │ -│ Percent of consumed tokens in this selected range │ -│ (/usage week for weekly) │ -│ │ -│ 11% of consumed tokens came from app "testmcp" │ -│ Tool results stay in context until compaction; │ -│ compact or disable sources you do not need. │ -│ │ -│ Skills │ -│ ├─ /tmux ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 8% │ -│ └─ /babysit ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 6% │ -│ │ -│ Subagents │ -│ ├─ babysit ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 13% │ -│ └─ code-review ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 9% │ -│ │ -│ Agent tasks │ -│ ├─ guardian ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 17% │ -│ └─ review ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 5% │ -│ │ -│ Apps │ -│ └─ testmcp ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 11% │ -╰─────────────────────────────────────────────────────╯ +Daily usage by token share +Percent of consumed tokens in this selected range +(/usage week for weekly) + +11% of consumed tokens came from app "testmcp" + Tool results stay in context until compaction; + compact or disable sources you do not need. + + Skills + ├─ /tmux ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 8% + └─ /babysit ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 6% + + Subagents + ├─ babysit ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 13% + └─ code-review ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 9% + + Agent tasks + ├─ guardian ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 17% + └─ review ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 5% + + Apps + └─ testmcp ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 11% diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_unattributed.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_unattributed.snap index f91ce72109..ba594e1c81 100644 --- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_unattributed.snap +++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_unattributed.snap @@ -4,11 +4,9 @@ expression: rendered --- /usage -╭─────────────────────────────────────────────────────╮ -│ Daily usage by token share │ -│ Percent of consumed tokens in this selected range │ -│ (/usage week for weekly) │ -│ │ -│ No attributed skills, subagents, agent tasks, │ -│ apps, MCP servers, or plugins in this range. │ -╰─────────────────────────────────────────────────────╯ +Daily usage by token share +Percent of consumed tokens in this selected range +(/usage week for weekly) + + No attributed skills, subagents, agent tasks, + apps, MCP servers, or plugins in this range. diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_weekly.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_weekly.snap index 803f36253b..3e9e2ce83b 100644 --- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_weekly.snap +++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__usage_output_weekly.snap @@ -4,18 +4,16 @@ expression: rendered --- /usage week -╭──────────────────────────────────────────────────────────╮ -│ Weekly usage by token share, Nov 7 to Nov 14 │ -│ Percent of consumed tokens in this selected range │ -│ │ -│ 17% of consumed tokens came from agent task "guardian" │ -│ │ -│ Skills │ -│ └─ /tmux ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 8% │ -│ │ -│ Subagents │ -│ └─ default ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 13% │ -│ │ -│ Agent tasks │ -│ └─ guardian ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 17% │ -╰──────────────────────────────────────────────────────────╯ +Weekly usage by token share, Nov 7 to Nov 14 +Percent of consumed tokens in this selected range + +17% of consumed tokens came from agent task "guardian" + + Skills + └─ /tmux ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 8% + + Subagents + └─ default ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 13% + + Agent tasks + └─ guardian ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 17% diff --git a/codex-rs/tui/src/chatwidget/usage.rs b/codex-rs/tui/src/chatwidget/usage.rs index fe02a1cadb..c328482864 100644 --- a/codex-rs/tui/src/chatwidget/usage.rs +++ b/codex-rs/tui/src/chatwidget/usage.rs @@ -6,7 +6,6 @@ use crate::history_cell::CompositeHistoryCell; use crate::history_cell::HistoryCell; use crate::history_cell::PlainHistoryCell; use crate::history_cell::plain_lines; -use crate::history_cell::with_border_with_inner_width; use crate::style::accent_style; use crate::terminal_palette::best_color; use crate::terminal_palette::default_bg; @@ -25,7 +24,6 @@ use unicode_width::UnicodeWidthChar; use unicode_width::UnicodeWidthStr; const USAGE_CARD_MAX_INNER_WIDTH: usize = 72; -const USAGE_CARD_EXTRA_HORIZONTAL_PADDING: usize = 1; const USAGE_BAR_WIDTH: usize = 20; const USAGE_BAR_MIN_LABEL_WIDTH: usize = 8; const USAGE_BAR_GLYPH: &str = "▄"; @@ -117,13 +115,7 @@ impl HistoryCell for UsageErrorHistoryCell { format!(" Failed to load usage: {}", self.error), available_width, ); - let inner_width = lines - .iter() - .map(line_display_width) - .max() - .unwrap_or(0) - .min(available_width); - with_usage_border(lines, inner_width) + lines } fn raw_lines(&self) -> Vec> { @@ -174,7 +166,7 @@ fn usage_report_lines(report: &UsageReport, width: u16) -> Vec> { " No tracked usage in this range yet.", inner_width, ); - return with_usage_border(lines, inner_width); + return lines; } if sections.iter().all(|(_, entries)| entries.is_empty()) { @@ -184,35 +176,17 @@ fn usage_report_lines(report: &UsageReport, width: u16) -> Vec> { " No attributed skills, subagents, agent tasks, apps, MCP servers, or plugins in this range.", inner_width, ); - return with_usage_border(lines, inner_width); + return lines; } for (label, entries) in sections { push_section(&mut lines, label, entries, label_column_width, inner_width); } - with_usage_border(lines, inner_width) + lines } fn usage_card_available_width(width: u16) -> Option { - let frame_width = 4 + USAGE_CARD_EXTRA_HORIZONTAL_PADDING * 2; - (usize::from(width) >= frame_width).then(|| { - usize::from(width) - .saturating_sub(frame_width) - .min(USAGE_CARD_MAX_INNER_WIDTH) - }) -} - -fn with_usage_border(lines: Vec>, inner_width: usize) -> Vec> { - let lines = lines - .into_iter() - .map(|line| { - let mut spans = Vec::with_capacity(line.spans.len() + 1); - spans.push(Span::from(" ".repeat(USAGE_CARD_EXTRA_HORIZONTAL_PADDING))); - spans.extend(line.spans); - Line::from(spans) - }) - .collect(); - with_border_with_inner_width(lines, inner_width + USAGE_CARD_EXTRA_HORIZONTAL_PADDING * 2) + (width > 0).then(|| usize::from(width).min(USAGE_CARD_MAX_INNER_WIDTH)) } fn usage_label_column_width(sections: &[(&'static str, &[UsageEntry])]) -> usize {