Skip to content

Commit f959c07

Browse files
committed
hide full filepath for all "user" prompts
1 parent 90ba895 commit f959c07

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,14 @@ export const askToSelectPrompt = async (
7676
): Promise<void> => {
7777
const { promptFiles, resource, quickInputService, labelService } = options;
7878

79-
const fileOptions = promptFiles.map(({ uri }) => {
80-
return createPickItem(uri, labelService);
79+
// a sanity check - this function must be used only if there are prompt files to show
80+
assert(
81+
promptFiles.length > 0,
82+
'Prompt files list must not be empty.',
83+
);
84+
85+
const fileOptions = promptFiles.map((promptFile) => {
86+
return createPickItem(promptFile, labelService);
8187
});
8288

8389
/**
@@ -98,7 +104,12 @@ export const askToSelectPrompt = async (
98104
// the currently active prompt file is always available in the selection dialog,
99105
// even if it is not included in the prompts list otherwise(from location setting)
100106
if (!activeItem) {
101-
activeItem = createPickItem(resource, labelService);
107+
activeItem = createPickItem({
108+
uri: resource,
109+
// "user" prompts are always registered in the prompts list, hence it
110+
// should be safe to assume that `resource` is not "user" prompt here
111+
type: 'local',
112+
}, labelService);
102113
fileOptions.push(activeItem);
103114
}
104115

@@ -191,16 +202,30 @@ export const askToSelectPrompt = async (
191202
* Creates a quick pick item for a prompt.
192203
*/
193204
const createPickItem = (
194-
uri: URI,
205+
promptFile: IPromptPath,
195206
labelService: ILabelService,
196207
): WithUriValue<IQuickPickItem> => {
208+
const { uri, type } = promptFile;
197209
const fileWithoutExtension = getCleanPromptName(uri);
198210

211+
// if a "user" prompt, don't show its filesystem path in
212+
// the user interface, but do that for all the "local" ones
213+
const description = (type === 'user')
214+
? localize(
215+
'user-prompt.capitalized',
216+
'User prompt',
217+
)
218+
: labelService.getUriLabel(dirname(uri), { relative: true });
219+
220+
const tooltip = (type === 'user')
221+
? description
222+
: uri.fsPath;
223+
199224
return {
200225
type: 'item',
201226
label: fileWithoutExtension,
202-
description: labelService.getUriLabel(dirname(uri), { relative: true }),
203-
tooltip: uri.fsPath,
227+
description,
228+
tooltip,
204229
value: uri,
205230
id: uri.toString(),
206231
};

0 commit comments

Comments
 (0)