Skip to content

Commit e088e4b

Browse files
authored
Adopt new tooltip in chat context item (#8399)
Part of microsoft/vscode#280658
1 parent c61ad28 commit e088e4b

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ declare module 'vscode' {
3939
* An optional description of the context item, e.g. to describe the item to the language model.
4040
*/
4141
modelDescription?: string;
42+
/**
43+
* An optional tooltip to show when hovering over the context item in the UI.
44+
*/
45+
tooltip?: MarkdownString;
4246
/**
4347
* The value of the context item. Can be omitted when returned from one of the `provide` methods if the provider supports `resolveChatContext`.
4448
*/

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ async function init(
269269
context.subscriptions.push(issuesFeatures);
270270
await issuesFeatures.initialize();
271271

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

277277
const notificationsFeatures = new NotificationsFeatureRegister(credentialStore, reposManager, telemetry, notificationsManager);

src/lm/issueContextProvider.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as vscode from 'vscode';
77
import { CommentEvent, EventType } from '../common/timelineEvent';
88
import { IssueModel } from '../github/issueModel';
99
import { IssueOverviewPanel } from '../github/issueOverview';
10+
import { issueMarkdown } from '../github/markdownUtils';
1011
import { RepositoriesManager } from '../github/repositoriesManager';
1112
import { getIssueNumberLabel } from '../github/utils';
1213
import { IssueQueryResult, StateManager } from '../issues/stateManager';
@@ -23,7 +24,8 @@ export namespace IssueChatContextItem {
2324

2425
export class IssueContextProvider implements vscode.ChatContextProvider {
2526
constructor(private readonly _stateManager: StateManager,
26-
private readonly _reposManager: RepositoriesManager
27+
private readonly _reposManager: RepositoriesManager,
28+
private readonly _context: vscode.ExtensionContext
2729
) { }
2830

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

@@ -71,6 +74,7 @@ export class IssueContextProvider implements vscode.ChatContextProvider {
7174
icon: new vscode.ThemeIcon('issues'),
7275
label: `#${issue.number} ${issue.title}`,
7376
modelDescription: 'The GitHub issue the user is viewing.',
77+
tooltip: new vscode.MarkdownString(`#${issue.number} ${issue.title}`),
7478
issue,
7579
command: {
7680
command: 'issue.openDescription',

src/lm/pullRequestContextProvider.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as vscode from 'vscode';
77
import { GitApiImpl } from '../api/api1';
88
import { Disposable } from '../common/lifecycle';
99
import { onceEvent } from '../common/utils';
10+
import { issueMarkdown } from '../github/markdownUtils';
1011
import { PullRequestModel } from '../github/pullRequestModel';
1112
import { PullRequestOverviewPanel } from '../github/pullRequestOverview';
1213
import { RepositoriesManager } from '../github/repositoriesManager';
@@ -28,7 +29,8 @@ export class PullRequestContextProvider extends Disposable implements vscode.Cha
2829

2930
constructor(private readonly _prsTreeModel: PrsTreeModel,
3031
private readonly _reposManager: RepositoriesManager,
31-
private readonly _git: GitApiImpl
32+
private readonly _git: GitApiImpl,
33+
private readonly _context: vscode.ExtensionContext
3234
) {
3335
super();
3436
}
@@ -102,6 +104,7 @@ Active pull request (may not be the same as open pull request): ${folderManager.
102104
}
103105
context.value = await this._resolvedPrValue(context.pr);
104106
context.modelDescription = 'All the information about the GitHub pull request the user is viewing, including comments, review threads, and changes.';
107+
context.tooltip = await issueMarkdown(context.pr, this._context, this._reposManager);
105108
return context;
106109
}
107110

@@ -117,6 +120,7 @@ Active pull request (may not be the same as open pull request): ${folderManager.
117120
icon: new vscode.ThemeIcon('git-pull-request'),
118121
label: `#${pr.number} ${pr.title}`,
119122
modelDescription: 'The GitHub pull request the user is viewing.',
123+
tooltip: new vscode.MarkdownString(`#${pr.number} ${pr.title}`),
120124
pr,
121125
command: {
122126
command: 'pr.openDescription',

0 commit comments

Comments
 (0)