@@ -17,8 +17,8 @@ use crate::types::{
1717
1818use super :: connect:: { kill_session_by_id, take_live_shared_session, workspace_session_spawn_lock} ;
1919use super :: helpers:: {
20- copy_agents_md_from_parent_to_worktree, normalize_setup_script, worktree_setup_marker_path ,
21- AGENTS_MD_FILE_NAME ,
20+ copy_agents_md_from_parent_to_worktree, normalize_setup_script, workspace_path_to_string ,
21+ worktree_setup_marker_path , AGENTS_MD_FILE_NAME ,
2222} ;
2323
2424pub ( crate ) async fn worktree_setup_status_core (
@@ -136,14 +136,15 @@ where
136136
137137 // Determine worktree root: per-workspace setting > global setting > default
138138 let worktree_root = if let Some ( custom_folder) = & parent_entry. settings . worktrees_folder {
139- PathBuf :: from ( custom_folder)
139+ PathBuf :: from ( workspace_path_to_string ( & PathBuf :: from ( custom_folder) ) )
140140 } else {
141141 let global_folder = {
142142 let settings = app_settings. lock ( ) . await ;
143143 settings. global_worktrees_folder . clone ( )
144144 } ;
145145 if let Some ( global_folder) = global_folder {
146- PathBuf :: from ( global_folder) . join ( & parent_entry. id )
146+ PathBuf :: from ( workspace_path_to_string ( & PathBuf :: from ( global_folder) ) )
147+ . join ( & parent_entry. id )
147148 } else {
148149 data_dir. join ( "worktrees" ) . join ( & parent_entry. id )
149150 }
@@ -154,6 +155,7 @@ where
154155 let safe_name = sanitize_worktree_name ( & branch) ;
155156 let worktree_path = unique_worktree_path ( & worktree_root, & safe_name) ?;
156157 let worktree_path_string = worktree_path. to_string_lossy ( ) . to_string ( ) ;
158+ let stored_worktree_path = workspace_path_to_string ( & worktree_path) ;
157159
158160 let repo_path = PathBuf :: from ( & parent_entry. path ) ;
159161 let branch_exists = git_branch_exists ( & repo_path, & branch) . await ?;
@@ -206,7 +208,7 @@ where
206208 let entry = WorkspaceEntry {
207209 id : Uuid :: new_v4 ( ) . to_string ( ) ,
208210 name : name. clone ( ) . unwrap_or_else ( || branch. clone ( ) ) ,
209- path : worktree_path_string ,
211+ path : stored_worktree_path ,
210212 kind : WorkspaceKind :: Worktree ,
211213 parent_id : Some ( parent_entry. id . clone ( ) ) ,
212214 worktree : Some ( WorktreeInfo { branch } ) ,
@@ -409,14 +411,14 @@ where
409411 // Use the same priority logic as add_worktree_core:
410412 // per-workspace setting > global setting > default
411413 let worktree_root = if let Some ( custom_folder) = & parent. settings . worktrees_folder {
412- PathBuf :: from ( custom_folder)
414+ PathBuf :: from ( workspace_path_to_string ( & PathBuf :: from ( custom_folder) ) )
413415 } else {
414416 let global_folder = {
415417 let settings = app_settings. lock ( ) . await ;
416418 settings. global_worktrees_folder . clone ( )
417419 } ;
418420 if let Some ( global_folder) = global_folder {
419- PathBuf :: from ( global_folder) . join ( & parent. id )
421+ PathBuf :: from ( workspace_path_to_string ( & PathBuf :: from ( global_folder) ) ) . join ( & parent. id )
420422 } else {
421423 data_dir. join ( "worktrees" ) . join ( & parent. id )
422424 }
@@ -428,12 +430,13 @@ where
428430 let current_path = PathBuf :: from ( & entry. path ) ;
429431 let next_path = unique_worktree_path_for_rename ( & worktree_root, & safe_name, & current_path) ?;
430432 let next_path_string = next_path. to_string_lossy ( ) . to_string ( ) ;
433+ let stored_next_path = workspace_path_to_string ( & next_path) ;
431434 let old_path_string = entry. path . clone ( ) ;
432435
433436 run_git_command ( & parent_root, & [ "branch" , "-m" , & old_branch, & final_branch] ) . await ?;
434437
435438 let mut moved_worktree = false ;
436- if next_path_string != old_path_string {
439+ if stored_next_path != old_path_string {
437440 if let Err ( error) = run_git_command (
438441 & parent_root,
439442 & [ "worktree" , "move" , & old_path_string, & next_path_string] ,
@@ -454,7 +457,7 @@ where
454457 if entry. name . trim ( ) == old_branch {
455458 entry. name = final_branch. clone ( ) ;
456459 }
457- entry. path = next_path_string . clone ( ) ;
460+ entry. path = stored_next_path . clone ( ) ;
458461 match entry. worktree . as_mut ( ) {
459462 Some ( worktree) => {
460463 worktree. branch = final_branch. clone ( ) ;
0 commit comments