2628
this._onDidChange.fire({ kind: 'completedRequest', request });
2629
}));
2631
>
2632
>
this.requestInProgress = this.lastRequestObs.map((request, r) => {
2633
>
return request?.response?.isInProgress.read(r) ?? false;
2634
>
});
2635
>
2636
>
this.hasActiveRequest = this.lastRequestObs.map((request, r) => {
2637
return request?.response?.isIncomplete.read(r) ?? false;
2639
>
2640
>
this.requestNeedsInput = this.lastRequestObs.map((request, r) => {
2641
>
const pendingInfo = request?.response?.isPendingConfirmation.read(r);
2642
>
if (!pendingInfo) {
2643
>
return undefined;
2644
>
}
2645
return {
2646
title: this.title,
2647
detail: pendingInfo.detail,
2648
};
2650
>
2651
>
// Retain a reference to itself when a request is in progress, so the ChatModel stays alive in the background
2652
>
// only while running a request. TODO also keep it alive for 5min or so so we don't have to dispose/restore too often?
2653
>
if (this.initialLocation === ChatAgentLocation.Chat && !initialModelProps.disableBackgroundKeepAlive) {
2654
>
const selfRef = this._register(new MutableDisposable<IChatModelReference>());
2655
>
this._register(autorun(r => {
2656
>
const inProgress = this.requestInProgress.read(r);
2657
>
const needsInput = this.requestNeedsInput.read(r);
2658
>
const shouldStayAlive = inProgress || !!needsInput;
2659
>
if (shouldStayAlive && !selfRef.value) {
2660
selfRef.value = chatService.acquireExistingSession(this._sessionResource, 'ChatModel#requestInProgressKeepAlive');
2661
>
} else if (!shouldStayAlive && selfRef.value) {
chatModel.ts
2662
selfRef.clear();
2663
}
2665
>
}
2666
>
}
2667
2668
startEditingSession(isGlobalEditingSession?: boolean, transferFromSession?: IChatEditingSession): void {