Skip to content

Commit c01c824

Browse files
Copilotalexr00
andcommitted
Move command registrations from pullRequestOverview.ts to commands.ts
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 4c48cff commit c01c824

2 files changed

Lines changed: 20 additions & 23 deletions

File tree

src/commands.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ChatSessionWithPR, CrossChatSessionWithPR } from './github/copilotApi';
2222
import { CopilotRemoteAgentManager } from './github/copilotRemoteAgent';
2323
import { FolderRepositoryManager } from './github/folderRepositoryManager';
2424
import { GitHubRepository } from './github/githubRepository';
25-
import { Issue } from './github/interface';
25+
import { Issue, MergeMethod } from './github/interface';
2626
import { IssueModel } from './github/issueModel';
2727
import { IssueOverviewPanel } from './github/issueOverview';
2828
import { GHPRComment, GHPRCommentThread, TemporaryComment } from './github/prComment';
@@ -815,6 +815,14 @@ export function registerCommands(
815815

816816
context.subscriptions.push(
817817
vscode.commands.registerCommand('pr.readyForReview', async (pr?: PRNode) => {
818+
// When called from webview context menu (no PRNode), trigger the webview action
819+
if (!pr && PullRequestOverviewPanel.currentPanel) {
820+
PullRequestOverviewPanel.currentPanel['_postMessage']({
821+
command: 'pr.readyForReview-trigger'
822+
});
823+
return;
824+
}
825+
818826
const folderManager = reposManager.getManagerForIssueModel(pr?.pullRequestModel);
819827
if (!folderManager) {
820828
return;
@@ -844,6 +852,17 @@ export function registerCommands(
844852
}),
845853
);
846854

855+
context.subscriptions.push(
856+
vscode.commands.registerCommand('pr.readyForReviewAndMerge', async (_context?: { mergeMethod: MergeMethod }) => {
857+
// This command is only called from webview context menu
858+
if (PullRequestOverviewPanel.currentPanel) {
859+
PullRequestOverviewPanel.currentPanel['_postMessage']({
860+
command: 'pr.readyForReviewAndMerge-trigger'
861+
});
862+
}
863+
}),
864+
);
865+
847866
context.subscriptions.push(
848867
vscode.commands.registerCommand('pr.dismissNotification', node => {
849868
if (node instanceof PRNode) {

src/github/pullRequestOverview.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
142142

143143
this.setVisibilityContext();
144144

145-
this._register(vscode.commands.registerCommand('pr.readyForReview', async () => {
146-
return this.readyForReviewCommand();
147-
}));
148-
this._register(vscode.commands.registerCommand('pr.readyForReviewAndMerge', async (context?: { mergeMethod: MergeMethod }) => {
149-
return this.readyForReviewAndMergeCommand(context);
150-
}));
151145
this._register(vscode.commands.registerCommand('review.approveDescription', (e) => this.approvePullRequestCommand(e)));
152146
this._register(vscode.commands.registerCommand('review.commentDescription', (e) => this.submitReviewCommand(e)));
153147
this._register(vscode.commands.registerCommand('review.requestChangesDescription', (e) => this.requestChangesCommand(e)));
@@ -684,22 +678,6 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
684678
}
685679
}
686680

687-
private async readyForReviewCommand(): Promise<void> {
688-
// Trigger the webview action by posting a message
689-
// This will use the existing webview logic which handles busy state
690-
this._postMessage({
691-
command: 'pr.readyForReview-trigger'
692-
});
693-
}
694-
695-
private async readyForReviewAndMergeCommand(_context?: { mergeMethod: MergeMethod }): Promise<void> {
696-
// Trigger the webview action by posting a message
697-
// This will use the existing webview logic which handles busy state
698-
this._postMessage({
699-
command: 'pr.readyForReviewAndMerge-trigger'
700-
});
701-
}
702-
703681
private async checkoutDefaultBranch(message: IRequestMessage<string>): Promise<void> {
704682
try {
705683
const prBranch = this._folderRepositoryManager.repository.state.HEAD?.name;

0 commit comments

Comments
 (0)