Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix: use quiescence drain for PTY prompt to prevent echo interleaving (#1133)
worktrunk-botd51527df654c
diff --git a/tests/common/pty.rs b/tests/common/pty.rsindex 47ee05824..399a79623 100644--- a/tests/common/pty.rs+++ b/tests/common/pty.rs@@ -333,6 +333,28 @@ fn prompted_pty_interaction(std::thread::sleep(poll);}+ // Quiescence drain: after detecting the marker, wait until the PTY+ // goes quiet before sending input. Without this, trailing prompt bytes+ // (ANSI resets, spaces) that arrive in a separate read chunk interleave+ // with the echo of our input, producing non-deterministic output on macOS.+ let quiescence = Duration::from_millis(20);+ let drain_ceiling = Duration::from_millis(500);+ let drain_start = Instant::now();+ let mut last_data = Instant::now();+ loop {+ while let Ok(chunk) = rx.try_recv() {+ accumulated.extend_from_slice(&chunk);+ last_data = Instant::now();+ }+ if last_data.elapsed() >= quiescence {+ break;+ }+ if drain_start.elapsed() >= drain_ceiling {+ break;+ }+ std::thread::sleep(poll);+ }+writer.write_all(input.as_bytes()).unwrap();writer.flush().unwrap();}