600
601
private async acquireOrRestoreLocalSession(sessionResource: URI, debugOwner?: string): Promise<IChatModelReference | undefined> {
603
>
const existingRef = this.acquireExistingSession(sessionResource, debugOwner);
604
>
if (existingRef) {
605
return existingRef;
606
}
608
>
let sessionData: ISerializedChatDataReference | undefined;
609
>
if (isEqual(this.transferredSessionResource, sessionResource)) {
610
this._transferredSessionResource = undefined;
611
sessionData = await this._chatSessionStore.readTransferredSession(sessionResource);
613
>
const localSessionId = LocalChatSessionUri.parseLocalSessionId(sessionResource);
614
>
if (localSessionId) {
615
>
sessionData = await this._chatSessionStore.readSession(localSessionId);
616
>
}
617
>
}
618
>
619
>
if (!sessionData) {
620
return undefined;
621
}
623
>
const sessionRef = this._sessionModels.acquireOrCreate({
624
>
initialData: sessionData,
625
>
location: sessionData.value.initialLocation ?? ChatAgentLocation.Chat,
626
>
sessionResource,
627
>
canUseTools: true,
628
>
}, debugOwner ?? 'ChatService#acquireOrRestoreLocalSession');
629
>
630
>
return sessionRef;
631
>
}
632
633
// There are some cases where this returns a real string. What happens if it doesn't?