From 4eeaa852598ce1eaa782a8cc38897019f302dd21 Mon Sep 17 00:00:00 2001 From: Cody De Arkland Date: Fri, 17 Apr 2026 00:43:56 -0700 Subject: [PATCH] fix: remove extra blank lines in `railway agent` REPL output The thinking spinner and the Chunk/ToolCallReady handlers were each unconditionally emitting a `println!()`, stacking multiple blank lines between user input and the agent's response. Drop the unconditional newline before the initial spinner, and only emit a leading newline in the Chunk/ToolCallReady handlers when a spinner wasn't just cleared (since `finish_and_clear` already leaves the cursor on a blank line). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/commands/agent.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/commands/agent.rs b/src/commands/agent.rs index 367b26717..781e95019 100644 --- a/src/commands/agent.rs +++ b/src/commands/agent.rs @@ -153,7 +153,6 @@ async fn run_single_shot( // Show a thinking spinner while waiting for the first event if is_tty { let msg = THINKING_MESSAGES[rand::thread_rng().gen_range(0..THINKING_MESSAGES.len())]; - println!(); spinner = Some(create_spinner(msg.dimmed().to_string())); } @@ -234,7 +233,6 @@ async fn run_repl( if is_tty { let msg = THINKING_MESSAGES[rand::thread_rng().gen_range(0..THINKING_MESSAGES.len())]; - println!(); spinner = Some(create_spinner(msg.dimmed().to_string())); } @@ -264,11 +262,11 @@ fn handle_event_human( ) { match event { ChatEvent::Chunk { text } => { - if let Some(s) = spinner.take() { - s.finish_and_clear(); - } + let cleared_spinner = spinner.take().map(|s| s.finish_and_clear()).is_some(); if !*has_printed_text { - println!(); + if !cleared_spinner { + println!(); + } print!("{} ", "Railway Agent:".purple().bold()); *has_printed_text = true; } @@ -277,11 +275,11 @@ fn handle_event_human( } ChatEvent::ToolCallReady { tool_name, .. } => { if is_tty { - if let Some(s) = spinner.take() { - s.finish_and_clear(); - } + let cleared_spinner = spinner.take().map(|s| s.finish_and_clear()).is_some(); *has_printed_text = false; - println!(); + if !cleared_spinner { + println!(); + } *spinner = Some(create_spinner(format!( "{} {}", "╰─".dimmed(),