diff --git a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts index a9c2548832685..eb115500062d0 100644 --- a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts @@ -116,12 +116,14 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge return localize('chatInput', "Chat Input"); } - setState(providerId: string, inputValue: string): void { + setState(providerId: string, inputValue: string | undefined): void { this.providerId = providerId; const history = this.historyService.getHistory(providerId); this.history = new HistoryNavigator(history, 50); - this.setValue(inputValue); + if (typeof inputValue === 'string') { + this.setValue(inputValue); + } } get element(): HTMLElement { diff --git a/src/vs/workbench/contrib/chat/browser/chatViewPane.ts b/src/vs/workbench/contrib/chat/browser/chatViewPane.ts index f9376fd13c5ec..8ea8b39634d09 100644 --- a/src/vs/workbench/contrib/chat/browser/chatViewPane.ts +++ b/src/vs/workbench/contrib/chat/browser/chatViewPane.ts @@ -86,7 +86,7 @@ export class ChatViewPane extends ViewPane implements IChatViewPane { })); } - private updateModel(model?: IChatModel | undefined): void { + private updateModel(model?: IChatModel | undefined, viewState?: IViewPaneState): void { this.modelDisposables.clear(); model = model ?? (this.chatService.transferredSessionData?.sessionId @@ -96,7 +96,7 @@ export class ChatViewPane extends ViewPane implements IChatViewPane { throw new Error('Could not start chat session'); } - this._widget.setModel(model, { ...this.viewState }); + this._widget.setModel(model, { ...(viewState ?? this.viewState) }); this.viewState.sessionId = model.sessionId; } @@ -165,8 +165,7 @@ export class ChatViewPane extends ViewPane implements IChatViewPane { if (this.widget.viewModel) { this.chatService.clearSession(this.widget.viewModel.sessionId); } - this.viewState.inputValue = ''; - this.updateModel(); + this.updateModel(undefined, { ...this.viewState, inputValue: undefined }); } loadSession(sessionId: string): void { diff --git a/src/vs/workbench/contrib/chat/browser/chatWidget.ts b/src/vs/workbench/contrib/chat/browser/chatWidget.ts index 1883e024483dd..89e4e1bd9407d 100644 --- a/src/vs/workbench/contrib/chat/browser/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatWidget.ts @@ -439,7 +439,7 @@ export class ChatWidget extends Disposable implements IChatWidget { this.viewModel = undefined; this.onDidChangeItems(); })); - this.inputPart.setState(model.providerId, viewState.inputValue ?? ''); + this.inputPart.setState(model.providerId, viewState.inputValue); if (this.tree) { this.onDidChangeItems();