Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions crates/goose-cli/src/session/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

// 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
// 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);
Expand Down
2 changes: 1 addition & 1 deletion ui/desktop/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": {
"name": "Apache-2.0"
},
"version": "1.0.26"
"version": "1.0.27"
},
"paths": {
"/agent/tools": {
Expand Down
Loading