chore: narrow windows shell fix after review

This commit is contained in:
3aKHP 2026-03-23 19:59:30 +08:00
parent 28043ff02b
commit af6440297e
4 changed files with 8 additions and 13 deletions

View file

@ -5,7 +5,6 @@ import process from "process"
import type { RooTerminal } from "./types"
import { BaseTerminal } from "./BaseTerminal"
import { BaseTerminalProcess } from "./BaseTerminalProcess"
import { getShell } from "../../utils/shell"
export class ExecaTerminalProcess extends BaseTerminalProcess {
private terminalRef: WeakRef<RooTerminal>
@ -41,7 +40,7 @@ export class ExecaTerminalProcess extends BaseTerminalProcess {
this.isHot = true
this.subprocess = execa({
shell: BaseTerminal.getExecaShellPath() || getShell(),
shell: BaseTerminal.getExecaShellPath() || true,
cwd: this.terminal.getCurrentWorkingDirectory(),
all: true,
// Ignore stdin to ensure non-interactive mode and prevent hanging

View file

@ -21,10 +21,6 @@ vitest.mock("ps-tree", () => ({
default: vitest.fn((_: number, cb: any) => cb(null, [])),
}))
vitest.mock("../../../utils/shell", () => ({
getShell: vitest.fn(() => "/mocked/default/shell"),
}))
import { execa } from "execa"
import { ExecaTerminalProcess } from "../ExecaTerminalProcess"
import { BaseTerminal } from "../BaseTerminal"
@ -67,7 +63,7 @@ describe("ExecaTerminalProcess", () => {
const execaMock = vitest.mocked(execa)
expect(execaMock).toHaveBeenCalledWith(
expect.objectContaining({
shell: "/mocked/default/shell",
shell: true,
cwd: "/test/cwd",
all: true,
env: expect.objectContaining({
@ -109,13 +105,13 @@ describe("ExecaTerminalProcess", () => {
)
})
it("should fall back to getShell() when execaShellPath is undefined", async () => {
it("should fall back to shell=true when execaShellPath is undefined", async () => {
BaseTerminal.setExecaShellPath(undefined)
await terminalProcess.run("echo test")
const execaMock = vitest.mocked(execa)
expect(execaMock).toHaveBeenCalledWith(
expect.objectContaining({
shell: "/mocked/default/shell",
shell: true,
}),
)
})

View file

@ -139,11 +139,11 @@ describe("Shell Detection Tests", () => {
expect(getShell()).toBe("C:\\Program Files\\PowerShell\\7\\pwsh.exe")
})
it("falls back to PowerShell 7 if profile includes 'powershell' but no path/source", () => {
it("falls back to legacy PowerShell if profile includes 'powershell' but no path/source", () => {
mockVsCodeConfig("windows", "PowerShell", {
PowerShell: {},
})
expect(getShell()).toBe("C:\\Program Files\\PowerShell\\7\\pwsh.exe")
expect(getShell()).toBe("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe")
})
it("uses WSL bash when profile indicates WSL source", () => {

View file

@ -205,8 +205,8 @@ function getWindowsShellFromVSCode(): string | null {
// If the profile is sourced from PowerShell, assume the newest
return SHELL_PATHS.POWERSHELL_7
}
// Otherwise, assume modern PowerShell 7 (pwsh.exe) as the default
return SHELL_PATHS.POWERSHELL_7
// Otherwise, assume legacy Windows PowerShell
return SHELL_PATHS.POWERSHELL_LEGACY
}
// If there's a specific path, return that immediately