Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Fix: Ensure "Already configured" logic considers completions
Maximilian Roos3b98dda56d16
diff --git a/src/main.rs b/src/main.rsindex c2f093324..39d24febd 100644--- a/src/main.rs+++ b/src/main.rs@@ -215,10 +215,23 @@ fn main() {.and_then(|scan_result| {use worktrunk::styling::format_bash_with_gutter;- let changes_count = scan_result+ // Count shells that became (more) configured+ // A shell counts if any of its components changed (extension or completions)+ let shells_configured_count = scan_result.configured.iter()- .filter(|r| !matches!(r.action, ConfigAction::AlreadyExists))+ .filter(|ext_result| {+ let ext_changed =+ !matches!(ext_result.action, ConfigAction::AlreadyExists);+ let comp_changed = scan_result+ .completion_results+ .iter()+ .find(|c| c.shell == ext_result.shell)+ .is_some_and(|c| {+ !matches!(c.action, ConfigAction::AlreadyExists)+ });+ ext_changed || comp_changed+ }).count();// Show configured shells grouped with their completions@@ -298,24 +311,26 @@ fn main() {return Err(anyhow::anyhow!("No shell config files found"));}- // Summary (count shells, not files - fish has both conf.d and completions)- if changes_count > 0 {+ // Summary+ if shells_configured_count > 0 {crate::output::blank()?;- let plural = if changes_count == 1 { "" } else { "s" };+ let plural = if shells_configured_count == 1 { "" } else { "s" };crate::output::success(format!(- "Configured {changes_count} shell{plural}"+ "Configured {shells_configured_count} shell{plural}"))?;} else {// No action: all shells were already configuredcrate::output::info("All shells already configured")?;}- // Restart hint for current shell (only if config files changed, not just completions)- if changes_count > 0 {+ // Restart hint: only shown if the current shell's extension changed+ // (completions are auto-sourced or sourced separately, no restart needed)+ if shells_configured_count > 0 {let current_shell = std::env::var("SHELL").ok().and_then(|s| s.rsplit('/').next().map(String::from));+ // Find if current shell had its extension changed (not just completions)let current_shell_result =current_shell.as_ref().and_then(|shell_name| {scan_resultdiff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex a8be8c58a..0f84cc9d5 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -175,6 +175,61 @@ fn test_configure_shell_fish() {);}+/// Test `wt config shell install` when extension exists but completions don't (Fish-specific)+/// Regression test: previously showed "All shells already configured" even when completions were added+#[test]+fn test_configure_shell_fish_completions_only() {+ let repo = TestRepo::new();+ let temp_home = TempDir::new().unwrap();++ // Create fish conf.d directory with wt.fish (extension exists)+ let conf_d = temp_home.path().join(".config/fish/conf.d");+ fs::create_dir_all(&conf_d).unwrap();+ let fish_config = conf_d.join("wt.fish");+ fs::write(+ &fish_config,+ "if type -q wt; command wt config shell init fish | source; end",+ )+ .unwrap();++ // But NO completions file exists++ let settings = setup_home_snapshot_settings(&temp_home);+ settings.bind(|| {+ let mut cmd = wt_command();+ repo.clean_cli_env(&mut cmd);+ set_temp_home_env(&mut cmd, temp_home.path());+ cmd.env("SHELL", "/bin/fish");+ cmd.arg("config")+ .arg("shell")+ .arg("install")+ .arg("fish")+ .arg("--force")+ .current_dir(repo.root_path());++ // Should say "Configured 1 shell" because completions were added,+ // NOT "All shells already configured"+ assert_cmd_snapshot!(cmd, @r"+ success: true+ exit_code: 0+ ----- stdout -----+ ⚪ Already configured shell extension for [1mfish[0m @ [1m~/.config/fish/conf.d/wt.fish[0m+ ✅ Created completions for [1mfish[0m @ [1m~/.config/fish/completions/wt.fish[0m++ ✅ Configured 1 shell++ ----- stderr -----+ ");+ });++ // Verify the completions file was created+ let completions_file = temp_home.path().join(".config/fish/completions/wt.fish");+ assert!(+ completions_file.exists(),+ "Fish completions file should be created"+ );+}+/// Test `wt config shell install` when no config files exist#[test]fn test_configure_shell_no_files() {