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,11 +128,15 @@ pub async fn cmd_read_inner(follow: bool, block: bool, debug: bool) -> anyhow::R
|
|||
print!("{}", line);
|
||||
let _ = std::io::stdout().lock().flush();
|
||||
|
||||
// In blocking mode, stop when we see a new user input (line starting with ">")
|
||||
if block && line.trim_start().starts_with('>') {
|
||||
// In blocking mode, stop when we see a new user input
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => break,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue