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: rerender chat pane when provider is added #195845

Merged
merged 1 commit into from
Oct 17, 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
3 changes: 3 additions & 0 deletions src/vs/workbench/contrib/chat/browser/chatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export class ChatViewPane extends ViewPane implements IChatViewPane {
// View state for the ViewPane is currently global per-provider basically, but some other strictly per-model state will require a separate memento.
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(); }
}));
}

private updateModel(model?: IChatModel | undefined): void {
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/chat/common/chatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export interface IChatService {
transferredSessionData: IChatTransferredSessionData | undefined;

onDidSubmitSlashCommand: Event<{ slashCommand: string; sessionId: string }>;
onDidRegisterProvider: Event<{ providerId: string }>;
registerProvider(provider: IChatProvider): IDisposable;
hasProviders(): boolean;
getProviderInfos(): IChatProviderInfo[];
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/contrib/chat/common/chatServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ export class ChatService extends Disposable implements IChatService {
private readonly _onDidDisposeSession = this._register(new Emitter<{ sessionId: string }>());
public readonly onDidDisposeSession = this._onDidDisposeSession.event;

private readonly _onDidRegisterProvider = this._register(new Emitter<{ providerId: string }>());
public readonly onDidRegisterProvider = this._onDidRegisterProvider.event;

constructor(
@IStorageService private readonly storageService: IStorageService,
@ILogService private readonly logService: ILogService,
Expand Down Expand Up @@ -743,6 +746,7 @@ export class ChatService extends Disposable implements IChatService {

this._providers.set(provider.id, provider);
this._hasProvider.set(true);
this._onDidRegisterProvider.fire({ providerId: provider.id });

Array.from(this._sessionModels.values())
.filter(model => model.providerId === provider.id)
Expand Down