diff --git a/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.ts b/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.ts index aaf3a9b134071..349bb815934db 100644 --- a/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.ts +++ b/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.ts @@ -54,6 +54,7 @@ export interface ISelectOptions { readonly optionRename?: boolean; readonly optionCopy?: boolean; readonly optionVisibility?: boolean; + readonly optionRun?: boolean; } export interface ISelectPromptResult { @@ -323,6 +324,11 @@ const MAKE_INVISIBLE_BUTTON: IQuickInputButton = { iconClass: ThemeIcon.asClassName(Codicon.eye), }; +const RUN_IN_CHAT_BUTTON: IQuickInputButton = { + tooltip: localize('runInChat', "Run in Chat View"), + iconClass: ThemeIcon.asClassName(Codicon.play), +}; + export class PromptFilePickers { constructor( @IQuickInputService private readonly _quickInputService: IQuickInputService, @@ -425,6 +431,9 @@ export class PromptFilePickers { private async _createPromptPickItems(options: ISelectOptions, token: CancellationToken): Promise<(IPromptPickerQuickPickItem | IQuickPickSeparator)[]> { const buttons: IQuickInputButton[] = []; + if (options.type === PromptsType.prompt && options.optionRun !== false) { + buttons.push(RUN_IN_CHAT_BUTTON); + } if (options.optionEdit !== false) { buttons.push(EDIT_BUTTON); } @@ -481,6 +490,9 @@ export class PromptFilePickers { const exts = (await this._promptsService.listPromptFilesForStorage(options.type, PromptsStorage.extension, token)).filter(isExtensionPromptPath); if (exts.length) { const extButtons: IQuickInputButton[] = []; + if (options.type === PromptsType.prompt && options.optionRun !== false) { + extButtons.push(RUN_IN_CHAT_BUTTON); + } if (options.optionEdit !== false) { extButtons.push(EDIT_BUTTON); } @@ -613,6 +625,15 @@ export class PromptFilePickers { } const value = item.promptFileUri; + if (button === RUN_IN_CHAT_BUTTON) { + const commandId = quickPick.keyMods.ctrlCmd === true + ? 'workbench.action.chat.run-in-new-chat.prompt.current' + : 'workbench.action.chat.run.prompt.current'; + await this._commandService.executeCommand(commandId, value); + quickPick.hide(); + return false; + } + // `edit` button was pressed, open the prompt file in editor if (button === EDIT_BUTTON) { await this._openerService.open(value); @@ -710,7 +731,8 @@ export class PromptFilePickers { optionDelete: true, optionRename: true, optionCopy: true, - optionVisibility: false + optionVisibility: false, + optionRun: false }; try {