Skip to content

Commit 13ee529

Browse files
Copilotalexr00
andauthored
Fix: Enter review mode for explicitly switched PRs regardless of state (#8130)
* Initial plan * Add _switchedToPullRequest to track explicitly switched PRs Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 6e1f6cc commit 13ee529

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/view/reviewManager.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ export class ReviewManager extends Disposable {
7575
* explicit user action from something like reloading on an existing PR branch.
7676
*/
7777
private justSwitchedToReviewMode: boolean = false;
78+
/**
79+
* The last pull request the user explicitly switched to via the switch method.
80+
* Used to enter review mode for this PR regardless of its state (open/closed/merged).
81+
*/
82+
private _switchedToPullRequest?: PullRequestModel;
7883

7984
public get switchingToReviewMode(): boolean {
8085
return this._switchingToReviewMode;
@@ -481,13 +486,16 @@ export class ReviewManager extends Disposable {
481486

482487
const useReviewConfiguration = getReviewMode();
483488

484-
if (pr.isClosed && !useReviewConfiguration.closed) {
489+
// If this is the PR the user explicitly switched to, always use review mode regardless of state
490+
const isSwitchedToPullRequest = this._switchedToPullRequest?.number === pr.number;
491+
492+
if (pr.isClosed && !useReviewConfiguration.closed && !isSwitchedToPullRequest) {
485493
Logger.appendLine('This PR is closed', this.id);
486494
await this.clear(true);
487495
return;
488496
}
489497

490-
if (pr.isMerged && !useReviewConfiguration.merged) {
498+
if (pr.isMerged && !useReviewConfiguration.merged && !isSwitchedToPullRequest) {
491499
Logger.appendLine('This PR is merged', this.id);
492500
await this.clear(true);
493501
return;
@@ -1090,6 +1098,7 @@ export class ReviewManager extends Disposable {
10901098
this.statusBarItem.command = undefined;
10911099
this.statusBarItem.show();
10921100
this.switchingToReviewMode = true;
1101+
this._switchedToPullRequest = pr;
10931102

10941103
try {
10951104
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification }, async (progress) => {
@@ -1243,6 +1252,7 @@ export class ReviewManager extends Disposable {
12431252

12441253
this._prNumber = undefined;
12451254
this._folderRepoManager.activePullRequest = undefined;
1255+
this._switchedToPullRequest = undefined;
12461256

12471257
if (this._statusBarItem) {
12481258
this._statusBarItem.hide();

0 commit comments

Comments
 (0)