feat: prompt command (MessageBox), admin status in banner

This commit is contained in:
Helios Agent 2026-03-03 15:44:27 +01:00
parent fdd2124da8
commit e0edf60461
No known key found for this signature in database
GPG key ID: C8259547CD8309B5
6 changed files with 100 additions and 0 deletions

View file

@ -23,9 +23,26 @@ mod windows_mgmt;
fn banner() {
println!();
println!(" {} HELIOS REMOTE v{} ({})", "".yellow().bold(), env!("CARGO_PKG_VERSION"), env!("GIT_COMMIT"));
#[cfg(windows)]
{
let admin = is_admin();
let admin_str = if admin {
"admin".green().bold()
} else {
"user (no admin)".yellow()
};
println!(" {} running as {}", "".repeat(20).dimmed(), admin_str);
}
#[cfg(not(windows))]
println!(" {}", "".repeat(45).dimmed());
}
#[cfg(windows)]
fn is_admin() -> bool {
use windows::Win32::UI::Shell::IsUserAnAdmin;
unsafe { IsUserAnAdmin().as_bool() }
}
macro_rules! log_status {
($($arg:tt)*) => {
println!(" {} {}", "".cyan().bold(), format!($($arg)*));
@ -325,6 +342,37 @@ async fn handle_message(
}
}
ServerMessage::PromptRequest { request_id, message, title } => {
let title = title.unwrap_or_else(|| "Helios Remote".to_string());
log_cmd!("prompt {}", &message[..message.len().min(60)]);
#[cfg(windows)]
{
use windows::core::PCWSTR;
use windows::Win32::UI::WindowsAndMessaging::{MessageBoxW, MB_OK, MB_ICONINFORMATION, HWND_DESKTOP};
let msg_wide: Vec<u16> = message.encode_utf16().chain(std::iter::once(0)).collect();
let title_wide: Vec<u16> = title.encode_utf16().chain(std::iter::once(0)).collect();
// Run blocking MessageBox in a thread so we don't block the async runtime
let msg_clone = message.clone();
tokio::task::spawn_blocking(move || {
unsafe {
MessageBoxW(
HWND_DESKTOP,
PCWSTR(msg_wide.as_ptr()),
PCWSTR(title_wide.as_ptr()),
MB_OK | MB_ICONINFORMATION,
);
}
}).await.ok();
log_ok!("User confirmed: {}", &msg_clone[..msg_clone.len().min(40)]);
}
#[cfg(not(windows))]
{
// On non-Windows just log it
println!(" [PROMPT] {}", message);
}
ClientMessage::Ack { request_id }
}
ServerMessage::ExecRequest { request_id, command } => {
// Truncate long commands for display
let cmd_display = if command.len() > 60 {