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

fix: don't show welcome view between reloads #195928

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: don't show welcome view between reloads
  • Loading branch information
joyceerhl committed Oct 18, 2023
commit 99e3cc32af46c111946a7bf92612315a4ff426da
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/chat/browser/chatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export class ChatViewPane extends ViewPane implements IChatViewPane {
this.memento = new Memento('interactive-session-view-' + this.chatViewOptions.providerId, this.storageService);
this.viewState = this.memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE) as IViewPaneState;
this._register(this.chatService.onDidRegisterProvider(({ providerId }) => {
if (providerId === this.chatViewOptions.providerId) { this.updateModel(); }
if (providerId === this.chatViewOptions.providerId && !this._widget?.viewModel) {
this.updateModel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this still not use the persisted session? I think you need to do all of this

let sessionId: string | undefined;
if (this.chatService.transferredSessionData) {
sessionId = this.chatService.transferredSessionData.sessionId;
this.viewState.inputValue = this.chatService.transferredSessionData.inputValue;
} else {
sessionId = this.viewState.sessionId;
}
const initialModel = sessionId ? this.chatService.getOrRestoreSession(sessionId) : undefined;
this.updateModel(initialModel);

}
}));
}

Expand All @@ -86,7 +88,7 @@ export class ChatViewPane extends ViewPane implements IChatViewPane {
}

override shouldShowWelcome(): boolean {
return !this.chatService.hasProviders();
return !this.chatService.hasSessions(this.chatViewOptions.providerId) && !this._widget?.viewModel;
}

protected override renderBody(parent: HTMLElement): void {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/common/chatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export interface IChatService {
onDidSubmitSlashCommand: Event<{ slashCommand: string; sessionId: string }>;
onDidRegisterProvider: Event<{ providerId: string }>;
registerProvider(provider: IChatProvider): IDisposable;
hasProviders(): boolean;
hasSessions(providerId: string): boolean;
getProviderInfos(): IChatProviderInfo[];
startSession(providerId: string, token: CancellationToken): ChatModel | undefined;
getSession(sessionId: string): IChatModel | undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/chat/common/chatServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,8 @@ export class ChatService extends Disposable implements IChatService {
});
}

hasProviders(): boolean {
return this._providers.size > 0;
public hasSessions(providerId: string): boolean {
return !!Object.values(this._persistedSessions).find((session) => session.providerId === providerId);
}

getProviderInfos(): IChatProviderInfo[] {
Expand Down
Loading