mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Debounce chatWidget view model changes (#208120)
Currently we can end up updating the chat list multiple times per frame With this change, we try to batch some of these updates to avoid this
This commit is contained in:
parent
57b0c146d0
commit
83eb3af362
|
@ -7,7 +7,7 @@ import * as dom from 'vs/base/browser/dom';
|
|||
import { ITreeContextMenuEvent, ITreeElement } from 'vs/base/browser/ui/tree/tree';
|
||||
import { disposableTimeout, timeout } from 'vs/base/common/async';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable, DisposableStore, IDisposable, MutableDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
|
@ -589,10 +589,15 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||
|
||||
this.container.setAttribute('data-session-id', model.sessionId);
|
||||
this.viewModel = this.instantiationService.createInstance(ChatViewModel, model, this._codeBlockModelCollection);
|
||||
this.viewModelDisposables.add(this.viewModel.onDidChange(e => {
|
||||
this.requestInProgress.set(this.viewModel!.requestInProgress);
|
||||
this.viewModelDisposables.add(Event.accumulate(this.viewModel.onDidChange, 0)(events => {
|
||||
if (!this.viewModel) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.requestInProgress.set(this.viewModel.requestInProgress);
|
||||
|
||||
this.onDidChangeItems();
|
||||
if (e?.kind === 'addRequest') {
|
||||
if (events.some(e => e?.kind === 'addRequest')) {
|
||||
revealLastElement(this.tree);
|
||||
this.focusInput();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue