@@ -726,12 +726,6 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
726726 }
727727
728728 this . copilotCLIAgents . trackSessionAgent ( session . object . sessionId , agent ?. name ) ;
729- if ( session . object . options . workingDirectory && ! session . object . options . isolationEnabled ) {
730- const workspaceFolder = this . workspaceService . getWorkspaceFolder ( session . object . options . workingDirectory ) ;
731- if ( workspaceFolder ) {
732- void this . workspaceFolderService . trackSessionWorkspaceFolder ( session . object . sessionId , workspaceFolder . fsPath ) ;
733- }
734- }
735729 if ( isUntitled ) {
736730 _untitledSessionIdMap . set ( session . object . sessionId , id ) ;
737731 disposables . add ( toDisposable ( ( ) => _untitledSessionIdMap . delete ( session . object . sessionId ) ) ) ;
@@ -901,9 +895,17 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
901895 this . logService . info ( `Using Copilot CLI session: ${ session . object . sessionId } (isNewSession: ${ isNewSession } , isolationEnabled: ${ isolationEnabled } , workingDirectory: ${ workingDirectory } , worktreePath: ${ worktreeProperties ?. worktreePath } , changesAction: ${ uncommitedChangesAction } )` ) ;
902896 if ( isNewSession ) {
903897 this . untitledSessionIdMapping . set ( id , session . object . sessionId ) ;
904- }
905- if ( isNewSession && worktreeProperties ) {
906- void this . copilotCLIWorktreeManagerService . setWorktreeProperties ( session . object . sessionId , worktreeProperties ) ;
898+ if ( worktreeProperties ) {
899+ void this . copilotCLIWorktreeManagerService . setWorktreeProperties ( session . object . sessionId , worktreeProperties ) ;
900+ }
901+ if ( session . object . options . workingDirectory && ! session . object . options . isolationEnabled ) {
902+ const workspaceFolder = this . workspaceService . getWorkspaceFolder ( session . object . options . workingDirectory ) ;
903+ if ( workspaceFolder ) {
904+ void this . workspaceFolderService . trackSessionWorkspaceFolder ( session . object . sessionId , workspaceFolder . fsPath ) ;
905+ } else {
906+ void this . workspaceFolderService . trackSessionWorkspaceFolder ( session . object . sessionId , session . object . options . workingDirectory . fsPath ) ;
907+ }
908+ }
907909 }
908910 disposables . add ( session . object . attachStream ( stream ) ) ;
909911 disposables . add ( session . object . attachPermissionHandler ( async ( permissionRequest : PermissionRequest , toolCall : ToolCall | undefined , token : vscode . CancellationToken ) => requestPermission ( this . instantiationService , permissionRequest , toolCall , this . toolsService , request . toolInvocationToken , token ) ) ) ;
0 commit comments