Skip to content

[Windows] Console windows flash during shell execution with hooks enabled; disabling hooks avoids the issue #48826

Closed as duplicate

Description

@jgsjss

Update: The console window flashing appears to be related to hooks.

I retested in fresh sessions using the same working directory and
the same prompt asking Codex to print the current directory.

  • With hooks enabled, separate console windows briefly appeared
    and disappeared.
  • With codex --disable hooks, the flashing did not occur.

This suggests that hooks being enabled is a relevant trigger.
My original comparison between 0.157.1 and 0.155.1 should not be
treated as confirmation of a version-specific regression.

Disabling hooks is a workaround in my environment. I have not yet
isolated whether the cause is a specific configured hook or
Codex's hook execution handling.

What version of Codex CLI is running?

0.157.1

What subscription do you have?

pro

Which model were you using?

gpt 6.0 astra

What platform is your computer?

window

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

No response

Codex doctor report

What issue are you seeing?

On Windows, Codex CLI 0.157.1 repeatedly opens and closes separate
console windows when executing shell commands. This interrupts
other desktop work.

What steps can reproduce the bug?

  1. Launch Codex CLI 0.157.1 from PowerShell.
  2. Ask Codex to run a shell command, such as printing the current directory.
  3. Observe a separate console window briefly appear and disappear.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    CLIIssues related to the Codex CLI
    windows-osIssues related to Codex on Windows systems
    tool-callsIssues related to tool calling
    on Sep 28, 2026
  2. etraut-openai commented on Sep 28, 2026

    @etraut-openai
    Contributor

    Thanks for the bug report. We understand the problem and will have it fixed in the next release.

  3. changed the title [-][Windows] Console windows flash during shell execution in 0.157.1; does not occur in 0.155.1[/-] [+][Windows] Console windows flash during shell execution with hooks enabled; disabling hooks avoids the issue[/+] on Sep 28, 2026
  4. ScienHAC commented on Sep 28, 2026

    @ScienHAC

    Root cause found. codex-rs/hooks/src/engine/command_runner.rs spawns hook commands on Windows via JobObject::spawn_contained, which calls JobObject::prepare_suspended_spawn in codex-rs/utils/pty/src/win/job.rs:

    pub fn prepare_suspended_spawn(&self, command: &mut Command) {
        command.creation_flags(CREATE_SUSPENDED).kill_on_drop(true);
    }

    This only ever sets CREATE_SUSPENDED — it never sets CREATE_NO_WINDOW, on either the successful containment path or the two failure-fallback sites (command_runner.rs:231, and the equivalent in codex-rs/git-utils/src/git_process.rs) that reset creation_flags(0). Since Command::creation_flags on Windows replaces rather than combines flags, every hook command (and git subprocess) launched through this path has lacked console-window suppression, which matches --disable hooks working around it here.

    This is distinct from #48483, which correctly added CREATE_NO_WINDOW as the default for codex_utils_pty::Command — but that only covers the PTY/exec path, not this second, independent JobObject::prepare_suspended_spawn used by the hooks and git-utils crates.

    Fix (compiles clean via cargo check -p codex-utils-pty -p codex-hooks -p codex-git-utils): OR in CREATE_NO_WINDOW alongside CREATE_SUSPENDED in the shared prepare_suspended_spawn, and fix the two fallback sites to clear only CREATE_SUSPENDED instead of zeroing all flags.

    I can't open a PR directly (external PR creation appears restricted on this repo), but the fix is up on my fork if a maintainer wants to pull it in: ScienHAC@b51e128

    This same root cause likely also explains the git.exe-flashing reports in other open duplicates (e.g. #24910, #48356), since git-utils shares the identical fallback pattern.

  5. ScienHAC commented on Sep 28, 2026

    @ScienHAC

    Please fix it Asap!!

  6. etraut-openai commented on Sep 29, 2026

    @etraut-openai
    Contributor

    We're tracking this in #48074, and we're working on a fix.

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 CLIbugSomething isn't workingtool-callsIssues related to tool callingwindows-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