Skip to content

Commit 4b2a9f5

Browse files
authored
debt - try to not cover the entire renderBody in try/catch (microsoft#264343)
1 parent 6cfcc7e commit 4b2a9f5

File tree

1 file changed

+42
-47
lines changed

1 file changed

+42
-47
lines changed

src/vs/workbench/contrib/chat/browser/chatViewPane.ts

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -178,58 +178,53 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate {
178178
}
179179

180180
protected override async renderBody(parent: HTMLElement): Promise<void> {
181-
try {
182-
super.renderBody(parent);
183-
184-
this._register(this.instantiationService.createInstance(ChatViewWelcomeController, parent, this, this.chatOptions.location));
185-
186-
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
187-
const locationBasedColors = this.getLocationBasedColors();
188-
const editorOverflowNode = this.layoutService.getContainer(getWindow(parent)).appendChild($('.chat-editor-overflow.monaco-editor'));
189-
this._register({ dispose: () => editorOverflowNode.remove() });
190-
191-
this._widget = this._register(scopedInstantiationService.createInstance(
192-
ChatWidget,
193-
this.chatOptions.location,
194-
{ viewId: this.id },
195-
{
196-
autoScroll: mode => mode !== ChatModeKind.Ask,
197-
renderFollowups: this.chatOptions.location === ChatAgentLocation.Panel,
198-
supportsFileReferences: true,
199-
rendererOptions: {
200-
renderTextEditsAsSummary: (uri) => {
201-
return true;
202-
},
203-
referencesExpandedWhenEmptyResponse: false,
204-
progressMessageAtBottomOfResponse: mode => mode !== ChatModeKind.Ask,
181+
super.renderBody(parent);
182+
183+
this._register(this.instantiationService.createInstance(ChatViewWelcomeController, parent, this, this.chatOptions.location));
184+
185+
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
186+
const locationBasedColors = this.getLocationBasedColors();
187+
const editorOverflowNode = this.layoutService.getContainer(getWindow(parent)).appendChild($('.chat-editor-overflow.monaco-editor'));
188+
this._register({ dispose: () => editorOverflowNode.remove() });
189+
190+
this._widget = this._register(scopedInstantiationService.createInstance(
191+
ChatWidget,
192+
this.chatOptions.location,
193+
{ viewId: this.id },
194+
{
195+
autoScroll: mode => mode !== ChatModeKind.Ask,
196+
renderFollowups: this.chatOptions.location === ChatAgentLocation.Panel,
197+
supportsFileReferences: true,
198+
rendererOptions: {
199+
renderTextEditsAsSummary: (uri) => {
200+
return true;
205201
},
206-
editorOverflowWidgetsDomNode: editorOverflowNode,
207-
enableImplicitContext: this.chatOptions.location === ChatAgentLocation.Panel,
208-
enableWorkingSet: 'explicit',
209-
supportsChangingModes: true,
202+
referencesExpandedWhenEmptyResponse: false,
203+
progressMessageAtBottomOfResponse: mode => mode !== ChatModeKind.Ask,
210204
},
211-
{
212-
listForeground: SIDE_BAR_FOREGROUND,
213-
listBackground: locationBasedColors.background,
214-
overlayBackground: locationBasedColors.overlayBackground,
215-
inputEditorBackground: locationBasedColors.background,
216-
resultEditorBackground: editorBackground,
217-
218-
}));
219-
this._register(this.onDidChangeBodyVisibility(visible => {
220-
this._widget.setVisible(visible);
205+
editorOverflowWidgetsDomNode: editorOverflowNode,
206+
enableImplicitContext: this.chatOptions.location === ChatAgentLocation.Panel,
207+
enableWorkingSet: 'explicit',
208+
supportsChangingModes: true,
209+
},
210+
{
211+
listForeground: SIDE_BAR_FOREGROUND,
212+
listBackground: locationBasedColors.background,
213+
overlayBackground: locationBasedColors.overlayBackground,
214+
inputEditorBackground: locationBasedColors.background,
215+
resultEditorBackground: editorBackground,
216+
221217
}));
222-
this._register(this._widget.onDidClear(() => this.clear()));
223-
this._widget.render(parent);
218+
this._register(this.onDidChangeBodyVisibility(visible => {
219+
this._widget.setVisible(visible);
220+
}));
221+
this._register(this._widget.onDidClear(() => this.clear()));
222+
this._widget.render(parent);
224223

225-
const info = this.getTransferredOrPersistedSessionInfo();
226-
const model = info.sessionId ? await this.chatService.getOrRestoreSession(info.sessionId) : undefined;
224+
const info = this.getTransferredOrPersistedSessionInfo();
225+
const model = info.sessionId ? await this.chatService.getOrRestoreSession(info.sessionId) : undefined;
227226

228-
await this.updateModel(model, info.inputValue || info.mode ? { inputState: { chatMode: info.mode }, inputValue: info.inputValue } : undefined);
229-
} catch (e) {
230-
this.logService.error(e);
231-
throw e;
232-
}
227+
await this.updateModel(model, info.inputValue || info.mode ? { inputState: { chatMode: info.mode }, inputValue: info.inputValue } : undefined);
233228
}
234229

235230
acceptInput(query?: string): void {

0 commit comments

Comments
 (0)