@@ -28,6 +28,7 @@ import { IInstantiationService } from '../../../../../../platform/instantiation/
28
28
import { IUserDataProfileService } from '../../../../../services/userDataProfile/common/userDataProfile.js' ;
29
29
import type { IChatPromptSlashCommand , ICustomChatMode , IMetadata , IPromptPath , IPromptsService , TPromptsStorage } from './types.js' ;
30
30
import { Emitter , Event } from '../../../../../../base/common/event.js' ;
31
+ import { CancellationToken } from '../../../../../../base/common/cancellation.js' ;
31
32
32
33
/**
33
34
* Provides prompt services.
@@ -111,13 +112,11 @@ export class PromptsService extends Disposable implements IPromptsService {
111
112
return this . cache . get ( model ) ;
112
113
}
113
114
114
- public async listPromptFiles ( type : PromptsType ) : Promise < readonly IPromptPath [ ] > {
115
- const userLocations = [ this . userDataService . currentProfile . promptsHome ] ;
116
-
115
+ public async listPromptFiles ( type : PromptsType , token : CancellationToken ) : Promise < readonly IPromptPath [ ] > {
117
116
const prompts = await Promise . all ( [
118
- this . fileLocator . listFilesIn ( userLocations , type )
117
+ this . fileLocator . listFiles ( type , 'user' , token )
119
118
. then ( withType ( 'user' , type ) ) ,
120
- this . fileLocator . listFiles ( type )
119
+ this . fileLocator . listFiles ( type , 'local' , token )
121
120
. then ( withType ( 'local' , type ) ) ,
122
121
] ) ;
123
122
@@ -160,7 +159,7 @@ export class PromptsService extends Disposable implements IPromptsService {
160
159
return data . promptPath . uri ;
161
160
}
162
161
163
- const files = await this . listPromptFiles ( PromptsType . prompt ) ;
162
+ const files = await this . listPromptFiles ( PromptsType . prompt , CancellationToken . None ) ;
164
163
const command = data . command ;
165
164
const result = files . find ( file => getPromptCommandName ( file . uri . path ) === command ) ;
166
165
if ( result ) {
@@ -174,7 +173,7 @@ export class PromptsService extends Disposable implements IPromptsService {
174
173
}
175
174
176
175
public async findPromptSlashCommands ( ) : Promise < IChatPromptSlashCommand [ ] > {
177
- const promptFiles = await this . listPromptFiles ( PromptsType . prompt ) ;
176
+ const promptFiles = await this . listPromptFiles ( PromptsType . prompt , CancellationToken . None ) ;
178
177
return promptFiles . map ( promptPath => {
179
178
const command = getPromptCommandName ( promptPath . uri . path ) ;
180
179
return {
@@ -190,7 +189,7 @@ export class PromptsService extends Disposable implements IPromptsService {
190
189
public readonly onDidChangeCustomChatModes : Event < void > = this . _onDidChangeCustomChatModesEmitter . event ;
191
190
192
191
public async getCustomChatModes ( ) : Promise < readonly ICustomChatMode [ ] > {
193
- const modeFiles = await this . listPromptFiles ( PromptsType . mode ) ;
192
+ const modeFiles = await this . listPromptFiles ( PromptsType . mode , CancellationToken . None ) ;
194
193
const metaDatas = await this . getAllMetadata ( modeFiles . map ( promptPath => promptPath . uri ) ) ;
195
194
return metaDatas . map ( metadata => {
196
195
return {
@@ -206,7 +205,7 @@ export class PromptsService extends Disposable implements IPromptsService {
206
205
public async findInstructionFilesFor (
207
206
files : readonly URI [ ] ,
208
207
) : Promise < readonly URI [ ] > {
209
- const instructionFiles = await this . listPromptFiles ( PromptsType . instructions ) ;
208
+ const instructionFiles = await this . listPromptFiles ( PromptsType . instructions , CancellationToken . None ) ;
210
209
if ( instructionFiles . length === 0 ) {
211
210
return [ ] ;
212
211
}
0 commit comments