fix(tui): perbaiki potensi terpotongnya baris token di widget Usage sidebar
Baris pertama widget Usage sebelumnya bisa melebihi lebar kolom sidebar (30 kolom) pada sesi dengan jumlah token besar, menyebabkan teks terpotong diam-diam tanpa wrap. Sekarang dipecah jadi beberapa baris pendek yang aman di lebar berapa pun yang realistis. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
31c01cdf1d
commit
7fd55fa86d
+21
-6
@@ -58,11 +58,18 @@ fn draw_tasks_widget(frame: &mut Frame, area: Rect, state: &crate::app::state::r
|
|||||||
frame.render_widget(paragraph, area);
|
frame.render_widget(paragraph, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compact Usage widget: main/self-learning token split, API call count,
|
/// Compact Usage widget: total tokens, main/self-learning token split,
|
||||||
/// and session clock. Always fits (the summary is a fixed handful of
|
/// API call count, and session clock. Always fits (the summary is a
|
||||||
/// lines), so there is no overflow hint — the `Overlay::Usage` "expand"
|
/// fixed handful of lines), so there is no overflow hint — the
|
||||||
/// view adds edit/review/lesson activity counters on top of this same
|
/// `Overlay::Usage` "expand" view adds edit/review/lesson activity
|
||||||
/// summary rather than showing more of a truncated list.
|
/// counters on top of this same summary rather than showing more of a
|
||||||
|
/// truncated list.
|
||||||
|
///
|
||||||
|
/// Each number gets its own short line rather than being crammed onto
|
||||||
|
/// one — the sidebar column is only ~28 usable characters wide after
|
||||||
|
/// borders, and a single `"{total} tok ({main} main / {learn} learn)"`
|
||||||
|
/// line silently clips (no `.wrap()` on this `Paragraph`) once token
|
||||||
|
/// counts reach 5-6 digits, which is routine for an agent session.
|
||||||
fn draw_usage_widget(frame: &mut Frame, area: Rect, state: &crate::app::state::rest::AppStateRest) {
|
fn draw_usage_widget(frame: &mut Frame, area: Rect, state: &crate::app::state::rest::AppStateRest) {
|
||||||
let block = Block::default()
|
let block = Block::default()
|
||||||
.title(Span::styled(" Usage ", Style::default().fg(Theme::INFO).add_modifier(Modifier::BOLD)))
|
.title(Span::styled(" Usage ", Style::default().fg(Theme::INFO).add_modifier(Modifier::BOLD)))
|
||||||
@@ -74,9 +81,17 @@ fn draw_usage_widget(frame: &mut Frame, area: Rect, state: &crate::app::state::r
|
|||||||
let summary = compute_usage_summary(&rt.usage, rt.session_start, now_ms);
|
let summary = compute_usage_summary(&rt.usage, rt.session_start, now_ms);
|
||||||
vec![
|
vec![
|
||||||
Line::from(Span::styled(
|
Line::from(Span::styled(
|
||||||
format!(" {} tok ({} main / {} learn)", summary.total_tokens, summary.main_tokens, summary.self_learning_tokens),
|
format!(" {} tok total", summary.total_tokens),
|
||||||
Style::default().fg(Theme::TEXT).add_modifier(Modifier::BOLD),
|
Style::default().fg(Theme::TEXT).add_modifier(Modifier::BOLD),
|
||||||
)),
|
)),
|
||||||
|
Line::from(Span::styled(
|
||||||
|
format!(" main: {} tok", summary.main_tokens),
|
||||||
|
Style::default().fg(Theme::TEXT_DIM),
|
||||||
|
)),
|
||||||
|
Line::from(Span::styled(
|
||||||
|
format!(" learn: {} tok", summary.self_learning_tokens),
|
||||||
|
Style::default().fg(Theme::TEXT_DIM),
|
||||||
|
)),
|
||||||
Line::from(Span::styled(
|
Line::from(Span::styled(
|
||||||
format!(" {} API calls", summary.api_calls),
|
format!(" {} API calls", summary.api_calls),
|
||||||
Style::default().fg(Theme::TEXT_DIM),
|
Style::default().fg(Theme::TEXT_DIM),
|
||||||
|
|||||||
Reference in New Issue
Block a user