Skip to content

Commit ba04345

Browse files
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>
1 parent 973f616 commit ba04345

8 files changed

Lines changed: 36 additions & 24 deletions

File tree

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/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ await client.stop()
9797
- `auto_restart` (bool): Auto-restart on crash (default: True)
9898
- `github_token` (str): GitHub token for authentication. When provided, takes priority over other auth methods.
9999
- `use_logged_in_user` (bool): Whether to use logged-in user for authentication (default: True, but False when `github_token` is provided). Cannot be used with `cli_url`.
100-
- `hide_cli_window` (bool): Hide console window when spawning CLI process on Windows (default: False). Useful for GUI applications to prevent terminal windows from appearing.
100+
101+
> **Note:** On Windows, the SDK automatically hides the console window when spawning the CLI process to avoid distracting users in GUI applications.
101102
102103
**SessionConfig Options (for `create_session`):**
103104

python/copilot/client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ def __init__(self, options: Optional[CopilotClientOptions] = None):
184184
"auto_start": opts.get("auto_start", True),
185185
"auto_restart": opts.get("auto_restart", True),
186186
"use_logged_in_user": use_logged_in_user,
187-
"hide_cli_window": opts.get("hide_cli_window", False),
188187
}
189188
if opts.get("cli_url"):
190189
self.options["cli_url"] = opts["cli_url"]
@@ -1174,9 +1173,8 @@ async def _start_cli_server(self) -> None:
11741173
"env": env,
11751174
}
11761175

1177-
# Add creation flags for Windows to hide console window if requested
1178-
if sys.platform == "win32" and self.options.get("hide_cli_window", False):
1179-
# CREATE_NO_WINDOW flag prevents console window from appearing on Windows
1176+
# On Windows, hide the console window to avoid distracting users in GUI apps
1177+
if sys.platform == "win32":
11801178
popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW
11811179

11821180
# Choose transport mode

python/copilot/types.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ class CopilotClientOptions(TypedDict, total=False):
9595
# When False, only explicit tokens (github_token or environment variables) are used.
9696
# Default: True (but defaults to False when github_token is provided)
9797
use_logged_in_user: bool
98-
# Whether to hide the console window when spawning the CLI process on Windows.
99-
# When True, prevents the CLI subprocess from showing a console window on Windows.
100-
# This is useful for GUI applications that should not display terminal windows.
101-
# Default: False (console window is visible)
102-
hide_cli_window: bool
10398

10499

105100
ToolResultType = Literal["success", "failure", "rejected", "denied"]

python/test_client.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,3 @@ def test_use_logged_in_user_with_cli_url_raises(self):
147147
CopilotClient(
148148
{"cli_url": "localhost:8080", "use_logged_in_user": False, "log_level": "error"}
149149
)
150-
151-
152-
class TestHideCliWindow:
153-
def test_hide_cli_window_default_false(self):
154-
client = CopilotClient({"log_level": "error"})
155-
assert not client.options.get("hide_cli_window")
156-
157-
def test_hide_cli_window_explicit_true(self):
158-
client = CopilotClient({"hide_cli_window": True, "log_level": "error"})
159-
assert client.options.get("hide_cli_window")
160-
161-
def test_hide_cli_window_explicit_false(self):
162-
client = CopilotClient({"hide_cli_window": False, "log_level": "error"})
163-
assert not client.options.get("hide_cli_window")

0 commit comments

Comments
 (0)