Johannes
2024-01-19 15:14:39 +01:00
parent 53661a1495
commit 53e467c211
@@ -106,6 +106,7 @@ export class InlineChatController implements IEditorContribution {
private _historyCandidate: string = '';
private _historyUpdate: (prompt: string) => void;
private _isDisposed: boolean = false;
private readonly _store = new DisposableStore();
private readonly _zone: Lazy<InlineChatZoneWidget>;
private readonly _ctxHasActiveRequest: IContextKey<boolean>;
@@ -189,12 +190,15 @@ export class InlineChatController implements IEditorContribution {
};
}
dispose(): void {
if (this._session) {
this._inlineChatSessionService.releaseSession(this._session);
async dispose(): Promise<void> {
if (this._currentRun) {
this._messages.fire((this._session?.lastExchange
? Message.PAUSE_SESSION
: Message.CANCEL_SESSION)
);
}
this._strategy?.dispose();
this._store.dispose();
this._isDisposed = true;
this._log('DISPOSED controller');
}
@@ -262,7 +266,7 @@ export class InlineChatController implements IEditorContribution {
protected async _nextState(state: State, options: InlineChatRunOptions): Promise<void> {
let nextState: State | void = state;
while (nextState) {
while (nextState && !this._isDisposed) {
this._log('setState to ', nextState);
nextState = await this[nextState](options);
}
@@ -457,20 +461,20 @@ export class InlineChatController implements IEditorContribution {
store.dispose();
}
this._zone.value.widget.selectAll(false);
if (message & (Message.CANCEL_INPUT | Message.CANCEL_SESSION)) {
return State.CANCEL;
}
if (message & Message.ACCEPT_SESSION) {
return State.ACCEPT;
}
if (message & Message.PAUSE_SESSION) {
return State.PAUSE;
}
if (message & Message.ACCEPT_SESSION) {
this._zone.value.widget.selectAll(false);
return State.ACCEPT;
}
if (message & Message.RERUN_INPUT && this._session.lastExchange) {
const { lastExchange } = this._session;
if (options.withIntentDetection === undefined) { // @ulugbekna: if we're re-running with intent detection turned off, no need to update `attempt` #