Skip to content

Commit 7427529

Browse files
committed
add the shortcut info for the 'prompt' item in the attachments list
1 parent 557dd4d commit 7427529

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { CancellationToken } from '../../../../../base/common/cancellation.js';
77
import { Codicon } from '../../../../../base/common/codicons.js';
8+
import { ResolvedKeybinding } from '../../../../../base/common/keybindings.js';
89
import { KeyCode, KeyMod } from '../../../../../base/common/keyCodes.js';
910
import { Schemas } from '../../../../../base/common/network.js';
1011
import { isElectron } from '../../../../../base/common/platform.js';
@@ -25,6 +26,7 @@ import { ICommandService } from '../../../../../platform/commands/common/command
2526
import { ContextKeyExpr, IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
2627
import { IFileService } from '../../../../../platform/files/common/files.js';
2728
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
29+
import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js';
2830
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js';
2931
import { ILabelService } from '../../../../../platform/label/common/label.js';
3032
import { AnythingQuickAccessProviderRunOptions } from '../../../../../platform/quickinput/common/quickAccess.js';
@@ -59,6 +61,7 @@ import { isQuickChat } from '../chatWidget.js';
5961
import { createFolderQuickPick, createMarkersQuickPick } from '../contrib/chatDynamicVariables.js';
6062
import { convertBufferToScreenshotVariable, ScreenshotVariableId } from '../contrib/screenshot.js';
6163
import { resizeImage } from '../imageUtils.js';
64+
import { COMMAND_ID as USE_PROMPT_COMMAND_ID } from '../promptSyntax/contributions/usePromptCommand.js';
6265
import { CHAT_CATEGORY } from './chatActions.js';
6366
import { ATTACH_PROMPT_ACTION_ID, AttachPromptAction, IChatAttachPromptActionOptions } from './chatAttachPromptAction/chatAttachPromptAction.js';
6467

@@ -75,7 +78,7 @@ export function registerChatContextActions() {
7578
*/
7679
type IAttachmentQuickPickItem = ICommandVariableQuickPickItem | IQuickAccessQuickPickItem | IToolQuickPickItem |
7780
IImageQuickPickItem | IOpenEditorsQuickPickItem | ISearchResultsQuickPickItem |
78-
IScreenShotQuickPickItem | IRelatedFilesQuickPickItem | IPromptInstructionsQuickPickItem | IFolderQuickPickItem | IDiagnosticsQuickPickItem;
81+
IScreenShotQuickPickItem | IRelatedFilesQuickPickItem | IReusablePromptQuickPickItem | IFolderQuickPickItem | IDiagnosticsQuickPickItem;
7982

8083
/**
8184
* These are the types that we can get out of the quick pick
@@ -144,7 +147,7 @@ function isRelatedFileQuickPickItem(obj: unknown): obj is IRelatedFilesQuickPick
144147
/**
145148
* Checks is a provided object is a prompt instructions quick pick item.
146149
*/
147-
function isPromptInstructionsQuickPickItem(obj: unknown): obj is IPromptInstructionsQuickPickItem {
150+
function isPromptInstructionsQuickPickItem(obj: unknown): obj is IReusablePromptQuickPickItem {
148151
if (!obj || typeof obj !== 'object') {
149152
return false;
150153
}
@@ -230,19 +233,23 @@ interface IDiagnosticsQuickPickItemWithFilter extends IQuickPickItem {
230233
}
231234

232235
/**
233-
* Quick pick item for prompt instructions attachment.
236+
* Quick pick item for reusable prompt attachment.
234237
*/
235-
interface IPromptInstructionsQuickPickItem extends IQuickPickItem {
238+
interface IReusablePromptQuickPickItem extends IQuickPickItem {
236239
/**
237-
* Unique kind identifier of the prompt instructions
238-
* attachment quick pick item.
240+
* The ID of the quick pick item.
239241
*/
240-
kind: 'prompt-instructions';
242+
id: 'reusable-prompt';
241243

242244
/**
243-
* The id of the qucik pick item.
245+
* Unique kind identifier of the reusable prompt attachment.
244246
*/
245-
id: string;
247+
kind: 'reusable-prompt';
248+
249+
/**
250+
* Keybinding of the command.
251+
*/
252+
keybinding?: ResolvedKeybinding;
246253
}
247254

248255
abstract class AttachFileAction extends Action2 {
@@ -674,6 +681,7 @@ export class AttachContextAction extends Action2 {
674681
const fileService = accessor.get(IFileService);
675682
const textModelService = accessor.get(ITextModelService);
676683
const instantiationService = accessor.get(IInstantiationService);
684+
const keybindingService = accessor.get(IKeybindingService);
677685

678686
const context: { widget?: IChatWidget; showFilesOnly?: boolean; placeholder?: string } | undefined = args[0];
679687
const widget = context?.widget ?? widgetService.lastFocusedWidget;
@@ -811,14 +819,17 @@ export class AttachContextAction extends Action2 {
811819
}
812820
}
813821

814-
// if the `prompt instructions` feature is enabled, add
815-
// the `Instructions` attachment type to the list
822+
// if the `reusable prompts` feature is enabled, add
823+
// the appropriate attachment type to the list
816824
if (widget.attachmentModel.promptInstructions.featureEnabled) {
825+
const keybinding = keybindingService.lookupKeybinding(USE_PROMPT_COMMAND_ID, contextKeyService);
826+
817827
quickPickItems.push({
818-
kind: 'prompt-instructions',
819-
id: 'prompt-instructions',
828+
kind: 'reusable-prompt',
829+
id: 'reusable-prompt',
820830
label: localize('chatContext.attach.prompt.label', 'Prompt...'),
821831
iconClass: ThemeIcon.asClassName(Codicon.bookmark),
832+
keybinding,
822833
});
823834
}
824835

0 commit comments

Comments
 (0)