Skip to content

Commit f1038d7

Browse files
CopilotpatnikoSteveSandersonMS
authored
Hide CLI console window on Windows across all SDKs (#329)
* Initial plan * Add hide_cli_window option to suppress console window on Windows Co-authored-by: patniko <26906478+patniko@users.noreply.github.com> * Address code review feedback: use conditional kwargs and idiomatic assertions Co-authored-by: patniko <26906478+patniko@users.noreply.github.com> * Make hiding CLI window default behavior across all SDKs - Python: Always hide window on Windows (removed hide_cli_window option) - Node.js: Add windowsHide: true to spawn options - Go: Add SysProcAttr with HideWindow on Windows via platform-specific files - .NET: Already had CreateNoWindow = true This ensures consistent behavior across all SDKs where the CLI subprocess console window is hidden on Windows to avoid distracting users in GUI apps. Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com> * Fix Go build --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: patniko <26906478+patniko@users.noreply.github.com> Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com> Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>
1 parent 273c425 commit f1038d7

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

go/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,9 @@ func (c *Client) startCLIServer(ctx context.Context) error {
10561056

10571057
c.process = exec.CommandContext(ctx, command, args...)
10581058

1059+
// Configure platform-specific process attributes (e.g., hide window on Windows)
1060+
configureProcAttr(c.process)
1061+
10591062
// Set working directory if specified
10601063
if c.options.Cwd != "" {
10611064
c.process.Dir = c.options.Cwd

go/process_other.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build !windows
2+
3+
package copilot
4+
5+
import "os/exec"
6+
7+
// configureProcAttr configures platform-specific process attributes.
8+
// On non-Windows platforms, this is a no-op.
9+
func configureProcAttr(cmd *exec.Cmd) {
10+
// No special configuration needed on non-Windows platforms
11+
}

go/process_windows.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//go:build windows
2+
3+
package copilot
4+
5+
import (
6+
"os/exec"
7+
"syscall"
8+
)
9+
10+
// configureProcAttr configures platform-specific process attributes.
11+
// On Windows, this hides the console window to avoid distracting users in GUI apps.
12+
func configureProcAttr(cmd *exec.Cmd) {
13+
cmd.SysProcAttr = &syscall.SysProcAttr{
14+
HideWindow: true,
15+
}
16+
}

nodejs/src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,12 +1053,14 @@ export class CopilotClient {
10531053
stdio: stdioConfig,
10541054
cwd: this.options.cwd,
10551055
env: envWithoutNodeDebug,
1056+
windowsHide: true,
10561057
});
10571058
} else {
10581059
this.cliProcess = spawn(this.options.cliPath, args, {
10591060
stdio: stdioConfig,
10601061
cwd: this.options.cwd,
10611062
env: envWithoutNodeDebug,
1063+
windowsHide: true,
10621064
});
10631065
}
10641066

python/copilot/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,9 @@ async def _start_cli_server(self) -> None:
11671167
if self.options.get("github_token"):
11681168
env["COPILOT_SDK_AUTH_TOKEN"] = self.options["github_token"]
11691169

1170+
# On Windows, hide the console window to avoid distracting users in GUI apps
1171+
creationflags = subprocess.CREATE_NO_WINDOW if sys.platform == "win32" else 0
1172+
11701173
# Choose transport mode
11711174
if self.options["use_stdio"]:
11721175
args.append("--stdio")
@@ -1179,6 +1182,7 @@ async def _start_cli_server(self) -> None:
11791182
bufsize=0,
11801183
cwd=self.options["cwd"],
11811184
env=env,
1185+
creationflags=creationflags,
11821186
)
11831187
else:
11841188
if self.options["port"] > 0:
@@ -1190,6 +1194,7 @@ async def _start_cli_server(self) -> None:
11901194
stderr=subprocess.PIPE,
11911195
cwd=self.options["cwd"],
11921196
env=env,
1197+
creationflags=creationflags,
11931198
)
11941199

11951200
# For stdio mode, we're ready immediately

0 commit comments

Comments
 (0)