diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs index 5b8deaf..ae420fd 100644 --- a/crates/client/src/main.rs +++ b/crates/client/src/main.rs @@ -374,18 +374,24 @@ async fn handle_message( let mut sh = shell.lock().await; match sh.run(&command, timeout_ms).await { Ok((stdout, stderr, exit_code)) => { - let first_line = stdout.trim().lines().next().unwrap_or("").to_string(); let result = if exit_code != 0 { - if first_line.is_empty() { - format!("exit {exit_code}") - } else { - format!("{first_line} · exit {exit_code}") - } + // For errors: use first non-empty stderr line (actual error message), + // ignoring PowerShell boilerplate like "+ CategoryInfo", "In Zeile:", etc. + let err_line = stderr.lines() + .map(|l| l.trim()) + .find(|l| !l.is_empty() + && !l.starts_with("In Zeile:") + && !l.starts_with("+ ") + && !l.starts_with("CategoryInfo") + && !l.starts_with("FullyQualifiedErrorId")) + .unwrap_or("error") + .to_string(); + err_line } else { - first_line // success: just the output, no "exit 0" + // Success: first stdout line, no exit code + stdout.trim().lines().next().unwrap_or("").to_string() }; display::cmd_done("⚡", "execute", &payload, exit_code == 0, &result); - let _ = stderr; ClientMessage::ExecResponse { request_id, stdout, stderr, exit_code } } Err(e) => {