Fix orchestration mail from WSL and SSH terminals (#3918)

This commit is contained in:
Jinwoo Hong
2026-05-31 15:13:15 -04:00
committed by GitHub
parent ce552c4a26
commit 4cc0147005
29 changed files with 1205 additions and 77 deletions
+60 -7
View File
@@ -9,7 +9,9 @@ vi.mock('node:child_process', () => ({
import { WslCliInstaller, _internals } from './wsl-cli-installer'
function makeHostStatus(launcherPath = 'C:\\Users\\me\\AppData\\Local\\Orca\\bin\\orca.cmd') {
function makeHostStatus(
launcherPath = 'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\resources\\bin\\orca.cmd'
) {
return {
platform: 'win32',
commandName: 'orca',
@@ -40,9 +42,6 @@ function createWslRunner(initialFile: string | null = null, pathIncludesLocalBin
if (command.includes('printf %s "$HOME"')) {
return '/home/alice'
}
if (command.includes('command -v powershell.exe')) {
return 'yes'
}
if (command.includes('case ":$PATH:"')) {
return pathIncludesLocalBin ? 'yes' : 'no'
}
@@ -57,6 +56,9 @@ function createWslRunner(initialFile: string | null = null, pathIncludesLocalBin
files.set(bridgePath, bridge)
return ''
}
if (command.includes('command -v powershell.exe')) {
return 'yes'
}
if (command.includes('rm -f')) {
if (
files.has(bridgePath) &&
@@ -114,11 +116,11 @@ describe('WslCliInstaller', () => {
expect(installed).toMatchObject({
state: 'installed',
pathConfigured: true,
launcherPath: 'C:\\Users\\me\\AppData\\Local\\Orca\\bin\\orca.cmd'
launcherPath: 'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\resources\\bin\\orca.cmd'
})
expect(wsl.getFile()).toBe(
_internals.buildWslLauncher(
'C:\\Users\\me\\AppData\\Local\\Orca\\bin\\orca.cmd',
'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\resources\\bin\\orca.cmd',
'/home/alice/.local/share/orca/orca-wsl-bridge.ps1'
)
)
@@ -195,7 +197,12 @@ describe('WslCliInstaller', () => {
)
const bridge = _internals.buildWslBridgeScript()
expect(launcher).toContain('powershell.exe -NoProfile -ExecutionPolicy Bypass -File')
expect(launcher).toContain('command -v powershell.exe')
expect(launcher).toContain('/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe')
expect(launcher).toContain(
'Orca WSL CLI requires Windows interop and could not find powershell.exe.'
)
expect(launcher).toContain('"$ORCA_POWERSHELL" -NoProfile -ExecutionPolicy Bypass -File')
expect(launcher).toContain('"$ORCA_WIN_LAUNCHER" "$@"')
expect(launcher).not.toContain('-Command')
expect(bridge).toContain('[Parameter(ValueFromRemainingArguments=$true)]')
@@ -223,6 +230,52 @@ describe('WslCliInstaller', () => {
expect(Buffer.from(encoded as string, 'base64').toString('utf8')).toBe(command)
})
it('treats absolute Windows PowerShell as interop-ready when powershell.exe is missing from PATH', async () => {
const wsl = createWslRunner()
const installer = new WslCliInstaller({
platform: 'win32',
distro: 'Ubuntu',
hostInstaller: { getStatus: async () => makeHostStatus() },
wslRunner: async (distro, command) => {
if (command.includes('command -v powershell.exe') && !command.includes('cat >')) {
expect(command).toContain('/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe')
return 'yes'
}
return wsl.runner(distro, command)
}
})
await expect(installer.getStatus()).resolves.toMatchObject({
state: 'not_installed',
commandPath: '/home/alice/.local/bin/orca-ide'
})
})
it('marks stale managed launchers that point at the old app bin instead of packaged resources', async () => {
const oldLauncher = _internals.buildWslLauncher(
'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\bin\\orca.cmd',
'/home/alice/.local/share/orca/orca-wsl-bridge.ps1'
)
const wsl = createWslRunner(oldLauncher)
const installer = new WslCliInstaller({
platform: 'win32',
distro: 'Ubuntu',
hostInstaller: { getStatus: async () => makeHostStatus() },
wslRunner: wsl.runner
})
await expect(installer.getStatus()).resolves.toMatchObject({
state: 'stale',
currentTarget: 'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\bin\\orca.cmd',
launcherPath: 'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\resources\\bin\\orca.cmd'
})
await expect(installer.install()).resolves.toMatchObject({
state: 'installed',
currentTarget: 'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\resources\\bin\\orca.cmd'
})
})
it('settles when wsl.exe never reports completion', async () => {
vi.useFakeTimers()
const killMock = vi.fn()
+1 -1
View File
@@ -234,7 +234,7 @@ export class WslCliInstaller {
(
await this.run(
this.distro,
'command -v powershell.exe >/dev/null 2>&1 && command -v wslpath >/dev/null 2>&1 && printf yes || printf no'
'{ command -v powershell.exe >/dev/null 2>&1 || [ -x /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; } && command -v wslpath >/dev/null 2>&1 && printf yes || printf no'
)
).trim() === 'yes'
if (!interopReady) {
+9 -1
View File
@@ -12,8 +12,16 @@ ${MANAGED_MARKER}
# ORCA_WIN_LAUNCHER_B64=${encodedTarget}
ORCA_WIN_LAUNCHER=${quoteShell(windowsLauncherPath)}
ORCA_BRIDGE_PS1=${quoteShell(bridgePath)}
if command -v powershell.exe >/dev/null 2>&1; then
ORCA_POWERSHELL=powershell.exe
elif [ -x /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
ORCA_POWERSHELL=/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
else
echo "Orca WSL CLI requires Windows interop and could not find powershell.exe." >&2
exit 1
fi
ORCA_BRIDGE_PS1_WIN=$(wslpath -w "$ORCA_BRIDGE_PS1")
exec powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$ORCA_BRIDGE_PS1_WIN" "$ORCA_WIN_LAUNCHER" "$@"
exec "$ORCA_POWERSHELL" -NoProfile -ExecutionPolicy Bypass -File "$ORCA_BRIDGE_PS1_WIN" "$ORCA_WIN_LAUNCHER" "$@"
`
}