diff --git a/crates/goose-cli/src/session/input.rs b/crates/goose-cli/src/session/input.rs index 34d385291f26..ef82a4900df8 100644 --- a/crates/goose-cli/src/session/input.rs +++ b/crates/goose-cli/src/session/input.rs @@ -21,6 +21,7 @@ pub enum InputResult { Clear, Recipe(Option), Compact, + ToggleFullToolOutput, } #[derive(Debug)] @@ -189,6 +190,7 @@ fn handle_slash_command(input: &str) -> Option { println!("{}", console::style("⚠️ Note: /summarize has been renamed to /compact and will be removed in a future release.").yellow()); Some(InputResult::Compact) } + "/r" => Some(InputResult::ToggleFullToolOutput), _ => None, } } @@ -300,6 +302,7 @@ fn print_help() { /exit or /quit - Exit the session /t - Toggle Light/Dark/Ansi theme /t - Set theme directly (light, dark, ansi) +/r - Toggle full tool output display (show complete tool parameters without truncation) /extension - Add a stdio extension (format: ENV1=val1 command args...) /builtin - Add builtin extensions by name (comma-separated) /prompts [--extension ] - List all available prompts, optionally filtered by extension @@ -356,6 +359,12 @@ mod tests { Some(InputResult::ToggleTheme) )); + // Test full tool output toggle + assert!(matches!( + handle_slash_command("/r"), + Some(InputResult::ToggleFullToolOutput) + )); + // Test extension command if let Some(InputResult::AddExtension(cmd)) = handle_slash_command("/extension foo bar") { assert_eq!(cmd, "foo bar"); diff --git a/crates/goose-cli/src/session/mod.rs b/crates/goose-cli/src/session/mod.rs index 8f63894a104c..3b420fb2fb07 100644 --- a/crates/goose-cli/src/session/mod.rs +++ b/crates/goose-cli/src/session/mod.rs @@ -507,6 +507,10 @@ impl CliSession { history.save(editor); self.handle_toggle_theme(); } + InputResult::ToggleFullToolOutput => { + history.save(editor); + self.handle_toggle_full_tool_output(); + } InputResult::SelectTheme(theme_name) => { history.save(editor); self.handle_select_theme(&theme_name); @@ -635,6 +639,27 @@ impl CliSession { output::set_theme(new_theme); } + fn handle_toggle_full_tool_output(&self) { + let enabled = output::toggle_full_tool_output(); + if enabled { + println!( + "{}", + console::style( + "✓ Full tool output enabled - tool parameters will no longer be truncated" + ) + .green() + ); + } else { + println!( + "{}", + console::style( + "✓ Full tool output disabled - tool parameters will be truncated to fit terminal width" + ) + .dim() + ); + } + } + fn handle_goose_mode(&self, mode: &str) -> Result<()> { let config = Config::global(); let mode = match GooseMode::from_str(&mode.to_lowercase()) { diff --git a/crates/goose-cli/src/session/output.rs b/crates/goose-cli/src/session/output.rs index 6c38b9f4de57..1c01eaad4d9a 100644 --- a/crates/goose-cli/src/session/output.rs +++ b/crates/goose-cli/src/session/output.rs @@ -63,6 +63,7 @@ thread_local! { .unwrap_or(Theme::Ansi) ) ); + static SHOW_FULL_TOOL_OUTPUT: RefCell = const { RefCell::new(false) }; } pub fn set_theme(theme: Theme) { @@ -88,6 +89,18 @@ pub fn get_theme() -> Theme { CURRENT_THEME.with(|t| *t.borrow()) } +pub fn toggle_full_tool_output() -> bool { + SHOW_FULL_TOOL_OUTPUT.with(|s| { + let mut val = s.borrow_mut(); + *val = !*val; + *val + }) +} + +pub fn get_show_full_tool_output() -> bool { + SHOW_FULL_TOOL_OUTPUT.with(|s| *s.borrow()) +} + // Simple wrapper around spinner to manage its state #[derive(Default)] pub struct ThinkingIndicator { @@ -612,8 +625,9 @@ fn print_value(value: &Value, debug: bool, reserve_width: usize) { let max_width = Term::stdout() .size_checked() .map(|(_h, w)| (w as usize).saturating_sub(reserve_width)); + let show_full = get_show_full_tool_output(); let formatted = match value { - Value::String(s) => match (max_width, debug) { + Value::String(s) => match (max_width, debug || show_full) { (Some(w), false) if s.len() > w => style(safe_truncate(s, w)), _ => style(s.to_string()), } @@ -990,6 +1004,19 @@ mod tests { } } + #[test] + fn test_toggle_full_tool_output() { + let initial = get_show_full_tool_output(); + + let after_first_toggle = toggle_full_tool_output(); + assert_eq!(after_first_toggle, !initial); + assert_eq!(get_show_full_tool_output(), after_first_toggle); + + let after_second_toggle = toggle_full_tool_output(); + assert_eq!(after_second_toggle, initial); + assert_eq!(get_show_full_tool_output(), initial); + } + #[test] fn test_long_path_shortening() { assert_eq!(