Fix Windows path/spawn regressions and session visibility (#552)

* Update OpenCode CLI detection

* fix(windows): handle cli file-url import and cmd shim spawn

Fixes #533 and #521.

* fix(windows): stabilize api path rewrite and session merge

Fixes #548.
This commit is contained in:
Bohdan Triapitsyn
2026-02-28 16:00:10 +02:00
committed by GitHub
parent 122a45a890
commit 6eb5d1afa9
6 changed files with 462 additions and 66 deletions
+11
View File
@@ -108,6 +108,16 @@ function isExecutable(filePath: string): boolean {
}
}
function shouldUseWindowsShell(binary: string): boolean {
if (process.platform !== 'win32') return false;
const trimmed = (binary || '').trim();
if (!trimmed) return true;
const ext = path.extname(trimmed).toLowerCase();
if (ext === '.cmd' || ext === '.bat') return true;
// Bare command names often resolve to .cmd shims via PATHEXT.
return !ext && !trimmed.includes('\\') && !trimmed.includes('/');
}
function appendToPath(dir: string) {
const trimmed = (dir || '').trim();
if (!trimmed) return;
@@ -349,6 +359,7 @@ async function spawnManagedOpenCodeServer(
cwd: workingDirectory,
env: { ...process.env },
stdio: ['ignore', 'pipe', 'pipe'],
shell: shouldUseWindowsShell(binary),
});
const url = await new Promise<string>((resolve, reject) => {