Skip to content
Draft
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
9 changes: 9 additions & 0 deletions src/@types/vscode.proposed.chatContextProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@ declare module 'vscode' {
* An optional description of the context item, e.g. to describe the item to the language model.
*/
modelDescription?: string;
/**
* An optional tooltip to show when hovering over the context item in the UI.
*/
tooltip?: MarkdownString;
/**
* The value of the context item. Can be omitted when returned from one of the `provide` methods if the provider supports `resolveChatContext`.
*/
value?: string;
/**
* An optional command that is executed when the context item is clicked.
* The original context item will be passed as the first argument to the command.
*/
command?: Command;
}

export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ async function init(
context.subscriptions.push(issuesFeatures);
await issuesFeatures.initialize();

const pullRequestContextProvider = new PullRequestContextProvider(prsTreeModel, reposManager, git);
const pullRequestContextProvider = new PullRequestContextProvider(prsTreeModel, reposManager, git, context);
vscode.chat.registerChatContextProvider({ scheme: 'webview-panel', pattern: '**/webview-PullRequestOverview**' }, 'githubpr', pullRequestContextProvider);
vscode.chat.registerChatContextProvider({ scheme: 'webview-panel', pattern: '**/webview-IssueOverview**' }, 'githubissue', new IssueContextProvider(issueStateManager, reposManager));
vscode.chat.registerChatContextProvider({ scheme: 'webview-panel', pattern: '**/webview-IssueOverview**' }, 'githubissue', new IssueContextProvider(issueStateManager, reposManager, context));
pullRequestContextProvider.initialize();

const notificationsFeatures = new NotificationsFeatureRegister(credentialStore, reposManager, telemetry, notificationsManager);
Expand Down
6 changes: 5 additions & 1 deletion src/lm/issueContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from 'vscode';
import { CommentEvent, EventType } from '../common/timelineEvent';
import { IssueModel } from '../github/issueModel';
import { IssueOverviewPanel } from '../github/issueOverview';
import { issueMarkdown } from '../github/markdownUtils';
import { RepositoriesManager } from '../github/repositoriesManager';
import { getIssueNumberLabel } from '../github/utils';
import { IssueQueryResult, StateManager } from '../issues/stateManager';
Expand All @@ -17,7 +18,8 @@ interface IssueChatContextItem extends vscode.ChatContextItem {

export class IssueContextProvider implements vscode.ChatContextProvider {
constructor(private readonly _stateManager: StateManager,
private readonly _reposManager: RepositoriesManager
private readonly _reposManager: RepositoriesManager,
private readonly _context: vscode.ExtensionContext
) { }

async provideChatContextForResource(_options: { resource: vscode.Uri }, _token: vscode.CancellationToken): Promise<IssueChatContextItem | undefined> {
Expand All @@ -30,6 +32,7 @@ export class IssueContextProvider implements vscode.ChatContextProvider {
async resolveChatContext(context: IssueChatContextItem, _token: vscode.CancellationToken): Promise<vscode.ChatContextItem> {
context.value = await this._resolvedIssueValue(context.issue);
context.modelDescription = 'All the information about the GitHub issue the user is viewing, including comments.';
context.tooltip = await issueMarkdown(context.issue, this._context, this._reposManager);
return context;
}

Expand Down Expand Up @@ -65,6 +68,7 @@ export class IssueContextProvider implements vscode.ChatContextProvider {
icon: new vscode.ThemeIcon('issues'),
label: `#${issue.number} ${issue.title}`,
modelDescription: 'The GitHub issue the user is viewing.',
tooltip: new vscode.MarkdownString(`#${issue.number} ${issue.title}`),
issue,
};
}
Expand Down
6 changes: 5 additions & 1 deletion src/lm/pullRequestContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from 'vscode';
import { GitApiImpl } from '../api/api1';
import { Disposable } from '../common/lifecycle';
import { onceEvent } from '../common/utils';
import { issueMarkdown } from '../github/markdownUtils';
import { PullRequestModel } from '../github/pullRequestModel';
import { PullRequestOverviewPanel } from '../github/pullRequestOverview';
import { RepositoriesManager } from '../github/repositoriesManager';
Expand All @@ -22,7 +23,8 @@ export class PullRequestContextProvider extends Disposable implements vscode.Cha

constructor(private readonly _prsTreeModel: PrsTreeModel,
private readonly _reposManager: RepositoriesManager,
private readonly _git: GitApiImpl
private readonly _git: GitApiImpl,
private readonly _context: vscode.ExtensionContext
) {
super();
}
Expand Down Expand Up @@ -96,6 +98,7 @@ Active pull request (may not be the same as open pull request): ${folderManager.
}
context.value = await this._resolvedPrValue(context.pr);
context.modelDescription = 'All the information about the GitHub pull request the user is viewing, including comments, review threads, and changes.';
context.tooltip = await issueMarkdown(context.pr, this._context, this._reposManager);
return context;
}

Expand All @@ -111,6 +114,7 @@ Active pull request (may not be the same as open pull request): ${folderManager.
icon: new vscode.ThemeIcon('git-pull-request'),
label: `#${pr.number} ${pr.title}`,
modelDescription: 'The GitHub pull request the user is viewing.',
tooltip: new vscode.MarkdownString(`#${pr.number} ${pr.title}`),
pr,
};
}
Expand Down