feat: prompt reads from stdin in CLI (🌀/🎤 table rows, purple answer)
This commit is contained in:
parent
9589958cb1
commit
1ec82cd177
2 changed files with 50 additions and 29 deletions
|
|
@ -360,35 +360,15 @@ async fn handle_message(
|
|||
}
|
||||
}
|
||||
|
||||
ServerMessage::PromptRequest { request_id, message, title } => {
|
||||
let _title = title.unwrap_or_else(|| "Helios Remote".to_string());
|
||||
#[cfg(windows)]
|
||||
let title = _title.clone();
|
||||
let payload = trunc(&message, 60);
|
||||
display::cmd_start("💬", "prompt", &payload);
|
||||
#[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();
|
||||
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();
|
||||
display::cmd_done("💬", "prompt", &payload, true, "confirmed");
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
println!(" [PROMPT] {}", message);
|
||||
display::cmd_done("💬", "prompt", &payload, true, "shown");
|
||||
}
|
||||
ServerMessage::PromptRequest { request_id, message, title: _ } => {
|
||||
display::prompt_waiting(&message);
|
||||
// Read user input from stdin (blocking)
|
||||
let answer = tokio::task::spawn_blocking(|| {
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).ok();
|
||||
input.trim().to_string()
|
||||
}).await.unwrap_or_default();
|
||||
display::prompt_done(&message, &answer);
|
||||
ClientMessage::Ack { request_id }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue