Skip to content

Commit 5c6caa7

Browse files
authored
Polish configure prompt files dialog (microsoft#250325)
* Polish comfigure prompt files dialog * add rename
1 parent 8436ef0 commit 5c6caa7

File tree

6 files changed

+51
-30
lines changed

6 files changed

+51
-30
lines changed

extensions/prompt-basics/snippets/prompt.code-snippets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"prefix": "New Reusable Chat Prompt",
44
"body": [
55
"---",
6-
"mode: '${1|ask,edit,agent|}'",
6+
"mode: ${1|ask,edit,agent|}",
77
"---",
88
"${2:Expected output and any relevant constraints for this task.}",
99
],

src/vs/workbench/contrib/chat/browser/actions/promptActions/chatAttachInstructionsAction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ import { IOpenerService } from '../../../../../../platform/opener/common/opener.
4040
const ATTACH_INSTRUCTIONS_ACTION_ID = 'workbench.action.chat.attach.instructions';
4141

4242
/**
43-
* Action ID for the `Manage Instruction` action.
43+
* Action ID for the `Configure Instruction` action.
4444
*/
45-
const MANAGE_INSTRUCTIONS_ACTION_ID = 'workbench.action.chat.manage.instructions';
45+
const CONFIGURE_INSTRUCTIONS_ACTION_ID = 'workbench.action.chat.configure.instructions';
4646

4747

4848
/**
@@ -156,8 +156,8 @@ class AttachInstructionsAction extends Action2 {
156156
class ManageInstructionsFilesAction extends Action2 {
157157
constructor() {
158158
super({
159-
id: MANAGE_INSTRUCTIONS_ACTION_ID,
160-
title: localize2('manage-instructions.capitalized.ellipses', "Manage Instructions Files..."),
159+
id: CONFIGURE_INSTRUCTIONS_ACTION_ID,
160+
title: localize2('configure-instructions', "Configure Instructions"),
161161
icon: Codicon.bookmark,
162162
f1: true,
163163
precondition: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled),
@@ -183,7 +183,7 @@ class ManageInstructionsFilesAction extends Action2 {
183183

184184
const placeholder = localize(
185185
'commands.prompt.manage-dialog.placeholder',
186-
'Select the instructions file to edit'
186+
'Select the instructions file to open'
187187
);
188188

189189
const result = await pickers.selectPromptFile({ placeholder, type: PromptsType.instructions, optionEdit: false });

src/vs/workbench/contrib/chat/browser/actions/promptActions/chatModeActions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ import { PromptsType } from '../../../../../../platform/prompts/common/prompts.j
1717
import { IOpenerService } from '../../../../../../platform/opener/common/opener.js';
1818

1919
/**
20-
* Action ID for the `Manage Custom Chat Mode` action.
20+
* Action ID for the `Configure Custom Chat Mode` action.
2121
*/
22-
const MANAGE_CUSTOM_MODE_ACTION_ID = 'workbench.action.chat.manage.mode';
22+
const COMFIGURE_MODES_ACTION_ID = 'workbench.action.chat.manage.mode';
2323

2424
class ManageModeAction extends Action2 {
2525
constructor() {
2626
super({
27-
id: MANAGE_CUSTOM_MODE_ACTION_ID,
28-
title: localize2('manage-mode.capitalized', "Manage Chat Modes..."),
29-
shortTitle: localize('manage-mode', "Manage Modes..."),
27+
id: COMFIGURE_MODES_ACTION_ID,
28+
title: localize2('configure-modes', "Configure Chat Modes"),
29+
shortTitle: localize('manage-mode', "Configure Modes"),
3030
icon: Codicon.bookmark,
3131
f1: true,
3232
precondition: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled),
@@ -50,7 +50,7 @@ class ManageModeAction extends Action2 {
5050

5151
const placeholder = localize(
5252
'commands.mode.select-dialog.placeholder',
53-
'Select the custom chat mode to edit'
53+
'Select the chat mode file to open'
5454
);
5555

5656
const result = await pickers.selectPromptFile({ placeholder, type: PromptsType.mode, optionEdit: false });

src/vs/workbench/contrib/chat/browser/actions/promptActions/chatRunPromptAction.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ const RUN_CURRENT_PROMPT_ACTION_ID = 'workbench.action.chat.run.prompt.current';
5757
const RUN_SELECTED_PROMPT_ACTION_ID = 'workbench.action.chat.run.prompt';
5858

5959
/**
60-
* Action ID for the `Manage Prompt Files...` action.
60+
* Action ID for the `Configure Prompt Files...` action.
6161
*/
62-
const MANAGE_SELECTED_PROMPT_ACTION_ID = 'workbench.action.chat.manage.prompts';
62+
const CONFIGURE_PROMPTS_ACTION_ID = 'workbench.action.chat.configure.prompts';
6363

6464
/**
6565
* Constructor options for the `Run Prompt` base action.
@@ -241,8 +241,8 @@ class RunSelectedPromptAction extends Action2 {
241241
class ManagePromptFilesAction extends Action2 {
242242
constructor() {
243243
super({
244-
id: MANAGE_SELECTED_PROMPT_ACTION_ID,
245-
title: localize2('manage-prompts.capitalized.ellipses', "Manage Prompt Files..."),
244+
id: CONFIGURE_PROMPTS_ACTION_ID,
245+
title: localize2('configure-prompts', "Configure Prompt Files"),
246246
icon: Codicon.bookmark,
247247
f1: true,
248248
precondition: ContextKeyExpr.and(PromptsConfig.enabledCtx, ChatContextKeys.enabled),

src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/promptFilePickers.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { askForPromptFileName } from '../../../../promptSyntax/contributions/cre
2424
import { IInstantiationService } from '../../../../../../../../platform/instantiation/common/instantiation.js';
2525
import { CancellationToken } from '../../../../../../../../base/common/cancellation.js';
2626
import { askForPromptSourceFolder } from '../../../../promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js';
27+
import { UILabelProvider } from '../../../../../../../../base/common/keybindingLabels.js';
28+
import { OS } from '../../../../../../../../base/common/platform.js';
2729

2830
/**
2931
* Options for the {@link askToSelectInstructions} function.
@@ -48,7 +50,7 @@ export interface ISelectOptions {
4850
readonly optionEdit?: boolean;
4951
readonly optionDelete?: boolean;
5052
readonly optionRename?: boolean;
51-
readonly optionMove?: boolean;
53+
readonly optionCopy?: boolean;
5254
}
5355

5456
export interface ISelectPromptResult {
@@ -153,14 +155,14 @@ const DELETE_BUTTON: IQuickInputButton = Object.freeze({
153155
*/
154156
const RENAME_BUTTON: IQuickInputButton = Object.freeze({
155157
tooltip: localize('rename', "Rename"),
156-
iconClass: ThemeIcon.asClassName(Codicon.pencil),
158+
iconClass: ThemeIcon.asClassName(Codicon.replace),
157159
});
158160

159161
/**
160162
* Button that copies a prompt file.
161163
*/
162164
const COPY_BUTTON: IQuickInputButton = Object.freeze({
163-
tooltip: localize('copy', "Copy"),
165+
tooltip: localize('copy', "Copy or Move (press {0})", UILabelProvider.modifierLabels[OS].ctrlKey),
164166
iconClass: ThemeIcon.asClassName(Codicon.copy),
165167
});
166168

@@ -186,7 +188,7 @@ export class PromptFilePickers {
186188
async selectPromptFile(options: ISelectOptions): Promise<ISelectPromptResult | undefined> {
187189
const quickPick = this._quickInputService.createQuickPick<IPromptPickerQuickPickItem>();
188190
quickPick.busy = true;
189-
quickPick.placeholder = localize('searching', 'Searching for files...');
191+
quickPick.placeholder = localize('searching', 'Searching file system...');
190192
try {
191193
const fileOptions = await this._createPromptPickItems(options);
192194
const activeItem = options.resource && fileOptions.find(f => extUri.isEqual(f.value, options.resource));
@@ -260,12 +262,12 @@ export class PromptFilePickers {
260262
if (options.optionEdit !== false) {
261263
buttons.push(EDIT_BUTTON);
262264
}
265+
if (options.optionCopy !== false) {
266+
buttons.push(COPY_BUTTON);
267+
}
263268
if (options.optionRename !== false) {
264269
buttons.push(RENAME_BUTTON);
265270
}
266-
if (options.optionMove !== false) {
267-
buttons.push(COPY_BUTTON);
268-
}
269271
if (options.optionDelete !== false) {
270272
buttons.push(DELETE_BUTTON);
271273
}
@@ -380,7 +382,8 @@ export class PromptFilePickers {
380382
// `copy` button was pressed, open the prompt file in editor
381383
if (button === COPY_BUTTON) {
382384
const currentFolder = dirname(value);
383-
const newFolder = await this._instaService.invokeFunction(askForPromptSourceFolder, options.type, currentFolder);
385+
const isMove = quickPick.keyMods.ctrlCmd;
386+
const newFolder = await this._instaService.invokeFunction(askForPromptSourceFolder, options.type, currentFolder, isMove);
384387
if (!newFolder) {
385388
return;
386389
}
@@ -389,7 +392,12 @@ export class PromptFilePickers {
389392
return;
390393
}
391394
const newFile = joinPath(newFolder.uri, newName);
392-
await this._fileService.copy(value, newFile);
395+
if (isMove) {
396+
await this._fileService.move(value, newFile);
397+
} else {
398+
await this._fileService.copy(value, newFile);
399+
}
400+
393401
await this._openerService.open(newFile);
394402

395403
return;

src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export async function askForPromptSourceFolder(
2727
accessor: ServicesAccessor,
2828
type: PromptsType,
2929
existingFolder?: URI | undefined,
30+
isMove: boolean = false,
3031
): Promise<IPromptPath | undefined> {
3132
const quickInputService = accessor.get(IQuickInputService);
3233
const promptsService = accessor.get(IPromptsService);
@@ -50,7 +51,7 @@ export async function askForPromptSourceFolder(
5051
}
5152

5253
const pickOptions: IPickOptions<IFolderQuickPickItem> = {
53-
placeHolder: existingFolder ? getPlaceholderStringforMove(type) : getPlaceholderStringforNew(type),
54+
placeHolder: existingFolder ? getPlaceholderStringforMove(type, isMove) : getPlaceholderStringforNew(type),
5455
canPickMany: false,
5556
matchOnDescription: true,
5657
};
@@ -128,14 +129,26 @@ function getPlaceholderStringforNew(type: PromptsType): string {
128129
}
129130
}
130131

131-
function getPlaceholderStringforMove(type: PromptsType): string {
132+
function getPlaceholderStringforMove(type: PromptsType, isMove: boolean): string {
133+
if (isMove) {
134+
switch (type) {
135+
case PromptsType.instructions:
136+
return localize('instructions.move.location.placeholder', "Select a location to move the instructions file to...");
137+
case PromptsType.prompt:
138+
return localize('prompt.move.location.placeholder', "Select a location to move the prompt file to...");
139+
case PromptsType.mode:
140+
return localize('mode.move.location.placeholder', "Select a location to move the mode file to...");
141+
default:
142+
throw new Error('Unknown prompt type');
143+
}
144+
}
132145
switch (type) {
133146
case PromptsType.instructions:
134-
return localize('workbench.command.instructions.move.location.placeholder', "Select a location to move the instructions file to...");
147+
return localize('instructions.copy.location.placeholder', "Select a location to copy the instructions file to...");
135148
case PromptsType.prompt:
136-
return localize('workbench.command.prompt.move.location.placeholder', "Select a location to move the prompt file to...");
149+
return localize('prompt.copy.location.placeholder', "Select a location to copy the prompt file to...");
137150
case PromptsType.mode:
138-
return localize('workbench.command.mode.move.location.placeholder', "Select a location to move the mode file to...");
151+
return localize('mode.copy.location.placeholder', "Select a location to copy the mode file to...");
139152
default:
140153
throw new Error('Unknown prompt type');
141154
}

0 commit comments

Comments
 (0)