fix: banner alignment + rename commands (execute, connect, list windows, set/get clipboard, etc)
This commit is contained in:
parent
20cae0b717
commit
9589958cb1
1 changed files with 34 additions and 26 deletions
|
|
@ -25,7 +25,14 @@ use display::trunc;
|
||||||
|
|
||||||
fn banner() {
|
fn banner() {
|
||||||
println!();
|
println!();
|
||||||
println!(" {} HELIOS REMOTE {}", "☀".yellow().bold(), env!("GIT_COMMIT"));
|
// Use same column layout as info_line: 2sp + emoji_cell(2w) + 2sp + name(14) + 2sp + value
|
||||||
|
// ☀ is 1-wide → emoji_cell pads to 2 → need 1 extra space to match
|
||||||
|
println!(
|
||||||
|
" {} {:<14} {}",
|
||||||
|
"☀ ".yellow().bold(), // 1-wide + explicit space = 2 display cols
|
||||||
|
"HELIOS REMOTE".bold(),
|
||||||
|
env!("GIT_COMMIT").dimmed()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_session_info(label: &str, sid: &uuid::Uuid) {
|
fn print_session_info(label: &str, sid: &uuid::Uuid) {
|
||||||
|
|
@ -44,6 +51,7 @@ fn print_session_info(label: &str, sid: &uuid::Uuid) {
|
||||||
|
|
||||||
display::info_line("🖥", "device:", &label.bold().to_string());
|
display::info_line("🖥", "device:", &label.bold().to_string());
|
||||||
display::info_line("🪪", "session:", &sid.to_string().dimmed().to_string());
|
display::info_line("🪪", "session:", &sid.to_string().dimmed().to_string());
|
||||||
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
@ -206,7 +214,7 @@ async fn main() {
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or(&config.relay_url);
|
.unwrap_or(&config.relay_url);
|
||||||
|
|
||||||
display::cmd_start("🌐", "connecting", host);
|
display::cmd_start("🌐", "connect", host);
|
||||||
|
|
||||||
let tls_connector = TlsConnector::builder()
|
let tls_connector = TlsConnector::builder()
|
||||||
.danger_accept_invalid_certs(true)
|
.danger_accept_invalid_certs(true)
|
||||||
|
|
@ -216,7 +224,7 @@ async fn main() {
|
||||||
|
|
||||||
match connect_async_tls_with_config(&config.relay_url, None, false, Some(connector)).await {
|
match connect_async_tls_with_config(&config.relay_url, None, false, Some(connector)).await {
|
||||||
Ok((ws_stream, _)) => {
|
Ok((ws_stream, _)) => {
|
||||||
display::cmd_done("🌐", "connecting", host, true, "connected");
|
display::cmd_done("🌐", "connect", host, true, "connected");
|
||||||
backoff = Duration::from_secs(1);
|
backoff = Duration::from_secs(1);
|
||||||
|
|
||||||
let (mut write, mut read) = ws_stream.split();
|
let (mut write, mut read) = ws_stream.split();
|
||||||
|
|
@ -272,12 +280,12 @@ async fn main() {
|
||||||
let _ = w.send(Message::Pong(data)).await;
|
let _ = w.send(Message::Pong(data)).await;
|
||||||
}
|
}
|
||||||
Ok(Message::Close(_)) => {
|
Ok(Message::Close(_)) => {
|
||||||
display::cmd_start("🌐", "connecting", host);
|
display::cmd_start("🌐", "connect", host);
|
||||||
display::cmd_done("🌐", "connecting", host, false, "connection lost");
|
display::cmd_done("🌐", "connect", host, false, "connection lost");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_done("🌐", "connecting", host, false, &format!("lost: {e}"));
|
display::cmd_done("🌐", "connect", host, false, &format!("lost: {e}"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -285,8 +293,8 @@ async fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_start("🌐", "connecting", host);
|
display::cmd_start("🌐", "connect", host);
|
||||||
display::cmd_done("🌐", "connecting", host, false, &format!("{e}"));
|
display::cmd_done("🌐", "connect", host, false, &format!("{e}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,7 +394,7 @@ async fn handle_message(
|
||||||
|
|
||||||
ServerMessage::ExecRequest { request_id, command, timeout_ms } => {
|
ServerMessage::ExecRequest { request_id, command, timeout_ms } => {
|
||||||
let payload = trunc(&command, 80);
|
let payload = trunc(&command, 80);
|
||||||
display::cmd_start("⚡", "exec", &payload);
|
display::cmd_start("⚡", "execute", &payload);
|
||||||
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)) => {
|
||||||
|
|
@ -400,12 +408,12 @@ async fn handle_message(
|
||||||
} else {
|
} else {
|
||||||
first_line // success: just the output, no "exit 0"
|
first_line // success: just the output, no "exit 0"
|
||||||
};
|
};
|
||||||
display::cmd_done("⚡", "exec", &payload, exit_code == 0, &result);
|
display::cmd_done("⚡", "execute", &payload, exit_code == 0, &result);
|
||||||
let _ = stderr;
|
let _ = stderr;
|
||||||
ClientMessage::ExecResponse { request_id, stdout, stderr, exit_code }
|
ClientMessage::ExecResponse { request_id, stdout, stderr, exit_code }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_done("⚡", "exec", &payload, false, &format!("exec failed: {e}"));
|
display::cmd_done("⚡", "execute", &payload, false, &format!("exec failed: {e}"));
|
||||||
ClientMessage::Error { request_id, message: format!("Exec failed for command {:?}.\nError: {e}", command) }
|
ClientMessage::Error { request_id, message: format!("Exec failed for command {:?}.\nError: {e}", command) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -442,28 +450,28 @@ async fn handle_message(
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerMessage::ListWindowsRequest { request_id } => {
|
ServerMessage::ListWindowsRequest { request_id } => {
|
||||||
display::cmd_start("🪟", "list-windows", "");
|
display::cmd_start("🪟", "list windows", "");
|
||||||
match windows_mgmt::list_windows() {
|
match windows_mgmt::list_windows() {
|
||||||
Ok(windows) => {
|
Ok(windows) => {
|
||||||
display::cmd_done("🪟", "list-windows", "", true, &format!("{} windows", windows.len()));
|
display::cmd_done("🪟", "list windows", "", true, &format!("{} windows", windows.len()));
|
||||||
ClientMessage::ListWindowsResponse { request_id, windows }
|
ClientMessage::ListWindowsResponse { request_id, windows }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_done("🪟", "list-windows", "", false, &e);
|
display::cmd_done("🪟", "list windows", "", false, &e);
|
||||||
ClientMessage::Error { request_id, message: e }
|
ClientMessage::Error { request_id, message: e }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerMessage::MinimizeAllRequest { request_id } => {
|
ServerMessage::MinimizeAllRequest { request_id } => {
|
||||||
display::cmd_start("🪟", "minimize-all", "");
|
display::cmd_start("🪟", "minimize all", "");
|
||||||
match windows_mgmt::minimize_all() {
|
match windows_mgmt::minimize_all() {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
display::cmd_done("🪟", "minimize-all", "", true, "done");
|
display::cmd_done("🪟", "minimize all", "", true, "done");
|
||||||
ClientMessage::Ack { request_id }
|
ClientMessage::Ack { request_id }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_done("🪟", "minimize-all", "", false, &e);
|
display::cmd_done("🪟", "minimize all", "", false, &e);
|
||||||
ClientMessage::Error { request_id, message: e }
|
ClientMessage::Error { request_id, message: e }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -471,14 +479,14 @@ async fn handle_message(
|
||||||
|
|
||||||
ServerMessage::FocusWindowRequest { request_id, window_id } => {
|
ServerMessage::FocusWindowRequest { request_id, window_id } => {
|
||||||
let payload = format!("{window_id}");
|
let payload = format!("{window_id}");
|
||||||
display::cmd_start("🪟", "focus-window", &payload);
|
display::cmd_start("🪟", "focus window", &payload);
|
||||||
match windows_mgmt::focus_window(window_id) {
|
match windows_mgmt::focus_window(window_id) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
display::cmd_done("🪟", "focus-window", &payload, true, "done");
|
display::cmd_done("🪟", "focus window", &payload, true, "done");
|
||||||
ClientMessage::Ack { request_id }
|
ClientMessage::Ack { request_id }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_done("🪟", "focus-window", &payload, false, &e);
|
display::cmd_done("🪟", "focus window", &payload, false, &e);
|
||||||
ClientMessage::Error { request_id, message: e }
|
ClientMessage::Error { request_id, message: e }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -575,18 +583,18 @@ async fn handle_message(
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerMessage::ClipboardGetRequest { request_id } => {
|
ServerMessage::ClipboardGetRequest { request_id } => {
|
||||||
display::cmd_start("📋", "clipboard-get", "");
|
display::cmd_start("📋", "get clipboard", "");
|
||||||
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;
|
||||||
match out {
|
match out {
|
||||||
Ok(o) => {
|
Ok(o) => {
|
||||||
let text = String::from_utf8_lossy(&o.stdout).trim().to_string();
|
let text = String::from_utf8_lossy(&o.stdout).trim().to_string();
|
||||||
display::cmd_done("📋", "clipboard-get", "", true, &text);
|
display::cmd_done("📋", "get clipboard", "", true, &text);
|
||||||
ClientMessage::ClipboardGetResponse { request_id, text }
|
ClientMessage::ClipboardGetResponse { request_id, text }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_done("📋", "clipboard-get", "", false, &format!("{e}"));
|
display::cmd_done("📋", "get clipboard", "", false, &format!("{e}"));
|
||||||
ClientMessage::Error { request_id, message: format!("Clipboard get failed: {e}") }
|
ClientMessage::Error { request_id, message: format!("Clipboard get failed: {e}") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -594,18 +602,18 @@ async fn handle_message(
|
||||||
|
|
||||||
ServerMessage::ClipboardSetRequest { request_id, text } => {
|
ServerMessage::ClipboardSetRequest { request_id, text } => {
|
||||||
let payload = trunc(&text, 60);
|
let payload = trunc(&text, 60);
|
||||||
display::cmd_start("📋", "clipboard-set", &payload);
|
display::cmd_start("📋", "set clipboard", &payload);
|
||||||
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])
|
||||||
.output().await;
|
.output().await;
|
||||||
match out {
|
match out {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
display::cmd_done("📋", "clipboard-set", &payload, true, &payload);
|
display::cmd_done("📋", "set clipboard", &payload, true, &payload);
|
||||||
ClientMessage::Ack { request_id }
|
ClientMessage::Ack { request_id }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
display::cmd_done("📋", "clipboard-set", &payload, false, &format!("{e}"));
|
display::cmd_done("📋", "set clipboard", &payload, false, &format!("{e}"));
|
||||||
ClientMessage::Error { request_id, message: format!("Clipboard set failed: {e}") }
|
ClientMessage::Error { request_id, message: format!("Clipboard set failed: {e}") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue