1253
return { model: realModel, sessionResource: realResource, newSessionResource: realResource };
1254
}
1256
>
// Track the materialization in-flight (keyed by the original untitled
1257
>
// resource) so a concurrent second send joins this one rather than creating
1258
>
// a duplicate real session. Store synchronously, before any await, so a
1259
>
// concurrent send reliably observes the in-flight materialization.
1260
>
const materialized = new DeferredPromise<URI | undefined>();
1261
>
this._inFlightUntitledMaterializations.set(untitledResource, materialized.p);
1262
>
try {
1263
>
const parsedRequest = this.parseChatRequest(untitledResource, request, options?.location ?? untitledModel.initialLocation, options);
1264
>
const commandPart = parsedRequest.parts.find((r): r is ChatRequestSlashCommandPart => r instanceof ChatRequestSlashCommandPart);
1265
>
const requestText = getPromptText(parsedRequest).message;
1266
>
1267
>
// Snapshot the untitled session's options up front: they seed
1268
>
// `createNewChatSessionItem` below and are pushed onto the real session
1269
>
// once it loads. Capturing before those steps avoids reading them back
1270
>
// after the untitled entry may have changed during materialization.
1271
>
const initialSessionOptions = this.chatSessionService.getSessionOptions(untitledResource);
1272
>
1273
>
const newItem = await this.chatSessionService.createNewChatSessionItem(getChatSessionType(untitledResource), { prompt: requestText, command: commandPart?.text, initialSessionOptions, untitledResource }, CancellationToken.None);
1274
if (!newItem) {
1275
materialized.complete(undefined);