Skip to content

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

fix(list): dim URL for current worktree when health check fails (#350)

Maximilian Roos3f74563188e4
diff --git a/src/commands/list/collect_progressive_impl.rs b/src/commands/list/collect_progressive_impl.rs
index 1948a53d0..b6e567fca 100644
--- a/src/commands/list/collect_progressive_impl.rs
+++ b/src/commands/list/collect_progressive_impl.rs
@@ -650,11 +650,16 @@ impl Task for UrlStatusTask {
};
// Parse port from URL and check if it's listening
- let active = parse_port_from_url(url).map(|port| {
- // Quick TCP connect check with 50ms timeout
- let addr = SocketAddr::from(([127, 0, 0, 1], port));
- TcpStream::connect_timeout(&addr, Duration::from_millis(50)).is_ok()
- });
+ // Skip health check in tests to avoid flaky results from random local processes
+ let active = if std::env::var("WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK").is_ok() {
+ Some(false)
+ } else {
+ parse_port_from_url(url).map(|port| {
+ // Quick TCP connect check with 50ms timeout
+ let addr = SocketAddr::from(([127, 0, 0, 1], port));
+ TcpStream::connect_timeout(&addr, Duration::from_millis(50)).is_ok()
+ })
+ };
// Return only active status (url=None to avoid overwriting the already-sent URL)
Ok(TaskResult::UrlStatus {
diff --git a/src/main.rs b/src/main.rs
index 8bec4a272..a984b6b30 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1181,10 +1181,10 @@ fn main() {
Commands::Select => handle_select(),
#[cfg(not(unix))]
Commands::Select => {
- output::print(error_message("wt select is not available on Windows"))?;
- output::print(hint_message(cformat!(
- "To see all worktrees, run <bright-black>wt list</>; to switch directly, run <bright-black>wt switch <branch></>"
- )))?;
+ let _ = output::print(error_message("wt select is not available on Windows"));
+ let _ = output::print(hint_message(cformat!(
+ "To see all worktrees, run <bright-black>wt list</>; to switch directly, run <bright-black>wt switch BRANCH</>"
+ )));
std::process::exit(1);
}
Commands::List {
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 3469b42b0..6c277a919 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -549,6 +549,8 @@ pub fn configure_cli_command(cmd: &mut Command) {
cmd.env("COLUMNS", "150");
// Enable warn-level logging so diagnostics show up in test failures
cmd.env("RUST_LOG", "warn");
+ // Skip URL health checks to avoid flaky tests from random local processes
+ cmd.env("WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK", "1");
// Pass through LLVM coverage profiling environment for subprocess coverage collection.
// When running under cargo-llvm-cov, spawned binaries need LLVM_PROFILE_FILE to record
diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rs
index 9be8b0b94..9304c59fc 100644
--- a/tests/integration_tests/configure_shell.rs
+++ b/tests/integration_tests/configure_shell.rs
@@ -946,6 +946,8 @@ mod pty_tests {
configure_pty_command(&mut cmd);
cmd.env("HOME", temp_home.path());
cmd.env("SHELL", "/bin/zsh");
+ // Disable zsh compinit security check (avoids "insecure directories" warning on CI)
+ cmd.env("ZSH_DISABLE_COMPFIX", "true");
let mut child = pair.slave.spawn_command(cmd).unwrap();
drop(pair.slave);