@@ -7,6 +7,7 @@ import * as nodePath from 'path';
77import vscode from 'vscode' ;
88import { parseSessionLogs , parseToolCallDetails } from '../../common/sessionParsing' ;
99import { COPILOT_ACCOUNTS } from '../common/comment' ;
10+ import { CopilotRemoteAgentConfig } from '../common/config' ;
1011import { COPILOT_LOGINS , copilotEventToStatus , CopilotPRStatus , mostRecentCopilotEvent } from '../common/copilot' ;
1112import { commands } from '../common/executeCommands' ;
1213import { Disposable } from '../common/lifecycle' ;
@@ -20,7 +21,6 @@ import { IAPISessionLogs, ICopilotRemoteAgentCommandArgs, ICopilotRemoteAgentCom
2021import { ChatSessionWithPR , CopilotApi , getCopilotApi , RemoteAgentJobPayload , SessionInfo , SessionSetupStep } from './copilotApi' ;
2122import { CopilotPRWatcher , CopilotStateModel } from './copilotPrWatcher' ;
2223import { ChatSessionContentBuilder } from './copilotRemoteAgent/chatSessionContentBuilder' ;
23- import { CopilotRemoteAgentConfig } from './copilotRemoteAgent/config' ;
2424import { GitOperationsManager } from './copilotRemoteAgent/gitOperationsManager' ;
2525import { CredentialStore } from './credentials' ;
2626import { ReposManagerState } from './folderRepositoryManager' ;
@@ -54,7 +54,6 @@ export class CopilotRemoteAgentManager extends Disposable {
5454 private readonly _onDidChangeChatSessions = this . _register ( new vscode . EventEmitter < void > ( ) ) ;
5555 readonly onDidChangeChatSessions = this . _onDidChangeChatSessions . event ;
5656
57- private readonly _config : CopilotRemoteAgentConfig ;
5857 private readonly gitOperationsManager : GitOperationsManager ;
5958
6059 constructor ( private credentialStore : CredentialStore , public repositoriesManager : RepositoriesManager , private telemetry : ITelemetry ) {
@@ -92,7 +91,6 @@ export class CopilotRemoteAgentManager extends Disposable {
9291
9392 // Set initial context
9493 this . updateAssignabilityContext ( ) ;
95- this . _config = new CopilotRemoteAgentConfig ( ) ;
9694 }
9795
9896 private _copilotApiPromise : Promise < CopilotApi | undefined > | undefined ;
@@ -108,11 +106,11 @@ export class CopilotRemoteAgentManager extends Disposable {
108106 }
109107
110108 public get enabled ( ) : boolean {
111- return this . _config . enabled ;
109+ return CopilotRemoteAgentConfig . getEnabled ( ) ;
112110 }
113111
114112 public get autoCommitAndPushEnabled ( ) : boolean {
115- return this . _config . autoCommitAndPushEnabled ;
113+ return CopilotRemoteAgentConfig . getAutoCommitAndPushEnabled ( ) ;
116114 }
117115
118116 private _repoManagerInitializationPromise : Promise < void > | undefined ;
@@ -162,7 +160,7 @@ export class CopilotRemoteAgentManager extends Disposable {
162160
163161 async isAvailable ( ) : Promise < boolean > {
164162 // Check if the manager is enabled, copilot API is available, and it's assignable
165- if ( ! this . _config . enabled ) {
163+ if ( ! CopilotRemoteAgentConfig . getEnabled ( ) ) {
166164 return false ;
167165 }
168166
@@ -300,7 +298,7 @@ export class CopilotRemoteAgentManager extends Disposable {
300298 let autoPushAndCommit = false ;
301299 const message = vscode . l10n . t ( 'Copilot coding agent will continue your work in \'{0}\'.' , repoName ) ;
302300 const detail = vscode . l10n . t ( 'Your chat context will be used to continue work in a new pull request.' ) ;
303- if ( source !== 'prompt' && hasChanges && this . _config . autoCommitAndPushEnabled ) {
301+ if ( source !== 'prompt' && hasChanges && CopilotRemoteAgentConfig . getAutoCommitAndPushEnabled ( ) ) {
304302 // Pending changes modal
305303 const modalResult = await vscode . window . showInformationMessage (
306304 message ,
@@ -331,7 +329,7 @@ export class CopilotRemoteAgentManager extends Disposable {
331329 if ( modalResult === PUSH_CHANGES ) {
332330 autoPushAndCommit = true ;
333331 }
334- } else if ( this . _config . promptForConfirmation ) {
332+ } else if ( CopilotRemoteAgentConfig . getPromptForConfirmation ( ) ) {
335333 // No pending changes modal
336334 const modalResult = await vscode . window . showInformationMessage (
337335 source !== 'prompt' ? message : vscode . l10n . t ( 'Copilot coding agent will implement the specification outlined in this prompt file' ) ,
@@ -348,7 +346,7 @@ export class CopilotRemoteAgentManager extends Disposable {
348346 }
349347
350348 if ( modalResult === CONTINUE_AND_DO_NOT_ASK_AGAIN ) {
351- await this . _config . disablePromptForConfirmation ( ) ;
349+ await CopilotRemoteAgentConfig . disablePromptForConfirmation ( ) ;
352350 }
353351
354352 if ( modalResult === LEARN_MORE ) {
@@ -442,7 +440,7 @@ export class CopilotRemoteAgentManager extends Disposable {
442440 let ref = baseRef ;
443441 const hasChanges = autoPushAndCommit && ( repository . state . workingTreeChanges . length > 0 || repository . state . indexChanges . length > 0 ) ;
444442 if ( hasChanges ) {
445- if ( ! this . _config . autoCommitAndPushEnabled ) {
443+ if ( ! CopilotRemoteAgentConfig . getAutoCommitAndPushEnabled ( ) ) {
446444 return { error : vscode . l10n . t ( 'Uncommitted changes detected. Please commit or stash your changes before starting the remote agent. Enable \'{0}\' to push your changes automatically.' , CODING_AGENT_AUTO_COMMIT_AND_PUSH ) , state : 'error' } ;
447445 }
448446 try {
@@ -455,7 +453,7 @@ export class CopilotRemoteAgentManager extends Disposable {
455453 const base_ref = hasChanges ? baseRef : ref ;
456454 try {
457455 if ( ! ( await ghRepository . hasBranch ( base_ref ) ) ) {
458- if ( ! this . _config . autoCommitAndPushEnabled ) {
456+ if ( ! CopilotRemoteAgentConfig . getAutoCommitAndPushEnabled ( ) ) {
459457 // We won't auto-push a branch if the user has disabled the setting
460458 return { error : vscode . l10n . t ( 'The branch \'{0}\' does not exist on the remote repository \'{1}/{2}\'. Please create the remote branch first.' , base_ref , owner , repo ) , state : 'error' } ;
461459 }
0 commit comments