From d7ebb2cc7dcab5b7d7c9bc98ad5b96652dcab650 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Sun, 29 Mar 2026 23:47:37 +0200 Subject: [PATCH] don't block chat when collecting instructions fail (#306161) --- .../contrib/chat/browser/widget/chatWidget.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts b/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts index c6bf65d2c52..1fddece433b 100644 --- a/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts @@ -2819,13 +2819,16 @@ export class ChatWidget extends Disposable implements IChatWidget { this.logService.debug(`ChatWidget#_autoAttachInstructions: skipped, autoAttachReferences is disabled`); return; } - - this.logService.debug(`ChatWidget#_autoAttachInstructions: prompt files are enabled`); - const enabledTools = this.input.currentModeKind === ChatModeKind.Agent ? this.input.selectedToolsModel.userSelectedTools.get() : undefined; - const enabledSubAgents = this.input.currentModeKind === ChatModeKind.Agent ? this.input.currentModeObs.get().agents?.get() : undefined; - const sessionResource = this._viewModel?.model.sessionResource; - const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, this.input.currentModeKind, enabledTools, enabledSubAgents, sessionResource); - await computer.collect(attachedContext, CancellationToken.None); + try { + this.logService.debug(`ChatWidget#_autoAttachInstructions: prompt files are enabled`); + const enabledTools = this.input.currentModeKind === ChatModeKind.Agent ? this.input.selectedToolsModel.userSelectedTools.get() : undefined; + const enabledSubAgents = this.input.currentModeKind === ChatModeKind.Agent ? this.input.currentModeObs.get().agents?.get() : undefined; + const sessionResource = this._viewModel?.model.sessionResource; + const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, this.input.currentModeKind, enabledTools, enabledSubAgents, sessionResource); + await computer.collect(attachedContext, CancellationToken.None); + } catch (err) { + this.logService.error(`ChatWidget#_autoAttachInstructions: failed to compute automatic instructions`, err); + } } delegateScrollFromMouseWheelEvent(browserEvent: IMouseWheelEvent): void {