mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 14:44:21 +01:00
fix: cap the repeat time when display usage (#2864)
This commit is contained in:
@@ -621,12 +621,19 @@ pub fn display_greeting() {
|
||||
pub fn display_context_usage(total_tokens: usize, context_limit: usize) {
|
||||
use console::style;
|
||||
|
||||
// Calculate percentage used
|
||||
let percentage = (total_tokens as f64 / context_limit as f64 * 100.0).round() as usize;
|
||||
if context_limit == 0 {
|
||||
println!("Context: Error - context limit is zero");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create dot visualization
|
||||
// Calculate percentage used with bounds checking
|
||||
let percentage =
|
||||
(((total_tokens as f64 / context_limit as f64) * 100.0).round() as usize).min(100);
|
||||
|
||||
// Create dot visualization with safety bounds
|
||||
let dot_count = 10;
|
||||
let filled_dots = ((percentage as f64 / 100.0) * dot_count as f64).round() as usize;
|
||||
let filled_dots =
|
||||
(((percentage as f64 / 100.0) * dot_count as f64).round() as usize).min(dot_count);
|
||||
let empty_dots = dot_count - filled_dots;
|
||||
|
||||
let filled = "●".repeat(filled_dots);
|
||||
|
||||
Reference in New Issue
Block a user