Skip to content

Commit

Permalink
Reuse chat widget and support status actions (#198479)
Browse files Browse the repository at this point in the history
* Reuse chat widget and support status

* Update cell chat actions
  • Loading branch information
rebornix authored Nov 17, 2023
1 parent 6805bb6 commit ed684fc
Show file tree
Hide file tree
Showing 6 changed files with 643 additions and 404 deletions.
19 changes: 15 additions & 4 deletions src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ export interface InlineChatWidgetViewState {
placeholder: string;
}

export interface IInlineChatWidgetConstructionOptions {
menuId: MenuId;
statusMenuId: MenuId;
feedbackMenuId: MenuId;
}

export class InlineChatWidget {

private static _modelPool: number = 1;
Expand Down Expand Up @@ -209,6 +215,7 @@ export class InlineChatWidget {

constructor(
private readonly parentEditor: ICodeEditor,
_options: IInlineChatWidgetConstructionOptions,
@IModelService private readonly _modelService: IModelService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
Expand Down Expand Up @@ -342,7 +349,7 @@ export class InlineChatWidget {

// toolbars

const toolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.editorToolbar, MENU_INLINE_CHAT_WIDGET, {
const toolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.editorToolbar, _options.menuId, {
telemetrySource: 'interactiveEditorWidget-toolbar',
toolbarOptions: { primaryGroup: 'main' }
});
Expand All @@ -362,7 +369,7 @@ export class InlineChatWidget {
return undefined;
}
};
const statusButtonBar = this._instantiationService.createInstance(MenuWorkbenchButtonBar, this._elements.statusToolbar, MENU_INLINE_CHAT_WIDGET_STATUS, workbenchMenubarOptions);
const statusButtonBar = this._instantiationService.createInstance(MenuWorkbenchButtonBar, this._elements.statusToolbar, _options.statusMenuId, workbenchMenubarOptions);
this._store.add(statusButtonBar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
this._store.add(statusButtonBar);

Expand All @@ -375,7 +382,7 @@ export class InlineChatWidget {
}
};

const feedbackToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.feedbackToolbar, MENU_INLINE_CHAT_WIDGET_FEEDBACK, { ...workbenchToolbarOptions, hiddenItemStrategy: HiddenItemStrategy.Ignore });
const feedbackToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.feedbackToolbar, _options.feedbackMenuId, { ...workbenchToolbarOptions, hiddenItemStrategy: HiddenItemStrategy.Ignore });
this._store.add(feedbackToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
this._store.add(feedbackToolbar);

Expand Down Expand Up @@ -864,7 +871,11 @@ export class InlineChatZoneWidget extends ZoneWidget {
this._ctxCursorPosition.reset();
}));

this.widget = this._instaService.createInstance(InlineChatWidget, this.editor);
this.widget = this._instaService.createInstance(InlineChatWidget, this.editor, {
menuId: MENU_INLINE_CHAT_WIDGET,
statusMenuId: MENU_INLINE_CHAT_WIDGET_STATUS,
feedbackMenuId: MENU_INLINE_CHAT_WIDGET_FEEDBACK
});
this._disposables.add(this.widget.onDidChangeHeight(() => this._relayout()));
this._disposables.add(this.widget);
this.create();
Expand Down
Loading

0 comments on commit ed684fc

Please sign in to comment.