Skip to content

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

feat(config): improve RUNTIME section display and add debug info (#394)

Maximilian Roos63ccd6f9f9e9
diff --git a/src/commands/config.rs b/src/commands/config.rs
index 2c7a2e8a8..46abd134f 100644
--- a/src/commands/config.rs
+++ b/src/commands/config.rs
@@ -160,21 +160,43 @@ fn render_runtime_info(out: &mut String) -> anyhow::Result<()> {
let version = version_str();
let shell_active = output::is_shell_integration_active();
- writeln!(out, "{}", format_heading("RUNTIME", None))?;
-
- // Version and binary name on one line
+ // Version as suffix to heading (avoid lonely gutter)
writeln!(
out,
"{}",
- format_with_gutter(&cformat!("<bold>{cmd}</> <dim>{version}</>"), None)
+ format_heading("RUNTIME", Some(&cformat!("{cmd} {version}")))
)?;
// Shell integration status
if shell_active {
writeln!(out, "{}", info_message("Shell integration active"))?;
} else {
- writeln!(out, "{}", hint_message("Shell integration not active"))?;
+ writeln!(out, "{}", warning_message("Shell integration not active"))?;
+ }
+
+ // Debug info for shell integration troubleshooting
+ // Show invocation details that help diagnose issues like https://github.com/max-sixty/worktrunk/pull/387
+ let invocation = crate::invocation_path();
+ let is_git_subcommand = crate::is_git_subcommand();
+ let is_explicit_path = crate::was_invoked_with_explicit_path();
+
+ // Build debug lines
+ let mut debug_lines = Vec::new();
+
+ // Always show how wt was invoked
+ debug_lines.push(cformat!("Invoked as: <bold>{invocation}</>"));
+
+ // Show relevant detection flags
+ if is_git_subcommand {
+ debug_lines.push("Git subcommand: yes (GIT_EXEC_PATH set)".to_string());
}
+ if is_explicit_path {
+ debug_lines.push("Explicit path: yes (contains path separator)".to_string());
+ }
+
+ // Show all debug info in a gutter
+ let debug_text = debug_lines.join("\n");
+ writeln!(out, "{}", format_with_gutter(&debug_text, None))?;
Ok(())
}
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index e343cf768..1a7a35370 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -2130,11 +2130,19 @@ pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {
// Normalize version strings in `wt config show` RUNTIME section
// Version can be: v0.8.5, v0.8.5-2-gabcdef, v0.8.5-dirty, or bare git hash (b9ffe83)
- // Match specifically after "wt" (bold+reset) to avoid matching commit hashes elsewhere
- // Pattern: wt<bold-reset> <dim>VERSION<dim-reset>
+ // New format: version as suffix to RUNTIME heading (e.g., "RUNTIME wt v0.9.0")
+ // Pattern: <cyan>RUNTIME</cyan> wt VERSION
settings.add_filter(
- r"(\x1b\[1mwt\x1b\[22m \x1b\[2m)(?:v[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9]+-g[0-9a-f]+)?(?:-dirty)?|[0-9a-f]{7,40})(\x1b\[22m)",
- "$1[VERSION]$2",
+ r"(RUNTIME\x1b\[39m wt )(?:v[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9]+-g[0-9a-f]+)?(?:-dirty)?|[0-9a-f]{7,40})",
+ "${1}[VERSION]",
+ );
+
+ // Normalize project root paths in "Invoked as:" debug output
+ // Tests run cargo which produces paths like /path/to/worktrunk/target/debug/wt
+ // Normalize to [PROJECT_ROOT]/target/debug/wt for deterministic snapshots
+ settings.add_filter(
+ r"(Invoked as: \x1b\[1m)[^\x1b]+/target/(debug|release)/wt(\x1b\[22m)",
+ "${1}[PROJECT_ROOT]/target/$2/wt$3",
);
// Remove trailing ANSI reset codes at end of lines for cross-platform consistency
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_empty_project_config.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_empty_project_config.snap
index 10d8553aa..38d2e8961 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_empty_project_config.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_empty_project_config.snap
@@ -42,6 +42,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
index e6a47f751..5785d4497 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
@@ -55,6 +55,7 @@ exit_code: 0
  ○ Ran command:
    nonexistent-llm-command-12345 -m test-model
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
index 375cd7f9f..de1bbd4d6 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
@@ -47,6 +47,7 @@ exit_code: 0
↳ CI status requires GitHub or GitLab remote
↳ Commit generation not configured
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap
index e9eabef19..0b51eafc4 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap
@@ -42,6 +42,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap
index e9eabef19..0b51eafc4 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap
@@ -42,6 +42,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
index e9eabef19..0b51eafc4 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
@@ -42,6 +42,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_no_user_config.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_no_user_config.snap
index 31d188f2e..f91f0c323 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_no_user_config.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_no_user_config.snap
@@ -42,6 +42,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
index bfeddcd0d..9b42322c4 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
@@ -34,6 +34,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
index a1416c05b..f02b9a36b 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
@@ -46,6 +46,7 @@ exit_code: 0
↳ To enable shell integration, run wt config shell install
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_shell_integration_active.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_shell_integration_active.snap
index ae5c53fad..c69ab41fd 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_shell_integration_active.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_shell_integration_active.snap
@@ -43,6 +43,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
+RUNTIME wt [VERSION]
○ Shell integration active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_warning.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_warning.snap
index b7e8362b9..f77de089a 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_warning.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_warning.snap
@@ -49,6 +49,7 @@ exit_code: 0
↳ If this is shell integration, report a false negative: https://github.com/max-sixty/worktrunk/issues/new?title=Shell%20integration%20detection%20false%20negative&body=Shell%20integration%20not%20detected%20despite%20config%20containing%20%60wt%60.%0A%0A%2A%2AUnmatched%20lines%3A%2A%2A%0A%60%60%60%0Aalias%20wt%3D%22git%20worktree%22%0A%60%60%60%0A%0A%2A%2AExpected%20behavior%3A%2A%2A%20These%20lines%20should%20be%20detected%20as%20shell%20integration.
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
index a1bc54b32..069718ac4 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
@@ -44,6 +44,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
index 5d1bf6f66..95f7f6f6d 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
@@ -46,6 +46,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_whitespace_only_project_config.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_whitespace_only_project_config.snap
index 10d8553aa..38d2e8961 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_whitespace_only_project_config.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_whitespace_only_project_config.snap
@@ -42,6 +42,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
index 29b0eeba5..81beb200f 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
@@ -48,6 +48,7 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
index 08ac85a35..b84ce072b 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
@@ -44,6 +44,7 @@ exit_code: 0
○ Skipped bash; ~/.bashrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
index 0049a9475..03f9ad952 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
@@ -46,6 +46,7 @@ exit_code: 0
○ Skipped bash; ~/.bashrc not found
○ Skipped fish; ~/.config/fish/conf.d not found
-RUNTIME
-  wt [VERSION]
-↳ Shell integration not active
+RUNTIME wt [VERSION]
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+  Explicit path: yes (contains path separator)