thinning message highlighted

This commit is contained in:
Dhanji Prasanna
2025-10-23 13:16:13 +11:00
parent efd4eca755
commit 0be4829ca9
6 changed files with 83 additions and 430 deletions

View File

@@ -169,7 +169,7 @@ use tracing::{error, info};
use g3_core::error_handling::{classify_error, ErrorType, RecoverableError};
mod retro_tui;
mod theme;
mod tui;
pub mod tui;
mod ui_writer_impl;
use retro_tui::RetroTui;
use theme::ColorTheme;
@@ -1099,9 +1099,8 @@ async fn run_interactive<W: UiWriter>(
continue;
}
"/thinnify" => {
output.print("🔧 Triggering manual context thinning...");
let summary = agent.force_thin();
output.print(&summary);
output.print_context_thinning(&summary);
continue;
}
"/readme" => {

View File

@@ -1,5 +1,6 @@
use crossterm::style::Color;
use crossterm::style::{SetForegroundColor, ResetColor};
use std::io::{self, Write};
use termimad::MadSkin;
/// Simple output handler with markdown support
@@ -93,6 +94,37 @@ impl SimpleOutput {
print!("{}", ResetColor);
println!(" {:.1}% | {}/{} tokens", percentage, used, total);
}
pub fn print_context_thinning(&self, message: &str) {
// Animated highlight for context thinning
// Use bright cyan/green with a quick flash animation
// Flash animation: print with bright background, then normal
let frames = vec![
"\x1b[1;97;46m", // Frame 1: Bold white on cyan background
"\x1b[1;97;42m", // Frame 2: Bold white on green background
"\x1b[1;96;40m", // Frame 3: Bold cyan on black background
];
println!();
// Quick flash animation
for frame in &frames {
print!("\r{}{}\x1b[0m", frame, message);
let _ = io::stdout().flush();
std::thread::sleep(std::time::Duration::from_millis(80));
}
// Final display with bright cyan and sparkle emojis
print!("\r\x1b[1;96m✨ {}\x1b[0m", message);
println!();
// Add a subtle "success" indicator line
println!("\x1b[2;36m └─ Context optimized successfully\x1b[0m");
println!();
let _ = io::stdout().flush();
}
}
#[cfg(test)]

View File

@@ -104,6 +104,37 @@ impl UiWriter for ConsoleUiWriter {
println!("{}", message);
}
fn print_context_thinning(&self, message: &str) {
// Animated highlight for context thinning
// Use bright cyan/green with a quick flash animation
// Flash animation: print with bright background, then normal
let frames = vec![
"\x1b[1;97;46m", // Frame 1: Bold white on cyan background
"\x1b[1;97;42m", // Frame 2: Bold white on green background
"\x1b[1;96;40m", // Frame 3: Bold cyan on black background
];
println!();
// Quick flash animation
for frame in &frames {
print!("\r{}{}\x1b[0m", frame, message);
let _ = io::stdout().flush();
std::thread::sleep(std::time::Duration::from_millis(80));
}
// Final display with bright cyan and sparkle emojis
print!("\r\x1b[1;96m✨ {}\x1b[0m", message);
println!();
// Add a subtle "success" indicator line
println!("\x1b[2;36m └─ Context optimized successfully\x1b[0m");
println!();
let _ = io::stdout().flush();
}
fn print_tool_header(&self, tool_name: &str) {
// Store the tool name and clear args for collection
*self.current_tool_name.lock().unwrap() = Some(tool_name.to_string());
@@ -360,6 +391,19 @@ impl UiWriter for RetroTuiWriter {
self.tui.output(message);
}
fn print_context_thinning(&self, message: &str) {
// For TUI, we'll use a highlighted output with special formatting
// The TUI will handle the visual presentation
// Add visual separators and emphasis
self.tui.output("");
self.tui.output("═══════════════════════════════════════════════════════════");
self.tui.output(&format!("{}", message));
self.tui.output(" └─ Context optimized successfully");
self.tui.output("═══════════════════════════════════════════════════════════");
self.tui.output("");
}
fn print_tool_header(&self, tool_name: &str) {
// Start collecting tool output
*self.current_tool_start.lock().unwrap() = Some(Instant::now());