Skip to content

Add ExecutionPolicy Bypass for powershell hooks#317383

Merged
pwang347 merged 10 commits into
mainfrom
pawang/hooksPwsh
May 19, 2026
Merged

Add ExecutionPolicy Bypass for powershell hooks#317383
pwang347 merged 10 commits into
mainfrom
pawang/hooksPwsh

Conversation

@pwang347
Copy link
Copy Markdown
Member

Fixes #315830

Copilot AI review requested due to automatic review settings May 19, 2026 20:45
Copy link
Copy Markdown
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 PR updates the Copilot extension’s hook execution on Windows to explicitly invoke PowerShell with -ExecutionPolicy Bypass when the system shell is cmd.exe, aligning hook behavior with environments where PowerShell execution policy would otherwise block hook scripts.

Changes:

  • Refactors hook process creation to derive { command, args, shell, env } via a new getShellCommand(...) helper.
  • On Windows + ComSpec=cmd.exe, runs powershell.exe directly with -ExecutionPolicy Bypass (and disables PowerShell update checks).
  • Adds unit tests covering shell selection behavior across Windows/non-Windows scenarios.
Show a summary per file
File Description
extensions/copilot/src/platform/chat/node/hookExecutor.ts Refactors hook spawning to select a shell strategy and adds PowerShell -ExecutionPolicy Bypass for the Windows cmd.exe case.
extensions/copilot/src/platform/chat/test/node/hookExecutor.spec.ts Adds tests asserting the selected shell/command/args for Windows vs non-Windows hook execution.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 3

Comment thread extensions/copilot/src/platform/chat/test/node/hookExecutor.spec.ts Outdated
Comment thread extensions/copilot/src/platform/chat/node/hookExecutor.ts Outdated
Comment thread extensions/copilot/src/platform/chat/node/hookExecutor.ts Outdated
@pwang347 pwang347 marked this pull request as ready for review May 19, 2026 22:38
@pwang347 pwang347 enabled auto-merge (squash) May 19, 2026 22:38
@pwang347 pwang347 merged commit 1f7db28 into main May 19, 2026
25 checks passed
@pwang347 pwang347 deleted the pawang/hooksPwsh branch May 19, 2026 23:12
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 19, 2026
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.

Insiders prioritizing Copilot CLI hooks over vscode extension hooks

3 participants