codex - ✅(Solved) Fix closing terminal with a pending command approval approves and executes the command [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17276Fetched 2026-04-10 03:43:09
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×4unlabeled ×2

PR fix notes

PR #17430: Handle closed TUI input stream as shutdown

Description (problem / solution / changelog)

Addresses #17276

Problem: Closing the terminal while the TUI input stream is pending could leave the app outside the normal shutdown path, which is risky when an approval prompt is active.

Solution: Treat a closed TUI input stream as ShutdownFirst so existing thread shutdown behavior cancels pending work and approvals before exit.

Changed files

  • codex-rs/tui/src/app.rs (modified, +9/-4)
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

0.118

What subscription do you have?

pro

Which model were you using?

5.4-high

What platform is your computer?

darwin

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

ghostty

What issue are you seeing?

5.4 requested to run an extremely destructive, harmful command (essentially nuking valuable data). at that point, the particular instance already showed a repeated pattern of being unhinged and misaligned, so I just closed the whole ghostty window instead of giving it a chance to course correct.

closing the window triggered the command to be invoked before exit, causing a few thousand dollars in data loss.

I get that users sign up for a lot of risk using a scrappy product like this, and that closing the window at that time was dumb, but I am confused as to why the app is architected like this.

What steps can reproduce the bug?

  1. have codex request a malicious, destructive command
  2. do not approve it due to how expensive and catastrophic the loss would be
  3. close the ghostty window

What is the expected behavior?

for command approval functionality to work, and for the overall system to not override the approval dialog and run destructive commands without me at least picking an option. or for clear warning like "approvals are not supposed to actually work, the system can randomly override and run things that violate your settings"

Additional information

No response

extent analysis

TL;DR

The issue can be mitigated by changing the behavior of the Codex CLI to not execute commands when the terminal window is closed, especially when a destructive command has been requested but not approved.

Guidance

  • Verify the current configuration of the Codex CLI to see if there are any settings that can be changed to prevent commands from being executed when the terminal window is closed.
  • Check if there are any updates to the Codex CLI that address this issue, as the current version (0.118) may have a bug that is causing this behavior.
  • Consider adding a confirmation prompt before closing the terminal window to ensure that any pending commands are not executed.
  • Review the documentation for the Codex CLI to see if there are any known issues or workarounds for this problem.

Example

No code snippet is provided as the issue does not imply a specific code-based solution.

Notes

The issue may be specific to the combination of the Codex CLI version (0.118), the subscription type (pro), and the terminal emulator (ghostty) being used. Further investigation is needed to determine the root cause of the problem.

Recommendation

Apply a workaround, such as adding a confirmation prompt before closing the terminal window, until a fixed version of the Codex CLI is available. This is because the current behavior of the Codex CLI poses a significant risk of data loss, and a workaround can help mitigate this risk until a more permanent solution is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING