Skip to content

Commit

Permalink
Don't clear chat input on "new session" (#198447)
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens authored Nov 16, 2023
1 parent 7d4091a commit 1c39707
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions src/vs/workbench/contrib/chat/browser/chatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1c39707

Please sign in to comment.