@@ -528,20 +528,20 @@ export class CopilotRemoteAgentManager extends Disposable {
528528 // We only create a new branch and commit if there are staged or working changes.
529529 // This could be improved if we add lower-level APIs to our git extension (e.g. in-memory temp git index).
530530
531- let ref = baseRef ;
531+ const base_ref = baseRef ; // This is the ref the PR will merge into
532+ let head_ref : string | undefined ; // This is the ref coding agent starts work from (omitted unless we push local changes)
532533 const hasChanges = autoPushAndCommit && ( repository . state . workingTreeChanges . length > 0 || repository . state . indexChanges . length > 0 ) ;
533534 if ( hasChanges ) {
534535 if ( ! CopilotRemoteAgentConfig . getAutoCommitAndPushEnabled ( ) ) {
535536 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' } ;
536537 }
537538 try {
538- await this . gitOperationsManager . commitAndPushChanges ( repoInfo ) ;
539+ head_ref = await this . gitOperationsManager . commitAndPushChanges ( repoInfo ) ;
539540 } catch ( error ) {
540541 return { error : error . message , state : 'error' } ;
541542 }
542543 }
543544
544- const base_ref = hasChanges ? baseRef : ref ;
545545 try {
546546 if ( ! ( await ghRepository . hasBranch ( base_ref ) ) ) {
547547 if ( ! CopilotRemoteAgentConfig . getAutoCommitAndPushEnabled ( ) ) {
@@ -577,7 +577,7 @@ export class CopilotRemoteAgentManager extends Disposable {
577577 body_placeholder : formatBodyPlaceholder ( problemContext || prompt ) ,
578578 base_ref,
579579 body_suffix,
580- ...( hasChanges && { head_ref : ref } )
580+ ...( head_ref && { head_ref } )
581581 }
582582 } ;
583583
@@ -591,7 +591,7 @@ export class CopilotRemoteAgentManager extends Disposable {
591591 number : pull_request . number ,
592592 link : pull_request . html_url ,
593593 webviewUri,
594- llmDetails : hasChanges ? `The pending changes have been pushed to branch '${ ref } '. ${ prLlmString } ` : prLlmString ,
594+ llmDetails : head_ref ? `Local pending changes have been pushed to branch '${ head_ref } '. ${ prLlmString } ` : prLlmString ,
595595 sessionId : session_id
596596 } ;
597597 } catch ( error ) {
0 commit comments