fix: flush stdout prompts in first-run config wizard

The prompt_config() function used print!() without flushing stdout,
causing all prompts to be buffered and invisible to the user. The
program appeared to hang silently after 'No config found — first-time
setup'.

Changes:
- Add std::io::stdout().flush().unwrap() after each print!() prompt
- Style prompts with cyan '→' prefix to match CLI conventions
- Show default values in square brackets for relay URL and label
- Use hostname() as default label (was previously Optional/None)
- Add blank line after prompts before '✓ Config saved'
This commit is contained in:
Helios 2026-03-03 14:11:58 +01:00
parent e32e09996b
commit 9e6878a93f
No known key found for this signature in database
GPG key ID: C8259547CD8309B5

View file

@ -90,31 +90,42 @@ impl Config {
}
fn prompt_config() -> Config {
use std::io::Write;
let relay_url = {
print!(" Relay server URL [default: wss://remote.agent-helios.me/ws]: ");
let default = "wss://remote.agent-helios.me/ws";
print!(" {} Relay URL [{}]: ", "".cyan().bold(), default);
std::io::stdout().flush().unwrap();
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let trimmed = input.trim();
if trimmed.is_empty() {
"wss://remote.agent-helios.me/ws".to_string()
default.to_string()
} else {
trimmed.to_string()
}
};
let api_key = {
print!(" API Key: ");
print!(" {} API Key: ", "".cyan().bold());
std::io::stdout().flush().unwrap();
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
input.trim().to_string()
};
let label = {
print!(" Label for this machine (optional, press Enter to skip): ");
let default_label = hostname();
print!(" {} Label for this PC [{}]: ", "".cyan().bold(), default_label);
std::io::stdout().flush().unwrap();
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let trimmed = input.trim().to_string();
if trimmed.is_empty() { None } else { Some(trimmed) }
if trimmed.is_empty() {
Some(default_label)
} else {
Some(trimmed)
}
};
Config { relay_url, api_key, label }
@ -136,6 +147,7 @@ async fn main() {
log_status!("No config found — first-time setup");
println!();
let c = prompt_config();
println!();
if let Err(e) = c.save() {
log_err!("Failed to save config: {e}");
} else {