diff --git a/packages/web/bin/cli.js b/packages/web/bin/cli.js index bc9bb830..1c5fc7e5 100755 --- a/packages/web/bin/cli.js +++ b/packages/web/bin/cli.js @@ -1821,6 +1821,15 @@ async function terminateProcessTree(pid, options = {}) { : 3000; if (process.platform === 'win32') { + try { + process.kill(pid); + } catch { + } + + if (await waitForProcessExit(pid, 800)) { + return true; + } + try { spawnSync('taskkill', ['/pid', String(pid), '/t'], { stdio: 'ignore', diff --git a/packages/web/server/lib/opencode/lifecycle.js b/packages/web/server/lib/opencode/lifecycle.js index 20d784cf..9d85d028 100644 --- a/packages/web/server/lib/opencode/lifecycle.js +++ b/packages/web/server/lib/opencode/lifecycle.js @@ -124,6 +124,15 @@ export const createOpenCodeLifecycleRuntime = (deps) => { } if (process.platform === 'win32') { + try { + child.kill(); + } catch { + } + + if (await waitForChildProcessClose(child, 800)) { + return; + } + try { spawnSync('taskkill', ['/pid', String(pid), '/t'], { stdio: 'ignore', diff --git a/packages/web/server/lib/terminal/runtime.js b/packages/web/server/lib/terminal/runtime.js index 2d104b69..2bb38170 100644 --- a/packages/web/server/lib/terminal/runtime.js +++ b/packages/web/server/lib/terminal/runtime.js @@ -130,7 +130,7 @@ export function createTerminalRuntime({ let lastError = null; for (const shell of shellCandidates) { try { - const ptyProcess = pty.spawn(shell, [], { + const ptyOptions = { name: 'xterm-256color', cols: cols || 80, rows: rows || 24, @@ -140,7 +140,13 @@ export function createTerminalRuntime({ TERM: 'xterm-256color', COLORTERM: 'truecolor', }, - }); + }; + + if (process.platform === 'win32') { + ptyOptions.useConpty = true; + } + + const ptyProcess = pty.spawn(shell, [], ptyOptions); return { ptyProcess, shell }; } catch (error) {