@@ -52,8 +52,15 @@ pub(crate) struct HookEvent {
5252pub ( crate ) enum HookEventPlan {
5353 SyncFiles ( Vec < String > ) ,
5454 AddBranch ( String ) ,
55- AddBranchAt { root : PathBuf , branch : String } ,
56- SyncCurrentBranch { branch : String , agent : HookAgent } ,
55+ AddBranchAt {
56+ root : PathBuf ,
57+ branch : String ,
58+ agent : HookAgent ,
59+ } ,
60+ SyncCurrentBranch {
61+ branch : String ,
62+ agent : HookAgent ,
63+ } ,
5764 DebouncedIncrementalSync ( HookAgent ) ,
5865 Noop ,
5966}
@@ -153,14 +160,15 @@ fn plan_shell_hook_event(
153160 } ;
154161 match crate :: hooks:: cursor_shell_sync_plan_with_current_branch ( command, current_branch) {
155162 crate :: hooks:: CursorShellSyncPlan :: BranchAdd ( branch) => {
156- branch_plan_for_root ( project_root, hook_project_root, branch)
163+ branch_plan_for_root ( project_root, hook_project_root, branch, event . agent )
157164 }
158165 crate :: hooks:: CursorShellSyncPlan :: WorktreeBranchAdd {
159166 branch,
160167 worktree_path,
161168 } => HookEventPlan :: AddBranchAt {
162169 root : crate :: hooks:: resolve_worktree_add_root ( command, cwd, & worktree_path) ,
163170 branch,
171+ agent : event. agent ,
164172 } ,
165173 crate :: hooks:: CursorShellSyncPlan :: IncrementalSync => {
166174 HookEventPlan :: DebouncedIncrementalSync ( event. agent )
@@ -175,6 +183,7 @@ fn plan_shell_hook_event(
175183 HookEventPlan :: AddBranchAt {
176184 root : hook_project_root,
177185 branch,
186+ agent : event. agent ,
178187 }
179188 }
180189 }
@@ -203,13 +212,15 @@ fn branch_plan_for_root(
203212 project_root : & Path ,
204213 hook_project_root : PathBuf ,
205214 branch : String ,
215+ agent : HookAgent ,
206216) -> HookEventPlan {
207217 if paths_same ( & hook_project_root, project_root) {
208218 HookEventPlan :: AddBranch ( branch)
209219 } else {
210220 HookEventPlan :: AddBranchAt {
211221 root : hook_project_root,
212222 branch,
223+ agent,
213224 }
214225 }
215226}
@@ -320,14 +331,20 @@ mod tests {
320331 }
321332
322333 fn assert_add_branch_at ( plan : HookEventPlan , expected_root : & Path , expected_branch : & str ) {
323- let HookEventPlan :: AddBranchAt { root, branch } = plan else {
334+ let HookEventPlan :: AddBranchAt {
335+ root,
336+ branch,
337+ agent,
338+ } = plan
339+ else {
324340 panic ! ( "expected AddBranchAt plan, got {plan:?}" ) ;
325341 } ;
326342 assert ! (
327343 super :: paths_same( & root, expected_root) ,
328344 "planned root {root:?} should match expected root {expected_root:?}"
329345 ) ;
330346 assert_eq ! ( branch, expected_branch) ;
347+ assert_eq ! ( agent, HookAgent :: Codex ) ;
331348 }
332349
333350 fn write_project_marker ( root : & Path ) {
@@ -543,6 +560,7 @@ mod tests {
543560 HookEventPlan :: AddBranchAt {
544561 root: Path :: new( "/tmp/wt" ) . to_path_buf( ) ,
545562 branch: "feature/daemon-hooks" . to_string( ) ,
563+ agent: HookAgent :: Codex ,
546564 }
547565 ) ;
548566 }
@@ -576,6 +594,7 @@ mod tests {
576594 HookEventPlan :: AddBranchAt {
577595 root: base_root. join( "wt" ) ,
578596 branch: "feature/daemon-hooks" . to_string( ) ,
597+ agent: HookAgent :: Codex ,
579598 }
580599 ) ;
581600 }
0 commit comments