Add common output hook types and reorganize related code#292961
Merged
roblourens merged 2 commits intomainfrom Feb 4, 2026
Merged
Add common output hook types and reorganize related code#292961roblourens merged 2 commits intomainfrom
roblourens merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request introduces common output hook types and reorganizes the hook execution code for better clarity and type safety. The main goal is to extract common flow control fields (like stopReason and messageForUser) from hook-specific output and provide a more semantic API structure.
Changes:
- Refactored the hook result types from an enum-based
ChatHookResultKindto an interface-basedChatHookResultwith explicit fields for common properties and hook-specific output - Introduced
ICommonHookOutputinterface to define reusable flow control fields across all hook types - Added logic to extract and separate common fields from hook-specific output, with stopReason-based early termination support
- Incremented the chatHooks API version from 1 to 2 to reflect the breaking changes
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.chatHooks.d.ts | Updated the proposed API: removed ChatHookResultKind enum and replaced it with ChatHookResult interface containing semantic fields; incremented version to 2 |
| src/vs/workbench/contrib/chat/common/hooksExecutionService.ts | Added ICommonHookOutput interface; introduced IHookCommandResult and refactored IHookResult to separate raw command results from semantic results; added IPreToolUseHookResult type; implemented result transformation logic with common field extraction and stopReason handling |
| src/vs/workbench/contrib/chat/test/common/hooksExecutionService.test.ts | Updated tests to use new type names and added comprehensive tests for common field extraction, defaults, and error handling |
| src/vs/workbench/contrib/chat/test/browser/tools/languageModelToolsService.test.ts | Updated mock hook results to match the new IPreToolUseHookResult interface structure with required output and success fields |
| src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts | Changed hardcoded string 'preToolUse' to use HookType.PreToolUse enum for better type safety |
| src/vs/workbench/api/test/node/extHostHooks.test.ts | Updated type references from HookResultKind to HookCommandResultKind and from IHookResult to include proper imports |
| src/vs/workbench/api/node/extHostHooksNode.ts | Updated to return IHookCommandResult and use HookCommandResultKind enum; simplified result conversion in executeHook |
| src/vs/workbench/api/common/extHostTypes.ts | Removed the ChatHookResultKind enum as it's no longer part of the API |
| src/vs/workbench/api/common/extHostTypeConverters.ts | Updated ChatHookResult converter to map the new interface fields instead of the old enum-based structure |
| src/vs/workbench/api/common/extHost.protocol.ts | Updated return type of $runHookCommand to IHookCommandResult |
| src/vs/workbench/api/common/extHost.api.impl.ts | Removed ChatHookResultKind from the exported API types |
| src/vs/workbench/api/browser/mainThreadHooks.ts | Updated proxy to use HookCommandResultKind and IHookCommandResult types |
| src/vs/platform/extensions/common/extensionsApiProposals.ts | Incremented chatHooks proposal version to 2 |
DonJayamanne
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce common output hook types and reorganize existing code for better clarity and structure.