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

Don't clear chat input on "new session" #198447

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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