304
305
private _generateTitleSoon(
307
>
promptContent: string,
308
>
isConversation: boolean,
309
>
fallbackTitle: string,
310
>
apply: (title: string) => void,
311
>
currentTitleMatchesFallback: () => boolean,
312
>
persist: (title: string) => void,
313
>
): void {
314
>
this._cancelTitleGeneration(key);
315
>
const source = new CancellationTokenSource();
316
>
this._titleGenerationCancellationSources.set(key, source);
317
>
void this._generateTitle(key, promptContent, isConversation, fallbackTitle, apply, currentTitleMatchesFallback, persist, source.token).catch(err => {
318
if (!source.token.isCancellationRequested) {
319
this._logService.warn(`[AgentHostSessionTitleController] Failed to apply generated title for ${key}`, err);
320
}
322
>
if (this._titleGenerationCancellationSources.get(key) === source) {
323
this._titleGenerationCancellationSources.delete(key);
324
source.dispose();
325
}
327
>
}
328
329
private async _generateTitle(
331
>
promptContent: string,
332
>
isConversation: boolean,
333
>
fallbackTitle: string,
334
>
apply: (title: string) => void,
335
>
currentTitleMatchesFallback: () => boolean,
336
>
persist: (title: string) => void,
337
>
token: CancellationToken,
338
>
): Promise<void> {
339
>
const generatedTitle = await this._generateTitleFromPrompt(promptContent, isConversation, token);
340
>
if (token.isCancellationRequested || !generatedTitle) {
341
return;
342
}