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:
parent
a3acf0a681
commit
e74d533748
1 changed files with 7 additions and 3 deletions
|
|
@ -128,9 +128,13 @@ 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.)
|
||||||
break;
|
if block && line.trim_start().starts_with("> ") {
|
||||||
|
let after_gt = line.trim_start().strip_prefix("> ").unwrap_or("");
|
||||||
|
if after_gt.contains(':') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => break,
|
Err(_) => break,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue