Skip to content

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.rs
index 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.rs
index 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) {
✓ 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 integration
");
});
@@ -82,7 +82,7 @@ fn test_configure_shell_specific_shell(repo: TestRepo, temp_home: TempDir) {
✓ 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 integration
");
});
@@ -158,7 +158,7 @@ fn test_configure_shell_fish(repo: TestRepo, temp_home: TempDir) {
✓ Created completions for fish @ ~/.config/fish/completions/wt.fish
✓ Configured 1 shell
- ↳ Restart shell to activate
+ ↳ Restart shell to activate shell integration
");
});
@@ -331,7 +331,7 @@ fn test_configure_shell_multiple_configs(repo: TestRepo, temp_home: TempDir) {
✓ Configured 2 shells
▲ 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 integration
");
});
@@ -391,7 +391,7 @@ fn test_configure_shell_mixed_states(repo: TestRepo, temp_home: TempDir) {
✓ 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 integration
");
});
@@ -765,7 +765,7 @@ fn test_configure_shell_no_warning_when_compinit_enabled(repo: TestRepo, temp_ho
✓ Added shell extension & completions for zsh @ ~/.zshrc
✓ Configured 1 shell
- ↳ Restart shell or run: source ~/.zshrc
+ ↳ Restart shell to activate shell integration
");
});
}
@@ -804,7 +804,7 @@ fn test_configure_shell_no_warning_for_bash_user(repo: TestRepo, temp_home: Temp
↳ Skipped fish; ~/.config/fish/conf.d not found
✓ Configured 2 shells
- ↳ Restart shell or run: source ~/.bashrc
+ ↳ Restart shell to activate shell integration
");
});
}
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.snap
index 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 integration
diff --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.snap
index 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
↳ Skipped fish; ~/.config/fish/conf.d not found
✓ Configured 1 shell
-↳ Restart shell or run: source ~/.bashrc
+↳ Restart shell to activate shell integration