(feat): Default Windows terminals to PowerShell instead of cmd.exe #1691
(feat): Default Windows terminals to PowerShell instead of cmd.exe #1691Justmalhar wants to merge 1 commit into
Conversation
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>
|
| 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
%%{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
Reviews (1): Last reviewed commit: "Default Windows terminals to PowerShell ..." | Re-trigger Greptile
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.tsnever passes an explicitshell) readenv.ComSpeconwin32. Windows always pointsComSpecat…\System32\cmd.exe, so every new terminal opened cmd.How
The
win32branch now returns…\System32\WindowsPowerShell\v1.0\powershell.exe, built from%SystemRoot%(honoring a relocated Windows install) with aC:\Windowsfallback. 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/.batprofiles likeclaudethroughcmd.exe /c) — unchanged.Tests
ComSpecno longer pulls it back to cmd.%SystemRoot%.