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
18 changes: 16 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,15 @@ impl App {
// Check if we have a pending confirmation for this exact session
if let Some((idx, ts)) = self.kill_confirm.take() {
if idx == self.selected && ts.elapsed().as_secs() < 2 {
// Confirmed — verify PID still runs expected binary before killing
// Confirmed — verify PID still runs a killable agent before killing
let pid = session.pid;
let verified = std::process::Command::new("ps")
.args(["-p", &pid.to_string(), "-o", "command="])
.output()
.ok()
.map(|output| {
let cmd = String::from_utf8_lossy(&output.stdout).trim().to_string();
is_supported_agent_command(&cmd)
is_killable_agent_command(&cmd)
})
.unwrap_or(false);
if !verified {
Expand Down Expand Up @@ -1083,6 +1083,11 @@ fn is_supported_agent_command(cmd: &str) -> bool {
|| crate::collector::process::cmd_has_binary(cmd, "opencode")
}

fn is_killable_agent_command(cmd: &str) -> bool {
is_supported_agent_command(cmd)
&& !(crate::collector::process::cmd_has_binary(cmd, "codex") && cmd.contains(" app-server"))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -1175,4 +1180,13 @@ mod tests {
assert!(is_supported_agent_command("/opt/homebrew/bin/opencode"));
assert!(!is_supported_agent_command("node server.js"));
}

#[test]
fn killable_agent_command_rejects_codex_app_server() {
assert!(is_killable_agent_command("codex --resume abc"));
assert!(is_killable_agent_command("/usr/local/bin/claude"));
assert!(!is_killable_agent_command(
"/Applications/Codex.app/Contents/Resources/codex app-server --analytics-default-enabled"
));
}
}
Loading
Loading