@@ -427,38 +427,48 @@ export class CopilotCLIChatSessionContentProvider extends Disposable implements
427427 if ( isUntitledSessionId ( copilotcliSessionId ) ) {
428428 const defaultRepo = await this . getDefaultUntitledSessionRepositoryOption ( copilotcliSessionId , token ) ;
429429 if ( defaultRepo ) {
430- options [ REPOSITORY_OPTION_ID ] = defaultRepo . fsPath ;
431- // Use the manager to track the selection for untitled sessions
432- this . folderRepositoryManager . setUntitledSessionFolder ( copilotcliSessionId , defaultRepo ) ;
433-
434- // Check if the default folder is a git repo so the branch dropdown appears immediately
435- const repoInfo = await this . folderRepositoryManager . getRepositoryInfo ( defaultRepo , token ) ;
436- if ( repoInfo . repository ) {
437- this . _selectedRepoForBranches = { repoUri : repoInfo . repository , headBranchName : repoInfo . headBranchName } ;
438- } else {
439- this . _selectedRepoForBranches = undefined ;
440- }
441- if ( repoInfo . repository && isIsolationOptionFeatureEnabled ( this . configurationService ) ) {
442- if ( ! _sessionIsolation . has ( copilotcliSessionId ) ) {
443- _sessionIsolation . set ( copilotcliSessionId , 'workspace' ) ;
430+ // Determine upfront whether the default repository/folder is trusted. We need to do
431+ // this since the user should not be presented with a resource trust dialog in case the
432+ // default repository/folder is not trusted.
433+ const defaultRepoIsTrusted = await vscode . workspace . isResourceTrusted ( defaultRepo ) ;
434+
435+ if ( defaultRepoIsTrusted ) {
436+ options [ REPOSITORY_OPTION_ID ] = defaultRepo . fsPath ;
437+ // Use the manager to track the selection for untitled sessions
438+ this . folderRepositoryManager . setUntitledSessionFolder ( copilotcliSessionId , defaultRepo ) ;
439+
440+ // Check if the default folder is a git repo so the branch dropdown appears immediately
441+ const repoInfo = await this . folderRepositoryManager . getRepositoryInfo ( defaultRepo , token ) ;
442+ if ( repoInfo . repository ) {
443+ this . _selectedRepoForBranches = { repoUri : repoInfo . repository , headBranchName : repoInfo . headBranchName } ;
444+ } else {
445+ this . _selectedRepoForBranches = undefined ;
444446 }
445- const isolationMode = _sessionIsolation . get ( copilotcliSessionId ) ! ;
446- options [ ISOLATION_OPTION_ID ] = {
447- id : isolationMode ,
448- name : isolationMode === 'worktree' ? l10n . t ( 'Worktree' ) : l10n . t ( 'Workspace' ) ,
449- icon : new vscode . ThemeIcon ( isolationMode === 'worktree' ? 'worktree' : 'folder' )
450- } ;
451- }
452- const shouldShowBranch = ! isIsolationOptionFeatureEnabled ( this . configurationService ) || _sessionIsolation . get ( copilotcliSessionId ) === 'worktree' ;
453- const branchItems = await this . getBranchOptionItems ( ) ;
454- if ( branchItems . length > 0 && shouldShowBranch ) {
455- _sessionBranch . set ( copilotcliSessionId , branchItems [ 0 ] . id ) ;
456- options [ BRANCH_OPTION_ID ] = {
457- id : branchItems [ 0 ] . id ,
458- name : branchItems [ 0 ] . name ,
459- icon : new vscode . ThemeIcon ( 'git-branch' )
460- } ;
447+ if ( repoInfo . repository && isIsolationOptionFeatureEnabled ( this . configurationService ) ) {
448+ if ( ! _sessionIsolation . has ( copilotcliSessionId ) ) {
449+ _sessionIsolation . set ( copilotcliSessionId , 'workspace' ) ;
450+ }
451+ const isolationMode = _sessionIsolation . get ( copilotcliSessionId ) ! ;
452+ options [ ISOLATION_OPTION_ID ] = {
453+ id : isolationMode ,
454+ name : isolationMode === 'worktree' ? l10n . t ( 'Worktree' ) : l10n . t ( 'Workspace' ) ,
455+ icon : new vscode . ThemeIcon ( isolationMode === 'worktree' ? 'worktree' : 'folder' )
456+ } ;
457+ }
458+ const shouldShowBranch = ! isIsolationOptionFeatureEnabled ( this . configurationService ) || _sessionIsolation . get ( copilotcliSessionId ) === 'worktree' ;
459+ const branchItems = await this . getBranchOptionItems ( ) ;
460+ if ( branchItems . length > 0 && shouldShowBranch ) {
461+ _sessionBranch . set ( copilotcliSessionId , branchItems [ 0 ] . id ) ;
462+ options [ BRANCH_OPTION_ID ] = {
463+ id : branchItems [ 0 ] . id ,
464+ name : branchItems [ 0 ] . name ,
465+ icon : new vscode . ThemeIcon ( 'git-branch' )
466+ } ;
467+ }
468+ } else {
469+ options [ REPOSITORY_OPTION_ID ] = '' ;
461470 }
471+
462472 this . notifyProviderOptionsChange ( ) ;
463473 }
464474 } else {
0 commit comments