Centralize g3 status message formatting
Extract a new g3_status module in g3-cli that provides consistent formatting for all 'g3:' prefixed system status messages. Key changes: - Add G3Status struct with methods for progress, done, failed, error, etc. - Add Status enum with Done, Failed, Error, Resolved, Insufficient, NoChanges - Add ThinResult struct in g3-core for semantic thinning data - Update UiWriter trait with print_thin_result() method - Refactor context thinning to return ThinResult instead of formatted strings - Update all callers to use the new centralized formatting - Session resume/decline messages now use G3Status - Compaction status messages now use G3Status This maintains clean separation of concerns: g3-core emits semantic data, g3-cli handles all terminal formatting and colors.
This commit is contained in:
@@ -212,38 +212,18 @@ impl UiWriter for ConsoleUiWriter {
|
||||
}
|
||||
|
||||
fn print_g3_progress(&self, message: &str) {
|
||||
use crossterm::style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor};
|
||||
use std::io::Write;
|
||||
print!(
|
||||
"{}{}g3:{}{} {} ...",
|
||||
SetAttribute(Attribute::Bold),
|
||||
SetForegroundColor(Color::Green),
|
||||
ResetColor,
|
||||
SetAttribute(Attribute::Reset),
|
||||
message
|
||||
);
|
||||
let _ = std::io::stdout().flush();
|
||||
crate::g3_status::G3Status::progress(message);
|
||||
}
|
||||
|
||||
fn print_g3_status(&self, message: &str, status: &str) {
|
||||
use crossterm::style::{Color, ResetColor, SetForegroundColor};
|
||||
use crate::g3_status::Status;
|
||||
let _ = message; // unused now - progress already printed the message
|
||||
let status_colored = if status.starts_with("error") || status == "failed" {
|
||||
format!(
|
||||
" {}[{}]{}",
|
||||
SetForegroundColor(Color::Red),
|
||||
status,
|
||||
ResetColor
|
||||
)
|
||||
} else {
|
||||
format!(" [{}]", status)
|
||||
};
|
||||
println!("{}", status_colored);
|
||||
crate::g3_status::G3Status::status(&Status::from_str(status));
|
||||
}
|
||||
|
||||
fn print_context_thinning(&self, message: &str) {
|
||||
// Simple status line output - message already contains ANSI formatting
|
||||
println!("{}", message);
|
||||
fn print_thin_result(&self, result: &g3_core::ThinResult) {
|
||||
// Use centralized G3Status formatting
|
||||
crate::g3_status::G3Status::thin_result(result);
|
||||
}
|
||||
|
||||
fn print_tool_header(&self, tool_name: &str, _tool_args: Option<&serde_json::Value>) {
|
||||
|
||||
Reference in New Issue
Block a user