Skip to content

Commit e314a3e

Browse files
Copilotalexr00
andcommitted
Use URI handler instead of direct GitHub URLs for Open button
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent c4ff85a commit e314a3e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ declare module 'vscode' {
9595
*/
9696
description?: string | MarkdownString;
9797

98+
/**
99+
* An optional badge that provides additional context about the chat session.
100+
*/
101+
badge?: string | MarkdownString;
102+
98103
/**
99104
* An optional status indicating the current state of the session.
100105
*/

src/lm/tools/summarizeIssueTool.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import * as vscode from 'vscode';
88
import { FetchIssueResult } from './fetchIssueTool';
99
import { concatAsyncIterable, TOOL_COMMAND_RESULT } from './toolsUtils';
10+
import { toOpenIssueWebviewUri, toOpenPullRequestWebviewUri } from '../../common/uri';
1011

1112
export class IssueSummarizationTool implements vscode.LanguageModelTool<FetchIssueResult> {
1213
public static readonly toolId = 'github-pull-request_issue_summarize';
@@ -64,12 +65,13 @@ Body: ${comment.body}
6465
const issueNumber = options.input.issueNumber;
6566
const itemType = options.input.itemType;
6667
if (owner && repo && issueNumber && itemType) {
67-
const type = itemType === 'issue' ? 'issues' : 'pull';
68-
const url = `https://github.com/${owner}/${repo}/${type}/${issueNumber}`;
68+
const uri = itemType === 'issue'
69+
? await toOpenIssueWebviewUri({ owner, repo, issueNumber })
70+
: await toOpenPullRequestWebviewUri({ owner, repo, pullRequestNumber: issueNumber });
6971
const openCommand: vscode.Command = {
7072
title: 'Open',
7173
command: 'vscode.open',
72-
arguments: [vscode.Uri.parse(url)]
74+
arguments: [uri]
7375
};
7476
content.push(new vscode.LanguageModelTextPart(TOOL_COMMAND_RESULT));
7577
content.push(new vscode.LanguageModelTextPart(JSON.stringify(openCommand)));

src/lm/tools/summarizeNotificationsTool.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import * as vscode from 'vscode';
88
import { FetchNotificationResult } from './fetchNotificationTool';
99
import { concatAsyncIterable, TOOL_COMMAND_RESULT } from './toolsUtils';
10+
import { toOpenIssueWebviewUri, toOpenPullRequestWebviewUri } from '../../common/uri';
1011

1112
export class NotificationSummarizationTool implements vscode.LanguageModelTool<FetchNotificationResult> {
1213
public static readonly toolId = 'github-pull-request_notification_summarize';
@@ -93,12 +94,13 @@ Body: ${comment.body}
9394

9495
// Add Open command
9596
if (owner && repo && itemNumber && itemType) {
96-
const type = itemType === 'issue' ? 'issues' : 'pull';
97-
const url = `https://github.com/${owner}/${repo}/${type}/${itemNumber}`;
97+
const uri = itemType === 'issue'
98+
? await toOpenIssueWebviewUri({ owner, repo, issueNumber: Number(itemNumber) })
99+
: await toOpenPullRequestWebviewUri({ owner, repo, pullRequestNumber: Number(itemNumber) });
98100
const openCommand: vscode.Command = {
99101
title: 'Open',
100102
command: 'vscode.open',
101-
arguments: [vscode.Uri.parse(url)]
103+
arguments: [uri]
102104
};
103105
content.push(new vscode.LanguageModelTextPart(TOOL_COMMAND_RESULT));
104106
content.push(new vscode.LanguageModelTextPart(JSON.stringify(openCommand)));

0 commit comments

Comments
 (0)