Skip to content

Commit b5a63e5

Browse files
authored
fix properly (#7717)
1 parent 93489a1 commit b5a63e5

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/github/copilotApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export class CopilotApi {
8383
const repoSlug = `${owner}/${name}`;
8484
const apiUrl = `/agents/swe/v0/jobs/${repoSlug}`;
8585
let status: number | undefined;
86+
Logger.trace(`postRemoteAgentJob: Posting job to ${apiUrl} with payload: ${JSON.stringify(payload)}`, CopilotApi.ID);
8687
try {
8788
const response = await this.makeApiCall(apiUrl, {
8889
method: 'POST',

src/github/copilotRemoteAgent.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

src/github/copilotRemoteAgent/gitOperationsManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export class GitOperationsManager {
2121

2222
await this.performCommit(asyncBranch, repository, commitMessage);
2323
await repository.push(remote.remoteName, asyncBranch, true);
24-
2524
this.showBranchSwitchNotification(repository, baseRef, asyncBranch);
25+
return asyncBranch; // This is the new head ref
2626
} catch (error) {
2727
await this.rollbackToOriginalBranch(repository, baseRef);
2828
Logger.error(`Failed to auto-commit and push pending changes: ${error}`, this.loggerID);

0 commit comments

Comments
 (0)