Skip to content

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

feat(list): add experimental per-task timeout config (#601)

Maximilian Roose551c4d3335a
diff --git a/.claude-plugin/skills/worktrunk/reference/config.md b/.claude-plugin/skills/worktrunk/reference/config.md
index 33cd1e1cc..4cdac22a9 100644
--- a/.claude-plugin/skills/worktrunk/reference/config.md
+++ b/.claude-plugin/skills/worktrunk/reference/config.md
@@ -350,6 +350,7 @@ worktree-path = "../{{ repo }}.{{ branch | sanitize }}"
full = false # Show CI and default-branch merge-base diffstat (`main…±` column) by default
branches = false # Include branches without worktrees by default
remotes = false # Include remote branches by default
+timeout-ms = 0 # (Experimental) Per-task timeout in ms; 0 = no timeout; --full disables
# Commit Defaults (shared by `wt step commit`, `wt step squash`, and `wt merge`)
[commit]
diff --git a/dev/config.example.toml b/dev/config.example.toml
index 324429ed3..1d876aa24 100644
--- a/dev/config.example.toml
+++ b/dev/config.example.toml
@@ -51,6 +51,7 @@ worktree-path = "../{{ repo }}.{{ branch | sanitize }}"
full = false # Show CI and default-branch merge-base diffstat (`main…±` column) by default
branches = false # Include branches without worktrees by default
remotes = false # Include remote branches by default
+timeout-ms = 0 # (Experimental) Per-task timeout in ms; 0 = no timeout; --full disables
# Commit Defaults (shared by `wt step commit`, `wt step squash`, and `wt merge`)
[commit]
diff --git a/docs/content/config.md b/docs/content/config.md
index 3a7765aab..cf73aadb3 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -360,6 +360,7 @@ worktree-path = "../{{ repo }}.{{ branch | sanitize }}"
full = false # Show CI and default-branch merge-base diffstat (`main…±` column) by default
branches = false # Include branches without worktrees by default
remotes = false # Include remote branches by default
+timeout-ms = 0 # (Experimental) Per-task timeout in ms; 0 = no timeout; --full disables
# Commit Defaults (shared by `wt step commit`, `wt step squash`, and `wt merge`)
[commit]
diff --git a/src/commands/list/collect.rs b/src/commands/list/collect.rs
index 0e2673b78..5aa13309f 100644
--- a/src/commands/list/collect.rs
+++ b/src/commands/list/collect.rs
@@ -318,6 +318,15 @@ struct MissingResult {
missing_kinds: Vec<TaskKind>,
}
+/// Cause of a task error.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum ErrorCause {
+ /// Command exceeded the configured timeout.
+ Timeout,
+ /// Any other error (permission denied, git error, etc.).
+ Other,
+}
+
/// Error during task execution.
///
/// Tasks return this instead of swallowing errors. The drain layer
@@ -327,16 +336,29 @@ pub struct TaskError {
pub item_idx: usize,
pub kind: TaskKind,
pub message: String,
+ /// What caused this error. Use `is_timeout()` to check.
+ cause: ErrorCause,
}
impl TaskError {
- pub fn new(item_idx: usize, kind: TaskKind, message: impl Into<String>) -> Self {
+ pub fn new(
+ item_idx: usize,
+ kind: TaskKind,
+ message: impl Into<String>,
+ cause: ErrorCause,
+ ) -> Self {
Self {
item_idx,
kind,
message: message.into(),
+ cause,
}
}
+
+ /// Whether this error was caused by a timeout.
+ pub fn is_timeout(&self) -> bool {
+ self.cause == ErrorCause::Timeout
+ }
}
/// Tracks expected result types per item for timeout diagnostics.
@@ -1280,6 +1302,10 @@ pub fn collect(
}
}
+ // Count errors for summary
+ let error_count = errors.len();
+ let timed_out_count = errors.iter().filter(|e| e.is_timeout()).count();
+
// Finalize progressive table or render buffered output
if let Some(mut table) = progressive_table {
// Build final summary string
@@ -1287,6 +1313,8 @@ pub fn collect(
&all_items,
show_branches || show_remotes,
layout.hidden_column_count,
+ error_count,
+ timed_out_count,
);
if table.is_tty() {
@@ -1312,6 +1340,8 @@ pub fn collect(
&all_items,
show_branches || show_remotes,
layout.hidden_column_count,
+ error_count,
+ timed_out_count,
);
crate::output::stdout(layout.format_header_line())?;
@@ -1325,13 +1355,17 @@ pub fn collect(
// Status symbols are now computed during data collection (both modes), no fallback needed
// Display collection errors/warnings (after table rendering)
- if !errors.is_empty() || progress_overflow {
+ // Filter out timeout errors - they're shown in the summary footer
+ let non_timeout_errors: Vec<_> = errors.iter().filter(|e| !e.is_timeout()).collect();
+
+ if !non_timeout_errors.is_empty() || progress_overflow {
let mut warning_parts = Vec::new();
- if !errors.is_empty() {
+ if !non_timeout_errors.is_empty() {
// Sort for deterministic output (tasks complete in arbitrary order)
- errors.sort_by_key(|e| (e.item_idx, e.kind));
- let error_lines: Vec<String> = errors
+ let mut sorted_errors = non_timeout_errors;
+ sorted_errors.sort_by_key(|e| (e.item_idx, e.kind));
+ let error_lines: Vec<String> = sorted_errors
.iter()
.map(|error| {
let name = all_items[error.item_idx].branch_name();
@@ -1583,3 +1617,20 @@ pub fn populate_item(
Ok(())
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_task_error_other_is_not_timeout() {
+ let error = TaskError::new(0, TaskKind::AheadBehind, "test error", ErrorCause::Other);
+ assert!(!error.is_timeout());
+ }
+
+ #[test]
+ fn test_task_error_timeout_is_timeout() {
+ let error = TaskError::new(0, TaskKind::AheadBehind, "timed out", ErrorCause::Timeout);
+ assert!(error.is_timeout());
+ }
+}
diff --git a/src/commands/list/collect_progressive_impl.rs b/src/commands/list/collect_progressive_impl.rs
index 087ba775e..15ddfaa3c 100644
--- a/src/commands/list/collect_progressive_impl.rs
+++ b/src/commands/list/collect_progressive_impl.rs
@@ -19,12 +19,13 @@
//! This avoids nested parallelism (Rayon → thread::scope) which could create 100+ threads.
use crossbeam_channel::Sender;
-use std::fmt::Display;
use std::sync::Arc;
use worktrunk::git::{BranchRef, LineDiff, Repository, WorktreeInfo};
use super::ci_status::PrStatus;
-use super::collect::{ExpectedResults, TaskError, TaskKind, TaskResult, detect_git_operation};
+use super::collect::{
+ ErrorCause, ExpectedResults, TaskError, TaskKind, TaskResult, detect_git_operation,
+};
use super::model::{
AheadBehind, BranchDiffTotals, CommitDetails, UpstreamStatus, WorkingTreeStatus,
};
@@ -116,8 +117,24 @@ pub struct TaskContext {
}
impl TaskContext {
- fn error(&self, kind: TaskKind, message: impl Display) -> TaskError {
- TaskError::new(self.item_idx, kind, message.to_string())
+ fn error(&self, kind: TaskKind, err: &anyhow::Error) -> TaskError {
+ // Check if any error in the chain is a timeout
+ let is_timeout = err.chain().any(|e| {
+ e.downcast_ref::<std::io::Error>()
+ .is_some_and(|io_err| io_err.kind() == std::io::ErrorKind::TimedOut)
+ });
+
+ let cause = if is_timeout {
+ let kind_str: &'static str = kind.into();
+ let sha = &self.branch_ref.commit_sha;
+ let short_sha = &sha[..sha.len().min(8)];
+ let branch = self.branch_ref.branch.as_deref().unwrap_or(short_sha);
+ log::debug!("Task {} timed out for {}", kind_str, branch);
+ ErrorCause::Timeout
+ } else {
+ ErrorCause::Other
+ };
+ TaskError::new(self.item_idx, kind, err.to_string(), cause)
}
/// Get the default branch (cached in Repository).
@@ -399,7 +416,7 @@ impl Task for CommitDetailsTask {
let repo = &ctx.repo;
let (timestamp, commit_message) = repo
.commit_details(&ctx.branch_ref.commit_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::CommitDetails {
item_idx: ctx.item_idx,
commit: CommitDetails {
@@ -431,7 +448,7 @@ impl Task for AheadBehindTask {
// merge_base() is cached, so this is cheap after first call.
let is_orphan = repo
.merge_base(&base, &ctx.branch_ref.commit_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?
+ .map_err(|e| ctx.error(Self::KIND, &e))?
.is_none();
if is_orphan {
@@ -450,11 +467,11 @@ impl Task for AheadBehindTask {
counts
} else {
repo.ahead_behind(&base, &ctx.branch_ref.commit_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?
+ .map_err(|e| ctx.error(Self::KIND, &e))?
}
} else {
repo.ahead_behind(&base, &ctx.branch_ref.commit_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?
+ .map_err(|e| ctx.error(Self::KIND, &e))?
};
Ok(TaskResult::AheadBehind {
@@ -486,7 +503,7 @@ impl Task for CommittedTreesMatchTask {
// worktrees, HEAD is the main worktree's HEAD.
let committed_trees_match = repo
.trees_match(&ctx.branch_ref.commit_sha, &base)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::CommittedTreesMatch {
item_idx: ctx.item_idx,
committed_trees_match,
@@ -528,7 +545,7 @@ impl Task for HasFileChangesTask {
let repo = &ctx.repo;
let has_file_changes = repo
.has_added_changes(branch, &target)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::HasFileChanges {
item_idx: ctx.item_idx,
@@ -571,7 +588,7 @@ impl Task for WouldMergeAddTask {
let repo = &ctx.repo;
let would_merge_add = repo
.would_merge_add_to_target(branch, &base)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::WouldMergeAdd {
item_idx: ctx.item_idx,
would_merge_add,
@@ -603,7 +620,7 @@ impl Task for IsAncestorTask {
let repo = &ctx.repo;
let is_ancestor = repo
.is_ancestor(&ctx.branch_ref.commit_sha, &base)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::IsAncestor {
item_idx: ctx.item_idx,
@@ -629,7 +646,7 @@ impl Task for BranchDiffTask {
let repo = &ctx.repo;
let diff = repo
.branch_diff_stats(&base, &ctx.branch_ref.commit_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::BranchDiff {
item_idx: ctx.item_idx,
@@ -657,14 +674,14 @@ impl Task for WorkingTreeDiffTask {
// `git stash create` which needs the index lock.
let status_output = wt
.run_command(&["--no-optional-locks", "status", "--porcelain"])
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
let (working_tree_status, is_dirty, has_conflicts) =
parse_working_tree_status(&status_output);
let working_tree_diff = if is_dirty {
wt.working_tree_diff_stats()
- .map_err(|e| ctx.error(Self::KIND, e))?
+ .map_err(|e| ctx.error(Self::KIND, &e))?
} else {
LineDiff::default()
};
@@ -698,7 +715,7 @@ impl Task for MergeTreeConflictsTask {
let repo = &ctx.repo;
let has_merge_tree_conflicts = repo
.has_merge_conflicts(&base, &ctx.branch_ref.commit_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::MergeTreeConflicts {
item_idx: ctx.item_idx,
has_merge_tree_conflicts,
@@ -734,7 +751,7 @@ impl Task for WorkingTreeConflictsTask {
// Both tasks run in parallel, and `git stash create` below needs the index lock.
let status_output = wt
.run_command(&["--no-optional-locks", "status", "--porcelain"])
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
let is_dirty = !status_output.trim().is_empty();
@@ -779,7 +796,7 @@ impl Task for WorkingTreeConflictsTask {
let has_conflicts = ctx
.repo
.has_merge_conflicts(&base, stash_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::WorkingTreeConflicts {
item_idx: ctx.item_idx,
@@ -844,7 +861,7 @@ impl Task for UpstreamTask {
// Get upstream branch (None is valid - just means no upstream configured)
let upstream_branch = repo
.upstream_branch(branch)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
let Some(upstream_branch) = upstream_branch else {
return Ok(TaskResult::Upstream {
item_idx: ctx.item_idx,
@@ -855,7 +872,7 @@ impl Task for UpstreamTask {
let remote = upstream_branch.split_once('/').map(|(r, _)| r.to_string());
let (ahead, behind) = repo
.ahead_behind(&upstream_branch, &ctx.branch_ref.commit_sha)
- .map_err(|e| ctx.error(Self::KIND, e))?;
+ .map_err(|e| ctx.error(Self::KIND, &e))?;
Ok(TaskResult::Upstream {
item_idx: ctx.item_idx,
@@ -1166,4 +1183,58 @@ mod tests {
assert_eq!(parse_port_from_url("http://127.0.0.1:9000"), Some(9000));
assert_eq!(parse_port_from_url("http://0.0.0.0:5000"), Some(5000));
}
+
+ #[test]
+ fn test_is_timeout_error_in_chain() {
+ use std::io::{Error as IoError, ErrorKind};
+
+ // Create a timeout error wrapped in anyhow
+ let timeout_io = IoError::new(ErrorKind::TimedOut, "operation timed out");
+ let anyhow_err = anyhow::Error::from(timeout_io).context("git status failed");
+
+ // Verify that checking the error chain finds the timeout
+ let is_timeout = anyhow_err.chain().any(|e| {
+ e.downcast_ref::<IoError>()
+ .is_some_and(|io_err| io_err.kind() == ErrorKind::TimedOut)
+ });
+ assert!(is_timeout, "should detect timeout in error chain");
+ }
+
+ #[test]
+ fn test_is_not_timeout_error() {
+ use std::io::{Error as IoError, ErrorKind};
+
+ // Create a non-timeout error
+ let other_io = IoError::new(ErrorKind::PermissionDenied, "access denied");
+ let anyhow_err = anyhow::Error::from(other_io).context("git status failed");
+
+ // Verify that checking the error chain does NOT find a timeout
+ let is_timeout = anyhow_err.chain().any(|e| {
+ e.downcast_ref::<IoError>()
+ .is_some_and(|io_err| io_err.kind() == ErrorKind::TimedOut)
+ });
+ assert!(
+ !is_timeout,
+ "should not detect timeout for non-timeout error"
+ );
+ }
+
+ #[test]
+ fn test_timeout_error_deeply_nested() {
+ use std::io::{Error as IoError, ErrorKind};
+
+ // Create a deeply nested timeout error
+ let timeout_io = IoError::new(ErrorKind::TimedOut, "operation timed out");
+ let anyhow_err = anyhow::Error::from(timeout_io)
+ .context("inner context")
+ .context("middle context")
+ .context("outer context");
+
+ // Verify that checking the error chain finds the timeout even when deeply nested
+ let is_timeout = anyhow_err.chain().any(|e| {
+ e.downcast_ref::<IoError>()
+ .is_some_and(|io_err| io_err.kind() == ErrorKind::TimedOut)
+ });
+ assert!(is_timeout, "should detect timeout even when deeply nested");
+ }
}
diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rs
index 5ca5929f9..8230ffba4 100644
--- a/src/commands/list/mod.rs
+++ b/src/commands/list/mod.rs
@@ -156,9 +156,6 @@ pub fn handle_list(
// Build skip set based on flags
// Without --full: skip expensive operations (BranchDiff, CiStatus, WorkingTreeConflicts)
- // TODO: WouldMergeAdd (~500ms-2s per worktree) is currently enabled for ⊂ detection.
- // If this causes performance issues, consider adding it back to skip_tasks or
- // implementing a timeout for the merge simulation.
let skip_tasks: std::collections::HashSet<TaskKind> = if show_full {
std::collections::HashSet::new() // Compute everything
} else {
@@ -183,6 +180,18 @@ pub fn handle_list(
// For testing: allow enabling skip_expensive_for_stale via env var
let skip_expensive_for_stale = std::env::var("WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD").is_ok();
+ // Per-task timeout from config (disabled with --full or timeout-ms = 0)
+ let command_timeout = if show_full {
+ None // --full disables timeout for complete data collection
+ } else {
+ config
+ .list
+ .as_ref()
+ .and_then(|l| l.timeout_ms)
+ .filter(|&ms| ms > 0) // 0 means "no timeout" (explicit disable)
+ .map(std::time::Duration::from_millis)
+ };
+
let list_data = collect::collect(
&repo,
show_branches,
@@ -191,7 +200,7 @@ pub fn handle_list(
show_progress,
render_table,
config,
- None, // No timeout for wt list
+ command_timeout,
skip_expensive_for_stale,
)?;
@@ -307,6 +316,8 @@ pub(crate) fn format_summary_message(
items: &[ListItem],
show_branches: bool,
hidden_column_count: usize,
+ error_count: usize,
+ timed_out_count: usize,
) -> String {
use anstyle::Style;
use worktrunk::styling::INFO_SYMBOL;
@@ -316,7 +327,25 @@ pub(crate) fn format_summary_message(
let summary = metrics
.summary_parts(show_branches, hidden_column_count)
.join(", ");
- format!("{INFO_SYMBOL} {dim}Showing {summary}{dim:#}")
+
+ if error_count > 0 {
+ let failure_msg = if error_count == timed_out_count {
+ // All failures are timeouts
+ let plural = if timed_out_count == 1 { "" } else { "s" };
+ format!("{timed_out_count} task{plural} timed out")
+ } else if timed_out_count > 0 {
+ // Mix of timeouts and other errors
+ let plural = if error_count == 1 { "" } else { "s" };
+ format!("{error_count} task{plural} failed ({timed_out_count} timed out)")
+ } else {
+ // No timeouts, just other errors
+ let plural = if error_count == 1 { "" } else { "s" };
+ format!("{error_count} task{plural} failed")
+ };
+ format!("{INFO_SYMBOL} {dim}Showing {summary}. {failure_msg}{dim:#}")
+ } else {
+ format!("{INFO_SYMBOL} {dim}Showing {summary}{dim:#}")
+ }
}
#[cfg(test)]
@@ -452,4 +481,47 @@ mod tests {
]
);
}
+
+ #[test]
+ fn test_format_summary_message_no_errors() {
+ let msg = format_summary_message(&[], false, 0, 0, 0);
+ assert!(msg.contains("Showing 0 worktrees"));
+ assert!(!msg.contains("failed"));
+ assert!(!msg.contains("timed out"));
+ }
+
+ #[test]
+ fn test_format_summary_message_all_timeouts() {
+ // 3 errors, all timeouts
+ let msg = format_summary_message(&[], false, 0, 3, 3);
+ assert!(msg.contains("3 tasks timed out"));
+ assert!(!msg.contains("failed"));
+ }
+
+ #[test]
+ fn test_format_summary_message_mixed_errors() {
+ // 5 errors, 3 are timeouts
+ let msg = format_summary_message(&[], false, 0, 5, 3);
+ assert!(msg.contains("5 tasks failed (3 timed out)"));
+ }
+
+ #[test]
+ fn test_format_summary_message_no_timeouts() {
+ // 2 errors, none are timeouts
+ let msg = format_summary_message(&[], false, 0, 2, 0);
+ assert!(msg.contains("2 tasks failed"));
+ assert!(!msg.contains("timed out"));
+ }
+
+ #[test]
+ fn test_format_summary_message_single_error() {
+ let msg = format_summary_message(&[], false, 0, 1, 0);
+ assert!(msg.contains("1 task failed"));
+ }
+
+ #[test]
+ fn test_format_summary_message_single_timeout() {
+ let msg = format_summary_message(&[], false, 0, 1, 1);
+ assert!(msg.contains("1 task timed out"));
+ }
}
diff --git a/src/config/user.rs b/src/config/user.rs
index ad7d9047e..593ed4707 100644
--- a/src/config/user.rs
+++ b/src/config/user.rs
@@ -247,7 +247,7 @@ pub struct UserProjectConfig {
}
/// Configuration for the `wt list` command
-#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
+#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
pub struct ListConfig {
/// Show CI and `main` diffstat by default
#[serde(skip_serializing_if = "Option::is_none")]
@@ -260,6 +260,13 @@ pub struct ListConfig {
/// Include remote branches by default
#[serde(skip_serializing_if = "Option::is_none")]
pub remotes: Option<bool>,
+
+ /// (Experimental) Per-task timeout in milliseconds.
+ /// When set to a positive value, git operations that exceed this timeout are terminated.
+ /// Timed-out tasks show defaults in the table. Set to 0 to explicitly disable timeout
+ /// (useful to override a global setting). Disabled when --full is used.
+ #[serde(rename = "timeout-ms", skip_serializing_if = "Option::is_none")]
+ pub timeout_ms: Option<u64>,
}
/// Configuration for the `wt step commit` command
@@ -911,12 +918,14 @@ rename-tab = "echo 'switched'"
full: Some(true),
branches: Some(false),
remotes: None,
+ timeout_ms: Some(500),
};
let json = serde_json::to_string(&config).unwrap();
let parsed: ListConfig = serde_json::from_str(&json).unwrap();
assert_eq!(parsed.full, Some(true));
assert_eq!(parsed.branches, Some(false));
assert_eq!(parsed.remotes, None);
+ assert_eq!(parsed.timeout_ms, Some(500));
}
#[test]
diff --git a/tests/integration_tests/list_config.rs b/tests/integration_tests/list_config.rs
index 169e897ed..e2135da3e 100644
--- a/tests/integration_tests/list_config.rs
+++ b/tests/integration_tests/list_config.rs
@@ -353,3 +353,101 @@ url = "http://localhost:8080/{{ branch }}"
let url = first["url"].as_str().unwrap();
assert_eq!(url, "http://localhost:8080/main");
}
+
+/// Test that timeout-ms config option is parsed correctly.
+/// We use a very short timeout (1ms) to trigger timeouts.
+#[rstest]
+fn test_list_config_timeout_triggers_timeouts(repo: TestRepo, temp_home: TempDir) {
+ // Create user config with a very short timeout
+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");
+ fs::create_dir_all(&global_config_dir).unwrap();
+ fs::write(
+ global_config_dir.join("config.toml"),
+ r#"worktree-path = "../{{ repo }}.{{ branch }}"
+
+[projects."repo".list]
+timeout-ms = 1
+"#,
+ )
+ .unwrap();
+
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ set_temp_home_env(&mut cmd, temp_home.path());
+ cmd.arg("list").current_dir(repo.root_path());
+
+ let output = cmd.output().unwrap();
+ let stderr = String::from_utf8_lossy(&output.stderr);
+
+ // With a 1ms timeout, some tasks should time out
+ // The footer should show the timeout count
+ assert!(
+ stderr.contains("timed out") || output.status.success(),
+ "Expected either timeout message in footer or success (if git was fast enough)"
+ );
+}
+
+/// Test that timeout-ms = 0 explicitly disables timeout.
+#[rstest]
+fn test_list_config_timeout_zero_means_no_timeout(repo: TestRepo, temp_home: TempDir) {
+ // Create user config with timeout-ms = 0
+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");
+ fs::create_dir_all(&global_config_dir).unwrap();
+ fs::write(
+ global_config_dir.join("config.toml"),
+ r#"worktree-path = "../{{ repo }}.{{ branch }}"
+
+[projects."repo".list]
+timeout-ms = 0
+"#,
+ )
+ .unwrap();
+
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ set_temp_home_env(&mut cmd, temp_home.path());
+ cmd.arg("list").current_dir(repo.root_path());
+
+ let output = cmd.output().unwrap();
+ let stderr = String::from_utf8_lossy(&output.stderr);
+
+ // With timeout-ms = 0, there should be no timeout
+ assert!(
+ !stderr.contains("timed out"),
+ "Expected no timeout message with timeout-ms = 0, but got: {}",
+ stderr
+ );
+}
+
+/// Test that --full disables the timeout.
+#[rstest]
+fn test_list_config_timeout_disabled_with_full(repo: TestRepo, temp_home: TempDir) {
+ // Create user config with a very short timeout
+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");
+ fs::create_dir_all(&global_config_dir).unwrap();
+ fs::write(
+ global_config_dir.join("config.toml"),
+ r#"worktree-path = "../{{ repo }}.{{ branch }}"
+
+[projects."repo".list]
+timeout-ms = 1
+"#,
+ )
+ .unwrap();
+
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ set_temp_home_env(&mut cmd, temp_home.path());
+ cmd.args(["list", "--full"]).current_dir(repo.root_path());
+
+ let output = cmd.output().unwrap();
+ let stderr = String::from_utf8_lossy(&output.stderr);
+
+ // With --full, the timeout is disabled so we shouldn't see timeout messages
+ // (though tasks may still fail for other reasons)
+ assert!(
+ !stderr.contains("timed out"),
+ "Expected no timeout message with --full flag, but got: {}",
+ stderr
+ );
+}
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_create.snap b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
index 030cc6ad6..3538e15a2 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_create.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
@@ -99,6 +99,7 @@ Creates ~/.config/worktrunk/config.toml with the following content:
full = false # Show CI and default-branch merge-base diffstat (`main…±` column) by default
branches = false # Include branches without worktrees by default
remotes = false # Include remote branches by default
+ timeout-ms = 0 # (Experimental) Per-task timeout in ms; 0 = no timeout; --full disables

# Commit Defaults (shared by `wt step commit`, `wt step squash`, and `wt merge`)
[commit]
diff --git a/tests/snapshots/integration__integration_tests__list__list_shows_warning_on_git_error.snap b/tests/snapshots/integration__integration_tests__list__list_shows_warning_on_git_error.snap
index 601cfda01..f2720483a 100644
--- a/tests/snapshots/integration__integration_tests__list__list_shows_warning_on_git_error.snap
+++ b/tests/snapshots/integration__integration_tests__list__list_shows_warning_on_git_error.snap
@@ -33,7 +33,7 @@ exit_code: 0
@ main ^ . a1e809f5 1d Initial commit
+ feature ✗ ⋯ ../repo.feature 00000000 55y 
-○ Showing 2 worktrees
+○ Showing 2 worktrees. 5 tasks failed
----- stderr -----
▲ Some git operations failed: