5
5
6
6
import { CancellationToken } from '../../../../../base/common/cancellation.js' ;
7
7
import { Codicon } from '../../../../../base/common/codicons.js' ;
8
+ import { ResolvedKeybinding } from '../../../../../base/common/keybindings.js' ;
8
9
import { KeyCode , KeyMod } from '../../../../../base/common/keyCodes.js' ;
9
10
import { Schemas } from '../../../../../base/common/network.js' ;
10
11
import { isElectron } from '../../../../../base/common/platform.js' ;
@@ -25,6 +26,7 @@ import { ICommandService } from '../../../../../platform/commands/common/command
25
26
import { ContextKeyExpr , IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js' ;
26
27
import { IFileService } from '../../../../../platform/files/common/files.js' ;
27
28
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js' ;
29
+ import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js' ;
28
30
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js' ;
29
31
import { ILabelService } from '../../../../../platform/label/common/label.js' ;
30
32
import { AnythingQuickAccessProviderRunOptions } from '../../../../../platform/quickinput/common/quickAccess.js' ;
@@ -59,6 +61,7 @@ import { isQuickChat } from '../chatWidget.js';
59
61
import { createFolderQuickPick , createMarkersQuickPick } from '../contrib/chatDynamicVariables.js' ;
60
62
import { convertBufferToScreenshotVariable , ScreenshotVariableId } from '../contrib/screenshot.js' ;
61
63
import { resizeImage } from '../imageUtils.js' ;
64
+ import { COMMAND_ID as USE_PROMPT_COMMAND_ID } from '../promptSyntax/contributions/usePromptCommand.js' ;
62
65
import { CHAT_CATEGORY } from './chatActions.js' ;
63
66
import { ATTACH_PROMPT_ACTION_ID , AttachPromptAction , IChatAttachPromptActionOptions } from './chatAttachPromptAction/chatAttachPromptAction.js' ;
64
67
@@ -75,7 +78,7 @@ export function registerChatContextActions() {
75
78
*/
76
79
type IAttachmentQuickPickItem = ICommandVariableQuickPickItem | IQuickAccessQuickPickItem | IToolQuickPickItem |
77
80
IImageQuickPickItem | IOpenEditorsQuickPickItem | ISearchResultsQuickPickItem |
78
- IScreenShotQuickPickItem | IRelatedFilesQuickPickItem | IPromptInstructionsQuickPickItem | IFolderQuickPickItem | IDiagnosticsQuickPickItem ;
81
+ IScreenShotQuickPickItem | IRelatedFilesQuickPickItem | IReusablePromptQuickPickItem | IFolderQuickPickItem | IDiagnosticsQuickPickItem ;
79
82
80
83
/**
81
84
* These are the types that we can get out of the quick pick
@@ -144,7 +147,7 @@ function isRelatedFileQuickPickItem(obj: unknown): obj is IRelatedFilesQuickPick
144
147
/**
145
148
* Checks is a provided object is a prompt instructions quick pick item.
146
149
*/
147
- function isPromptInstructionsQuickPickItem ( obj : unknown ) : obj is IPromptInstructionsQuickPickItem {
150
+ function isPromptInstructionsQuickPickItem ( obj : unknown ) : obj is IReusablePromptQuickPickItem {
148
151
if ( ! obj || typeof obj !== 'object' ) {
149
152
return false ;
150
153
}
@@ -230,19 +233,23 @@ interface IDiagnosticsQuickPickItemWithFilter extends IQuickPickItem {
230
233
}
231
234
232
235
/**
233
- * Quick pick item for prompt instructions attachment.
236
+ * Quick pick item for reusable prompt attachment.
234
237
*/
235
- interface IPromptInstructionsQuickPickItem extends IQuickPickItem {
238
+ interface IReusablePromptQuickPickItem extends IQuickPickItem {
236
239
/**
237
- * Unique kind identifier of the prompt instructions
238
- * attachment quick pick item.
240
+ * The ID of the quick pick item.
239
241
*/
240
- kind : 'prompt-instructions ' ;
242
+ id : 'reusable-prompt ' ;
241
243
242
244
/**
243
- * The id of the qucik pick item .
245
+ * Unique kind identifier of the reusable prompt attachment .
244
246
*/
245
- id : string ;
247
+ kind : 'reusable-prompt' ;
248
+
249
+ /**
250
+ * Keybinding of the command.
251
+ */
252
+ keybinding ?: ResolvedKeybinding ;
246
253
}
247
254
248
255
abstract class AttachFileAction extends Action2 {
@@ -674,6 +681,7 @@ export class AttachContextAction extends Action2 {
674
681
const fileService = accessor . get ( IFileService ) ;
675
682
const textModelService = accessor . get ( ITextModelService ) ;
676
683
const instantiationService = accessor . get ( IInstantiationService ) ;
684
+ const keybindingService = accessor . get ( IKeybindingService ) ;
677
685
678
686
const context : { widget ?: IChatWidget ; showFilesOnly ?: boolean ; placeholder ?: string } | undefined = args [ 0 ] ;
679
687
const widget = context ?. widget ?? widgetService . lastFocusedWidget ;
@@ -811,14 +819,17 @@ export class AttachContextAction extends Action2 {
811
819
}
812
820
}
813
821
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
816
824
if ( widget . attachmentModel . promptInstructions . featureEnabled ) {
825
+ const keybinding = keybindingService . lookupKeybinding ( USE_PROMPT_COMMAND_ID , contextKeyService ) ;
826
+
817
827
quickPickItems . push ( {
818
- kind : 'prompt-instructions ' ,
819
- id : 'prompt-instructions ' ,
828
+ kind : 'reusable-prompt ' ,
829
+ id : 'reusable-prompt ' ,
820
830
label : localize ( 'chatContext.attach.prompt.label' , 'Prompt...' ) ,
821
831
iconClass : ThemeIcon . asClassName ( Codicon . bookmark ) ,
832
+ keybinding,
822
833
} ) ;
823
834
}
824
835
0 commit comments