Skip to content

fix: pass windowsHide to the git execSync calls so no console window is created on Windows - #102

Open
leonvchan wants to merge 1 commit into
supermemoryai:mainfrom
leonvchan:fix/windowshide-execsync
Open

leonvchan wants to merge 1 commit into
supermemoryai:mainfrom
leonvchan:fix/windowshide-execsync

Conversation

@leonvchan

Copy link
Copy Markdown

Fixes #101.

execSync with a string command runs through cmd.exe on Windows, and windowsHide defaults to false, so the child process is created with a console window whenever the caller has no console of its own — which is the case for the OpenCode service process. A newly created console window takes foreground focus, which breaks IME composition while a session is in use.

The CLI entrypoint already passes windowsHide: true, which suggests the omission here is an oversight. stdio: ["pipe", "pipe", "pipe"] does not suppress the window on Windows — only windowsHide does.

This adds windowsHide: true to the six execSync option objects in src/services/tags.ts. No other change.

Measured on Windows 11 (build 26200.8655), OpenCode 2.0.21, plugin 2.0.15

  • before: a 60 ms process/window watcher recorded 105 visible ConsoleWindowClass windows in 133 s while a session was active;
  • after applying this change to the installed copy and rebooting: 1 visible console window over 153 s, and it occurred during cold npx startup of the MCP servers, not during turns.

Attribution caveat, stated plainly: that capture could not isolate this plugin from other console-window sources (OpenCode's own MCP startup also spawns cmd.exe /d /s /c "npx ...", whose children include node.exe and git-remote-https.exe). This PR therefore rests on the code defect, not on a clean A/B.

Not addressed here

Two things noticed while investigating, left alone to keep this PR minimal:

  • getGitRoot() is not memoized (repoInfoCache only covers getGitRepoInfo()), so it shells out to git on every call.
  • execSync with a string command also routes through cmd.exe; execFileSync("git", [...]) with an argv array would avoid that extra process layer entirely.

`execSync` with a string command runs through `cmd.exe` on Windows, and
`windowsHide` defaults to false, so the child process is created with a console
window whenever the caller has no console of its own — which is the case for the
OpenCode service process. A newly created console window takes foreground focus,
which breaks IME composition while a session is in use.

The CLI entrypoint already passes `windowsHide: true`; these six call sites in
`src/services/tags.ts` did not. `stdio: ["pipe", "pipe", "pipe"]` does not
suppress the window on Windows — only `windowsHide` does.

Fixes supermemoryai#101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2: execSync("git ...") spawns a visible cmd.exe window on Windows and breaks IME input

1 participant