Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear partial query quick chats when closed #196598

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/vs/workbench/contrib/chat/browser/chatQuick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as dom from 'vs/base/browser/dom';
import { Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
import { disposableTimeout } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Emitter } from 'vs/base/common/event';
import { Emitter, Event } from 'vs/base/common/event';
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { Selection } from 'vs/editor/common/core/selection';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
Expand Down Expand Up @@ -61,6 +61,14 @@ export class QuickChatService extends Disposable implements IQuickChatService {
this.close();
} else {
this.open(providerId, options);
// If this is a partial query, the value should be cleared when closed as otherwise it
// would remain for the next time the quick chat is opened in any context.
if (options?.isPartialQuery) {
const disposable = this._store.add(Event.once(this.onDidClose)(() => {
this._currentChat?.clearValue();
this._store.delete(disposable);
}));
}
}
}

Expand Down Expand Up @@ -300,6 +308,10 @@ class QuickChat extends Disposable {
this.focus(selection);
}

clearValue(): void {
this.widget.inputEditor.setValue('');
}

private updateModel(): void {
this.model ??= this.chatService.startSession(this._options.providerId, CancellationToken.None);
if (!this.model) {
Expand Down
Loading