Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Unify background hook output into single line (#908)
Maximilian Roosabc4dd221683
diff --git a/docs/demos/snapshots/wt-core.snap b/docs/demos/snapshots/wt-core.snapindex 0c4dda4af..6b8410665 100644--- a/docs/demos/snapshots/wt-core.snap+++ b/docs/demos/snapshots/wt-core.snap@@ -13,7 +13,7 @@ $ wt switch alpha[0m$ wt switch --create api✓ Created branch api from main and worktree @ <DEMO_DIR>/.demo-wt-core/w/acme.api-◎ Running post-start hooks: project:dev+◎ Running post-start: project:dev[0m$ wt list --full[1mBranch[0m [1mStatus[0m [1mHEAD±[0m [1mmain↕[0m [1mmain…±[0m [1mRemote⇅[0m [1mCI[0m [1mCommit[0m [1mAge[0mdiff --git a/src/commands/handle_switch.rs b/src/commands/handle_switch.rsindex 4f605175f..6dfe0e6aa 100644--- a/src/commands/handle_switch.rs+++ b/src/commands/handle_switch.rs@@ -133,16 +133,26 @@ pub fn handle_switch(// Spawn background hooks after success message// - post-switch: runs on ALL switches (shows "@ path" when shell won't be there)// - post-start: runs only when creating a NEW worktree+ // Batch hooks into a single message when both types are presentif !skip_hooks {let ctx = CommandContext::new(&repo, config, Some(&branch_info.branch), result.path(), yes);- // Post-switch runs first (immediate "I'm here" signal)- ctx.spawn_post_switch_commands(&extra_vars, hooks_display_path.as_deref())?;-- // Post-start runs only on creation (setup tasks)+ // Collect hooks from both types, then spawn as a single batch+ let mut hooks = super::hooks::prepare_background_hooks(+ &ctx,+ HookType::PostSwitch,+ &extra_vars,+ hooks_display_path.as_deref(),+ )?;if matches!(&result, SwitchResult::Created { .. }) {- ctx.spawn_post_start_commands(&extra_vars, hooks_display_path.as_deref())?;+ hooks.extend(super::hooks::prepare_background_hooks(+ &ctx,+ HookType::PostStart,+ &extra_vars,+ hooks_display_path.as_deref(),+ )?);}+ super::hooks::spawn_background_hooks(&ctx, hooks)?;}// Execute user command after post-start hooks have been spawneddiff --git a/src/commands/hook_commands.rs b/src/commands/hook_commands.rsindex 0eaa189d0..48222b5f9 100644--- a/src/commands/hook_commands.rs+++ b/src/commands/hook_commands.rs@@ -29,7 +29,7 @@ use super::context::CommandEnv;use super::hooks::execute_hook;use super::hooks::{HookFailureStrategy, check_name_filter_matched, prepare_hook_commands, run_hook_with_filter,- spawn_hook_commands_background,+ spawn_background_hooks,};use super::project_config::collect_commands_for_hooks;@@ -141,7 +141,7 @@ pub fn run_hook(user_config,project_config,)?;- spawn_hook_commands_background(&ctx, commands, hook_type)+ spawn_background_hooks(&ctx, commands)} else {run_hook_with_filter(&ctx,@@ -180,7 +180,7 @@ pub fn run_hook(user_config,project_config,)?;- spawn_hook_commands_background(&ctx, commands, hook_type)+ spawn_background_hooks(&ctx, commands)} else {run_hook_with_filter(&ctx,@@ -283,7 +283,7 @@ pub fn run_hook(user_config,project_config,)?;- spawn_hook_commands_background(&ctx, commands, hook_type)+ spawn_background_hooks(&ctx, commands)} else {run_hook_with_filter(&ctx,diff --git a/src/commands/hooks.rs b/src/commands/hooks.rsindex 206a1af45..2ea49f8ab 100644--- a/src/commands/hooks.rs+++ b/src/commands/hooks.rs@@ -148,12 +148,12 @@ fn filter_by_name(/// Used for post-start and post-switch hooks during normal worktree operations./// Commands are spawned and immediately detached - we don't wait for them.///-/// By default, shows a single-line summary of all hooks being run.+/// By default, shows a single-line summary of all hooks being run, with support+/// for multiple hook types in a single message (e.g., "Running post-switch: user:foo; post-start: project:bar")./// With `-v`, shows verbose per-hook output with command details.-pub fn spawn_hook_commands_background(+pub fn spawn_background_hooks(ctx: &CommandContext,commands: Vec<SourcedCommand>,- hook_type: HookType,) -> anyhow::Result<()> {if commands.is_empty() {return Ok(());@@ -162,29 +162,39 @@ pub fn spawn_hook_commands_background(let verbose = verbosity();if verbose == 0 {- // Single-line summary: "Running post-start hooks @ path: user:bg, project"- let names: Vec<String> = commands- .iter()- .map(|c| cformat!("<bold>{}</>", c.summary_name()))- .collect();+ // Group commands by hook type, preserving insertion order+ let groups = group_commands_by_hook_type(&commands);// All commands in a batch share the same display_path (set by prepare_hook_commands)let display_path = commands.first().and_then(|c| c.display_path.as_ref());+ // Format: "Running {type}: {names}[; {type}: {names}]... [@ {path}]"+ let type_segments: Vec<String> = groups+ .iter()+ .map(|(hook_type, cmds)| {+ let names: Vec<String> = cmds+ .iter()+ .map(|c| cformat!("<bold>{}</>", c.summary_name()))+ .collect();+ format!("{hook_type}: {}", names.join(", "))+ })+ .collect();+let message = match display_path {Some(path) => {let path_display = format_path_for_display(path);cformat!(- "Running {hook_type} hooks @ <bold>{path_display}</>: {}",- names.join(", ")+ "Running {} @ <bold>{path_display}</>",+ type_segments.join("; "))}- None => format!("Running {hook_type} hooks: {}", names.join(", ")),+ None => format!("Running {}", type_segments.join("; ")),};eprintln!("{}", progress_message(message));}- // Track index for unnamed commands to prevent log collisions- let mut unnamed_index = 0usize;+ // Track index for unnamed commands to prevent log collisions (per hook type)+ // Use a Vec since HookType doesn't implement Hash+ let mut unnamed_indices: Vec<(HookType, usize)> = Vec::new();for cmd in &commands {if verbose >= 1 {@@ -194,13 +204,22 @@ pub fn spawn_hook_commands_background(let name = match &cmd.prepared.name {Some(n) => n.clone(),None => {- let idx = unnamed_index;- unnamed_index += 1;+ let idx = if let Some((_, count)) = unnamed_indices+ .iter_mut()+ .find(|(t, _)| *t == cmd.hook_type)+ {+ let result = *count;+ *count += 1;+ result+ } else {+ unnamed_indices.push((cmd.hook_type, 1));+ 0+ };format!("cmd-{idx}")}};- // Use HookLog for consistent log file naming- let hook_log = HookLog::hook(cmd.source, hook_type, &name);+ // Use HookLog with the command's own hook_type for consistent log file naming+ let hook_log = HookLog::hook(cmd.source, cmd.hook_type, &name);if let Err(err) = spawn_detached(ctx.repo,@@ -222,6 +241,25 @@ pub fn spawn_hook_commands_background(Ok(())}+/// Group commands by hook type, preserving insertion order.+///+/// Returns a vector of (HookType, Vec<&SourcedCommand>) tuples.+/// This preserves the order in which hook types were first encountered+/// (e.g., post-switch before post-start).+fn group_commands_by_hook_type(+ commands: &[SourcedCommand],+) -> Vec<(HookType, Vec<&SourcedCommand>)> {+ let mut groups: Vec<(HookType, Vec<&SourcedCommand>)> = Vec::new();+ for cmd in commands {+ if let Some((_, vec)) = groups.iter_mut().find(|(t, _)| *t == cmd.hook_type) {+ vec.push(cmd);+ } else {+ groups.push((cmd.hook_type, vec![cmd]));+ }+ }+ groups+}+/// Check if a name filter was provided but no commands matched./// Returns an error listing available command names if so.pub(crate) fn check_name_filter_matched(@@ -404,12 +442,46 @@ pub fn execute_hook(.map_err(worktrunk::git::add_hook_skip_hint)}+/// Prepare background hooks with automatic config lookup.+///+/// This is a convenience wrapper that:+/// 1. Loads project config from the repository+/// 2. Looks up user hooks from the config+/// 3. Prepares commands ready for spawning+///+/// Use this to collect hooks from multiple types, then call `spawn_background_hooks`+/// once to spawn them all with a unified message.+pub(crate) fn prepare_background_hooks(+ ctx: &CommandContext,+ hook_type: HookType,+ extra_vars: &[(&str, &str)],+ display_path: Option<&Path>,+) -> anyhow::Result<Vec<SourcedCommand>> {+ let project_config = ctx.repo.load_project_config()?;+ let user_hooks = ctx.config.hooks(ctx.project_id().as_deref());+ let (user_config, proj_config) =+ lookup_hook_configs(&user_hooks, project_config.as_ref(), hook_type);++ prepare_hook_commands(+ ctx,+ user_config,+ proj_config,+ hook_type,+ extra_vars,+ None, // no filter for automatic background hooks+ display_path,+ )+}+/// Spawn hook commands as background processes with automatic config lookup.////// This is a convenience wrapper that:/// 1. Loads project config from the repository/// 2. Looks up user hooks from the config/// 3. Prepares and spawns background commands+///+/// For spawning multiple hook types in a single message, use `prepare_background_hooks`+/// to collect hooks, then `spawn_background_hooks` to spawn them.pub fn spawn_hook_background(ctx: &CommandContext,hook_type: HookType,@@ -432,7 +504,7 @@ pub fn spawn_hook_background(display_path,)?;- spawn_hook_commands_background(ctx, commands, hook_type)+ spawn_background_hooks(ctx, commands)}#[cfg(test)]diff --git a/src/commands/worktree/hooks.rs b/src/commands/worktree/hooks.rsindex d65cd2760..f824a8716 100644--- a/src/commands/worktree/hooks.rs+++ b/src/commands/worktree/hooks.rs@@ -1,6 +1,6 @@//! Hook execution for worktree operations.//!-//! CommandContext implementations for post-create, post-start, post-switch, and post-remove hooks.+//! CommandContext implementations for post-create and post-remove hooks.use std::path::Path;@@ -9,8 +9,7 @@ use worktrunk::path::to_posix_path;use crate::commands::command_executor::CommandContext;use crate::commands::hooks::{- HookFailureStrategy, execute_hook, prepare_hook_commands, spawn_hook_background,- spawn_hook_commands_background,+ HookFailureStrategy, execute_hook, prepare_hook_commands, spawn_background_hooks,};impl<'a> CommandContext<'a> {@@ -32,24 +31,6 @@ impl<'a> CommandContext<'a> {)}- /// Spawn post-start commands in parallel as background processes (non-blocking)- pub fn spawn_post_start_commands(- &self,- extra_vars: &[(&str, &str)],- display_path: Option<&Path>,- ) -> anyhow::Result<()> {- spawn_hook_background(self, HookType::PostStart, extra_vars, None, display_path)- }-- /// Spawn post-switch commands in parallel as background processes (non-blocking)- pub fn spawn_post_switch_commands(- &self,- extra_vars: &[(&str, &str)],- display_path: Option<&Path>,- ) -> anyhow::Result<()> {- spawn_hook_background(self, HookType::PostSwitch, extra_vars, None, display_path)- }-/// Spawn post-remove commands in parallel as background processes (non-blocking)////// Runs after worktree removal. Commands execute from the invoking worktree (where@@ -108,6 +89,6 @@ impl<'a> CommandContext<'a> {display_path,)?;- spawn_hook_commands_background(self, commands, HookType::PostRemove)+ spawn_background_hooks(self, commands)}}diff --git a/src/output/global.rs b/src/output/global.rsindex fc6ea4f1b..1f00d70ed 100644--- a/src/output/global.rs+++ b/src/output/global.rs@@ -302,11 +302,12 @@ pub fn pre_hook_display_path(hooks_run_at: &std::path::Path) -> Option<&std::pat/// # Examples////// ```ignore-/// // In post-create, post-start, post-switch hooks (creation path):-/// ctx.spawn_post_start_commands(&extra_vars, post_hook_display_path(&destination))?;+/// // Prepare and spawn hooks with display path:+/// let hooks = prepare_background_hooks(&ctx, HookType::PostStart, &extra_vars, post_hook_display_path(&destination))?;+/// spawn_background_hooks(&ctx, hooks)?;////// // After remove when switching to main:-/// ctx.spawn_post_switch_commands(&[], post_hook_display_path(main_path))?;+/// spawn_hook_background(&ctx, HookType::PostSwitch, &[], None, post_hook_display_path(main_path))?;/// ```pub fn post_hook_display_path(destination: &std::path::Path) -> Option<&std::path::Path> {if is_shell_integration_active() {diff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rsindex 99a9ec5b9..c5603b4cd 100644--- a/tests/integration_tests/switch.rs+++ b/tests/integration_tests/switch.rs@@ -1297,6 +1297,32 @@ fn test_switch_post_hook_no_path_with_shell_integration(repo: TestRepo) {);}+/// When both post-switch and post-start hooks are configured, they should be combined+/// into a single output line with format: "Running post-switch: {names}; post-start: {names} @ path"+#[rstest]+fn test_switch_combined_post_switch_and_post_start_hooks(repo: TestRepo) {+ // Create project config with both post-switch and post-start hooks+ let config_dir = repo.root_path().join(".config");+ fs::create_dir_all(&config_dir).unwrap();+ fs::write(+ config_dir.join("wt.toml"),+ r#"post-switch = "echo switched"+post-start = "echo started"+"#,+ )+ .unwrap();++ repo.commit("Add config");++ // Run switch --create (triggers both post-switch and post-start)+ // Should show a single combined line: "Running post-switch: project; post-start: project @ path"+ snapshot_switch(+ "switch_combined_hooks",+ &repo,+ &["--create", "combined-hooks-test", "--yes"],+ );+}+#[rstest]fn test_switch_clobber_path_with_extension(repo: TestRepo) {// Calculate where the worktree would be createddiff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rsindex de55f15b0..0b62d78f0 100644--- a/tests/integration_tests/user_hooks.rs+++ b/tests/integration_tests/user_hooks.rs@@ -927,6 +927,46 @@ vars = "echo 'repo={{ repo }} branch={{ branch }}' > template_vars.txt"// Combined User and Project Hooks Tests// ============================================================================+/// Test that both user and project unnamed hooks of the same type run and get unique log names.+/// This exercises the unnamed index tracking when multiple unnamed hooks share the same hook type.+#[rstest]+fn test_user_and_project_unnamed_post_start(repo: TestRepo) {+ // Create project config with unnamed post-start hook+ repo.write_project_config(r#"post-start = "echo 'PROJECT_POST_START' > project_bg.txt""#);+ repo.commit("Add project config");++ // Write user config with unnamed hook AND pre-approve project command+ repo.write_test_config(+ r#"post-start = "echo 'USER_POST_START' > user_bg.txt"++[projects."../origin"]+approved-commands = ["echo 'PROJECT_POST_START' > project_bg.txt"]+"#,+ );++ snapshot_switch(+ "user_and_project_unnamed_post_start",+ &repo,+ &["--create", "feature"],+ );++ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");++ // Wait for both background commands+ wait_for_file(&worktree_path.join("user_bg.txt"));+ wait_for_file(&worktree_path.join("project_bg.txt"));++ // Both should have run+ assert!(+ worktree_path.join("user_bg.txt").exists(),+ "User post-start should have run"+ );+ assert!(+ worktree_path.join("project_bg.txt").exists(),+ "Project post-start should have run"+ );+}+#[rstest]fn test_user_and_project_post_start_both_run(repo: TestRepo) {// Create project config with post-start hookdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snapindex b943a4d07..0e1e0a80f 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap@@ -44,4 +44,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject:server[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject:server[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snapindex 4f2a8ffb9..98b794dd3 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap@@ -44,6 +44,6 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39m[36m◎[39m [36mExecuting (--execute) @ [1m_REPO_.feature[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Execute flag'[0m[2m [0m[2m[36m>[0m[2m execute.txtdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snapindex 45fe63744..1bace5de4 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snapindex 45fe63744..1bace5de4 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snapindex 45fe63744..1bace5de4 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snapindex 45fe63744..1bace5de4 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snapindex ea936c9a5..256036748 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snap@@ -41,4 +41,4 @@ exit_code: 0[32m✓[39m [32mCreated branch [1mfeature[22m from [1mmain[22m and worktree @ [1m_REPO_.feature[22m[39m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snapindex c131ecb6f..d23c048b0 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject:task1[22m, [1mproject:task2[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject:task1[22m, [1mproject:task2[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snapindex c307a61e5..d5ec256ba 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject:task1[22m, [1mproject:task2[22m, [1mproject:task3[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject:task1[22m, [1mproject:task2[22m, [1mproject:task3[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snapindex 45fe63744..1bace5de4 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__fish_wrapper_preserves_progress_messages.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__fish_wrapper_preserves_progress_messages.snapindex b42cbeb58..fd59a9fcd 100644--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__fish_wrapper_preserves_progress_messages.snap+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__fish_wrapper_preserves_progress_messages.snap@@ -5,4 +5,4 @@ expression: "&output.combined"[32m✓[39m [32mCreated branch [1mfish-bg[22m from [1mmain[22m and worktree @ [1m_REPO_.fish-bg[22m[39m[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m-[36m◎[39m [36mRunning post-start hooks: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_post_create.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_post_create.snapindex 6e711d1d4..cb3c6d5d3 100644--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_post_create.snap+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_post_create.snap@@ -10,4 +10,4 @@ expression: "&output.combined"Installed 24 packages in 1.2s[32m✓[39m [32mCreated branch [1mfeature-x[22m from [1mmain[22m and worktree @ [1m_REPO_.feature-x[22m[39m[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m-[36m◎[39m [36mRunning post-start hooks: [1mproject:dev[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject:dev[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_hooks_zsh.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_hooks_zsh.snapindex b3c6e2bf1..24f58df62 100644--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_hooks_zsh.snap+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_hooks_zsh.snap@@ -11,4 +11,4 @@ Installing dependencies...Building project...[32m✓[39m [32mCreated branch [1mfeature-hooks[22m from [1mmain[22m and worktree @ [1m_REPO_.feature-hooks[22m[39m[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m-[36m◎[39m [36mRunning post-start hooks: [1mproject:server[22m, [1mproject:watch[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject:server[22m, [1mproject:watch[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_post_start_command_no_directive_leak.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_post_start_command_no_directive_leak.snapindex ad7e2e5e1..ecd3749fa 100644--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_post_start_command_no_directive_leak.snap+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__switch_with_post_start_command_no_directive_leak.snap@@ -5,4 +5,4 @@ expression: "&output.combined"[32m✓[39m [32mCreated branch [1mfeature-with-hooks[22m from [1mmain[22m and worktree @ [1m_REPO_.feature-with-hooks[22m[39m[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m-[36m◎[39m [36mRunning post-start hooks: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__wrapper_preserves_progress_messages.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__wrapper_preserves_progress_messages.snapindex edf35c1fa..c83cfa7b1 100644--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__wrapper_preserves_progress_messages.snap+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__wrapper_preserves_progress_messages.snap@@ -5,4 +5,4 @@ expression: "&output.combined"[32m✓[39m [32mCreated branch [1mfeature-bg[22m from [1mmain[22m and worktree @ [1m_REPO_.feature-bg[22m[39m[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m-[36m◎[39m [36mRunning post-start hooks: [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_combined_hooks.snap b/tests/snapshots/integration__integration_tests__switch__switch_combined_hooks.snapnew file mode 100644index 000000000..0f4a938c9--- /dev/null+++ b/tests/snapshots/integration__integration_tests__switch__switch_combined_hooks.snap@@ -0,0 +1,47 @@+---+source: tests/integration_tests/switch.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - combined-hooks-test+ - "--yes"+ env:+ APPDATA: "[TEST_CONFIG_HOME]"+ CLICOLOR_FORCE: "1"+ COLUMNS: "500"+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"+ GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"+ PATH: "[PATH]"+ PSModulePath: ""+ RUST_LOG: warn+ SHELL: ""+ TERM: alacritty+ USERPROFILE: "[TEST_HOME]"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WT_TEST_DELAYED_STREAM_MS: "-1"+ WT_TEST_EPOCH: "1735776000"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+[32m✓[39m [32mCreated branch [1mcombined-hooks-test[22m from [1mmain[22m and worktree @ [1m_REPO_.combined-hooks-test[22m[39m+[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m+[33m▲[39m [33mCannot change directory — shell integration not installed[39m+[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m+[36m◎[39m [36mRunning post-switch: [1mproject[22m; post-start: [1mproject[22m @ [1m_REPO_.combined-hooks-test[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_post_hook_no_path_with_shell_integration.snap b/tests/snapshots/integration__integration_tests__switch__switch_post_hook_no_path_with_shell_integration.snapindex 783200b63..9069e8cc5 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_post_hook_no_path_with_shell_integration.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_post_hook_no_path_with_shell_integration.snap@@ -42,4 +42,4 @@ exit_code: 0----- stderr -----[32m✓[39m [32mCreated branch [1mpost-hook-shell-test[22m from [1mmain[22m and worktree @ [1m_REPO_.post-hook-shell-test[22m[39m[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m-[36m◎[39m [36mRunning post-switch hooks: [1mproject[22m[39m+[36m◎[39m [36mRunning post-switch: [1mproject[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_post_hook_path_annotation.snap b/tests/snapshots/integration__integration_tests__switch__switch_post_hook_path_annotation.snapindex 880651e75..ed8d6516b 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_post_hook_path_annotation.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_post_hook_path_annotation.snap@@ -43,4 +43,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-switch hooks @ [1m_REPO_.post-hook-test[22m: [1mproject[22m[39m+[36m◎[39m [36mRunning post-switch: [1mproject[22m @ [1m_REPO_.post-hook-test[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_post_start.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_post_start.snapindex ecd41b96b..b1879e5d1 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_post_start.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_post_start.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1muser:bg[22m, [1mproject[22m[39m+[36m◎[39m [36mRunning post-start: [1muser:bg[22m, [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_unnamed_post_start.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_unnamed_post_start.snapnew file mode 100644index 000000000..38a97a301--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_unnamed_post_start.snap@@ -0,0 +1,46 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ APPDATA: "[TEST_CONFIG_HOME]"+ CLICOLOR_FORCE: "1"+ COLUMNS: "500"+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"+ GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"+ PATH: "[PATH]"+ PSModulePath: ""+ RUST_LOG: warn+ SHELL: ""+ TERM: alacritty+ USERPROFILE: "[TEST_HOME]"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WT_TEST_DELAYED_STREAM_MS: "-1"+ WT_TEST_EPOCH: "1735776000"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+[32m✓[39m [32mCreated branch [1mfeature[22m from [1mmain[22m and worktree @ [1m_REPO_.feature[22m[39m+[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m+[33m▲[39m [33mCannot change directory — shell integration not installed[39m+[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m+[36m◎[39m [36mRunning post-start: [1muser[22m, [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_executes.snapindex 80c2d83e8..24cb419ae 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_executes.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_executes.snap@@ -39,4 +39,4 @@ exit_code: 0----- stderr -----[36m◎ Removing [1mfeature[22m worktree & branch in background (--force-delete)[39m-[36m◎[39m [36mRunning post-remove hooks: [1muser:cleanup[22m[39m+[36m◎[39m [36mRunning post-remove: [1muser:cleanup[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_executes.snapindex 70ab4e5b5..f038c71b7 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_executes.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_executes.snap@@ -42,4 +42,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [90mwt config create[39m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22m-[36m◎[39m [36mRunning post-start hooks @ [1m_REPO_.feature[22m: [1muser:bg[22m[39m+[36m◎[39m [36mRunning post-start: [1muser:bg[22m @ [1m_REPO_.feature[22m[39m