Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/desktop-electron/src/main/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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"],
})
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/lsp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export namespace LSP {
return {
process: spawn(item.command[0], item.command.slice(1), {
cwd: root,
windowsHide: process.platform === "win32",
Comment thread
Hona marked this conversation as resolved.
Outdated
env: {
...process.env,
...item.env,
Expand Down
14 changes: 13 additions & 1 deletion packages/opencode/src/lsp/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn, type ChildProcessWithoutNullStreams } from "child_process"
import { spawn as launch, type ChildProcessWithoutNullStreams, type SpawnOptionsWithoutStdio } from "child_process"
import path from "path"
import os from "os"
import { Global } from "../global"
Expand All @@ -14,6 +14,18 @@ import { Process } from "../util/process"
import { which } from "../util/which"
import { Module } from "@opencode-ai/util/module"

const hide = process.platform === "win32"

function spawn(cmd: string, opts: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams
function spawn(cmd: string, args: readonly string[], opts?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams
function spawn(cmd: string, args?: readonly string[] | SpawnOptionsWithoutStdio, opts: SpawnOptionsWithoutStdio = {}) {
Comment thread
Hona marked this conversation as resolved.
Outdated
const cfg = Array.isArray(args) ? opts : (args ?? {})
return launch(cmd, Array.isArray(args) ? [...args] : [], {
...cfg,
windowsHide: hide,
})
}
Comment thread
Hona marked this conversation as resolved.
Outdated

export namespace LSPServer {
const log = Log.create({ service: "lsp.server" })
const pathExists = async (p: string) =>
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion packages/opencode/src/shell/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/bash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/util/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading