mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-25 18:14:58 +00:00
fix(electron): hide Windows background consoles (#16842)
Co-authored-by: Brendan Allan <git@brendonovich.dev>
This commit is contained in:
@@ -107,7 +107,7 @@ export function syncCli() {
|
|||||||
|
|
||||||
let version = ""
|
let version = ""
|
||||||
try {
|
try {
|
||||||
version = execFileSync(installPath, ["--version"]).toString().trim()
|
version = execFileSync(installPath, ["--version"], { windowsHide: true }).toString().trim()
|
||||||
} catch {
|
} catch {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ export function spawnCommand(args: string, extraEnv: Record<string, string>) {
|
|||||||
console.log(`[cli] Executing: ${cmd} ${cmdArgs.join(" ")}`)
|
console.log(`[cli] Executing: ${cmd} ${cmdArgs.join(" ")}`)
|
||||||
const child = spawn(cmd, cmdArgs, {
|
const child = spawn(cmd, cmdArgs, {
|
||||||
env: envs,
|
env: envs,
|
||||||
detached: true,
|
detached: process.platform !== "win32",
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ export namespace LSP {
|
|||||||
return {
|
return {
|
||||||
process: spawn(item.command[0], item.command.slice(1), {
|
process: spawn(item.command[0], item.command.slice(1), {
|
||||||
cwd: root,
|
cwd: root,
|
||||||
|
windowsHide: true,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
...item.env,
|
...item.env,
|
||||||
|
|||||||
@@ -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 path from "path"
|
||||||
import os from "os"
|
import os from "os"
|
||||||
import { Global } from "../global"
|
import { Global } from "../global"
|
||||||
@@ -14,6 +14,11 @@ import { Process } from "../util/process"
|
|||||||
import { which } from "../util/which"
|
import { which } from "../util/which"
|
||||||
import { Module } from "@opencode-ai/util/module"
|
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 {
|
export namespace LSPServer {
|
||||||
const log = Log.create({ service: "lsp.server" })
|
const log = Log.create({ service: "lsp.server" })
|
||||||
const pathExists = async (p: string) =>
|
const pathExists = async (p: string) =>
|
||||||
|
|||||||
@@ -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, {
|
const proc = spawn(shell, args, {
|
||||||
cwd,
|
cwd,
|
||||||
detached: process.platform !== "win32",
|
detached: process.platform !== "win32",
|
||||||
|
windowsHide: process.platform === "win32",
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ export namespace Shell {
|
|||||||
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
await new Promise<void>((resolve) => {
|
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("exit", () => resolve())
|
||||||
killer.once("error", () => resolve())
|
killer.once("error", () => resolve())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ export const BashTool = Tool.define("bash", async () => {
|
|||||||
},
|
},
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
detached: process.platform !== "win32",
|
detached: process.platform !== "win32",
|
||||||
|
windowsHide: process.platform === "win32",
|
||||||
})
|
})
|
||||||
|
|
||||||
let output = ""
|
let output = ""
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export namespace Process {
|
|||||||
cwd: opts.cwd,
|
cwd: opts.cwd,
|
||||||
env: opts.env === null ? {} : opts.env ? { ...process.env, ...opts.env } : undefined,
|
env: opts.env === null ? {} : opts.env ? { ...process.env, ...opts.env } : undefined,
|
||||||
stdio: [opts.stdin ?? "ignore", opts.stdout ?? "ignore", opts.stderr ?? "ignore"],
|
stdio: [opts.stdin ?? "ignore", opts.stdout ?? "ignore", opts.stderr ?? "ignore"],
|
||||||
|
windowsHide: process.platform === "win32",
|
||||||
})
|
})
|
||||||
|
|
||||||
let closed = false
|
let closed = false
|
||||||
|
|||||||
Reference in New Issue
Block a user