fix(client): per-command emojis, remove separator line, fix admin line indent

This commit is contained in:
Helios Agent 2026-03-03 16:28:26 +01:00
parent 20e97b932b
commit 314ebab5c9
No known key found for this signature in database
GPG key ID: C8259547CD8309B5

View file

@ -26,14 +26,14 @@ fn banner() {
#[cfg(windows)] #[cfg(windows)]
{ {
let admin = is_admin(); let admin = is_admin();
let admin_str = if admin { let (icon, admin_str) = if admin {
"admin".green().bold() ("👑", "admin".green().bold().to_string())
} else { } else {
"user (no admin)".yellow() ("👤", "user (no admin)".yellow().to_string())
}; };
println!(" running as {}", admin_str); println!(" {} {}", icon, admin_str);
} }
println!(" {}", "".repeat(45).dimmed()); println!();
} }
#[cfg(windows)] #[cfg(windows)]
@ -77,8 +77,8 @@ macro_rules! log_err {
} }
macro_rules! log_cmd { macro_rules! log_cmd {
($($arg:tt)*) => { ($emoji:expr, $($arg:tt)*) => {
println!(" {} {}", "".yellow().bold(), format!($($arg)*)); println!(" {} {}", $emoji, format!($($arg)*));
}; };
} }
@ -340,7 +340,7 @@ async fn handle_message(
) -> ClientMessage { ) -> ClientMessage {
match msg { match msg {
ServerMessage::ScreenshotRequest { request_id } => { ServerMessage::ScreenshotRequest { request_id } => {
log_cmd!("screenshot"); log_cmd!("📷", "screenshot");
match screenshot::take_screenshot() { match screenshot::take_screenshot() {
Ok((image_base64, width, height)) => { Ok((image_base64, width, height)) => {
log_ok!("Done {} {}×{}", "·".dimmed(), width, height); log_ok!("Done {} {}×{}", "·".dimmed(), width, height);
@ -365,7 +365,7 @@ async fn handle_message(
let _title = title.unwrap_or_else(|| "Helios Remote".to_string()); let _title = title.unwrap_or_else(|| "Helios Remote".to_string());
#[cfg(windows)] #[cfg(windows)]
let title = _title.clone(); let title = _title.clone();
log_cmd!("prompt {}", &message[..message.len().min(60)]); log_cmd!("💬", "prompt {}", &message[..message.len().min(60)]);
#[cfg(windows)] #[cfg(windows)]
{ {
use windows::core::PCWSTR; use windows::core::PCWSTR;
@ -400,7 +400,7 @@ async fn handle_message(
} else { } else {
command.clone() command.clone()
}; };
log_cmd!("exec {}", cmd_display); log_cmd!("", "exec {}", cmd_display);
let mut sh = shell.lock().await; let mut sh = shell.lock().await;
match sh.run(&command, timeout_ms).await { match sh.run(&command, timeout_ms).await {
Ok((stdout, stderr, exit_code)) => { Ok((stdout, stderr, exit_code)) => {
@ -443,7 +443,7 @@ async fn handle_message(
} }
ServerMessage::ClickRequest { request_id, x, y, button } => { ServerMessage::ClickRequest { request_id, x, y, button } => {
log_cmd!("click ({x}, {y}) {:?}", button); log_cmd!("🖱 ", "click ({x}, {y}) {:?}", button);
match input::click(x, y, &button) { match input::click(x, y, &button) {
Ok(()) => { Ok(()) => {
log_ok!("Done"); log_ok!("Done");
@ -460,7 +460,7 @@ async fn handle_message(
} }
ServerMessage::TypeRequest { request_id, text } => { ServerMessage::TypeRequest { request_id, text } => {
log_cmd!("type {} chars", text.len()); log_cmd!("", "type {} chars", text.len());
match input::type_text(&text) { match input::type_text(&text) {
Ok(()) => { Ok(()) => {
log_ok!("Done"); log_ok!("Done");
@ -477,7 +477,7 @@ async fn handle_message(
} }
ServerMessage::ListWindowsRequest { request_id } => { ServerMessage::ListWindowsRequest { request_id } => {
log_cmd!("list-windows"); log_cmd!("🪟", "list-windows");
match windows_mgmt::list_windows() { match windows_mgmt::list_windows() {
Ok(windows) => { Ok(windows) => {
log_ok!("{} windows", windows.len()); log_ok!("{} windows", windows.len());
@ -491,7 +491,7 @@ async fn handle_message(
} }
ServerMessage::MinimizeAllRequest { request_id } => { ServerMessage::MinimizeAllRequest { request_id } => {
log_cmd!("minimize-all"); log_cmd!("🪟", "minimize-all");
match windows_mgmt::minimize_all() { match windows_mgmt::minimize_all() {
Ok(()) => { Ok(()) => {
log_ok!("Done"); log_ok!("Done");
@ -505,7 +505,7 @@ async fn handle_message(
} }
ServerMessage::FocusWindowRequest { request_id, window_id } => { ServerMessage::FocusWindowRequest { request_id, window_id } => {
log_cmd!("focus-window {window_id}"); log_cmd!("🪟", "focus-window {window_id}");
match windows_mgmt::focus_window(window_id) { match windows_mgmt::focus_window(window_id) {
Ok(()) => { Ok(()) => {
log_ok!("Done"); log_ok!("Done");
@ -519,7 +519,7 @@ async fn handle_message(
} }
ServerMessage::MaximizeAndFocusRequest { request_id, window_id } => { ServerMessage::MaximizeAndFocusRequest { request_id, window_id } => {
log_cmd!("maximize-and-focus {window_id}"); log_cmd!("🪟", "maximize-and-focus {window_id}");
match windows_mgmt::maximize_and_focus(window_id) { match windows_mgmt::maximize_and_focus(window_id) {
Ok(()) => { Ok(()) => {
log_ok!("Done"); log_ok!("Done");
@ -533,6 +533,7 @@ async fn handle_message(
} }
ServerMessage::VersionRequest { request_id } => { ServerMessage::VersionRequest { request_id } => {
log_cmd!(" ", "version");
ClientMessage::VersionResponse { ClientMessage::VersionResponse {
request_id, request_id,
version: env!("CARGO_PKG_VERSION").to_string(), version: env!("CARGO_PKG_VERSION").to_string(),
@ -541,7 +542,7 @@ async fn handle_message(
} }
ServerMessage::UploadRequest { request_id, path, content_base64 } => { ServerMessage::UploadRequest { request_id, path, content_base64 } => {
log_cmd!("upload → {}", path); log_cmd!("", "upload → {}", path);
match (|| -> Result<(), String> { match (|| -> Result<(), String> {
let bytes = base64::engine::general_purpose::STANDARD let bytes = base64::engine::general_purpose::STANDARD
.decode(&content_base64) .decode(&content_base64)
@ -564,7 +565,7 @@ async fn handle_message(
} }
ServerMessage::DownloadRequest { request_id, path } => { ServerMessage::DownloadRequest { request_id, path } => {
log_cmd!("download ← {}", path); log_cmd!("", "download ← {}", path);
match std::fs::read(&path) { match std::fs::read(&path) {
Ok(bytes) => { Ok(bytes) => {
let size = bytes.len() as u64; let size = bytes.len() as u64;
@ -580,7 +581,7 @@ async fn handle_message(
} }
ServerMessage::RunRequest { request_id, program, args } => { ServerMessage::RunRequest { request_id, program, args } => {
log_cmd!("run {}", program); log_cmd!("🚀", "run {}", program);
use std::process::Command as StdCommand; use std::process::Command as StdCommand;
match StdCommand::new(&program).args(&args).spawn() { match StdCommand::new(&program).args(&args).spawn() {
Ok(_) => { Ok(_) => {
@ -595,7 +596,7 @@ async fn handle_message(
} }
ServerMessage::ClipboardGetRequest { request_id } => { ServerMessage::ClipboardGetRequest { request_id } => {
log_cmd!("clipboard-get"); log_cmd!("📋", "clipboard-get");
let out = tokio::process::Command::new("powershell.exe") let out = tokio::process::Command::new("powershell.exe")
.args(["-NoProfile", "-NonInteractive", "-Command", "Get-Clipboard"]) .args(["-NoProfile", "-NonInteractive", "-Command", "Get-Clipboard"])
.output().await; .output().await;
@ -610,7 +611,7 @@ async fn handle_message(
} }
ServerMessage::ClipboardSetRequest { request_id, text } => { ServerMessage::ClipboardSetRequest { request_id, text } => {
log_cmd!("clipboard-set {} chars", text.len()); log_cmd!("📋", "clipboard-set {} chars", text.len());
let cmd = format!("Set-Clipboard -Value '{}'", text.replace('\'', "''")); let cmd = format!("Set-Clipboard -Value '{}'", text.replace('\'', "''"));
let out = tokio::process::Command::new("powershell.exe") let out = tokio::process::Command::new("powershell.exe")
.args(["-NoProfile", "-NonInteractive", "-Command", &cmd]) .args(["-NoProfile", "-NonInteractive", "-Command", &cmd])