feat: add hotkey to toggle full tool output display (#6067)

Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
This commit is contained in:
Abhijay Jain
2026-01-09 23:38:56 +05:30
committed by GitHub
parent a153c06aaf
commit 085f48a297
3 changed files with 62 additions and 1 deletions
+9
View File
@@ -21,6 +21,7 @@ pub enum InputResult {
Clear,
Recipe(Option<String>),
Compact,
ToggleFullToolOutput,
}
#[derive(Debug)]
@@ -189,6 +190,7 @@ fn handle_slash_command(input: &str) -> Option<InputResult> {
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 <name> - Set theme directly (light, dark, ansi)
/r - Toggle full tool output display (show complete tool parameters without truncation)
/extension <command> - Add a stdio extension (format: ENV1=val1 command args...)
/builtin <names> - Add builtin extensions by name (comma-separated)
/prompts [--extension <name>] - 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");
+25
View File
@@ -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()) {
+28 -1
View File
@@ -63,6 +63,7 @@ thread_local! {
.unwrap_or(Theme::Ansi)
)
);
static SHOW_FULL_TOOL_OUTPUT: RefCell<bool> = 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!(