OpenCode plugin: console window flashes on every tool call on Windows (execFileSync missing windowsHide)

Abierto Apto para principiantes
#1,682 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
92/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
bun, go, javascript

Línea de trabajo

Comienza con internal/agents/opencode/plugin/gortex.js, en la llamada a execFileSync descrita alrededor de la línea 352, y comprueba después el archivo golden renderizado cmd/gortex/testdata/agent-render/opencode.txt. Añade la opción que falta en la plantilla y regenera el golden para que ambos artefactos coincidan. Amplía internal/agents/opencode/plugin_test.go para comprobar que la opción está presente y ejecuta las pruebas relevantes de Go en internal/agents/opencode. Se considera terminado cuando el plugin de OpenCode generado oculta las consolas secundarias en Windows y mantiene el contrato existente del hook de stdin/stdout.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

On Windows, OpenCode flashes a console window (opens and closes) on every tool call and every user message once the Gortex OpenCode bridge plugin is installed. The plugin runs gortex hook --agent=opencode via execFileSync without windowsHide: true, so Windows allocates a new console for the child process.

The plugin host runs inside OpenCode's Bun process, which has no console attached, so each hook invocation gets its own console window. With the default hooks this happens:

  • once per tool call (tool.execute.before / execute.before)
  • once per permission prompt (permission.ask / permission.evaluate)
  • twice per user message (session briefing on the first turn + chat.message)

To Reproduce

  1. On Windows 11, run gortex install (or gortex init --agents opencode) with OpenCode detected.
  2. Open OpenCode in any repo.
  3. Run a tool, e.g. ask the agent to run git status.
  4. A console window flashes for each hook invocation. Restarting the TUI does not help; the flash correlates 1:1 with tool calls.

Root cause

internal/agents/opencode/plugin/gortex.js (tag v0.64.11, still present on main), call site at line 352:

const out = execFileSync(GORTEX_BIN, HOOK_ARGV.slice(1), {
  input: JSON.stringify(envelope),
  encoding: "utf8",
  maxBuffer: 16 * 1024 * 1024,
  timeout: HOOK_TIMEOUT_MS,
  stdio: ["pipe", "pipe", "ignore"],
  // windowsHide missing
});

windowsHide defaults to false. Node's docs: "Hide the subprocess console window that would normally be created on Windows systems. Default: false."

Bun ships a lint rule for this exact failure mode (bun/no-console-window-flash):

On Windows, a child process started from an app without a console gets its own console window. The window opens and closes again as the process runs, which users see as a black flash. windowsHide: true prevents it and has no effect on other systems.

For contrast, the sibling rtk OpenCode plugin already sets windowsHide: true on both of its execFile calls (lines 84 and 121 of its rtk.ts), so the pattern is established in OpenCode plugins on Windows.

Expected behavior

No console window is created; the hook runs hidden and the TUI stays clean.

Proposed fix (one line)

       stdio: ["pipe", "pipe", "ignore"],
+      windowsHide: true,
     });

windowsHide is ignored on Linux/macOS, so there is no behavior change outside Windows. The hook still receives its envelope on stdin and writes its decision on stdout through the existing pipes.

Blast radius for the generated artifacts:

  • internal/agents/opencode/plugin/gortex.js — the template above.
  • cmd/gortex/testdata/agent-render/opencode.txt — rendered golden, must be regenerated.
  • internal/agents/opencode/plugin_test.go:394 already asserts exactly one execFileSync( call site; adding a strings.Contains(pluginSource, "windowsHide: true") assertion would lock the fix in.

Verified locally

I patched the generated ~/.config/opencode/plugin/gortex.js on my machine with the one-line change:

  • bun -e 'await import("file:///.../plugin/gortex.js")' → parses cleanly under Bun 1.4.5 (OpenCode's runtime).
  • Replicated the exact options object and invoked gortex hook --agent=opencode with a tool.execute.before envelope → returns its decision JSON ({} for a benign git status), so the hook contract is unaffected.
  • After restarting the TUI, the flash is gone.

Note that this file is generated, so the local patch is overwritten by gortex install / gortex init --agents opencode; the fix has to land in the adapter template to persist.

Environment

$ gortex version
gortex v0.64.11+c7abb9b
  commit:  c7abb9b
  built:   2026-10-26T21:52:09Z
  go:      go1.27.3
  os/arch: windows/amd64

go version is unavailable on this machine — Gortex was installed from the release binary, so no Go toolchain is present.

  • OS: Windows 11 Pro 10.0.26300
  • OpenCode: v2.4.2 (Bun 1.4.5)
  • Adapter: opencode (user-level plugin at ~/.config/opencode/plugin/gortex.js)

Additional context

Related closed Windows console-window issues are all on the daemon side (#217 "gortex daemon start --detach make terminals flicker in Windows", #783 "Windows daemon can spawn visible go.exe console windows via go/packages"), fixed with HideWindow / CREATE_NO_WINDOW. The OpenCode bridge path was missed. No open issue or PR currently mentions windowsHide or the plugin console flash.

Lenguaje dominante
Go
Estrellas
1.9k
Forks
171
Merge medio
12 h 43 min
PR fusionados (30 d)
347

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de zzet/gortex

Todos los issues de zzet/gortex

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.