diff --git a/build/lib/policies/policyData.jsonc b/build/lib/policies/policyData.jsonc index 53387c4fa34..7489336e814 100644 --- a/build/lib/policies/policyData.jsonc +++ b/build/lib/policies/policyData.jsonc @@ -169,6 +169,20 @@ "type": "boolean", "default": true }, + { + "key": "chat.useHooks", + "name": "ChatHooks", + "category": "InteractiveSession", + "minimumVersion": "1.109", + "localization": { + "description": { + "key": "chat.useHooks.description", + "value": "Controls whether chat hooks are executed at strategic points during an agent's workflow. Hooks are loaded from the files configured in `#chat.hookFilesLocations#`." + } + }, + "type": "boolean", + "default": true + }, { "key": "chat.tools.terminal.enableAutoApprove", "name": "ChatToolsTerminalEnableAutoApprove", diff --git a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts index d9a0dbe7a6a..13e9b83a523 100644 --- a/src/vs/workbench/contrib/chat/browser/chat.contribution.ts +++ b/src/vs/workbench/contrib/chat/browser/chat.contribution.ts @@ -958,7 +958,7 @@ configurationRegistry.registerConfiguration({ patternErrorMessage: nls.localize('chat.hookFilesLocations.invalidPath', "Paths must be relative or start with '~/'. Absolute paths and '\\' separators are not supported."), }, restricted: true, - tags: ['prompts', 'hooks', 'agent'], + tags: ['preview', 'prompts', 'hooks', 'agent'], examples: [ { [DEFAULT_HOOK_FILE_PATHS[0].path]: true, @@ -971,12 +971,24 @@ configurationRegistry.registerConfiguration({ }, [PromptsConfig.USE_CHAT_HOOKS]: { type: 'boolean', - title: nls.localize('chat.useChatHooks.title', "Use Chat Hooks",), - markdownDescription: nls.localize('chat.useChatHooks.description', "Controls whether chat hooks are executed at strategic points during an agent's workflow. Hooks are loaded from the files configured in `#chat.hookFilesLocations#`.",), + title: nls.localize('chat.useHooks.title', "Use Chat Hooks",), + markdownDescription: nls.localize('chat.useHooks.description', "Controls whether chat hooks are executed at strategic points during an agent's workflow. Hooks are loaded from the files configured in `#chat.hookFilesLocations#`.",), default: true, restricted: true, disallowConfigurationDefault: true, - tags: ['prompts', 'hooks', 'agent'] + tags: ['preview', 'prompts', 'hooks', 'agent'], + policy: { + name: 'ChatHooks', + category: PolicyCategory.InteractiveSession, + minimumVersion: '1.109', + value: (policyData) => policyData.chat_preview_features_enabled === false ? false : undefined, + localization: { + description: { + key: 'chat.useHooks.description', + value: nls.localize('chat.useHooks.description', "Controls whether chat hooks are executed at strategic points during an agent's workflow. Hooks are loaded from the files configured in `#chat.hookFilesLocations#`.",) + } + }, + } }, [PromptsConfig.PROMPT_FILES_SUGGEST_KEY]: { type: 'object', diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/config/config.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/config/config.ts index 4b9621c5547..89d415a99ef 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/config/config.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/config/config.ts @@ -108,7 +108,7 @@ export namespace PromptsConfig { /** * Configuration key for chat hooks usage. */ - export const USE_CHAT_HOOKS = 'chat.useChatHooks'; + export const USE_CHAT_HOOKS = 'chat.useHooks'; /** * Configuration key for enabling stronger skill adherence prompt (experimental). diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts index 7d4cb5cc352..e32abc667f0 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts @@ -177,7 +177,10 @@ export class PromptsService extends Disposable implements IPromptsService { this.cachedHooks = this._register(new CachedPromise( (token) => this.computeHooks(token), - () => this.getFileLocatorEvent(PromptsType.hook) + () => Event.any( + this.getFileLocatorEvent(PromptsType.hook), + Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration(PromptsConfig.USE_CHAT_HOOKS)), + ) )); // Hack: Subscribe to activate caching (CachedPromise only caches when onDidChange has listeners) @@ -1000,6 +1003,11 @@ export class PromptsService extends Disposable implements IPromptsService { } private async computeHooks(token: CancellationToken): Promise { + const useChatHooks = this.configurationService.getValue(PromptsConfig.USE_CHAT_HOOKS); + if (!useChatHooks) { + return undefined; + } + const hookFiles = await this.listPromptFiles(PromptsType.hook, token); if (hookFiles.length === 0) { diff --git a/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts b/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts index 4b8f27cdd9b..63a328d454b 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts @@ -257,7 +257,7 @@ export const tocData: ITOCEntry = { 'chat.useNestedAgentsMdFiles', 'chat.useAgentSkills', 'chat.experimental.useSkillAdherencePrompt', - 'chat.useChatHooks', + 'chat.useHooks', 'chat.includeApplyingInstructions', 'chat.includeReferencedInstructions', 'chat.sendElementsToChat.*',