Skip to content

Commit

Permalink
Fix error when closing inline chat widgets (#234950)
Browse files Browse the repository at this point in the history
Set lastItem before rendering list, chat which may try to reference lastItem
Fix #234596
  • Loading branch information
roblourens authored Dec 2, 2024
1 parent 2ed1e9b commit 5fe8e27
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ export class ChatWidget extends Disposable implements IChatWidget {

this._onWillMaybeChangeHeight.fire();

this.lastItem = treeItems.at(-1)?.element;
ChatContextKeys.lastItemId.bindTo(this.contextKeyService).set(this.lastItem ? [this.lastItem.id] : []);
this.tree.setChildren(null, treeItems, {
diffIdentityProvider: {
getId: (element) => {
Expand All @@ -543,10 +545,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
this.layoutDynamicChatTreeItemMode();
}

this.lastItem = treeItems[treeItems.length - 1]?.element;
if (this.lastItem) {
ChatContextKeys.lastItemId.bindTo(this.contextKeyService).set([this.lastItem.id]);
}
if (this.lastItem && isResponseVM(this.lastItem) && this.lastItem.isComplete) {
this.renderFollowups(this.lastItem.replyFollowups, this.lastItem);
} else if (!treeItems.length && this.viewModel) {
Expand Down

0 comments on commit 5fe8e27

Please sign in to comment.