From 7fd55fa86dfe8f9a4581f02fa9220cd5d1ba600c Mon Sep 17 00:00:00 2001 From: asepharyana Date: Tue, 14 Jul 2026 22:59:20 +0700 Subject: [PATCH] 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 --- src/view/sidebar.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/view/sidebar.rs b/src/view/sidebar.rs index 1a50267..07c994a 100644 --- a/src/view/sidebar.rs +++ b/src/view/sidebar.rs @@ -58,11 +58,18 @@ fn draw_tasks_widget(frame: &mut Frame, area: Rect, state: &crate::app::state::r frame.render_widget(paragraph, area); } -/// Compact Usage widget: main/self-learning token split, API call count, -/// and session clock. Always fits (the summary is a fixed handful of -/// lines), so there is no overflow hint — the `Overlay::Usage` "expand" -/// view adds edit/review/lesson activity counters on top of this same -/// summary rather than showing more of a truncated list. +/// Compact Usage widget: total tokens, main/self-learning token split, +/// API call count, and session clock. Always fits (the summary is a +/// fixed handful of lines), so there is no overflow hint — the +/// `Overlay::Usage` "expand" view adds edit/review/lesson activity +/// 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) { let block = Block::default() .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); vec![ 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), )), + 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( format!(" {} API calls", summary.api_calls), Style::default().fg(Theme::TEXT_DIM),