You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Always consume the checkout result — on the success path this is the
1671
+
// intended await; on a throw it ensures the in-flight checkout settles
1672
+
// (and aborts its children) instead of mutating the tree in the
1673
+
// background. checkoutExistingPullRequest never rejects.
1674
+
if(existingPrCheckoutPromise){
1675
+
this.logExistingPrCheckoutResult(
1676
+
prUrl,
1677
+
awaitexistingPrCheckoutPromise,
1678
+
);
1679
+
}
1680
+
}
1650
1681
1651
1682
letacpSessionId: string|null=null;
1652
1683
if(nativeResume){
@@ -3285,6 +3316,54 @@ export class AgentServer {
3285
3316
return`Continue working on the existing PR branch. If it is not already checked out, check it out with \`gh pr checkout ${prUrl}\`. Do not check it out again when it is already active.`;
3286
3317
}
3287
3318
3319
+
/**
3320
+
* Fire-and-overlap: starts the best-effort PR-branch checkout so it runs
3321
+
* concurrently with the rest of session setup, returning the promise (or
3322
+
* null when there is nothing to check out). Only runs when auto-publishing,
3323
+
* matching the system-prompt fallback's gate: a review-first run must not
3324
+
* silently check out a branch the prompt told the agent to leave alone.
3325
+
*/
3326
+
privatebuildExistingPrCheckoutPromise(
3327
+
prUrl: string|null,
3328
+
): Promise<ExistingPrCheckoutResult>|null{
3329
+
if(!prUrl||!this.config.repositoryPath){
3330
+
returnnull;
3331
+
}
3332
+
if(!this.shouldAutoPublishCloudChanges()){
3333
+
returnnull;
3334
+
}
3335
+
returncheckoutExistingPullRequest({
3336
+
repositoryPath: this.config.repositoryPath,
3337
+
prUrl,
3338
+
});
3339
+
}
3340
+
3341
+
/**
3342
+
* Consume a pre-checkout result without throwing — a transient `gh` failure
3343
+
* must fall back to the agent's own checkout (via the system-prompt
3344
+
* instruction), never abort session start.
3345
+
*/
3346
+
privatelogExistingPrCheckoutResult(
3347
+
prUrl: string|null,
3348
+
result: ExistingPrCheckoutResult,
3349
+
): void{
3350
+
if(result.status==="failed"){
3351
+
this.logger.warn(
3352
+
"Existing PR pre-checkout failed; agent will retry if needed",
3353
+
{
3354
+
prUrl,
3355
+
error: result.error,
3356
+
},
3357
+
);
3358
+
}else{
3359
+
this.logger.debug("Existing PR branch prepared before session start",{
0 commit comments