From a4e2777ce1e702ce314b5d4f91d09095c55d883b Mon Sep 17 00:00:00 2001 From: Oleg Solomko Date: Tue, 15 Apr 2025 17:20:19 -0700 Subject: [PATCH] cleanup --- .../dialogs/askToSelectPrompt/utils/runPrompt.ts | 15 +++++++++------ .../promptInstructionsCollectionWidget.ts | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/actions/reusablePromptActions/dialogs/askToSelectPrompt/utils/runPrompt.ts b/src/vs/workbench/contrib/chat/browser/actions/reusablePromptActions/dialogs/askToSelectPrompt/utils/runPrompt.ts index 3d9e322e5b8..52cda1fd7c3 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/reusablePromptActions/dialogs/askToSelectPrompt/utils/runPrompt.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/reusablePromptActions/dialogs/askToSelectPrompt/utils/runPrompt.ts @@ -8,6 +8,7 @@ import { IChatWidget } from '../../../../../chat.js'; import { getChatWidgetObject } from './attachInstructions.js'; import { URI } from '../../../../../../../../../base/common/uri.js'; import { extUri } from '../../../../../../../../../base/common/resources.js'; +import { assertDefined } from '../../../../../../../../../base/common/types.js'; import { IViewsService } from '../../../../../../../../services/views/common/viewsService.js'; import { ICommandService } from '../../../../../../../../../platform/commands/common/commands.js'; @@ -67,7 +68,7 @@ export const runPromptFile = async ( }; /** - * Check if provided uri is already set as the implicit context + * Check if provided uri is already set as the implicit context. */ const isSetInImplicitContext = ( promptUri: URI, @@ -78,11 +79,6 @@ const isSetInImplicitContext = ( return false; } - if (implicitContext.value === undefined) { - // the user turned off implicit context in the settings - return false; - } - if (implicitContext.enabled === false) { // the user disabled the implicit context in the chat view return false; @@ -92,6 +88,13 @@ const isSetInImplicitContext = ( return false; } + // we expect all implicit prompt file attachments + // to have the `value` property to be present + assertDefined( + implicitContext.value, + 'Prompt value must always be defined.', + ); + const uri = URI.isUri(implicitContext.value) ? implicitContext.value : implicitContext.value.uri; diff --git a/src/vs/workbench/contrib/chat/browser/attachments/promptInstructions/promptInstructionsCollectionWidget.ts b/src/vs/workbench/contrib/chat/browser/attachments/promptInstructions/promptInstructionsCollectionWidget.ts index a7b9fe714b3..a6cbf93700a 100644 --- a/src/vs/workbench/contrib/chat/browser/attachments/promptInstructions/promptInstructionsCollectionWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/attachments/promptInstructions/promptInstructionsCollectionWidget.ts @@ -9,11 +9,11 @@ import { ResourceLabels } from '../../../../../browser/labels.js'; import { Disposable } from '../../../../../../base/common/lifecycle.js'; import { ILogService } from '../../../../../../platform/log/common/log.js'; import { InstructionsAttachmentWidget } from './promptInstructionsWidget.js'; +import { PROMPT_LANGUAGE_ID } from '../../../common/promptSyntax/constants.js'; +import { IModelService } from '../../../../../../editor/common/services/model.js'; +import { ILanguageService } from '../../../../../../editor/common/languages/language.js'; import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js'; import { ChatPromptAttachmentsCollection } from '../../chatAttachmentModel/chatPromptAttachmentsCollection.js'; -import { ILanguageService } from '../../../../../../editor/common/languages/language.js'; -import { IModelService } from '../../../../../../editor/common/services/model.js'; -import { PROMPT_LANGUAGE_ID } from '../../../common/promptSyntax/constants.js'; /** * Widget for a collection of prompt instructions attachments.