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

Aperta Adatta ai principianti
#1,682 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
92/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, go, javascript

Direzione di ricerca

Inizia da internal/agents/opencode/plugin/gortex.js, alla chiamata a execFileSync descritta intorno alla riga 352, quindi controlla il file golden renderizzato cmd/gortex/testdata/agent-render/opencode.txt. Aggiungi l’opzione mancante nel template e rigenera il golden in modo che entrambi gli artefatti corrispondano. Estendi internal/agents/opencode/plugin_test.go per verificare che l’opzione sia presente ed esegui i test Go pertinenti in internal/agents/opencode. Il lavoro è completo quando il plugin OpenCode generato nasconde le console child su Windows mantenendo il contratto esistente dell’hook stdin/stdout.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
1.9k
Fork
171
Merge medio
12h 43m
PR unite (30g)
347

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di zzet/gortex

Tutte le issue di zzet/gortex

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.