Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,14 @@
"type": "string",
"description": "The key of the notification"
},
"itemNumber": {
"type": "string",
"description": "The number of the issue/PR in the notification"
},
"itemType": {
"type": "string",
"description": "The type of the item in the notification - whether it is an issue or a PR"
},
Comment on lines +3320 to +3323
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"itemType": {
"type": "string",
"description": "The type of the item in the notification - whether it is an issue or a PR"
},
"itemType": {
"type": "string",
"enum": [
"issue",
"pr"
],
"description": "The type of the item in the notification - whether it is an issue or a PR"
},

"fileChanges": {
"type": "array",
"items": {
Expand Down
13 changes: 9 additions & 4 deletions src/lm/tools/fetchNotificationTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface FetchNotificationResult {
}[];
owner: string;
repo: string;
itemNumber: string;
itemType: 'issue' | 'pr';
fileChanges?: FileChange[];
threadId: number,
notificationKey: string
Expand All @@ -54,8 +56,8 @@ export class FetchNotificationTool extends RepoToolBase<FetchNotificationToolPar
thread_id: threadId
});
const threadData = thread.data;
const issueNumber = threadData.subject.url.split('/').pop();
if (issueNumber === undefined) {
const itemNumber = threadData.subject.url.split('/').pop();
if (itemNumber === undefined) {
return undefined;
}
const lastUpdatedAt = threadData.updated_at;
Expand All @@ -64,10 +66,11 @@ export class FetchNotificationTool extends RepoToolBase<FetchNotificationToolPar
const owner = threadData.repository.owner.login;
const name = threadData.repository.name;
const { folderManager } = await this.getRepoInfo({ owner, name });
const issueOrPR = await folderManager.resolveIssueOrPullRequest(owner, name, Number(issueNumber));
const issueOrPR = await folderManager.resolveIssueOrPullRequest(owner, name, Number(itemNumber));
if (!issueOrPR) {
throw new Error(`No notification found with thread ID #${threadId}.`);
}
const itemType = issueOrPR instanceof PullRequestModel ? 'pr' : 'issue';
const notificationKey = getNotificationKey(owner, name, String(issueOrPR.number));
const comments = issueOrPR.item.comments ?? [];
let unreadComments: { body: string; }[];
Expand All @@ -88,7 +91,9 @@ export class FetchNotificationTool extends RepoToolBase<FetchNotificationToolPar
title: issueOrPR.title,
body: issueOrPR.body,
owner,
repo: name
repo: name,
itemNumber,
itemType
};
if (issueOrPR instanceof PullRequestModel) {
const fileChanges = await issueOrPR.getFileChangesInfo();
Expand Down
9 changes: 9 additions & 0 deletions src/lm/tools/summarizeNotificationsTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import { concatAsyncIterable, TOOL_COMMAND_RESULT } from './toolsUtils';
export class NotificationSummarizationTool implements vscode.LanguageModelTool<FetchNotificationResult> {
public static readonly toolId = 'github-pull-request_notification_summarize';

async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<FetchNotificationResult>): Promise<vscode.PreparedToolInvocation> {
const parameters = options.parameters;
const type = parameters.itemType === 'issue' ? 'issues' : 'pull';
const url = `https://github.com/${parameters.owner}/${parameters.repo}/${type}/${parameters.itemNumber}`;
return {
invocationMessage: vscode.l10n.t('Fetching item [#{0}]({1}) from GitHub', parameters.itemNumber, url)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
invocationMessage: vscode.l10n.t('Fetching item [#{0}]({1}) from GitHub', parameters.itemNumber, url)
invocationMessage: type === 'issue' ? vscode.l10n.t('Fetching issue [#{0}]({1}) from GitHub', parameters.itemNumber, url) : vscode.l10n.t('Fetching pull request [#{0}]({1}) from GitHub', parameters.itemNumber, url)

};
}

async invoke(options: vscode.LanguageModelToolInvocationOptions<FetchNotificationResult>, _token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult | undefined> {
let notificationInfo: string = '';
const lastReadAt = options.parameters.lastReadAt;
Expand Down