From 04dd772f6f2b96e9a2a9df865572cc7c1c8878b9 Mon Sep 17 00:00:00 2001 From: Wes Date: Fri, 6 Feb 2026 16:12:32 -0700 Subject: [PATCH] fix: run actions from project subpath instead of worktree root When a project has a subpath configured (e.g., builderbot/staged), actions like justfile commands were running from the worktree root instead of the subfolder where the justfile actually lives. Both run_branch_action and run_prerun_actions now use get_branch_working_dir() to resolve the effective working directory (worktree + project subpath), consistent with how AI sessions and notes already handle this. --- staged/src-tauri/src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/staged/src-tauri/src/lib.rs b/staged/src-tauri/src/lib.rs index f7f0b3a..c23c852 100644 --- a/staged/src-tauri/src/lib.rs +++ b/staged/src-tauri/src/lib.rs @@ -1742,6 +1742,11 @@ async fn run_prerun_actions( .list_project_actions_by_type(&branch.project_id, crate::store::ActionType::Prerun) .map_err(|e| e.to_string())?; + // Use the effective working directory (worktree + project subpath) + // so actions run from the directory where build files (justfile, etc.) live + let working_dir = get_branch_working_dir(&store, &branch)?; + let working_dir_str = working_dir.to_string_lossy().to_string(); + // Execute each prerun action in order for action in prerun_actions { if let Err(e) = runner.run_action( @@ -1749,7 +1754,7 @@ async fn run_prerun_actions( store.clone(), branch.id.clone(), action.id.clone(), - branch.worktree_path.clone(), + working_dir_str.clone(), ) { eprintln!("Failed to run prerun action '{}': {}", action.name, e); // Continue with other actions even if one fails @@ -3064,6 +3069,10 @@ fn run_branch_action( .map_err(|e| e.to_string())? .ok_or_else(|| format!("Branch not found: {}", branch_id))?; + // Use the effective working directory (worktree + project subpath) + // so actions run from the directory where build files (justfile, etc.) live + let working_dir = get_branch_working_dir(&state, &branch)?; + // Run the action runner .run_action( @@ -3071,7 +3080,7 @@ fn run_branch_action( state.inner().clone(), branch_id, action_id, - branch.worktree_path, + working_dir.to_string_lossy().to_string(), ) .map_err(|e| e.to_string()) }