diff --git a/src/commands/bot.rs b/src/commands/bot.rs index 947b606..d454bd5 100644 --- a/src/commands/bot.rs +++ b/src/commands/bot.rs @@ -40,12 +40,25 @@ impl ClaudeSession { .current_dir(&work_dir) .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .stderr(Stdio::null()) + .stderr(Stdio::piped()) .spawn() .context("failed to start claude process")?; let stdin = child.stdin.take().context("failed to capture claude stdin")?; let stdout = child.stdout.take().context("failed to capture claude stdout")?; + let stderr = child.stderr.take().context("failed to capture claude stderr")?; + + // Background task: log stderr + tokio::spawn(async move { + let reader = BufReader::new(stderr); + let mut lines = reader.lines(); + while let Ok(Some(line)) = lines.next_line().await { + eprintln!("bot: claude stderr: {}", line); + } + }); + + // Brief wait to check if the process exits immediately + tokio::time::sleep(std::time::Duration::from_millis(500)).await; let (tx, rx) = tokio::sync::mpsc::channel::(16); @@ -58,8 +71,14 @@ impl ClaudeSession { loop { let line = match lines.next_line().await { Ok(Some(l)) => l, - Ok(None) => break, - Err(_) => break, + Ok(None) => { + eprintln!("bot: claude stdout closed"); + break; + } + Err(e) => { + eprintln!("bot: claude stdout error: {}", e); + break; + } }; if line.trim().is_empty() { @@ -106,7 +125,8 @@ impl ClaudeSession { } // Wait for child to exit - let _ = child.wait().await; + let status = child.wait().await; + eprintln!("bot: claude process exited: {:?}", status); }); Ok(Self {