Skip to content

Windows: visible console windows flash for shell process children on every session/turn #48422

Description

@qwq233

What version of Codex CLI is running?

codex-cli 0.157.1

What subscription do you have?

Plus

Which model were you using?

No response

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

Windows Terminal + Powershell

Codex doctor report

What issue are you seeing?

On Windows, a batch of visible console windows flashes for git.exe / pwsh.exe (and other helper) child processes:

  • several git.exe windows on every new session, and again on every turn;
  • pwsh.exe windows for shell/exec child processes.

What steps can reproduce the bug?

  1. On Windows, run codex interactively (e.g. in Windows Terminal) on a project inside a git repository (default config, no --no-daemon).
  2. Start a new thread and send a turn.
  3. Observe console windows flashing for git.exe (session start + every turn) and pwsh.exe (shell/exec helpers).

Workaround that confirms the diagnosis: codex --no-daemon runs the session embedded in the TUI process (console attached), and the flashing stops.

What is the expected behavior?

No visible console windows. Helper subprocesses spawned by the console-less daemon backend should either inherit a hidden console or be created with CREATE_NO_WINDOW.

Additional information

Source analysis at tag rust-v0.157.1:

Why the spawning process has no console:

  • codex-rs/features/src/lib.rs:941-944 — daemon_auto_start is enabled by default.
  • codex-rs/tui/src/startup_orchestration.rs:494-544 — TUI auto-starts the shared daemon and targets AppServerTarget::LocalDaemon (session runs in the daemon's app-server backend, not in the TUI).
  • codex-rs/app-server-daemon/src/backend/pid_start.rs:209 — backend spawn uses DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB → no console. spawn_without_inheriting_stdio (backend/windows.rs:56+) only clears stdio handle inheritance and adds no window suppression.

Unsuppressed child spawns from that console-less backend:

  • git.exe (dominant source): codex-rs/git-utils/src/git_process.rs:47-63 goes through JobObject::spawn_contained, and codex-rs/utils/pty/src/win/job.rs:125-127 only sets CREATE_SUSPENDED (no CREATE_NO_WINDOW); the fallback path resets creation_flags(0). Volume: new session → codex-rs/rollout/src/recorder.rs:1977-1978 → collect_git_info (git-utils/src/info.rs:66-82) = 4 spawns; every turn → codex-rs/core/src/turn_metadata.rs:547-551 = 3 more (plus a possible fsmonitor probe). Direct Command::new("git") sites in git-utils (apply.rs / baseline.rs / branch.rs / operations.rs) share the gap.
  • pwsh.exe / shell helpers: codex-rs/exec-server/src/fs_sandbox.rs:516, codex-rs/exec-server/src/shell_snapshot.rs:287, codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs:118 (ConsoleMode::Inherit, mapped to flags 0 in process.rs:109-113; default WindowsSandboxLevel::Disabled takes this path), codex-rs/hooks/src/engine/command_runner.rs:233-245, codex-rs/hooks/src/legacy_notify.rs:53-66, codex-rs/cli/src/desktop_app/windows.rs:34-56.
  • The codebase already sets CREATE_NO_WINDOW correctly elsewhere (e.g. bin/command_runner/win.rs:351, rmcp-client/src/stdio_server_launcher.rs:297), so this looks like an omission.
  • Checked against current main (e72da2b, 2026-09-26): git_process.rs, job.rs, legacy.rs, pid_start.rs are unchanged vs 0.157.1 — upgrading does not fix this.

Suggested fix:

  1. Minimal: in codex-rs/app-server-daemon/src/backend/pid_start.rs:209, replace DETACHED_PROCESS with CREATE_NO_WINDOW (keeps the backend detached from the launching terminal and breakaway-safe, but gives it a hidden console that children inherit — removes the flashing for all daemon-managed backends in one line).
  2. Robust: also set CREATE_NO_WINDOW at the individual spawn sites above (git_process / job.rs, unified_exec legacy backend + (None, NoWindow) mapping in process.rs:109-113, exec-server spawns, hooks, desktop_app powershell) so any console-less parent is covered.

This issue is written by codex and review by human.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIapp-serverIssues involving app server protocol or interfacesbugSomething isn't workingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions