Skip to content

Conversation

@muyuanjin
Copy link
Contributor

What

Fix terminal history truncation that can occur when clearing a multi-line input with Ctrl+C after a /status command, and add a regression test around the TUI history handling.

Why

In some cases the Codex CLI would appear to "lose" earlier parts of the session history, including the initial /status command and even parts of the welcome banner, after the following sequence:

  1. Start Codex CLI.
  2. Run /status and wait for the status card to finish rendering.
  3. Paste a multi-line input into the prompt (for example 1\n2\n...\n30\n).
  4. Do not send the message; press Ctrl+C once to clear the input.
  5. Paste another multi-line input and press Ctrl+C again.

After a few repetitions, earlier history from the terminal scrollback (including /status output, and sometimes the >_ OpenAI Codex (v...) banner) would intermittently disappear and could not be recovered by scrolling.

This change fixes that behavior in the TUI so that the terminal history remains intact when clearing multi-line input, even after repeated Ctrl+C operations.

How

  • Add a regression test that exercises the TUI / history path around multi-line input and Ctrl+C clearing.
  • Adjust the TUI history handling so that clearing the input does not cause the underlying recorded terminal history to be truncated.

The new test fails before this fix and passes after it, which helps guard against regressions in this area.

Notes / Related Issues

  • This should improve the behavior described in Codex Truncates Chat Messages When Scrolling #6427 and also help with similar cases like Codex client output truncated when scrolling in Zellij #2558 where terminal history appeared to be lost.

  • Once history is preserved more reliably, it becomes easier to notice another, possibly related, issue: occasionally Codex will emit very large outputs directly into the normal conversation stream instead of folding them into the history view (Ctrl+T). For example, during testing I observed a run of:

    Ran bash -lc "grep -R --line-number 'maskAssetId' ."
    

    which produced tens of screens of output in the primary chat view without being folded.

    These sporadic, unfolded long outputs might have contributed to earlier reports of history "disappearing", since they can push a large amount of content through the terminal and interact badly with scrollback limits.

I am happy to adjust the test naming or structure if you prefer a different place for this regression test.

@etraut-openai
Copy link
Collaborator

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@muyuanjin
Copy link
Contributor Author

This PR should also improve issue #5589. I found the terminal history to be much more stable during testing.

@muyuanjin muyuanjin force-pushed the bug/terminal-history-truncation branch from 8fb88df to c5adb0a Compare December 1, 2025 17:04
@etraut-openai
Copy link
Collaborator

After reviewing the PR, we've decided to pass on this fix. While it does mitigate several bugs that were previously reported, it potentially creates other issues.

A member of the codex team is currently working on a significant update to the code that writes cells to the screen. This change aims to address these bugs in a more holistic way.

Thanks again for taking the time to submit the PR.

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