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

Handle updating the chat view with persisted session after logging in #198147

Merged
merged 1 commit into from
Nov 13, 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
10 changes: 4 additions & 6 deletions src/vs/workbench/contrib/chat/browser/chatListRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
return template;
}

renderElement(node: ITreeNode<ChatTreeItem, FuzzyScore>, index: number, templateData: IChatListItemTemplate, height?: number): void {
renderElement(node: ITreeNode<ChatTreeItem, FuzzyScore>, index: number, templateData: IChatListItemTemplate): void {
const { element } = node;
const kind = isRequestVM(element) ? 'request' :
isResponseVM(element) ? 'response' :
Expand Down Expand Up @@ -320,7 +320,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
convertParsedRequestToMarkdown(element.message);
this.basicRenderElement([new MarkdownString(markdown)], element, index, templateData);
} else {
this.renderWelcomeMessage(element, templateData, height);
this.renderWelcomeMessage(element, templateData);
}
}

Expand Down Expand Up @@ -460,7 +460,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
}
}

private renderWelcomeMessage(element: IChatWelcomeMessageViewModel, templateData: IChatListItemTemplate, height?: number) {
private renderWelcomeMessage(element: IChatWelcomeMessageViewModel, templateData: IChatListItemTemplate) {
dom.clearNode(templateData.value);
dom.clearNode(templateData.referencesListContainer);

Expand All @@ -479,9 +479,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
}
}

// When going from welcome content to actual chat list items, rowContainer.offsetHeight is initially 0,
// but the height that we get from `renderElement` is accurate, so use that
const newHeight = templateData.rowContainer.offsetHeight === 0 && height ? height : templateData.rowContainer.offsetHeight;
const newHeight = templateData.rowContainer.offsetHeight;
const fireEvent = !element.currentRenderedHeight || element.currentRenderedHeight !== newHeight;
element.currentRenderedHeight = newHeight;
if (fireEvent) {
Expand Down
12 changes: 11 additions & 1 deletion src/vs/workbench/contrib/chat/browser/chatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,17 @@ export class ChatViewPane extends ViewPane implements IChatViewPane {
if (providerId === this.chatViewOptions.providerId && !this._widget?.viewModel) {
const sessionId = this.getSessionId();
const model = sessionId ? this.chatService.getOrRestoreSession(sessionId) : undefined;
this.updateModel(model);

// The widget may be hidden at this point, because welcome views were allowed. Use setVisible to
// avoid doing a render while the widget is hidden. This is changing the condition in `shouldShowWelcome`
// so it should fire onDidChangeViewWelcomeState.
try {
this._widget.setVisible(false);
this.updateModel(model);
this._onDidChangeViewWelcomeState.fire();
} finally {
this.widget.setVisible(true);
}
}
}));
}
Expand Down