fix(tui): remove usage report border

This commit is contained in:
Felipe Coury
2026-05-30 13:43:25 -03:00
parent 56314eb68b
commit 099075fa4b
5 changed files with 51 additions and 85 deletions

View File

@@ -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

View File

@@ -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%

View File

@@ -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.

View File

@@ -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%

View File

@@ -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<Line<'static>> {
@@ -174,7 +166,7 @@ fn usage_report_lines(report: &UsageReport, width: u16) -> Vec<Line<'static>> {
" 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<Line<'static>> {
" 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<usize> {
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<Line<'static>>, inner_width: usize) -> Vec<Line<'static>> {
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 {