Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor: always use pipeline runner for background hooks (#1912)
Maximilian Roos268882ee6d68
diff --git a/src/commands/commit.rs b/src/commands/commit.rsindex bdd990a75..b5f130558 100644--- a/src/commands/commit.rs+++ b/src/commands/commit.rs@@ -8,7 +8,7 @@ use worktrunk::styling::{use super::command_executor::CommandContext;use super::hooks::{- HookCommandSpec, HookFailureStrategy, prepare_background_hooks, spawn_prepared_hooks,+ HookCommandSpec, HookFailureStrategy, prepare_background_hooks, spawn_hook_pipeline,};use super::repository_ext::warn_about_untracked_files;@@ -240,9 +240,11 @@ impl CommitOptions<'_> {.into_iter().map(|target| ("target", target)).collect();- let hooks =- prepare_background_hooks(self.ctx, HookType::PostCommit, &extra_vars, None)?;- spawn_prepared_hooks(self.ctx, hooks)?;+ for steps in+ prepare_background_hooks(self.ctx, HookType::PostCommit, &extra_vars, None)?+ {+ spawn_hook_pipeline(self.ctx, steps)?;+ }}Ok(())diff --git a/src/commands/handle_switch.rs b/src/commands/handle_switch.rsindex 619751c1a..1b79fe321 100644--- a/src/commands/handle_switch.rs+++ b/src/commands/handle_switch.rs@@ -183,40 +183,27 @@ pub(crate) fn spawn_switch_background_hooks() -> anyhow::Result<()> {let ctx = CommandContext::new(repo, config, branch, result.path(), yes);- let mut flat_hooks = Vec::new();-- // Spawn each hook type's pipeline independently — pipelines carry a single- // hook_type/source/context, so mixing types in one runner would give later- // steps the wrong template variables (e.g., {{ hook_type }}).- // Flat hooks are spawned as independent processes, so accumulating them- // across hook types for a combined display message is fine.- match super::hooks::prepare_background_hooks(+ for steps in super::hooks::prepare_background_hooks(&ctx,HookType::PostSwitch,extra_vars,hooks_display_path,)? {- super::hooks::PreparedHooks::Flat(cmds) => flat_hooks.extend(cmds),- super::hooks::PreparedHooks::Pipeline(steps) => {- super::hooks::spawn_hook_pipeline(&ctx, steps)?;- }+ super::hooks::spawn_hook_pipeline(&ctx, steps)?;}if matches!(result, SwitchResult::Created { .. }) {- match super::hooks::prepare_background_hooks(+ for steps in super::hooks::prepare_background_hooks(&ctx,HookType::PostStart,extra_vars,hooks_display_path,)? {- super::hooks::PreparedHooks::Flat(cmds) => flat_hooks.extend(cmds),- super::hooks::PreparedHooks::Pipeline(steps) => {- super::hooks::spawn_hook_pipeline(&ctx, steps)?;- }+ super::hooks::spawn_hook_pipeline(&ctx, steps)?;}}- super::hooks::spawn_background_hooks(&ctx, flat_hooks)+ Ok(())}/// Handle the switch command.diff --git a/src/commands/hook_commands.rs b/src/commands/hook_commands.rsindex 0c872de45..0148f7ff4 100644--- a/src/commands/hook_commands.rs+++ b/src/commands/hook_commands.rs@@ -27,8 +27,8 @@ use super::command_executor::build_hook_context;use super::command_executor::CommandContext;use super::context::CommandEnv;use super::hooks::{- HookCommandSpec, HookFailureStrategy, check_name_filter_matched, prepare_background_hooks,- prepare_hook_commands, run_hook_with_filter, spawn_background_hooks, spawn_prepared_hooks,+ HookCommandSpec, HookFailureStrategy, SourcedStep, check_name_filter_matched,+ prepare_background_hooks, prepare_hook_commands, run_hook_with_filter, spawn_hook_pipeline,};use super::project_config::collect_commands_for_hooks;@@ -67,8 +67,8 @@ fn run_post_hook(// Default to background execution; --foreground is for debugging.if !foreground.unwrap_or(false) {if name_filter.is_some() {- // Name filtering operates on individual commands — use the flat path- // which extracts matching commands regardless of pipeline structure.+ // Name filtering operates on individual commands — extract matching+ // commands, convert to pipeline steps, and spawn via pipeline runner.let commands = prepare_hook_commands(ctx,HookCommandSpec {@@ -81,12 +81,23 @@ fn run_post_hook(},)?;check_name_filter_matched(name_filter, commands.len(), user_config, project_config)?;- return spawn_background_hooks(ctx, commands);+ let steps: Vec<SourcedStep> = commands+ .into_iter()+ .map(|cmd| SourcedStep {+ step: super::command_executor::PreparedStep::Single(cmd.prepared),+ source: cmd.source,+ hook_type: cmd.hook_type,+ display_path: cmd.display_path,+ })+ .collect();+ return spawn_hook_pipeline(ctx, steps);}- // No name filter: use the unified path that auto-detects pipeline vs flat.- let hooks = prepare_background_hooks(ctx, hook_type, extra_vars, None)?;- return spawn_prepared_hooks(ctx, hooks);+ // No name filter: prepare as pipeline steps and spawn per source.+ for steps in prepare_background_hooks(ctx, hook_type, extra_vars, None)? {+ spawn_hook_pipeline(ctx, steps)?;+ }+ return Ok(());}run_filtered_hook(diff --git a/src/commands/hooks.rs b/src/commands/hooks.rsindex f22368a22..5d225163d 100644--- a/src/commands/hooks.rs+++ b/src/commands/hooks.rs@@ -7,13 +7,13 @@ use worktrunk::config::CommandConfig;use worktrunk::git::WorktrunkError;use worktrunk::path::format_path_for_display;use worktrunk::styling::{- eprintln, error_message, format_bash_with_gutter, progress_message, verbosity, warning_message,+ eprintln, error_message, format_bash_with_gutter, progress_message, warning_message,};use super::command_executor::{CommandContext, PreparedCommand, PreparedStep, prepare_commands, prepare_steps,};-use crate::commands::process::{HookLog, spawn_detached, spawn_detached_exec};+use crate::commands::process::{HookLog, spawn_detached_exec};use crate::output::execute_command_in_worktree;/// A prepared command with its source information.@@ -159,137 +159,6 @@ fn filter_by_name(}}-/// Spawn hook commands as background (detached) processes.-///-/// 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, 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_background_hooks(- ctx: &CommandContext,- commands: Vec<SourcedCommand>,-) -> anyhow::Result<()> {- if commands.is_empty() {- return Ok(());- }-- let verbose = verbosity();-- if verbose == 0 {- // 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 {} @ <bold>{path_display}</>",- type_segments.join("; ")- )- }- None => format!("Running {}", type_segments.join("; ")),- };- eprintln!("{}", progress_message(message));- }-- // 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 {- cmd.announce()?;- }-- let name = match &cmd.prepared.name {- Some(n) => n.clone(),- None => {- 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 with the command's own hook_type for consistent log file naming- let hook_log = HookLog::hook(cmd.source, cmd.hook_type, &name);-- // Lazy commands (referencing vars.) carry the raw template in lazy_template.- // Expand them before spawning, same as run_hook_with_filter does for foreground.- let expanded = if let Some(ref template) = cmd.prepared.lazy_template {- let name_label = cmd.summary_name();- match expand_lazy_template(template, &cmd.prepared.context_json, ctx.repo, &name_label)- {- Ok(s) => s,- Err(err) => {- eprintln!(- "{}",- warning_message(format!(- "Failed to expand template for \"{name_label}\": {err}"- ))- );- continue;- }- }- } else {- cmd.prepared.expanded.clone()- };-- let log_label = format!("{} {}", cmd.hook_type, cmd.summary_name());- if let Err(err) = spawn_detached(- ctx.repo,- ctx.worktree_path,- &expanded,- ctx.branch_or_head(),- &hook_log,- Some(&cmd.prepared.context_json),- ) {- let err_msg = err.to_string();- let message = match &cmd.prepared.name {- Some(name) => format!("Failed to spawn \"{name}\": {err_msg}"),- None => format!("Failed to spawn command: {err_msg}"),- };- eprintln!("{}", warning_message(message));- } else {- // Background: outcome unknown, log with null exit/duration- worktrunk::command_log::log_command(&log_label, &expanded, None, None);- }- }-- Ok(())-}--/// Prepared hooks ready for background spawning — either flat commands or a pipeline.-pub(crate) enum PreparedHooks {- /// Traditional flat commands (string or map config) — spawned independently.- Flat(Vec<SourcedCommand>),- /// Pipeline steps (list config) — spawned as `wt hook run-pipeline`.- Pipeline(Vec<SourcedStep>),-}-/// A pipeline step with source information, for pipeline-aware execution.pub struct SourcedStep {pub step: PreparedStep,@@ -301,33 +170,31 @@ pub struct SourcedStep {/// Format a summary description of a pipeline for display.////// Shows step names/counts with `→` separating serial steps.+/// Named steps show their name; unnamed steps show their source (`user`/`project`)./// Example: "install → build, lint"+///+/// TODO: Rethink hook display presentation. Current issues:+/// - Arrows (`→`) add visual noise and aren't obviously meaningful to users+/// - Multiple unnamed steps from the same source repeat the label (`user → user`)+/// - Source prefix was dropped for named steps (`user:bg` → `bg`) — less+/// informative when both user and project hooks are present+/// - Combined hook-type messages were split (`post-switch: X; post-start: Y`+/// → two separate lines) — more verbose for the common create casefn format_pipeline_summary(steps: &[SourcedStep]) -> String {- let mut unnamed_idx = 0usize;let mut parts = Vec::new();for step in steps {+ let source_label = step.source.to_string();match &step.step {PreparedStep::Single(cmd) => {- let name = match &cmd.name {- Some(n) => cformat!("<bold>{}</>", n),- None => {- let label = format!("cmd-{unnamed_idx}");- unnamed_idx += 1;- cformat!("<bold>{}</>", label)- }- };- parts.push(name);+ let label = cmd.name.as_deref().unwrap_or(&source_label);+ parts.push(cformat!("<bold>{}</>", label));}PreparedStep::Concurrent(cmds) => {let names: Vec<String> = cmds.iter()- .map(|c| match &c.name {- Some(n) => cformat!("<bold>{}</>", n),- None => {- let label = format!("cmd-{unnamed_idx}");- unnamed_idx += 1;- cformat!("<bold>{}</>", label)- }+ .map(|c| {+ let label = c.name.as_deref().unwrap_or(&source_label);+ cformat!("<bold>{}</>", label)}).collect();parts.push(names.join(", "));@@ -344,7 +211,7 @@ fn format_pipeline_summary(steps: &[SourcedStep]) -> String {/// process expands templates just-in-time and executes each step via/// the detected shell.///-/// Used for post-* hooks when the config uses a pipeline (list form).+/// Used for all post-* background hooks regardless of config format.pub fn spawn_hook_pipeline(ctx: &CommandContext, steps: Vec<SourcedStep>) -> anyhow::Result<()> {use super::pipeline_spec::{PipelineCommandSpec, PipelineSpec, PipelineStepSpec};@@ -439,58 +306,6 @@ pub fn spawn_hook_pipeline(ctx: &CommandContext, steps: Vec<SourcedStep>) -> anyOk(())}-/// Prepare hook steps as a pipeline, preserving serial/concurrent structure.-///-/// Accepts pre-looked-up configs to avoid redundant loading.-fn prepare_pipeline_hooks_with_configs(- ctx: &CommandContext,- user_config: Option<&CommandConfig>,- proj_config: Option<&CommandConfig>,- hook_type: HookType,- extra_vars: &[(&str, &str)],- display_path: Option<&Path>,-) -> anyhow::Result<Vec<SourcedStep>> {- let display_path = display_path.map(|p| p.to_path_buf());- let mut all_steps = Vec::new();-- let sources = [- (HookSource::User, user_config),- (HookSource::Project, proj_config),- ];-- for (source, config) in sources {- let Some(config) = config else { continue };- let steps = prepare_steps(config, ctx, extra_vars, hook_type, source)?;- all_steps.extend(steps.into_iter().map(|step| SourcedStep {- step,- source,- hook_type,- display_path: display_path.clone(),- }));- }-- Ok(all_steps)-}--/// 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(@@ -666,64 +481,56 @@ pub fn execute_hook(/// Prepare background hooks with automatic config lookup.///-/// Returns `PreparedHooks::Pipeline` when any source uses a list config,-/// or `PreparedHooks::Flat` for traditional string/map configs.-/// Callers should use `spawn_prepared_hooks` to execute the result.+/// Returns pipeline steps grouped by source — one group per source that has+/// hooks configured. Each group should be spawned as an independent pipeline+/// so that user and project hooks remain independent (a user hook failure+/// doesn't abort project hooks).pub(crate) fn prepare_background_hooks(ctx: &CommandContext,hook_type: HookType,extra_vars: &[(&str, &str)],display_path: Option<&Path>,-) -> anyhow::Result<PreparedHooks> {+) -> anyhow::Result<Vec<Vec<SourcedStep>>> {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);- if [user_config, proj_config]- .iter()- .any(|c| c.is_some_and(CommandConfig::is_pipeline))- {- let steps = prepare_pipeline_hooks_with_configs(- ctx,- user_config,- proj_config,- hook_type,- extra_vars,- display_path,- )?;- return Ok(PreparedHooks::Pipeline(steps));- }+ let display_path = display_path.map(|p| p.to_path_buf());+ let mut groups = Vec::new();- let commands = prepare_hook_commands(- ctx,- HookCommandSpec {- user_config,- project_config: proj_config,- hook_type,- extra_vars,- name_filter: None,- display_path,- },- )?;- Ok(PreparedHooks::Flat(commands))-}+ let sources = [+ (HookSource::User, user_config),+ (HookSource::Project, proj_config),+ ];-/// Spawn prepared hooks (either flat or pipeline).-pub(crate) fn spawn_prepared_hooks(- ctx: &CommandContext,- hooks: PreparedHooks,-) -> anyhow::Result<()> {- match hooks {- PreparedHooks::Flat(commands) => spawn_background_hooks(ctx, commands),- PreparedHooks::Pipeline(steps) => spawn_hook_pipeline(ctx, steps),+ for (source, config) in sources {+ let Some(config) = config else { continue };+ let steps = prepare_steps(config, ctx, extra_vars, hook_type, source)?;+ if steps.is_empty() {+ continue;+ }+ groups.push(+ steps+ .into_iter()+ .map(|step| SourcedStep {+ step,+ source,+ hook_type,+ display_path: display_path.clone(),+ })+ .collect(),+ );}++ Ok(groups)}/// Expand a lazy template using its command's context JSON.///-/// Used by both `spawn_background_hooks` (background) and `run_hook_with_filter`-/// (foreground) to expand templates that reference `vars.*` at execution time.+/// Used by `run_hook_with_filter` (foreground) to expand templates that+/// reference `vars.*` at execution time. Background hooks handle lazy+/// expansion inside the pipeline runner process instead.fn expand_lazy_template(template: &str,context_json: &str,@@ -844,8 +651,9 @@ mod tests {make_sourced_step(PreparedStep::Single(make_cmd(None, "npm run build"))),];let summary = format_pipeline_summary(&steps);- assert!(summary.contains("cmd-0"));- assert!(summary.contains("cmd-1"));+ // Unnamed steps show source name ("user" from make_sourced_step)+ assert!(summary.contains("user"));+ assert!(summary.contains("→"));}#[test]diff --git a/src/commands/merge.rs b/src/commands/merge.rsindex 4bd38d66b..a0bd885d8 100644--- a/src/commands/merge.rs+++ b/src/commands/merge.rs@@ -9,7 +9,7 @@ use super::command_executor::CommandContext;use super::commit::CommitOptions;use super::context::CommandEnv;use super::hooks::{- HookFailureStrategy, execute_hook, prepare_background_hooks, spawn_prepared_hooks,+ HookFailureStrategy, execute_hook, prepare_background_hooks, spawn_hook_pipeline,};use super::project_config::{ApprovableCommand, collect_commands_for_hooks};use super::repository_ext::{@@ -355,8 +355,9 @@ pub fn handle_merge(opts: MergeOptions<'_>) -> anyhow::Result<()> {extra.push(("short_commit", sc));}- let hooks = prepare_background_hooks(&ctx, HookType::PostMerge, &extra, display_path)?;- spawn_prepared_hooks(&ctx, hooks)?;+ for steps in prepare_background_hooks(&ctx, HookType::PostMerge, &extra, display_path)? {+ spawn_hook_pipeline(&ctx, steps)?;+ }}Ok(())diff --git a/src/commands/picker/mod.rs b/src/commands/picker/mod.rsindex 7660c0f51..0138dfa53 100644--- a/src/commands/picker/mod.rs+++ b/src/commands/picker/mod.rs@@ -28,7 +28,7 @@ use super::handle_switch::{approve_switch_hooks, run_pre_switch_hooks, spawn_switch_background_hooks, switch_extra_vars,};use super::hooks::{- HookFailureStrategy, execute_hook, prepare_background_hooks, spawn_prepared_hooks,+ HookFailureStrategy, execute_hook, prepare_background_hooks, spawn_hook_pipeline,};use super::list::collect;use super::repository_ext::{RemoveTarget, RepositoryCliExt};@@ -143,13 +143,14 @@ impl PickerCollector {&repo,);let extra_vars = remove_vars.extra_vars(hook_branch);- let hooks = prepare_background_hooks(+ for steps in prepare_background_hooks(&post_ctx,worktrunk::HookType::PostRemove,&extra_vars,None, // no display path in TUI context- )?;- spawn_prepared_hooks(&post_ctx, hooks)?;+ )? {+ spawn_hook_pipeline(&post_ctx, steps)?;+ }}RemoveResult::BranchOnly {branch_name,diff --git a/src/commands/step_commands.rs b/src/commands/step_commands.rsindex d3ba741d5..099ecf019 100644--- a/src/commands/step_commands.rs+++ b/src/commands/step_commands.rs@@ -38,7 +38,7 @@ use super::commit::{CommitGenerator, CommitOptions, StageMode};use super::context::CommandEnv;use super::hooks::{HookCommandSpec, HookFailureStrategy, prepare_background_hooks, run_hook_with_filter,- spawn_prepared_hooks,+ spawn_hook_pipeline,};use super::repository_ext::{RemoveTarget, RepositoryCliExt};use super::worktree::BranchDeletionMode;@@ -365,8 +365,9 @@ pub fn handle_squash(// Spawn post-commit hooks in background (respects --no-verify)if verify {let extra_vars: Vec<(&str, &str)> = vec![("target", integration_target.as_str())];- let hooks = prepare_background_hooks(&ctx, HookType::PostCommit, &extra_vars, None)?;- spawn_prepared_hooks(&ctx, hooks)?;+ for steps in prepare_background_hooks(&ctx, HookType::PostCommit, &extra_vars, None)? {+ spawn_hook_pipeline(&ctx, steps)?;+ }}Ok(SquashResult::Squashed)diff --git a/src/output/global.rs b/src/output/global.rsindex 9a5d010bc..bc7607e11 100644--- a/src/output/global.rs+++ b/src/output/global.rs@@ -446,8 +446,9 @@ pub fn pre_hook_display_path(hooks_run_at: &std::path::Path) -> Option<&std::pat////// ```ignore/// // 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)?;+/// for steps in prepare_background_hooks(&ctx, HookType::PostStart, &extra_vars, post_hook_display_path(&destination))? {+/// spawn_hook_pipeline(&ctx, steps)?;+/// }/// ```pub fn post_hook_display_path(destination: &std::path::Path) -> Option<&std::path::Path> {if is_shell_integration_active() {diff --git a/src/output/handlers.rs b/src/output/handlers.rsindex aa651bc97..98dad7024 100644--- a/src/output/handlers.rs+++ b/src/output/handlers.rs@@ -14,8 +14,7 @@ use crate::commands::branch_deletion::{};use crate::commands::command_executor::CommandContext;use crate::commands::hooks::{- HookFailureStrategy, execute_hook, prepare_background_hooks, spawn_background_hooks,- spawn_hook_pipeline,+ HookFailureStrategy, execute_hook, prepare_background_hooks, spawn_hook_pipeline,};use crate::commands::process::{HookLog, InternalOp, build_remove_command, build_remove_command_staged, spawn_detached,@@ -843,19 +842,14 @@ fn spawn_hooks_after_remove(// branch since both post-remove and post-switch are consequences of that removal.let remove_ctx = CommandContext::new(repo, &config, Some(removed_branch), main_path, false);- let mut flat_hooks = Vec::new();-- // Post-remove hooks (pipeline-aware via prepare_background_hooks).- match prepare_background_hooks(+ // Post-remove hooks.+ for steps in prepare_background_hooks(&remove_ctx,worktrunk::HookType::PostRemove,&extra_vars,display_path,)? {- crate::commands::hooks::PreparedHooks::Flat(cmds) => flat_hooks.extend(cmds),- crate::commands::hooks::PreparedHooks::Pipeline(steps) => {- spawn_hook_pipeline(&remove_ctx, steps)?;- }+ spawn_hook_pipeline(&remove_ctx, steps)?;}// Post-switch: only when the user actually changed directory.@@ -865,20 +859,17 @@ fn spawn_hooks_after_remove(let dest_branch = repo.worktree_at(main_path).branch()?;let switch_ctx =CommandContext::new(repo, &config, dest_branch.as_deref(), main_path, false);- match prepare_background_hooks(+ for steps in prepare_background_hooks(&switch_ctx,worktrunk::HookType::PostSwitch,&[],display_path,)? {- crate::commands::hooks::PreparedHooks::Flat(cmds) => flat_hooks.extend(cmds),- crate::commands::hooks::PreparedHooks::Pipeline(steps) => {- spawn_hook_pipeline(&switch_ctx, steps)?;- }+ spawn_hook_pipeline(&switch_ctx, steps)?;}}- spawn_background_hooks(&remove_ctx, flat_hooks)+ Ok(())}// ============================================================================diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rsindex d6e79bfcd..30d1f1b4f 100644--- a/tests/integration_tests/merge.rs+++ b/tests/integration_tests/merge.rs@@ -808,17 +808,11 @@ deploy = "echo 'Deploying branch {{ branch }}' > deploy.txt"Some(&feature_wt)));- // Verify both commands ran+ // Verify both commands ran (poll for background pipeline runner completion)let notify_file = repo.root_path().join("notify.txt");let deploy_file = repo.root_path().join("deploy.txt");- assert!(- notify_file.exists(),- "Notify command should have created marker file"- );- assert!(- deploy_file.exists(),- "Deploy command should have created marker file"- );+ wait_for_file(¬ify_file);+ wait_for_file(&deploy_file);}#[rstest]diff --git a/tests/integration_tests/post_start_commands.rs b/tests/integration_tests/post_start_commands.rsindex 3836f9c30..535a3b8b8 100644--- a/tests/integration_tests/post_start_commands.rs+++ b/tests/integration_tests/post_start_commands.rs@@ -982,57 +982,36 @@ approved-commands = [snapshot_switch("post_start_separate_logs", &repo, &["--create", "feature"]);- // Wait for all 3 log files to be created (poll, don't use fixed sleep)+ // Map configs run as a concurrent group in one pipeline runner process,+ // producing a single log file. Wait for it and verify all outputs are present.let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");let git_common_dir = resolve_git_common_dir(&worktree_path);let log_dir = git_common_dir.join("wt/logs");- wait_for_file_count(&log_dir, "log", 3);+ wait_for_file_count(&log_dir, "log", 1);- let log_files: Vec<_> = fs::read_dir(&log_dir)+ let log_file = fs::read_dir(&log_dir).unwrap().filter_map(|e| e.ok())- .filter(|e| e.path().extension().and_then(|s| s.to_str()) == Some("log"))- .collect();-- // Wait for content to be flushed in each log file before reading- for entry in &log_files {- wait_for_file_content(&entry.path());- }-- // Read all log files and verify no cross-contamination- let mut found_outputs = vec![false, false, false];- for entry in log_files {- let contents = fs::read_to_string(entry.path()).unwrap();- let count_task1 = contents.matches("TASK1_OUTPUT").count();- let count_task2 = contents.matches("TASK2_OUTPUT").count();- let count_task3 = contents.matches("TASK3_OUTPUT").count();-- // Each log should contain exactly one task's output- let total_outputs = count_task1 + count_task2 + count_task3;- assert_eq!(- total_outputs,- 1,- "Each log should contain exactly one task's output, found {} in {:?}",- total_outputs,- entry.path()- );-- if count_task1 == 1 {- found_outputs[0] = true;- }- if count_task2 == 1 {- found_outputs[1] = true;- }- if count_task3 == 1 {- found_outputs[2] = true;+ .find(|e| e.path().extension().and_then(|s| s.to_str()) == Some("log"))+ .expect("should have one log file");++ // Poll for all outputs — concurrent commands may flush at different times.+ let start = std::time::Instant::now();+ let timeout = std::time::Duration::from_secs(15);+ loop {+ let contents = fs::read_to_string(log_file.path()).unwrap_or_default();+ if contents.contains("TASK1_OUTPUT")+ && contents.contains("TASK2_OUTPUT")+ && contents.contains("TASK3_OUTPUT")+ {+ break;}+ assert!(+ start.elapsed() < timeout,+ "Timed out waiting for all outputs in log. Got: {contents}"+ );+ std::thread::sleep(std::time::Duration::from_millis(50));}-- assert!(- found_outputs.iter().all(|&x| x),- "Should find output from all three tasks, found: {:?}",- found_outputs- );}#[rstest]diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rsindex 64dfe7cce..3c002459c 100644--- a/tests/integration_tests/user_hooks.rs+++ b/tests/integration_tests/user_hooks.rs@@ -467,13 +467,10 @@ notify = "echo 'USER_POST_MERGE_RAN' > user_postmerge.txt"Some(&feature_wt),);- // Post-merge runs in the destination (main) worktree+ // Post-merge runs in the destination (main) worktree (poll for pipeline runner)let main_worktree = repo.root_path();let marker_file = main_worktree.join("user_postmerge.txt");- assert!(- marker_file.exists(),- "User post-merge hook should have run in main worktree"- );+ wait_for_file(&marker_file);}// ============================================================================@@ -1543,7 +1540,9 @@ fn test_concurrent_hook_single_failure(repo: TestRepo) {#[rstest]fn test_concurrent_hook_multiple_failures(repo: TestRepo) {- // Write project config with multiple named hooks (table format)+ // Write project config with multiple named hooks (table format).+ // Map configs run as a concurrent group in one pipeline runner,+ // producing a single log file with all outputs.repo.write_project_config(r#"[post-start]first = "echo FIRST_OUTPUT"@@ -1563,46 +1562,30 @@ second = "echo SECOND_OUTPUT""wt hook post-start should succeed (spawns in background)");- // Wait for both log files to be created+ // Wait for the pipeline log file to be createdlet log_dir = resolve_git_common_dir(repo.root_path()).join("wt/logs");- wait_for_file_count(&log_dir, "log", 2);+ wait_for_file_count(&log_dir, "log", 1);- // Collect log files and their contents- let log_files: Vec<_> = fs::read_dir(&log_dir)+ let log_file = fs::read_dir(&log_dir).unwrap().filter_map(|e| e.ok())- .filter(|e| e.path().extension().is_some_and(|ext| ext == "log"))- .collect();- assert_eq!(log_files.len(), 2, "Should have 2 log files");-- // Wait for content in both log files- for log_file in &log_files {- wait_for_file_content(&log_file.path());- }+ .find(|e| e.path().extension().is_some_and(|ext| ext == "log"))+ .expect("Should have a log file");- // Collect all log contents- let mut found_first = false;- let mut found_second = false;- for log_file in &log_files {- let name = log_file.file_name().to_string_lossy().to_string();- let content = fs::read_to_string(log_file.path()).unwrap();- if name.contains("first") {- assert!(- content.contains("FIRST_OUTPUT"),- "first log should contain FIRST_OUTPUT, got: {content}"- );- found_first = true;- }- if name.contains("second") {- assert!(- content.contains("SECOND_OUTPUT"),- "second log should contain SECOND_OUTPUT, got: {content}"- );- found_second = true;+ // Poll for both outputs — concurrent commands may flush at different times.+ let start = std::time::Instant::now();+ let timeout = std::time::Duration::from_secs(15);+ loop {+ let content = fs::read_to_string(log_file.path()).unwrap_or_default();+ if content.contains("FIRST_OUTPUT") && content.contains("SECOND_OUTPUT") {+ break;}+ assert!(+ start.elapsed() < timeout,+ "Timed out waiting for both outputs in log. Got: {content}"+ );+ thread::sleep(std::time::Duration::from_millis(50));}- assert!(found_first, "Should have log for 'first' hook");- assert!(found_second, "Should have log for 'second' hook");}#[rstest]diff --git a/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_fallback_to_list.snap b/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_fallback_to_list.snapindex d37c8b4bd..e046e92a8 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_fallback_to_list.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_fallback_to_list.snap@@ -23,7 +23,7 @@ info:NO_COLOR: ""PATH: "[PATH]"PSModulePath: ""- PWD: /private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpYBhGY0/repo+ PWD: /private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmppIn3mC/repoRUST_LOG: warnSHELL: ""TERM: alacrittydiff --git a/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_no_recovery.snap b/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_no_recovery.snapindex 16f01cfa1..938a54040 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_no_recovery.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_no_recovery.snap@@ -23,7 +23,7 @@ info:NO_COLOR: ""PATH: "[PATH]"PSModulePath: ""- PWD: /private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpwp292D/repo.feature+ PWD: /private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp782Z3R/repo.featureRUST_LOG: warnSHELL: ""TERM: alacrittydiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snapindex 431f50fab..4801b4f2d 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap@@ -23,7 +23,7 @@ info:NO_COLOR: ""PATH: "[PATH]"PSModulePath: ""- PWD: /private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpqEGnx2/repo+ PWD: /private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpREIpNJ/repoRUST_LOG: warnSHELL: ""TERM: alacrittydiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snapindex dd948888d..7d290aa9b 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap@@ -51,4 +51,4 @@ exit_code: 0[36m◎[39m [36mRemoving [1mfeature[22m worktree & branch in background (same commit as [1mmain[22m,[39m [2m_[22m[36m)[39m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-merge: [1mproject:notify[22m, [1mproject:deploy[22m @ [1m_REPO_[22m[39m+[36m◎[39m [36mRunning post-merge: [1mnotify[22m, [1mdeploy[22m @ [1m_REPO_[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_pipeline_serial_ordering.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_pipeline_serial_ordering.snapindex 97fb4f73a..fcbb9dc3a 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_pipeline_serial_ordering.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_pipeline_serial_ordering.snap@@ -51,4 +51,4 @@ exit_code: 0[36m◎[39m [36mRemoving [1mfeature[22m worktree & branch in background (same commit as [1mmain[22m,[39m [2m_[22m[36m)[39m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-merge: [1mcmd-0[22m → [1mcmd-1[22m @ [1m_REPO_[22m[39m+[36m◎[39m [36mRunning post-merge: [1mproject[22m → [1mproject[22m @ [1m_REPO_[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap b/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snapindex 821427314..560e081af 100644--- a/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap+++ b/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap@@ -81,4 +81,4 @@ test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fin[36m◎[39m [36mRemoving [1mfeature-auth[22m worktree & branch in background (same commit as [1mmain[22m,[39m [2m_[22m[36m)[39m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-merge: [1mproject:install[22m @ [1m_REPO_[22m[39m+[36m◎[39m [36mRunning post-merge: [1minstall[22m @ [1m_REPO_[22m[39mdiff --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 5e7e504ab..d92e27423 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@@ -50,4 +50,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mproject:server[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mserver[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_mixed_user_pipeline_project_flat.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_mixed_user_pipeline_project_flat.snapindex 5bce534bc..c802dcdd1 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_mixed_user_pipeline_project_flat.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_mixed_user_pipeline_project_flat.snap@@ -47,4 +47,5 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mcmd-0[22m → [1muser_bg[22m → [1mproj[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1muser[22m → [1muser_bg[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mproj[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 e3a712cb2..77cc8f47e 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@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mproject:task1[22m, [1mproject:task2[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mtask1[22m, [1mtask2[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_pipeline_template_vars.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_pipeline_template_vars.snapindex 81ab49267..b76744008 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_pipeline_template_vars.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_pipeline_template_vars.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mcmd-0[22m → [1mcheck[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m → [1mcheck[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_project_pipeline.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_project_pipeline.snapindex 4194897b4..a052db68a 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_project_pipeline.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_project_pipeline.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mcmd-0[22m → [1mtask1[22m, [1mtask2[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m → [1mtask1[22m, [1mtask2[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 5a8a33cac..14bd30c6d 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@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mproject:task1[22m, [1mproject:task2[22m, [1mproject:task3[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mtask1[22m, [1mtask2[22m, [1mtask3[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snapindex 3e4975728..a345075c2 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap@@ -56,5 +56,4 @@ exit_code: 0[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'verbose test'[0m[2m [0m[2m[36m>[0m[2m verbose.txt[107m [0m [2m→[22m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'verbose test'[0m[2m [0m[2m[36m>[0m[2m verbose.txt-[36m◎[39m [36mRunning post-start [1mproject:setup[22m @ [1m_REPO_.feature[22m[39m-[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'verbose test'[0m[2m [0m[2m[36m>[0m[2m verbose.txt+[36m◎[39m [36mRunning post-start: [1msetup[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_pre_start.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_pre_start.snapindex 61d8e4fa8..196a71415 100644--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_pre_start.snap+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_hooks_pre_start.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 [4mwt config create[24m[22m-[36m◎[39m [36mRunning post-start: [1mproject:dev[22m[39m+[36m◎[39m [36mRunning post-start: [1mdev[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 3c5c142fc..4e40b132a 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 [4mwt config create[24m[22m-[36m◎[39m [36mRunning post-start: [1mproject:server[22m, [1mproject:watch[22m[39m+[36m◎[39m [36mRunning post-start: [1mserver[22m, [1mwatch[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_combined_hooks.snap b/tests/snapshots/integration__integration_tests__switch__switch_combined_hooks.snapindex e4744f67c..28c98927a 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_combined_hooks.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_combined_hooks.snap@@ -48,4 +48,5 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-switch: [1mproject[22m; post-start: [1mproject[22m @ [1m_REPO_.combined-hooks-test[22m[39m+[36m◎[39m [36mRunning post-switch: [1mproject[22m @ [1m_REPO_.combined-hooks-test[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.combined-hooks-test[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__post_remove_runs_at_primary.snap b/tests/snapshots/integration__integration_tests__user_hooks__post_remove_runs_at_primary.snapindex eff79ee4a..32bc6145a 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__post_remove_runs_at_primary.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__post_remove_runs_at_primary.snap@@ -44,4 +44,4 @@ exit_code: 0----- stderr -----[36m◎[39m [36mRemoving [1mfeature[22m worktree & branch in background (--force-delete)[39m-[36m◎[39m [36mRunning post-remove: [1muser:cleanup[22m @ [1m_REPO_[22m[39m+[36m◎[39m [36mRunning post-remove: [1mcleanup[22m @ [1m_REPO_[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__standalone_hook_name_filtered_lazy_template.snap b/tests/snapshots/integration__integration_tests__user_hooks__standalone_hook_name_filtered_lazy_template.snapindex b403b3cef..d18017c06 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__standalone_hook_name_filtered_lazy_template.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__standalone_hook_name_filtered_lazy_template.snap@@ -43,4 +43,4 @@ exit_code: 0----- stdout ---------- stderr ------[36m◎[39m [36mRunning post-start: [1muser:db[22m[39m+[36m◎[39m [36mRunning post-start: [1mdb[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 6fbb1dc5f..24b279fc5 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@@ -47,4 +47,5 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1muser:bg[22m, [1mproject[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mbg[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [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.snapindex b0ec18080..4f402a9be 100644--- 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.snap@@ -47,4 +47,5 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1muser[22m, [1mproject[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1muser[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mproject[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_executes.snapindex 7ab9fdde4..96973e967 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_executes.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_executes.snap@@ -48,4 +48,4 @@ exit_code: 0[36m◎[39m [36mGenerating commit message and committing changes... [90m(1 file, [32m+1[39m[39m[90m)[39m[39m[107m [0m [1mfeat: test commit[22m[32m✓[39m [32mCommitted changes @ [2m[HASH][22m[39m-[36m◎[39m [36mRunning post-commit: [1muser:notify[22m[39m+[36m◎[39m [36mRunning post-commit: [1mnotify[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_failure.snapindex ce070b5fe..2e28c1702 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_failure.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_commit_failure.snap@@ -48,4 +48,4 @@ exit_code: 0[36m◎[39m [36mGenerating commit message and committing changes... [90m(1 file, [32m+1[39m[39m[90m)[39m[39m[107m [0m [1mfeat: test commit[22m[32m✓[39m [32mCommitted changes @ [2m[HASH][22m[39m-[36m◎[39m [36mRunning post-commit: [1muser:failing[22m[39m+[36m◎[39m [36mRunning post-commit: [1mfailing[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_merge_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_merge_executes.snapindex 356cc723b..8d523fc47 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_merge_executes.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_merge_executes.snap@@ -50,4 +50,4 @@ exit_code: 0[107m [0m 1 file changed, 1 insertion(+)[32m✓[39m [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m[2m○[22m Worktree preserved (--no-remove)-[36m◎[39m [36mRunning post-merge: [1muser:notify[22m @ [1m_REPO_[22m[39m+[36m◎[39m [36mRunning post-merge: [1mnotify[22m @ [1m_REPO_[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 be9aee07f..8170647d3 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@@ -44,4 +44,4 @@ exit_code: 0----- stderr -----[36m◎[39m [36mRemoving [1mfeature[22m worktree & branch in background (--force-delete)[39m-[36m◎[39m [36mRunning post-remove: [1muser:cleanup[22m[39m+[36m◎[39m [36mRunning post-remove: [1mcleanup[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_pipeline_ordering.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_pipeline_ordering.snapindex 4973de02a..87fac2fcd 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_pipeline_ordering.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_remove_pipeline_ordering.snap@@ -44,4 +44,4 @@ exit_code: 0----- stderr -----[36m◎[39m [36mRemoving [1mfeature[22m worktree & branch in background (--force-delete)[39m-[36m◎[39m [36mRunning post-remove: [1mcmd-0[22m → [1mcmd-1[22m[39m+[36m◎[39m [36mRunning post-remove: [1muser[22m → [1muser[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 f101632a7..1c61979d8 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@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1muser:bg[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mbg[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_all.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_all.snapindex 8826fa696..c50461f7a 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_all.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_all.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1muser:a[22m, [1muser:b[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1ma[22m, [1mb[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_failure.snapindex 9c1f8b784..1eb41851b 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_failure.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_concurrent_failure.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mfail[22m, [1mok[22m → [1mcmd-0[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1mfail[22m, [1mok[22m → [1muser[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_failure.snapindex 8421a5d74..bede0ea0f 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_failure.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_failure.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mcmd-0[22m → [1mbg[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1muser[22m → [1mbg[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_lazy_vars_bg.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_lazy_vars_bg.snapindex 6ea25cb95..dd9e86e93 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_lazy_vars_bg.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_lazy_vars_bg.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mcmd-0[22m → [1mdb[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1muser[22m → [1mdb[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_ordering.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_ordering.snapindex 8421a5d74..bede0ea0f 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_ordering.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_pipeline_ordering.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-start: [1mcmd-0[22m → [1mbg[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-start: [1muser[22m → [1mbg[22m @ [1m_REPO_.feature[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_switch_pipeline_via_create.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_switch_pipeline_via_create.snapindex f68acd762..ae637e73e 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_switch_pipeline_via_create.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_switch_pipeline_via_create.snap@@ -47,4 +47,4 @@ exit_code: 0[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [4mwt config shell install[24m[22m-[36m◎[39m [36mRunning post-switch: [1mcmd-0[22m → [1mcheck[22m @ [1m_REPO_.feature[22m[39m+[36m◎[39m [36mRunning post-switch: [1muser[22m → [1mcheck[22m @ [1m_REPO_.feature[22m[39m