Skip to content

(feat): Default Windows terminals to PowerShell instead of cmd.exe #1691

Open
Justmalhar wants to merge 1 commit into
getpaseo:mainfrom
Justmalhar:main
Open

(feat): Default Windows terminals to PowerShell instead of cmd.exe #1691
Justmalhar wants to merge 1 commit into
getpaseo:mainfrom
Justmalhar:main

Conversation

@Justmalhar

Copy link
Copy Markdown

What

New terminals on Windows now launch Windows PowerShell instead of cmd.exe.

Why

resolveDefaultTerminalShell (the single source of truth for a new terminal's shell — terminal-manager.ts never passes an explicit shell) read env.ComSpec on win32. Windows always points ComSpec at …\System32\cmd.exe, so every new terminal opened cmd.

How

The win32 branch now returns …\System32\WindowsPowerShell\v1.0\powershell.exe, built from %SystemRoot% (honoring a relocated Windows install) with a C:\Windows fallback. Windows PowerShell 5.1 ships in System32 on every supported Windows, so the path is always valid and the resolver stays pure/synchronous (no PATH probing).

Untouched and verified safe:

  • resolveTerminalSpawnCommand (routes agent .cmd/.bat profiles like claude through cmd.exe /c) — unchanged.
  • Shell integration only ever existed for zsh, so there's no Windows integration to lose.

Tests

  • Rewrote the contract unit test to expect PowerShell and assert ComSpec no longer pulls it back to cmd.
  • Added a test for a relocated %SystemRoot%.

Note: this is a hardcoded switch with no opt-out. If a per-user shell knob is wanted later, the clean spot is a PASEO_TERMINAL_SHELL check at the top of the same win32 branch.

resolveDefaultTerminalShell read ComSpec on win32, which Windows always
points at cmd.exe, so every new terminal launched cmd. Default to Windows
PowerShell 5.1 (present in System32 on all supported Windows) instead,
honoring a relocated %SystemRoot%. Keeps the resolver pure/synchronous.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@Justmalhar Justmalhar changed the title Default Windows terminals to PowerShell instead of cmd.exe (#1) Default Windows terminals to PowerShell instead of cmd.exe Jun 23, 2026
@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown

Greptile Summary

This PR changes the default terminal shell on Windows from cmd.exe (previously derived via ComSpec) to Windows PowerShell 5.1 at %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe.

  • terminal.ts: The win32 branch of resolveDefaultTerminalShell now builds the PowerShell path from env.SystemRoot ?? env.SYSTEMROOT ?? "C:\\Windows", completely ignoring ComSpec. The resolver remains pure and synchronous.
  • terminal.test.ts: The contract test is rewritten to assert PowerShell is returned and ComSpec no longer influences the result; a second new test covers a relocated %SystemRoot% (e.g., D:\Windows).

Confidence Score: 5/5

Safe to merge — the change is a targeted, two-line swap with well-exercised tests and no impact on agent command routing.

The implementation correctly reads SystemRoot/SYSTEMROOT from the environment, falls back to C:\Windows, and constructs a path that is always valid on supported Windows versions. The old ComSpec logic is fully removed with no dead code. Tests cover the empty-env case, the ComSpec-is-present case, and a relocated %SystemRoot%. No existing behavior on non-Windows platforms is touched.

No files require special attention.

Important Files Changed

Filename Overview
packages/server/src/terminal/terminal.ts Replaces ComSpec lookup with a hardcoded PowerShell path built from %SystemRoot%; change is minimal, correct, and pure.
packages/server/src/terminal/terminal.test.ts Test updated to assert PowerShell is returned and ComSpec is ignored; new test covers relocated %SystemRoot%. Both tests exercise the module interface directly with no banned patterns.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[resolveDefaultTerminalShell called] --> B{platform === 'win32'?}
    B -- No --> C[return env.SHELL or /bin/sh]
    B -- Yes --> D[read env.SystemRoot or env.SYSTEMROOT]
    D --> E{env var present?}
    E -- Yes --> F[systemRoot = env value]
    E -- No --> G[systemRoot = 'C:\\Windows']
    F --> H[return systemRoot + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe']
    G --> H
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[resolveDefaultTerminalShell called] --> B{platform === 'win32'?}
    B -- No --> C[return env.SHELL or /bin/sh]
    B -- Yes --> D[read env.SystemRoot or env.SYSTEMROOT]
    D --> E{env var present?}
    E -- Yes --> F[systemRoot = env value]
    E -- No --> G[systemRoot = 'C:\\Windows']
    F --> H[return systemRoot + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe']
    G --> H
Loading

Reviews (1): Last reviewed commit: "Default Windows terminals to PowerShell ..." | Re-trigger Greptile

@Justmalhar Justmalhar changed the title Default Windows terminals to PowerShell instead of cmd.exe (feat): Default Windows terminals to PowerShell instead of cmd.exe Jun 24, 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.

1 participant