1353
1354
private refreshFollowupsCancellationToken(sessionResource: URI): CancellationToken {
1355
>
this._sessionFollowupCancelTokens.get(sessionResource)?.cancel();
chatServiceImpl.ts
1356
>
const newTokenSource = new CancellationTokenSource();
1357
>
this._sessionFollowupCancelTokens.set(sessionResource, newTokenSource);
1358
>
1359
>
return newTokenSource.token;
1360
>
}
1361
1362
private _sendRequestAsync(model: ChatModel, sessionResource: URI, parsedRequest: IParsedChatRequest, attempt: number, enableCommandDetection: boolean, defaultAgent: IChatAgentData, location: ChatAgentLocation, options?: IChatSendRequestOptions): IChatSendRequestResponseState {
1363
>
const followupsCancelToken = this.refreshFollowupsCancellationToken(sessionResource);
chatServiceImpl.ts
1364
>
let request: ChatRequestModel | undefined;
1365
>
const agentPart = parsedRequest.parts.find((r): r is ChatRequestAgentPart => r instanceof ChatRequestAgentPart);
1366
>
const agentSlashCommandPart = parsedRequest.parts.find((r): r is ChatRequestAgentSubcommandPart => r instanceof ChatRequestAgentSubcommandPart);
1367
>
const commandPart = parsedRequest.parts.find((r): r is ChatRequestSlashCommandPart => r instanceof ChatRequestSlashCommandPart);
1368
>
const requests = [...model.getRequests()];
1369
>
const isTerminalCommand = isTerminalCommandPrompt(parsedRequest.text, this.chatSessionService.getCapabilitiesForSessionType(getChatSessionType(sessionResource))?.terminalCommandPrefix);
1370
>
const requestTelemetry = this.instantiationService.createInstance(ChatRequestTelemetry, {
1371
>
agent: agentPart?.agent ?? defaultAgent,
1372
>
agentSlashCommandPart,
1373
>
commandPart,
1374
>
sessionResource: model.sessionResource,
1375
>
location: model.initialLocation,
1376
>
options,
1377
>
enableCommandDetection
1378
>
});
1379
>
1380
>
let gotProgress = false;
1381
>
const requestType = commandPart ? 'slashCommand' : 'string';
1382
>
1383
>
const responseCreated = new DeferredPromise<IChatResponseModel>();
1384
>
let responseCreatedComplete = false;
1385
>
function completeResponseCreated(): void {
1386
>
if (!responseCreatedComplete && request?.response) {
1387
>
responseCreated.complete(request.response);
1388
>
responseCreatedComplete = true;
1389
>
}
1390
>
}
1391
>
1392
>
const store = new DisposableStore();
1393
>
const source = store.add(new CancellationTokenSource());
1394
>
const token = source.token;
1395
>
const sendRequestInternal = async () => {
1396
>
const progressCallback = (progress: IChatProgress[]) => {
1397
if (token.isCancellationRequested) {
1398
return;