Skip to content

Commit ed684fc

Browse files
authored
Reuse chat widget and support status actions (#198479)
* Reuse chat widget and support status * Update cell chat actions
1 parent 6805bb6 commit ed684fc

6 files changed

Lines changed: 643 additions & 404 deletions

File tree

src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ export interface InlineChatWidgetViewState {
131131
placeholder: string;
132132
}
133133

134+
export interface IInlineChatWidgetConstructionOptions {
135+
menuId: MenuId;
136+
statusMenuId: MenuId;
137+
feedbackMenuId: MenuId;
138+
}
139+
134140
export class InlineChatWidget {
135141

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

210216
constructor(
211217
private readonly parentEditor: ICodeEditor,
218+
_options: IInlineChatWidgetConstructionOptions,
212219
@IModelService private readonly _modelService: IModelService,
213220
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
214221
@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
@@ -342,7 +349,7 @@ export class InlineChatWidget {
342349

343350
// toolbars
344351

345-
const toolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.editorToolbar, MENU_INLINE_CHAT_WIDGET, {
352+
const toolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.editorToolbar, _options.menuId, {
346353
telemetrySource: 'interactiveEditorWidget-toolbar',
347354
toolbarOptions: { primaryGroup: 'main' }
348355
});
@@ -362,7 +369,7 @@ export class InlineChatWidget {
362369
return undefined;
363370
}
364371
};
365-
const statusButtonBar = this._instantiationService.createInstance(MenuWorkbenchButtonBar, this._elements.statusToolbar, MENU_INLINE_CHAT_WIDGET_STATUS, workbenchMenubarOptions);
372+
const statusButtonBar = this._instantiationService.createInstance(MenuWorkbenchButtonBar, this._elements.statusToolbar, _options.statusMenuId, workbenchMenubarOptions);
366373
this._store.add(statusButtonBar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
367374
this._store.add(statusButtonBar);
368375

@@ -375,7 +382,7 @@ export class InlineChatWidget {
375382
}
376383
};
377384

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

@@ -864,7 +871,11 @@ export class InlineChatZoneWidget extends ZoneWidget {
864871
this._ctxCursorPosition.reset();
865872
}));
866873

867-
this.widget = this._instaService.createInstance(InlineChatWidget, this.editor);
874+
this.widget = this._instaService.createInstance(InlineChatWidget, this.editor, {
875+
menuId: MENU_INLINE_CHAT_WIDGET,
876+
statusMenuId: MENU_INLINE_CHAT_WIDGET_STATUS,
877+
feedbackMenuId: MENU_INLINE_CHAT_WIDGET_FEEDBACK
878+
});
868879
this._disposables.add(this.widget.onDidChangeHeight(() => this._relayout()));
869880
this._disposables.add(this.widget);
870881
this.create();

0 commit comments

Comments
 (0)