Skip to content

Fix exit code 0 hook rendering for pretooluse - #320520

Merged
Paul (pwang347) merged 1 commit into
mainfrom
pawang/hookOutput
Jun 9, 2026
Merged

Paul (pwang347) merged 1 commit into
mainfrom
pawang/hookOutput

Conversation

@pwang347

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 9, 2026 00:00
@pwang347
Paul (pwang347) marked this pull request as ready for review June 9, 2026 00:01
@pwang347
Paul (pwang347) enabled auto-merge (squash) June 9, 2026 00:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 deny reasons across hook results (including mixing success-deny with error-deny) while still selecting the most restrictive decision.
  • Render a PreToolUse hookProgress error block for any final deny, not only hook execution errors.
  • Extend unit tests to cover outputStream rendering 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}`);
}

@justschen Justin Chen (justschen) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm!

@pwang347
Paul (pwang347) merged commit dad1bb1 into main Jun 9, 2026
26 checks passed
@pwang347
Paul (pwang347) deleted the pawang/hookOutput branch June 9, 2026 00:19
@vs-code-engineering vs-code-engineering Bot added this to the 1.125.0 milestone Jun 9, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants