From 9e6878a93fa079ac5274d1d24426119d7246f5d7 Mon Sep 17 00:00:00 2001 From: Helios Date: Tue, 3 Mar 2026 14:11:58 +0100 Subject: [PATCH] fix: flush stdout prompts in first-run config wizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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' --- crates/client/src/main.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs index 86e7c87..9d26d9d 100644 --- a/crates/client/src/main.rs +++ b/crates/client/src/main.rs @@ -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 {