Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/goose-cli/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ impl CliSession {
})
.collect();

output::run_status_hook("waiting");
let input = input::get_input(&mut editor, Some(&conversation_strings))?;
if matches!(input, InputResult::Exit) {
break;
Expand Down Expand Up @@ -595,6 +596,7 @@ impl CliSession {

let _provider = self.agent.provider().await?;

output::run_status_hook("thinking");
output::show_thinking();
let start_time = Instant::now();
self.process_agent_response(true, CancellationToken::default())
Expand Down
27 changes: 27 additions & 0 deletions crates/goose-cli/src/session/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,33 @@ pub fn hide_thinking() {
}
}

pub fn run_status_hook(status: &str) {
if let Ok(hook) = Config::global().get_param::<String>("GOOSE_STATUS_HOOK") {
let status = status.to_string();
std::thread::spawn(move || {
#[cfg(target_os = "windows")]
let result = std::process::Command::new("cmd")
.arg("/C")
.arg(format!("{} {}", hook, status))
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();

#[cfg(not(target_os = "windows"))]
let result = std::process::Command::new("sh")
.arg("-c")
.arg(format!("{} {}", hook, status))
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();

Comment on lines +169 to +186
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Execute the hook directly without a shell to avoid potential injection. Use Command::new(&hook).arg(&status) instead of passing through sh -c. This is safer and simpler.

Suggested change
#[cfg(target_os = "windows")]
let result = std::process::Command::new("cmd")
.arg("/C")
.arg(format!("{} {}", hook, status))
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();
#[cfg(not(target_os = "windows"))]
let result = std::process::Command::new("sh")
.arg("-c")
.arg(format!("{} {}", hook, status))
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();
let result = std::process::Command::new(&hook)
.arg(&status)
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();

Copilot uses AI. Check for mistakes.
Comment on lines +169 to +186
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Execute the hook directly without a shell to avoid potential injection. Use Command::new(&hook).arg(&status) instead of passing through cmd /C. This is safer and simpler.

Suggested change
#[cfg(target_os = "windows")]
let result = std::process::Command::new("cmd")
.arg("/C")
.arg(format!("{} {}", hook, status))
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();
#[cfg(not(target_os = "windows"))]
let result = std::process::Command::new("sh")
.arg("-c")
.arg(format!("{} {}", hook, status))
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();
let result = std::process::Command::new(&hook)
.arg(&status)
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status();

Copilot uses AI. Check for mistakes.
let _ = result;
});
}
}

pub fn is_showing_thinking() -> bool {
THINKING.with(|t| t.borrow().is_shown())
}
Expand Down
Loading