Repository navigation
Fix exit code 0 hook rendering for pretooluse - #320520
Merged
Merged
Conversation
Paul (pwang347)
marked this pull request as ready for review
June 9, 2026 00:01
Paul (pwang347)
enabled auto-merge (squash)
June 9, 2026 00:01
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Copilot Chat PreToolUse hook result collapsing/rendering so that deny decisions from successful hooks (exit code 0) reliably produce a visible hookProgress error block, and so multiple deny reasons can be surfaced together.
Changes:
- Collect and aggregate multiple
denyreasons across hook results (including mixing success-deny with error-deny) while still selecting the most restrictive decision. - Render a
PreToolUsehookProgresserror block for any finaldeny, not only hook execution errors. - Extend unit tests to cover
outputStreamrendering and multi-reason deny aggregation.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/chat/vscode-node/chatHookService.ts | Updates PreToolUse collapsing to aggregate deny reasons and always render a deny block in chat output. |
| extensions/copilot/src/extension/chat/test/vscode-node/chatHookService.spec.ts | Updates collapsing test helper and adds coverage for deny rendering in outputStream. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
Comment on lines
428
to
433
| onError: (errorMessage) => { | ||
| const messageWithTool = errorMessage | ||
| ? l10n.t('Tried to use {0} - {1}', toolName, errorMessage) | ||
| : l10n.t('Tried to use {0} - an unexpected error occurred', toolName); | ||
| outputStream?.hookProgress('PreToolUse', formatHookErrorMessage(messageWithTool)); | ||
| if (errorMessage) { | ||
| denyReasons.push(errorMessage); | ||
| } | ||
| mostRestrictiveDecision = 'deny'; | ||
| winningReason = messageWithTool || winningReason; | ||
| }, |
Comment on lines
+599
to
+601
| } | ||
| outputStream?.hookProgress('PreToolUse', `A hook prevented chat from continuing. ${renderedReason}`); | ||
| } |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.