From 7e59e181f7486653a9f7b38f7021d9448f1c21a3 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Fri, 26 Dec 2025 12:58:13 +1100 Subject: [PATCH] context line ui --- crates/g3-cli/src/lib.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/g3-cli/src/lib.rs b/crates/g3-cli/src/lib.rs index 76362ce..bd5d32c 100644 --- a/crates/g3-cli/src/lib.rs +++ b/crates/g3-cli/src/lib.rs @@ -2042,16 +2042,32 @@ fn display_context_progress(agent: &Agent, _output: &SimpleOutpu Color::Red }; + // Format tokens as compact strings (e.g., "38.5k" instead of "38531") + let format_tokens = |tokens: u32| -> String { + if tokens >= 1_000_000 { + format!("{:.1}m", tokens as f64 / 1_000_000.0) + } else if tokens >= 1_000 { + let k = tokens as f64 / 1000.0; + if k >= 100.0 { + format!("{:.0}k", k) + } else { + format!("{:.1}k", k) + } + } else { + format!("{}", tokens) + } + }; + // Print with colored dots (using print! directly to handle color codes) print!( - "Context: {}{}{}{} {:.0}% ({}/{} tokens)\n", + "{}{}{}{} {}/{} ◉ | {:.0}%\n", SetForegroundColor(color), filled_str, empty_str, ResetColor, - percentage, - context.used_tokens, - context.total_tokens + format_tokens(context.used_tokens), + format_tokens(context.total_tokens), + percentage ); }