3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { IChatWidget } from '../../chat.js' ;
6
+ import { ChatViewId , IChatWidget } from '../../chat.js' ;
7
7
import { CHAT_CATEGORY } from '../chatActions.js' ;
8
8
import { URI } from '../../../../../../base/common/uri.js' ;
9
9
import { OS } from '../../../../../../base/common/platform.js' ;
@@ -14,7 +14,6 @@ import { ThemeIcon } from '../../../../../../base/common/themables.js';
14
14
import { ResourceContextKey } from '../../../../../common/contextkeys.js' ;
15
15
import { KeyCode , KeyMod } from '../../../../../../base/common/keyCodes.js' ;
16
16
import { PROMPT_LANGUAGE_ID } from '../../../common/promptSyntax/constants.js' ;
17
- import { IPromptsService } from '../../../common/promptSyntax/service/types.js' ;
18
17
import { ILocalizedString , localize , localize2 } from '../../../../../../nls.js' ;
19
18
import { UILabelProvider } from '../../../../../../base/common/keybindingLabels.js' ;
20
19
import { ICommandAction } from '../../../../../../platform/action/common/action.js' ;
@@ -31,7 +30,7 @@ import { KeybindingWeight } from '../../../../../../platform/keybinding/common/k
31
30
import { Action2 , MenuId , registerAction2 } from '../../../../../../platform/actions/common/actions.js' ;
32
31
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js' ;
33
32
import { PromptsType } from '../../../../../../platform/prompts/common/prompts.js' ;
34
- import { CancellationToken } from '../../../../../../base/ common/cancellation .js' ;
33
+ import { IOpenerService } from '../../../../../../platform/opener/ common/opener .js' ;
35
34
36
35
/**
37
36
* Condition for the `Run Current Prompt` action.
@@ -57,6 +56,11 @@ const RUN_CURRENT_PROMPT_ACTION_ID = 'workbench.action.chat.run.prompt.current';
57
56
*/
58
57
const RUN_SELECTED_PROMPT_ACTION_ID = 'workbench.action.chat.run.prompt' ;
59
58
59
+ /**
60
+ * Action ID for the `Manage Prompt Files...` action.
61
+ */
62
+ const MANAGE_SELECTED_PROMPT_ACTION_ID = 'workbench.action.chat.manage.prompts' ;
63
+
60
64
/**
61
65
* Constructor options for the `Run Prompt` base action.
62
66
*/
@@ -203,21 +207,18 @@ class RunSelectedPromptAction extends Action2 {
203
207
accessor : ServicesAccessor ,
204
208
) : Promise < void > {
205
209
const viewsService = accessor . get ( IViewsService ) ;
206
- const promptsService = accessor . get ( IPromptsService ) ;
207
210
const commandService = accessor . get ( ICommandService ) ;
208
211
const instaService = accessor . get ( IInstantiationService ) ;
209
212
210
213
const pickers = instaService . createInstance ( PromptFilePickers ) ;
211
214
212
- // find all prompt files in the user workspace
213
- const promptFiles = await promptsService . listPromptFiles ( PromptsType . prompt , CancellationToken . None ) ;
214
215
const placeholder = localize (
215
216
'commands.prompt.select-dialog.placeholder' ,
216
217
'Select the prompt file to run (hold {0}-key to use in new chat)' ,
217
218
UILabelProvider . modifierLabels [ OS ] . ctrlKey
218
219
) ;
219
220
220
- const result = await pickers . selectPromptFile ( { promptFiles , placeholder, type : PromptsType . prompt } ) ;
221
+ const result = await pickers . selectPromptFile ( { placeholder, type : PromptsType . prompt } ) ;
221
222
222
223
if ( result === undefined ) {
223
224
return ;
@@ -237,6 +238,45 @@ class RunSelectedPromptAction extends Action2 {
237
238
}
238
239
}
239
240
241
+ class ManagePromptFilesAction extends Action2 {
242
+ constructor ( ) {
243
+ super ( {
244
+ id : MANAGE_SELECTED_PROMPT_ACTION_ID ,
245
+ title : localize2 ( 'manage-prompts.capitalized.ellipses' , "Manage Prompt Files..." ) ,
246
+ icon : Codicon . bookmark ,
247
+ f1 : true ,
248
+ precondition : ContextKeyExpr . and ( PromptsConfig . enabledCtx , ChatContextKeys . enabled ) ,
249
+ category : CHAT_CATEGORY ,
250
+ menu : {
251
+ id : MenuId . ViewTitle ,
252
+ when : ContextKeyExpr . equals ( 'view' , ChatViewId ) ,
253
+ order : 10 ,
254
+ group : '1_open'
255
+ } ,
256
+
257
+ } ) ;
258
+ }
259
+
260
+ public override async run (
261
+ accessor : ServicesAccessor ,
262
+ ) : Promise < void > {
263
+ const openerService = accessor . get ( IOpenerService ) ;
264
+ const instaService = accessor . get ( IInstantiationService ) ;
265
+
266
+ const pickers = instaService . createInstance ( PromptFilePickers ) ;
267
+
268
+ const placeholder = localize (
269
+ 'commands.prompt.manage-dialog.placeholder' ,
270
+ 'Select the prompt file to open'
271
+ ) ;
272
+
273
+ const result = await pickers . selectPromptFile ( { placeholder, type : PromptsType . prompt , optionEdit : false } ) ;
274
+ if ( result !== undefined ) {
275
+ await openerService . open ( result . promptFile ) ;
276
+ }
277
+ }
278
+ }
279
+
240
280
241
281
/**
242
282
* Gets `URI` of a prompt file open in an active editor instance, if any.
@@ -305,4 +345,5 @@ export const registerRunPromptActions = () => {
305
345
registerAction2 ( RunCurrentPromptInNewChatAction ) ;
306
346
registerAction2 ( RunCurrentPromptAction ) ;
307
347
registerAction2 ( RunSelectedPromptAction ) ;
348
+ registerAction2 ( ManagePromptFilesAction ) ;
308
349
} ;
0 commit comments