diff --git a/.changeset/heavy-feet-judge.md b/.changeset/heavy-feet-judge.md new file mode 100644 index 0000000000..b9b3ca0f7b --- /dev/null +++ b/.changeset/heavy-feet-judge.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Safer shell profile path check diff --git a/src/utils/__tests__/shell.test.ts b/src/utils/__tests__/shell.test.ts index dee997a752..9c2b23aaa5 100644 --- a/src/utils/__tests__/shell.test.ts +++ b/src/utils/__tests__/shell.test.ts @@ -97,6 +97,12 @@ describe("Shell Detection Tests", () => { expect(getShell()).toBe("C:\\Windows\\System32\\cmd.exe") }) + it("handles undefined profile gracefully", () => { + // Mock a case where defaultProfileName exists but the profile doesn't + mockVsCodeConfig("windows", "NonexistentProfile", {}) + expect(getShell()).toBe("C:\\Windows\\System32\\cmd.exe") + }) + it("respects userInfo() if no VS Code config is available", () => { vscode.workspace.getConfiguration = () => ({ get: () => undefined }) as any ;(userInfo as any) = () => ({ shell: "C:\\Custom\\PowerShell.exe" }) diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 8871550a0e..2f7ffb3a88 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -105,7 +105,7 @@ function getWindowsShellFromVSCode(): string | null { } // If there's a specific path, return that immediately - if (profile.path) { + if (profile?.path) { return profile.path }