Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface ISelectOptions {
readonly optionRename?: boolean;
readonly optionCopy?: boolean;
readonly optionVisibility?: boolean;
readonly optionRun?: boolean;
}

export interface ISelectPromptResult {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -710,7 +731,8 @@ export class PromptFilePickers {
optionDelete: true,
optionRename: true,
optionCopy: true,
optionVisibility: false
optionVisibility: false,
optionRun: false
};

try {
Expand Down
Loading