summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLuke Parker <[email protected]>2026-03-11 13:33:06 +1000
committerGitHub <[email protected]>2026-03-11 13:33:06 +1000
commit4ab35d2c5c92ccbd88dea65e8c2e0f6af748b884 (patch)
treed510e4efb6bfd11b501520b2cb3aa7a6f69cf2bb
parentb4ae030fc2395887bac8df072627366c6f2c269c (diff)
downloadopencode-4ab35d2c5c92ccbd88dea65e8c2e0f6af748b884.tar.gz
opencode-4ab35d2c5c92ccbd88dea65e8c2e0f6af748b884.zip
fix(electron): hide Windows background consoles (#16842)
Co-authored-by: Brendan Allan <[email protected]>
-rw-r--r--packages/desktop-electron/src/main/cli.ts4
-rw-r--r--packages/opencode/src/lsp/index.ts1
-rw-r--r--packages/opencode/src/lsp/server.ts7
-rw-r--r--packages/opencode/src/session/prompt.ts1
-rw-r--r--packages/opencode/src/shell/shell.ts5
-rw-r--r--packages/opencode/src/tool/bash.ts1
-rw-r--r--packages/opencode/src/util/process.ts1
7 files changed, 16 insertions, 4 deletions
diff --git a/packages/desktop-electron/src/main/cli.ts b/packages/desktop-electron/src/main/cli.ts
index e338d3913..fba301f36 100644
--- a/packages/desktop-electron/src/main/cli.ts
+++ b/packages/desktop-electron/src/main/cli.ts
@@ -107,7 +107,7 @@ export function syncCli() {
let version = ""
try {
- version = execFileSync(installPath, ["--version"]).toString().trim()
+ version = execFileSync(installPath, ["--version"], { windowsHide: true }).toString().trim()
} catch {
return
}
@@ -147,7 +147,7 @@ export function spawnCommand(args: string, extraEnv: Record<string, string>) {
console.log(`[cli] Executing: ${cmd} ${cmdArgs.join(" ")}`)
const child = spawn(cmd, cmdArgs, {
env: envs,
- detached: true,
+ detached: process.platform !== "win32",
windowsHide: true,
stdio: ["ignore", "pipe", "pipe"],
})
diff --git a/packages/opencode/src/lsp/index.ts b/packages/opencode/src/lsp/index.ts
index 9d7d30632..6ea7554c0 100644
--- a/packages/opencode/src/lsp/index.ts
+++ b/packages/opencode/src/lsp/index.ts
@@ -114,6 +114,7 @@ export namespace LSP {
return {
process: spawn(item.command[0], item.command.slice(1), {
cwd: root,
+ windowsHide: true,
env: {
...process.env,
...item.env,
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts
index 71f50c94b..c918008b4 100644
--- a/packages/opencode/src/lsp/server.ts
+++ b/packages/opencode/src/lsp/server.ts
@@ -1,4 +1,4 @@
-import { spawn, type ChildProcessWithoutNullStreams } from "child_process"
+import { spawn as launch, type ChildProcessWithoutNullStreams } from "child_process"
import path from "path"
import os from "os"
import { Global } from "../global"
@@ -14,6 +14,11 @@ import { Process } from "../util/process"
import { which } from "../util/which"
import { Module } from "@opencode-ai/util/module"
+const spawn = ((cmd, args, opts) => {
+ if (Array.isArray(args)) return launch(cmd, [...args], { ...(opts ?? {}), windowsHide: true });
+ return launch(cmd, { ...(args ?? {}), windowsHide: true });
+}) as typeof launch
+
export namespace LSPServer {
const log = Log.create({ service: "lsp.server" })
const pathExists = async (p: string) =>
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 7698b78ba..655afd2b1 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -1629,6 +1629,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
const proc = spawn(shell, args, {
cwd,
detached: process.platform !== "win32",
+ windowsHide: process.platform === "win32",
stdio: ["ignore", "pipe", "pipe"],
env: {
...process.env,
diff --git a/packages/opencode/src/shell/shell.ts b/packages/opencode/src/shell/shell.ts
index 60ae46f5e..a30889d69 100644
--- a/packages/opencode/src/shell/shell.ts
+++ b/packages/opencode/src/shell/shell.ts
@@ -15,7 +15,10 @@ export namespace Shell {
if (process.platform === "win32") {
await new Promise<void>((resolve) => {
- const killer = spawn("taskkill", ["/pid", String(pid), "/f", "/t"], { stdio: "ignore" })
+ const killer = spawn("taskkill", ["/pid", String(pid), "/f", "/t"], {
+ stdio: "ignore",
+ windowsHide: true,
+ })
killer.once("exit", () => resolve())
killer.once("error", () => resolve())
})
diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts
index 3be273486..109a66536 100644
--- a/packages/opencode/src/tool/bash.ts
+++ b/packages/opencode/src/tool/bash.ts
@@ -173,6 +173,7 @@ export const BashTool = Tool.define("bash", async () => {
},
stdio: ["ignore", "pipe", "pipe"],
detached: process.platform !== "win32",
+ windowsHide: process.platform === "win32",
})
let output = ""
diff --git a/packages/opencode/src/util/process.ts b/packages/opencode/src/util/process.ts
index 473ee27dc..049096937 100644
--- a/packages/opencode/src/util/process.ts
+++ b/packages/opencode/src/util/process.ts
@@ -60,6 +60,7 @@ export namespace Process {
cwd: opts.cwd,
env: opts.env === null ? {} : opts.env ? { ...process.env, ...opts.env } : undefined,
stdio: [opts.stdin ?? "ignore", opts.stdout ?? "ignore", opts.stderr ?? "ignore"],
+ windowsHide: process.platform === "win32",
})
let closed = false