Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor: unify shell restart messages (#381)
Maximilian Roos8a9db5f8f068
diff --git a/src/output/handlers.rs b/src/output/handlers.rsindex ad67c7543..a99254065 100644--- a/src/output/handlers.rs+++ b/src/output/handlers.rs@@ -436,17 +436,8 @@ pub fn print_shell_install_result(.find(|r| r.shell.to_string().eq_ignore_ascii_case(shell_name))});- if let Some(result) = current_shell_result {- // Fish auto-sources from conf.d, so just say "Restart shell"- // Bash/Zsh can source directly for immediate activation- if matches!(result.shell, Shell::Fish) {- super::print(hint_message("Restart shell to activate"))?;- } else {- let path = format_path_for_display(&result.path);- super::print(hint_message(cformat!(- "Restart shell or run: <bright-black>source {path}</>"- )))?;- }+ if current_shell_result.is_some() {+ super::print(hint_message("Restart shell to activate shell integration"))?;}}@@ -464,9 +455,8 @@ pub fn print_shell_install_result(/// | Unsupported shell | Hint: `Shell integration not yet supported for <shell> (supports bash, zsh, fish, PowerShell)` |/// | $SHELL not set | Hint: `To enable automatic cd, run wt config shell install` |/// | Current shell already installed | Hint: `Restart shell to activate shell integration` |-/// | `skip-shell-integration-prompt` | Hint: `To enable automatic cd, run wt config shell install` |+/// | `skip-shell-integration-prompt` / Non-TTY / `--execute` | Hint: `To enable automatic cd, run wt config shell install` |/// | TTY | Prompt: `❯ Install shell integration? [y/N/?]` |-/// | Non-TTY / `--execute` | Hint: `To enable automatic cd, run wt config shell install` |////// When prompting:/// 1. Show prompt with preview of ALL shells that would be configured@@ -537,14 +527,8 @@ pub fn prompt_shell_integration(return Ok(false);}- // Already prompted before (they declined) - show install hint- if config.skip_shell_integration_prompt {- super::print(hint_message(shell_integration_hint()))?;- return Ok(false);- }-- // Non-TTY or skip_prompt: Show hint (can't or shouldn't prompt interactively)- if !is_tty || skip_prompt {+ // Can't or shouldn't prompt - show install hint+ if config.skip_shell_integration_prompt || !is_tty || skip_prompt {super::print(hint_message(shell_integration_hint()))?;return Ok(false);}diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex 5c9ec74d6..6286dbd43 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -40,7 +40,7 @@ fn test_configure_shell_with_yes(repo: TestRepo, temp_home: TempDir) {[32m✓[39m [32mConfigured 1 shell[39m[33m▲[39m [33mCompletions require compinit; add to ~/.zshrc before the wt line:[39m[107m [0m [2m[0m[2m[34mautoload[0m[2m [0m[2m[36m-Uz[0m[2m compinit [0m[2m[36m&&[0m[2m [0m[2m[34mcompinit[0m[2m[0m- [2m↳[22m [2mRestart shell or run: [90msource ~/.zshrc[39m[22m+ [2m↳[22m [2mRestart shell to activate shell integration[22m");});@@ -82,7 +82,7 @@ fn test_configure_shell_specific_shell(repo: TestRepo, temp_home: TempDir) {[32m✓[39m [32mConfigured 1 shell[39m[33m▲[39m [33mCompletions require compinit; add to ~/.zshrc before the wt line:[39m[107m [0m [2m[0m[2m[34mautoload[0m[2m [0m[2m[36m-Uz[0m[2m compinit [0m[2m[36m&&[0m[2m [0m[2m[34mcompinit[0m[2m[0m- [2m↳[22m [2mRestart shell or run: [90msource ~/.zshrc[39m[22m+ [2m↳[22m [2mRestart shell to activate shell integration[22m");});@@ -158,7 +158,7 @@ fn test_configure_shell_fish(repo: TestRepo, temp_home: TempDir) {[32m✓[39m [32mCreated completions for [1mfish[22m @ [1m~/.config/fish/completions/wt.fish[22m[39m[32m✓[39m [32mConfigured 1 shell[39m- [2m↳[22m [2mRestart shell to activate[22m+ [2m↳[22m [2mRestart shell to activate shell integration[22m");});@@ -331,7 +331,7 @@ fn test_configure_shell_multiple_configs(repo: TestRepo, temp_home: TempDir) {[32m✓[39m [32mConfigured 2 shells[39m[33m▲[39m [33mCompletions require compinit; add to ~/.zshrc before the wt line:[39m[107m [0m [2m[0m[2m[34mautoload[0m[2m [0m[2m[36m-Uz[0m[2m compinit [0m[2m[36m&&[0m[2m [0m[2m[34mcompinit[0m[2m[0m- [2m↳[22m [2mRestart shell or run: [90msource ~/.zshrc[39m[22m+ [2m↳[22m [2mRestart shell to activate shell integration[22m");});@@ -391,7 +391,7 @@ fn test_configure_shell_mixed_states(repo: TestRepo, temp_home: TempDir) {[32m✓[39m [32mConfigured 1 shell[39m[33m▲[39m [33mCompletions require compinit; add to ~/.zshrc before the wt line:[39m[107m [0m [2m[0m[2m[34mautoload[0m[2m [0m[2m[36m-Uz[0m[2m compinit [0m[2m[36m&&[0m[2m [0m[2m[34mcompinit[0m[2m[0m- [2m↳[22m [2mRestart shell or run: [90msource ~/.zshrc[39m[22m+ [2m↳[22m [2mRestart shell to activate shell integration[22m");});@@ -765,7 +765,7 @@ fn test_configure_shell_no_warning_when_compinit_enabled(repo: TestRepo, temp_ho[32m✓[39m [32mAdded shell extension & completions for [1mzsh[22m @ [1m~/.zshrc[22m[39m[32m✓[39m [32mConfigured 1 shell[39m- [2m↳[22m [2mRestart shell or run: [90msource ~/.zshrc[39m[22m+ [2m↳[22m [2mRestart shell to activate shell integration[22m");});}@@ -804,7 +804,7 @@ fn test_configure_shell_no_warning_for_bash_user(repo: TestRepo, temp_home: Temp[2m↳[22m [2mSkipped [90mfish[39m; [90m~/.config/fish/conf.d[39m not found[22m[32m✓[39m [32mConfigured 2 shells[39m- [2m↳[22m [2mRestart shell or run: [90msource ~/.bashrc[39m[22m+ [2m↳[22m [2mRestart shell to activate shell integration[22m");});}diff --git a/tests/integration_tests/snapshots/integration__integration_tests__configure_shell__pty_tests__install_preview_with_gutter.snap b/tests/integration_tests/snapshots/integration__integration_tests__configure_shell__pty_tests__install_preview_with_gutter.snapindex a0befd3b0..9690a2655 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__configure_shell__pty_tests__install_preview_with_gutter.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__configure_shell__pty_tests__install_preview_with_gutter.snap@@ -12,4 +12,4 @@ y✓ Configured 1 shell▲ Completions require compinit; add to ~/.zshrc before the wt line:autoload -Uz compinit && compinit-↳ Restart shell or run: source ~/.zshrc+↳ Restart shell to activate shell integrationdiff --git a/tests/snapshots/integration__integration_tests__shell_integration_prompt__pty_tests__prompt_accept.snap b/tests/snapshots/integration__integration_tests__shell_integration_prompt__pty_tests__prompt_accept.snapindex ec68ce6ea..47662a943 100644--- a/tests/snapshots/integration__integration_tests__shell_integration_prompt__pty_tests__prompt_accept.snap+++ b/tests/snapshots/integration__integration_tests__shell_integration_prompt__pty_tests__prompt_accept.snap@@ -13,4 +13,4 @@ y[2m↳[22m [2mSkipped [90mfish[39m; [90m~/.config/fish/conf.d[39m not found[22m[32m✓[39m [32mConfigured 1 shell[39m-[2m↳[22m [2mRestart shell or run: [90msource ~/.bashrc[39m[22m+[2m↳[22m [2mRestart shell to activate shell integration[22m