Skip to content

fix(appcontainer): suppress empty console window for piped sandbox children#569

Merged
MGudgin merged 1 commit into
microsoft:mainfrom
caarlos0:windows-nowindow
Jun 25, 2026
Merged

fix(appcontainer): suppress empty console window for piped sandbox children#569
MGudgin merged 1 commit into
microsoft:mainfrom
caarlos0:windows-nowindow

Conversation

@caarlos0

@caarlos0 caarlos0 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

📖 Description

The Windows ProcessContainer backends (BaseContainer + AppContainer) launched
console-subsystem children (e.g. pwsh, cmd, rg, …)
without CREATE_NO_WINDOW. On a headless host with piped stdio Windows
allocates a new console that briefly flashes on screen, even though stdio is
redirected via pipes (STARTF_USESTDHANDLES).

This sets CREATE_NO_WINDOW on both spawn paths (base_container_runner and
appcontainer_runner, including BaseContainer's env-not-supported retry) when
stdio is piped:

let no_window_flag = if pipe_mode { CREATE_NO_WINDOW.0 } else { 0 };

The pipe_mode guard is essential: in console-sharing (ConPTY) mode the child
inherits the parent's live console for interactive I/O, where CREATE_NO_WINDOW
must not be set (it would detach the child and break the interactive shell). The
mxc-sdk streaming dispatch always spawns with StdioMode::Pipes, so pipe_mode
is always true for SDK callers.

🔗 References

n/a

🔍 Validation

  • cargo fmt --all -- --check, cargo clippy -p wxc_common -p mxc-sdk --all-targets -- -D warnings, and cargo test -p wxc_common -p mxc-sdk pass on the pinned 1.93 toolchain.
  • The two runner files are cfg(windows)-gated and can't be compiled on macOS; the change only conditionally OR-s CREATE_NO_WINDOW into the existing creation flags and was matched against rustfmt output. Windows build/test coverage comes from CI.

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

…ildren

The Windows ProcessContainer backends (BaseContainer + AppContainer) launched
console-subsystem children (pwsh, cmd, rg, LSP shims, MCP stdio servers, …)
without CREATE_NO_WINDOW. On a headless host with piped stdio — the in-process
mxc-sdk streaming path now used by copilot-agent-runtime — Windows allocates a
new console that briefly flashes on screen even though stdio is redirected.

Set CREATE_NO_WINDOW on both spawn paths (including BaseContainer's
env-not-supported retry) when stdio is piped. The pipe_mode guard is essential:
in console-sharing (ConPTY) mode the child inherits the parent's live console
for interactive I/O, where CREATE_NO_WINDOW must not be set. The mxc-sdk always
streams over pipes, so it gets windowless spawns with no API or consumer change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 25, 2026 13:52
@caarlos0 caarlos0 requested a review from a team as a code owner June 25, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 prevents brief “empty console window” flashes when the Windows ProcessContainer backends (BaseContainer + AppContainer) spawn console-subsystem children with piped stdio (the mxc-sdk streaming path). It does so by conditionally adding CREATE_NO_WINDOW to the process creation flags only when pipe_mode is active, preserving ConPTY/console-sharing behavior for interactive runs.

Changes:

  • Add CREATE_NO_WINDOW to BaseContainer child creation flags when pipe_mode is true (including the env-not-supported retry path).
  • Add CREATE_NO_WINDOW to AppContainer CreateProcessW flags when pipe_mode is true.
Show a summary per file
File Description
src/backends/appcontainer/common/src/base_container_runner.rs ORs CREATE_NO_WINDOW into BaseContainer process creation flags when pipe_mode is enabled, including retry without env block.
src/backends/appcontainer/common/src/appcontainer_runner.rs ORs CREATE_NO_WINDOW into AppContainer CreateProcessW flags when pipe_mode is enabled.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@caarlos0 caarlos0 closed this Jun 25, 2026
@caarlos0 caarlos0 reopened this Jun 25, 2026
@MGudgin MGudgin merged commit 22f8a46 into microsoft:main Jun 25, 2026
32 of 33 checks passed
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.

3 participants