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

Separate chat widget view 'context' from view 'options' #194670

Merged
merged 1 commit into from
Oct 2, 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: 3 additions & 3 deletions src/vs/workbench/contrib/chat/browser/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ export interface IChatFileTreeInfo {

export type ChatTreeItem = IChatRequestViewModel | IChatResponseViewModel | IChatWelcomeMessageViewModel;

export interface IBaseChatWidgetViewContext {
export interface IChatWidgetViewOptions {
renderInputOnTop?: boolean;
renderStyle?: 'default' | 'compact';
}

export interface IChatViewViewContext extends IBaseChatWidgetViewContext {
export interface IChatViewViewContext {
viewId: string;
}

export interface IChatResourceViewContext extends IBaseChatWidgetViewContext {
export interface IChatResourceViewContext {
resource: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/browser/chatEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class ChatEditor extends EditorPane {
scopedInstantiationService.createInstance(
ChatWidget,
{ resource: true },
{},
{
listForeground: editorForeground,
listBackground: editorBackground,
Expand Down Expand Up @@ -118,4 +119,3 @@ export class ChatEditor extends EditorPane {
}
}
}

3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/chat/browser/chatQuick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ class QuickChat extends Disposable {
this.widget = this._register(
scopedInstantiationService.createInstance(
ChatWidget,
{ resource: true, renderInputOnTop: true, renderStyle: 'compact' },
{ resource: true },
{ renderInputOnTop: true, renderStyle: 'compact' },
{
listForeground: quickInputForeground,
listBackground: quickInputBackground,
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/contrib/chat/browser/chatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class ChatViewPane extends ViewPane implements IChatViewPane {
this._widget = this._register(scopedInstantiationService.createInstance(
ChatWidget,
{ viewId: this.id },
{},
{
listForeground: SIDE_BAR_FOREGROUND,
listBackground: this.getBackgroundColor(),
Expand Down Expand Up @@ -168,5 +169,3 @@ export class ChatViewPane extends ViewPane implements IChatViewPane {
super.saveState();
}
}


7 changes: 4 additions & 3 deletions src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { IViewsService } from 'vs/workbench/common/views';
import { ChatTreeItem, IChatAccessibilityService, IChatCodeBlockInfo, IChatFileTreeInfo, IChatWidget, IChatWidgetService, IChatWidgetViewContext } from 'vs/workbench/contrib/chat/browser/chat';
import { ChatTreeItem, IChatWidgetViewOptions, IChatAccessibilityService, IChatCodeBlockInfo, IChatFileTreeInfo, IChatWidget, IChatWidgetService, IChatWidgetViewContext } from 'vs/workbench/contrib/chat/browser/chat';
import { ChatInputPart } from 'vs/workbench/contrib/chat/browser/chatInputPart';
import { ChatAccessibilityProvider, ChatListDelegate, ChatListItemRenderer, IChatListItemRendererOptions, IChatRendererDelegate } from 'vs/workbench/contrib/chat/browser/chatListRenderer';
import { ChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatOptions';
Expand Down Expand Up @@ -121,6 +121,7 @@ export class ChatWidget extends Disposable implements IChatWidget {

constructor(
readonly viewContext: IChatWidgetViewContext,
private readonly viewOptions: IChatWidgetViewOptions,
private readonly styles: IChatWidgetStyles,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
Expand Down Expand Up @@ -158,8 +159,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
render(parent: HTMLElement): void {
const viewId = 'viewId' in this.viewContext ? this.viewContext.viewId : undefined;
this.editorOptions = this._register(this.instantiationService.createInstance(ChatEditorOptions, viewId, this.styles.listForeground, this.styles.inputEditorBackground, this.styles.resultEditorBackground));
const renderInputOnTop = this.viewContext.renderInputOnTop ?? false;
const renderStyle = this.viewContext.renderStyle;
const renderInputOnTop = this.viewOptions.renderInputOnTop ?? false;
const renderStyle = this.viewOptions.renderStyle;

this.container = dom.append(parent, $('.interactive-session'));
if (renderInputOnTop) {
Expand Down