Skip to content

Commit 8691426

Browse files
Abhijay007fbalicchia
authored andcommitted
feat: add hotkey to toggle full tool output display (aaif-goose#6067)
Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
1 parent f0af3eb commit 8691426

3 files changed

Lines changed: 62 additions & 1 deletion

File tree

crates/goose-cli/src/session/input.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub enum InputResult {
2121
Clear,
2222
Recipe(Option<String>),
2323
Compact,
24+
ToggleFullToolOutput,
2425
}
2526

2627
#[derive(Debug)]
@@ -189,6 +190,7 @@ fn handle_slash_command(input: &str) -> Option<InputResult> {
189190
println!("{}", console::style("⚠️ Note: /summarize has been renamed to /compact and will be removed in a future release.").yellow());
190191
Some(InputResult::Compact)
191192
}
193+
"/r" => Some(InputResult::ToggleFullToolOutput),
192194
_ => None,
193195
}
194196
}
@@ -300,6 +302,7 @@ fn print_help() {
300302
/exit or /quit - Exit the session
301303
/t - Toggle Light/Dark/Ansi theme
302304
/t <name> - Set theme directly (light, dark, ansi)
305+
/r - Toggle full tool output display (show complete tool parameters without truncation)
303306
/extension <command> - Add a stdio extension (format: ENV1=val1 command args...)
304307
/builtin <names> - Add builtin extensions by name (comma-separated)
305308
/prompts [--extension <name>] - List all available prompts, optionally filtered by extension
@@ -356,6 +359,12 @@ mod tests {
356359
Some(InputResult::ToggleTheme)
357360
));
358361

362+
// Test full tool output toggle
363+
assert!(matches!(
364+
handle_slash_command("/r"),
365+
Some(InputResult::ToggleFullToolOutput)
366+
));
367+
359368
// Test extension command
360369
if let Some(InputResult::AddExtension(cmd)) = handle_slash_command("/extension foo bar") {
361370
assert_eq!(cmd, "foo bar");

crates/goose-cli/src/session/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,10 @@ impl CliSession {
507507
history.save(editor);
508508
self.handle_toggle_theme();
509509
}
510+
InputResult::ToggleFullToolOutput => {
511+
history.save(editor);
512+
self.handle_toggle_full_tool_output();
513+
}
510514
InputResult::SelectTheme(theme_name) => {
511515
history.save(editor);
512516
self.handle_select_theme(&theme_name);
@@ -635,6 +639,27 @@ impl CliSession {
635639
output::set_theme(new_theme);
636640
}
637641

642+
fn handle_toggle_full_tool_output(&self) {
643+
let enabled = output::toggle_full_tool_output();
644+
if enabled {
645+
println!(
646+
"{}",
647+
console::style(
648+
"✓ Full tool output enabled - tool parameters will no longer be truncated"
649+
)
650+
.green()
651+
);
652+
} else {
653+
println!(
654+
"{}",
655+
console::style(
656+
"✓ Full tool output disabled - tool parameters will be truncated to fit terminal width"
657+
)
658+
.dim()
659+
);
660+
}
661+
}
662+
638663
fn handle_goose_mode(&self, mode: &str) -> Result<()> {
639664
let config = Config::global();
640665
let mode = match GooseMode::from_str(&mode.to_lowercase()) {

crates/goose-cli/src/session/output.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ thread_local! {
6363
.unwrap_or(Theme::Ansi)
6464
)
6565
);
66+
static SHOW_FULL_TOOL_OUTPUT: RefCell<bool> = const { RefCell::new(false) };
6667
}
6768

6869
pub fn set_theme(theme: Theme) {
@@ -88,6 +89,18 @@ pub fn get_theme() -> Theme {
8889
CURRENT_THEME.with(|t| *t.borrow())
8990
}
9091

92+
pub fn toggle_full_tool_output() -> bool {
93+
SHOW_FULL_TOOL_OUTPUT.with(|s| {
94+
let mut val = s.borrow_mut();
95+
*val = !*val;
96+
*val
97+
})
98+
}
99+
100+
pub fn get_show_full_tool_output() -> bool {
101+
SHOW_FULL_TOOL_OUTPUT.with(|s| *s.borrow())
102+
}
103+
91104
// Simple wrapper around spinner to manage its state
92105
#[derive(Default)]
93106
pub struct ThinkingIndicator {
@@ -612,8 +625,9 @@ fn print_value(value: &Value, debug: bool, reserve_width: usize) {
612625
let max_width = Term::stdout()
613626
.size_checked()
614627
.map(|(_h, w)| (w as usize).saturating_sub(reserve_width));
628+
let show_full = get_show_full_tool_output();
615629
let formatted = match value {
616-
Value::String(s) => match (max_width, debug) {
630+
Value::String(s) => match (max_width, debug || show_full) {
617631
(Some(w), false) if s.len() > w => style(safe_truncate(s, w)),
618632
_ => style(s.to_string()),
619633
}
@@ -990,6 +1004,19 @@ mod tests {
9901004
}
9911005
}
9921006

1007+
#[test]
1008+
fn test_toggle_full_tool_output() {
1009+
let initial = get_show_full_tool_output();
1010+
1011+
let after_first_toggle = toggle_full_tool_output();
1012+
assert_eq!(after_first_toggle, !initial);
1013+
assert_eq!(get_show_full_tool_output(), after_first_toggle);
1014+
1015+
let after_second_toggle = toggle_full_tool_output();
1016+
assert_eq!(after_second_toggle, initial);
1017+
assert_eq!(get_show_full_tool_output(), initial);
1018+
}
1019+
9931020
#[test]
9941021
fn test_long_path_shortening() {
9951022
assert_eq!(

0 commit comments

Comments
 (0)