Skip to content

bug(core): llm and setup subprocesses still open console windows on Windows #641

Description

@Alan-TheGentleman

📋 Pre-flight Checks

  • I have searched existing issues and this is not a duplicate
  • I understand this issue needs status:approved before a PR can be opened

📝 Bug Description

Follow-up to #599, which was fixed in #604 for the project-detection path only.

#604 introduced newProjectCommandContext in internal/project, a build-tagged helper that sets SysProcAttr{HideWindow: true} on Windows so git.exe subprocesses no longer allocate a visible console. It was wired into detectGitRootDir and detectFromGitRemote, the two call sites named in #599's evidence chain.

Two other subprocess call sites have the same problem and were deliberately left out of #604's scope:

  • internal/llm/claude.go:140defaultRunCLI spawns the agent CLI (claude, opencode) via exec.CommandContext. On Windows this flashes a console window the same way, and it runs whenever an LLM-backed feature is invoked.
  • internal/setup/setup.go:36runCommand uses exec.Command(...).CombinedOutput(). This one runs during interactive engram setup, where a console window is much less surprising, so it is lower priority.

🔄 Steps to Reproduce

On Windows, trigger any code path that reaches defaultRunCLI (an LLM-backed command) and observe the transient console window, same signature as #599: a conhost.exe / terminal window appearing and vanishing.

✅ Expected Behavior

Subprocesses spawned by Engram on Windows should not allocate a visible console.

❌ Actual Behavior

internal/llm and internal/setup subprocesses still allocate one.

📦 Affected Area

Core (internal/llm, internal/setup)

💡 Proposed Solution

Reuse the pattern from #604 rather than duplicating it. newProjectCommandContext currently lives in internal/project and is unexported, so lifting it into a small shared internal package (something like internal/proc) that project, llm, and setup can all import is probably cleaner than three build-tagged copies.

Note that internal/setup/setup.go wraps the call in a runCommand function variable for test injection, so the helper needs to fit that seam.

📎 Additional Context

Worth keeping the cross-compile check that #604's review established: GOOS=windows GOARCH=amd64 go build ./.... The Windows-only files never compile on macOS/Linux dev machines or in the default CI job, so they can break without anyone noticing until a Windows user reports it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions