Skip to content

Add common output hook types and reorganize related code#292961

Merged
roblourens merged 2 commits intomainfrom
roblou/gorgeous-caribou
Feb 4, 2026
Merged

Add common output hook types and reorganize related code#292961
roblourens merged 2 commits intomainfrom
roblou/gorgeous-caribou

Conversation

@roblourens
Copy link
Member

Introduce common output hook types and reorganize existing code for better clarity and structure.

Copilot AI review requested due to automatic review settings February 4, 2026 23:12
@roblourens roblourens enabled auto-merge (squash) February 4, 2026 23:12
@roblourens roblourens self-assigned this Feb 4, 2026
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ChatHookResultKind to an interface-based ChatHookResult with explicit fields for common properties and hook-specific output
  • Introduced ICommonHookOutput interface 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

@roblourens roblourens merged commit 704095a into main Feb 4, 2026
27 of 28 checks passed
@roblourens roblourens deleted the roblou/gorgeous-caribou branch February 4, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants