cli steering: only advertise steering when reader is active

Codex review: on non-unix the reader never spawns even when the session
is interactive, so gate the hint line on SteerControl::is_active() and
the spinner hint on cfg!(unix).
This commit is contained in:
Michael Neale 2026-07-03 06:56:15 +10:00
parent 818eaf52d5
commit 838631de5d
2 changed files with 15 additions and 3 deletions

View file

@ -507,9 +507,10 @@ impl CliSession {
async fn run_interactive(&mut self, prompt: Option<String>) -> Result<()> { async fn run_interactive(&mut self, prompt: Option<String>) -> Result<()> {
// Advertise mid-run steering in the thinking spinner when the steer // Advertise mid-run steering in the thinking spinner when the steer
// reader will be active (interactive tty session). // reader will be active (interactive tty session on a platform that
// supports mid-run stdin reading).
output::set_steer_hint_enabled( output::set_steer_hint_enabled(
std::io::stdin().is_terminal() && std::io::stdout().is_terminal(), cfg!(unix) && std::io::stdin().is_terminal() && std::io::stdout().is_terminal(),
); );
if let Some(prompt) = prompt { if let Some(prompt) = prompt {
let msg = Message::user().with_text(&prompt); let msg = Message::user().with_text(&prompt);
@ -1210,7 +1211,9 @@ impl CliSession {
&& std::io::stdin().is_terminal() && std::io::stdin().is_terminal()
&& std::io::stdout().is_terminal(); && std::io::stdout().is_terminal();
let (steer_control, mut steer_rx) = steer::spawn_steer_reader(steer_enabled); let (steer_control, mut steer_rx) = steer::spawn_steer_reader(steer_enabled);
if steer_enabled { // Only advertise steering when a reader actually started (it does
// not on non-unix platforms even when `steer_enabled` is true).
if steer_control.is_active() {
output::render_steer_hint(); output::render_steer_hint();
} }

View file

@ -67,6 +67,15 @@ pub fn spawn_steer_reader(enabled: bool) -> (SteerControl, mpsc::UnboundedReceiv
) )
} }
impl SteerControl {
/// Whether a reader thread is actually running. False when steering was
/// disabled or the platform does not support mid-run stdin reading
/// (non-unix), in which case no steering UI should be shown.
pub fn is_active(&self) -> bool {
self.handle.is_some()
}
}
pub struct SteerControl { pub struct SteerControl {
stop: Arc<AtomicBool>, stop: Arc<AtomicBool>,
paused: Arc<AtomicBool>, paused: Arc<AtomicBool>,