Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/@types/vscode.proposed.chatParticipantAdditions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ declare module 'vscode' {
isComplete?: boolean;
toolSpecificData?: ChatTerminalToolInvocationData;
fromSubAgent?: boolean;
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;

constructor(toolName: string, toolCallId: string, isError?: boolean);
}
Expand Down
27 changes: 26 additions & 1 deletion src/github/createPRViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,28 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
return this._replyMessage(message, undefined);
}

private async openCreateInBrowser(): Promise<void> {
// Get the base repository info
const baseRepo = this.getBaseGitHubRepo();
if (!baseRepo) {
vscode.window.showErrorMessage(vscode.l10n.t('Unable to find repository to create pull request in.'));
return;
}

// Get the compare branch name - this is the branch we want to create a PR from
const compareBranch = this._defaultCompareBranch;
if (!compareBranch) {
vscode.window.showErrorMessage(vscode.l10n.t('Unable to determine branch to create pull request from.'));
return;
}

// Construct the GitHub URL for creating a PR
// Format: https://github.com/{owner}/{repo}/pull/new/{branch}
const url = `${baseRepo.remote.normalizedHost}/${baseRepo.remote.owner}/${baseRepo.remote.repositoryName}/pull/new/${encodeURIComponent(compareBranch)}`;

await vscode.env.openExternal(vscode.Uri.parse(url));
}

protected override async _onDidReceiveMessage(message: IRequestMessage<any>) {
const result = await super._onDidReceiveMessage(message);
if (result !== this.MESSAGE_UNHANDLED) {
Expand Down Expand Up @@ -539,6 +561,9 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
case 'pr.removeLabel':
return this.removeLabel(message);

case 'pr.openCreateInBrowser':
return this.openCreateInBrowser();

default:
return this.MESSAGE_UNHANDLED;
}
Expand Down Expand Up @@ -1342,4 +1367,4 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
vscode.window.showErrorMessage('Unsupported webview message');
}
}
}
}
4 changes: 4 additions & 0 deletions webviews/common/createContextNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export class CreatePRContextNew {
return this.postMessage({ command: 'pr.cancelCreate', args });
};

public openCreateInBrowser = (): Promise<void> => {
return this.postMessage({ command: 'pr.openCreateInBrowser' });
};

public updateState = (params: Partial<CreateParamsNew>, reset: boolean = false): void => {
this.createParams = reset ? { ...defaultCreateParams, ...params } : { ...this.createParams, ...params };
vscode.setState(this.createParams);
Expand Down
4 changes: 4 additions & 0 deletions webviews/createPullRequestViewNew/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ export function main() {
Cancel
</button>

<button disabled={isBusy || !ctx.initialized} className='secondary' onClick={() => ctx.openCreateInBrowser()} title='Create pull request on GitHub.com'>
Create in Browser
</button>

<ContextDropdown optionsContext={() => makeCreateMenuContext(params)}
defaultAction={onCreateButton}
defaultOptionLabel={() => createMethodLabel(ctx.createParams.isDraft, ctx.createParams.autoMerge, ctx.createParams.autoMergeMethod, ctx.createParams.baseHasMergeQueue).label}
Expand Down