@@ -22,6 +22,14 @@ function getPersistedSessions(): PersistedSession[] {
2222 return ( store as any ) . get ( "sessions" , [ ] ) ;
2323}
2424
25+ function getWorktreeBaseDir ( ) : string {
26+ const settings = ( store as any ) . get ( "terminalSettings" ) ;
27+ if ( settings && settings . worktreeDir ) {
28+ return settings . worktreeDir ;
29+ }
30+ return path . join ( os . homedir ( ) , "worktrees" ) ;
31+ }
32+
2533function isTerminalReady ( buffer : string , startPos : number = 0 ) : boolean {
2634 const searchBuffer = buffer . slice ( startPos ) ;
2735
@@ -63,7 +71,7 @@ function extractProjectMcpConfig(projectDir: string): any {
6371// Get a safe directory name from project path, with collision handling
6472function getProjectWorktreeDirName ( projectDir : string ) : string {
6573 const baseName = path . basename ( projectDir ) ;
66- const worktreesBaseDir = path . join ( os . homedir ( ) , "worktrees" ) ;
74+ const worktreesBaseDir = getWorktreeBaseDir ( ) ;
6775 const candidatePath = path . join ( worktreesBaseDir , baseName ) ;
6876
6977 // If directory doesn't exist or points to the same project, use base name
@@ -90,7 +98,7 @@ function getProjectWorktreeDirName(projectDir: string): string {
9098function writeMcpConfigFile ( projectDir : string , mcpServers : any ) : string | null {
9199 try {
92100 const projectDirName = getProjectWorktreeDirName ( projectDir ) ;
93- const worktreesDir = path . join ( os . homedir ( ) , "worktrees" ) ;
101+ const worktreesDir = getWorktreeBaseDir ( ) ;
94102 if ( ! fs . existsSync ( worktreesDir ) ) {
95103 fs . mkdirSync ( worktreesDir , { recursive : true } ) ;
96104 }
@@ -303,7 +311,7 @@ async function createWorktree(projectDir: string, parentBranch: string, sessionN
303311 const git = simpleGit ( projectDir ) ;
304312
305313 const projectDirName = getProjectWorktreeDirName ( projectDir ) ;
306- const worktreesBaseDir = path . join ( os . homedir ( ) , "worktrees" ) ;
314+ const worktreesBaseDir = getWorktreeBaseDir ( ) ;
307315 const projectWorktreeDir = path . join ( worktreesBaseDir , projectDirName ) ;
308316 const worktreeName = customBranchName || `session${ sessionNumber } ` ;
309317 const worktreePath = path . join ( projectWorktreeDir , worktreeName ) ;
0 commit comments