Files
orca/src/main/runtime/this-orca-launch-host.test.ts
T
Brennan Benson e92f38d722 fix(launch-prompt): the PowerShell a pane is spawned as is a host fact
c729128c3a typed a PowerShell prompt holding `"` or a trailing `\` on the line
because it treated 5.1 and 7 as indistinguishable, so 5.1 broke it as main
does. But this Orca chooses the executable it spawns: the requested shell, the
PowerShell implementation setting, then whether pwsh.exe is installed.

LaunchHost gains windowsPowerShell, derived by spawnedWindowsPowerShell from
those same inputs (main reads its pwsh probe cache, the renderer main's probe
over the existing IPC). On powershell.exe those prompts are measured damaged
and get a launch file (or main's paste on an AI button); on pwsh.exe they ride
the line, which carried them exactly. The PowerShell stays unknown, and main's
delivery decides, for an SSH or paired host and before the pwsh probe answers.
2026-10-02 06:21:57 -07:00

54 lines
1.8 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest'
import { cachedPwshAvailability } from '../pwsh'
import { thisOrcaLaunchHost } from './this-orca-launch-host'
vi.mock('../pwsh', () => ({ cachedPwshAvailability: vi.fn(() => null) }))
const realPlatform = process.platform
function onPlatform(platform: NodeJS.Platform): void {
Object.defineProperty(process, 'platform', { value: platform, configurable: true })
}
// Why: this Orca spawns its own Windows panes, so it knows the PowerShell that gets the line.
describe('the PowerShell a launch this Orca runs lands in', () => {
afterEach(() => {
onPlatform(realPlatform)
vi.mocked(cachedPwshAvailability).mockReturnValue(null)
})
it('follows the requested shell, then the settings and the pwsh probe, on this Windows machine', () => {
onPlatform('win32')
const settings = {
terminalWindowsShell: 'powershell.exe',
terminalWindowsPowerShellImplementation: 'auto' as const
}
const host = (windowsShellOverride?: string) =>
thisOrcaLaunchHost({
launchPlatform: 'win32',
isRemote: false,
settings,
windowsShellOverride
})
expect(host().windowsPowerShell).toBeNull()
vi.mocked(cachedPwshAvailability).mockReturnValue(false)
expect(host().windowsPowerShell).toBe('powershell.exe')
expect(host('pwsh.exe').windowsPowerShell).toBe('pwsh.exe')
expect(
thisOrcaLaunchHost({ launchPlatform: 'win32', isRemote: true, settings }).windowsPowerShell
).toBeNull()
})
it('knows none for a launch on another platform', () => {
onPlatform('darwin')
vi.mocked(cachedPwshAvailability).mockReturnValue(true)
expect(
thisOrcaLaunchHost({
launchPlatform: 'win32',
isRemote: false,
settings: { terminalWindowsShell: 'pwsh.exe' }
}).windowsPowerShell
).toBeNull()
})
})