Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix: Use patient backoff for PTY drain in progressive output tests (#57)

Maximilian Roos8b0352d1c95e
diff --git a/README.md b/README.md
index ae5f83346..5da9c95cb 100644
--- a/README.md
+++ b/README.md
@@ -181,17 +181,6 @@ git branch -d feature</pre></td>
Many Worktrunk users will just use the commands above. For more:
-### Shell integration
-
-Shell integration lets `wt switch`, `wt merge`, and `wt remove` change
-directories:
-
-```console
-wt config shell install # Bash, Zsh, Fish
-```
-
-or for manual setup: `wt config shell --help`.
-
### LLM commit messages
Worktrunk can invoke external commands to generate commit messages.
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index a816bf75e..a1e17a2fc 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -1001,15 +1001,6 @@ impl Default for ExponentialBackoff {
}
impl ExponentialBackoff {
- /// Create with fast initial polling (1ms start), good for low-latency scenarios.
- pub fn fast() -> Self {
- Self {
- initial_ms: 1,
- max_ms: 100,
- timeout: std::time::Duration::from_secs(5),
- }
- }
-
/// Sleep for the appropriate duration based on attempt number.
pub fn sleep(&self, attempt: u32) {
let ms = (self.initial_ms * (1u64 << attempt.min(20))).min(self.max_ms);
diff --git a/tests/common/progressive_output.rs b/tests/common/progressive_output.rs
index 8be5b6640..0240f9c22 100644
--- a/tests/common/progressive_output.rs
+++ b/tests/common/progressive_output.rs
@@ -110,9 +110,8 @@ const OUTPUT_POLL_INTERVAL_MS: u64 = 10;
/// Number of consecutive "no data" reads required before considering the stream truly empty.
/// On Linux, the PTY may return EOF before all data has arrived (kernel scheduling).
-/// With exponential backoff (1ms → 2ms → 4ms → 8ms → 16ms), threshold 6 gives ~31ms
-/// of total waiting, enough for slow CI systems to flush PTY buffers.
-const STABLE_READ_THRESHOLD: u32 = 6;
+/// Uses default exponential backoff (10ms → 500ms cap, 5s timeout) for reliability.
+const STABLE_READ_THRESHOLD: u32 = 4;
/// Strategy for capturing progressive output snapshots
#[derive(Debug, Clone)]
@@ -431,7 +430,8 @@ pub fn capture_progressive_output(
if let Ok(Some(_)) = child.try_wait() {
// Drain remaining PTY data using exponential backoff.
// Requires STABLE_READ_THRESHOLD consecutive EOFs before considering done.
- let backoff = ExponentialBackoff::fast();
+ // Uses default backoff (500ms cap, 5s timeout) for reliability on slow CI.
+ let backoff = ExponentialBackoff::default();
let mut attempt = 0u32;
let mut consecutive_no_data = 0u32;
let drain_start = Instant::now();
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index c0fefebd6..327692187 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -710,10 +710,12 @@ fn test_merge_squash_llm_error() {
// This tests that:
// 1. The full command (with args) is shown in the error header
// 2. The error output appears in a gutter
+ // Note: We consume stdin first to avoid race condition where stdin write fails
+ // before stderr is captured (broken pipe if process exits before reading stdin)
let worktrunk_config = r#"
[commit-generation]
command = "sh"
-args = ["-c", "echo 'Error: connection refused' >&2 && exit 1"]
+args = ["-c", "cat > /dev/null; echo 'Error: connection refused' >&2 && exit 1"]
"#;
fs::write(repo.test_config_path(), worktrunk_config).unwrap();
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap
index edd1327a9..a051030ae 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_error.snap
@@ -30,4 +30,4 @@ exit_code: 1
  Error: connection refused
⚪ Ran command:
-  sh -c echo 'Error: connection refused' >&2 && exit 1
+  sh -c cat > /dev/null; echo 'Error: connection refused' >&2 && exit 1