Skip to content

Comments

Port upstream PR #329: Hide CLI console window on Windows#28

Merged
krukow merged 3 commits intomainfrom
copilot/port-upstream-pr-329
Feb 21, 2026
Merged

Port upstream PR #329: Hide CLI console window on Windows#28
krukow merged 3 commits intomainfrom
copilot/port-upstream-pr-329

Conversation

Copy link
Contributor

Copilot AI commented Feb 21, 2026

Upstream PR #329 adds windowsHide: true (Node.js), CREATE_NO_WINDOW (Python), and SysProcAttr.HideWindow (Go) to prevent a console window flash when spawning the CLI from GUI applications.

JVM already handles this — OpenJDK's ProcessImpl_md.c sets CREATE_NO_WINDOW automatically when all stdio handles are pipes (not inherited from parent console):

// ProcessImpl_md.c — processCreate()
DWORD processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT;
if (GetConsoleWindow() != NULL &&
    (si.hStdInput == stdIOE[0] || si.hStdOutput == stdIOE[1] || ...))
    processFlag &= ~CREATE_NO_WINDOW;  // only removed when handles are inherited

Since ProcessBuilder defaults to Redirect.PIPE for all streams, we get CREATE_NO_WINDOW for free. No JNA needed.

  • process.clj: Add explicit Redirect.PIPE calls for all three streams — makes the Windows intent self-documenting and guards against regressions if someone later switches a redirect to INHERIT
  • CHANGELOG.md: Upstream sync entry for PR #329
Original prompt

This section details on the original issue you should resolve

<issue_title>Port upstream PR #329: Hide CLI console window on Windows</issue_title>
<issue_description>## Upstream Change

Upstream PR github/copilot-sdk#329 adds automatic hiding of the CLI console window on Windows when spawning the CLI subprocess. This prevents a distracting terminal window appearing in GUI applications.

Node.js change (nodejs/src/client.ts):

this.cliProcess = spawn(command, spawnArgs, {
    stdio: ...,
    cwd: this.options.cwd,
    env: envWithoutNodeDebug,
    windowsHide: true,  // <-- added
});

Why Not Auto-Ported

The Clojure SDK uses Java's ProcessBuilder to spawn the CLI process (src/github/copilot_sdk/process.clj). Unlike Node.js's spawn which has a built-in windowsHide option, ProcessBuilder does not support hiding the Windows console window natively.

Options to port this to JVM:

  1. JNA (Java Native Access) — Add a JNA dependency and call Windows CreateProcess directly with CREATE_NO_WINDOW. This adds a native dependency but works cleanly.

  2. Reflection into ProcessImpl — Fragile, not recommended.

  3. Accept as JVM limitation — Document that on Windows, a console window may briefly appear. The SDK primarily targets server-side use cases where this is less of a concern.

  4. ProcessBuilder.inheritIO() + redirects — Doesn't help with window visibility.

Recommendation

If the Clojure SDK targets Windows GUI applications, option 1 (JNA) is the cleanest approach. Otherwise, document the limitation.

The relevant Clojure file to modify is src/github/copilot_sdk/process.clj, specifically the spawn-cli function (lines 29-88).

Affected Upstream Files

  • nodejs/src/client.tswindowsHide: true in both stdio and TCP spawn calls
  • python/copilot/client.pyCREATE_NO_WINDOW flag on Windows
  • go/client.go + go/process_windows.go — platform-specific SysProcAttr.HideWindow

Testing

After implementing, verify that on Windows, no console window appears when using the SDK from a GUI application (e.g., a JavaFX or Swing app).

Generated by Upstream Sync Agent

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Add explicit PIPE redirect configuration to ProcessBuilder in spawn-cli,
ensuring the JVM sets CREATE_NO_WINDOW on Windows. This prevents a
console window from appearing when spawning the CLI from GUI applications.

The JVM's ProcessImpl already uses CREATE_NO_WINDOW when all stdio handles
are pipes (not inherited from parent console). Making the PIPE redirects
explicit documents this intent and protects against regressions.

Co-authored-by: krukow <3635+krukow@users.noreply.github.com>
Copilot AI changed the title [WIP] Port upstream PR #329 to hide CLI console window on Windows Port upstream PR #329: Hide CLI console window on Windows Feb 21, 2026
@krukow krukow marked this pull request as ready for review February 21, 2026 10:12
Copilot AI review requested due to automatic review settings February 21, 2026 10:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ports upstream PR #329, which adds automatic hiding of the CLI console window on Windows when spawning the CLI subprocess from GUI applications. While the upstream Node.js SDK added an explicit windowsHide: true option, the JVM already provides this behavior through OpenJDK's ProcessImpl_md.c, which sets CREATE_NO_WINDOW when all stdio handles use PIPE redirects (not INHERIT).

Changes:

  • Made PIPE redirects explicit in spawn-cli to ensure Windows console hiding and document the intent
  • Added CHANGELOG entry documenting the upstream sync

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/github/copilot_sdk/process.clj Added explicit PIPE redirects for stdin/stdout/stderr with detailed comments explaining the Windows CREATE_NO_WINDOW behavior
CHANGELOG.md Added entry under "Added (upstream PR #329 sync)" documenting the Windows console window hiding feature

Copy link
Collaborator

@krukow krukow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed PR #28. I don't see any blocking issues: explicit PIPE redirects in process.clj preserve current behavior while making the Windows no-console intent explicit, and the changelog entry accurately documents the upstream parity.

@krukow krukow merged commit ed12088 into main Feb 21, 2026
6 checks passed
@krukow krukow deleted the copilot/port-upstream-pr-329 branch February 21, 2026 10:32
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.

Port upstream PR #329: Hide CLI console window on Windows

2 participants