fix: improve blocking read end-of-response detection

The original '>' detection was too broad and caught tool output lines.
Now we look for '> X: ' pattern (user prompt with speaker prefix) to
detect the start of a new user input, which marks the end of the
previous response.
This commit is contained in:
Kent Overstreet 2026-03-21 23:40:48 -04:00
parent a3acf0a681
commit e74d533748

View file

@ -128,11 +128,15 @@ pub async fn cmd_read_inner(follow: bool, block: bool, debug: bool) -> anyhow::R
print!("{}", line); print!("{}", line);
let _ = std::io::stdout().lock().flush(); let _ = std::io::stdout().lock().flush();
// In blocking mode, stop when we see a new user input (line starting with ">") // In blocking mode, stop when we see a new user input
if block && line.trim_start().starts_with('>') { // Format: "> X: " where X is a speaker (P, K, etc.)
if block && line.trim_start().starts_with("> ") {
let after_gt = line.trim_start().strip_prefix("> ").unwrap_or("");
if after_gt.contains(':') {
break; break;
} }
} }
}
Err(_) => break, Err(_) => break,
} }
} }