@@ -11,6 +11,7 @@ import { IChatAttachPromptActionOptions } from '../chatAttachPromptAction.js';
11
11
import { IPromptPath } from '../../../../common/promptSyntax/service/types.js' ;
12
12
import { DisposableStore } from '../../../../../../../base/common/lifecycle.js' ;
13
13
import { dirname , extUri } from '../../../../../../../base/common/resources.js' ;
14
+ import { DOCUMENTATION_URL } from '../../../../common/promptSyntax/constants.js' ;
14
15
import { isLinux , isWindows } from '../../../../../../../base/common/platform.js' ;
15
16
import { ILabelService } from '../../../../../../../platform/label/common/label.js' ;
16
17
import { IOpenerService } from '../../../../../../../platform/opener/common/opener.js' ;
@@ -50,6 +51,20 @@ export interface ISelectPromptOptions {
50
51
readonly quickInputService : IQuickInputService ;
51
52
}
52
53
54
+ /**
55
+ * A special quick pick item that links to the documentation.
56
+ */
57
+ const DOCS_OPTION : WithUriValue < IQuickPickItem > = {
58
+ type : 'item' ,
59
+ label : localize (
60
+ 'commands.prompts.use.select-dialog.docs-label' ,
61
+ 'Learn how to create reusable prompts' ,
62
+ ) ,
63
+ description : DOCUMENTATION_URL ,
64
+ tooltip : DOCUMENTATION_URL ,
65
+ value : URI . parse ( DOCUMENTATION_URL ) ,
66
+ } ;
67
+
53
68
/**
54
69
* Shows the prompt selection dialog to the user that allows to select a prompt file(s).
55
70
*
@@ -61,16 +76,15 @@ export const askToSelectPrompt = async (
61
76
) : Promise < void > => {
62
77
const { promptFiles, resource, quickInputService, labelService } = options ;
63
78
64
- // a sanity check - this function must be used only if there are prompt files to show
65
- assert (
66
- promptFiles . length > 0 ,
67
- 'Prompt files list must not be empty.' ,
68
- ) ;
69
-
70
79
const fileOptions = promptFiles . map ( ( { uri } ) => {
71
80
return createPickItem ( uri , labelService ) ;
72
81
} ) ;
73
82
83
+ /**
84
+ * Add a link to the documentation to the end of prompts list.
85
+ */
86
+ fileOptions . push ( DOCS_OPTION ) ;
87
+
74
88
// if a resource is provided, create an `activeItem` for it to pre-select
75
89
// it in the UI, and sort the list so the active item appears at the top
76
90
let activeItem : WithUriValue < IQuickPickItem > | undefined ;
@@ -101,6 +115,13 @@ export const askToSelectPrompt = async (
101
115
} ) ;
102
116
}
103
117
118
+ /**
119
+ * If still no active item present, fall back to the first item in the list.
120
+ */
121
+ if ( ! activeItem ) {
122
+ activeItem = fileOptions [ 0 ] ;
123
+ }
124
+
104
125
// otherwise show the prompt file selection dialog
105
126
const { openerService } = options ;
106
127
@@ -129,8 +150,17 @@ export const askToSelectPrompt = async (
129
150
const { selectedItems } = quickPick ;
130
151
const { alt, ctrlCmd } = quickPick . keyMods ;
131
152
153
+ // sanity check to confirm our expectations
154
+ assert (
155
+ selectedItems . length === 1 ,
156
+ `Only one item can be accepted, got '${ selectedItems . length } '.` ,
157
+ ) ;
158
+
159
+ // whether user selected the docs link option
160
+ const docsSelected = ( selectedItems [ 0 ] === DOCS_OPTION ) ;
161
+
132
162
// if `super` key was pressed, open the selected prompt file(s)
133
- if ( ctrlCmd ) {
163
+ if ( ctrlCmd || docsSelected ) {
134
164
return await openFiles ( selectedItems , openerService ) ;
135
165
}
136
166
0 commit comments