--no-alt-screen still does not preserve scrollback in xterm.js-based terminals (VS Code integrated terminal reproduces)`

Open 💬 5 comments Opened Mar 11, 2026 by imsuperli

What version of Codex CLI is running?

0.111.0

What subscription do you have?

Plus

Which model were you using?

gpt-5.4

What platform is your computer?

windows 11 x64

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

Windows Terminal (powershell)

What issue are you seeing?

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

Reproduces in:

  • VS Code integrated terminal
  • My own Electron app embedding xterm.js

Does not reproduce in:

  • Windows Terminal + PowerShell 7

### What issue are you seeing?

When I run codex --no-alt-screen, once the conversation exceeds one screen, I still cannot scroll back to earlier content in xterm.js-based terminals. I can only see the currently visible screen contents.

I also reproduced the same issue in the VS Code integrated terminal, so this does not appear to be specific to my own Electron app.

This makes --no-alt-screen hard to use as a practical workaround for terminal scrollback, because disabling the alternate screen does not actually preserve the prior conversation in these environments.

Behavior summary:

  • In Windows Terminal + PowerShell 7, I can scroll back normally.
  • In xterm.js-based terminals (my Electron app and VS Code integrated terminal), I cannot.

Based on discussion in xtermjs/xterm.js#5745, an xterm.js maintainer suggested that Codex may be explicitly clearing the visible screen and purging scrollback on the normal buffer (for example via CSI
2J
/ CSI 3J) instead of only avoiding the alternate screen. If that analysis is correct, then --no-alt-screen still does not provide native scrollback in terminals that implement those control sequences
strictly.

This seems related to earlier Codex issues around scrollback / alternate screen, but not fully solved by --no-alt-screen.

What steps can reproduce the bug?

  1. Open a VS Code integrated terminal on Windows.
  2. Run codex --no-alt-screen.
  3. Have a conversation long enough to exceed one screen.
  4. Try to scroll up to view earlier conversation content.
  5. Observe that only the current screen contents are available.
  6. Repeat the same test in an Electron app using xterm.js and observe the same behavior.
  7. Repeat the same test in Windows Terminal + PowerShell 7 and note that scrollback works there.

What is the expected behavior?

codex --no-alt-screen should preserve earlier conversation output in the terminal's normal scrollback buffer, so users can scroll up and review previous content in terminals that support native scrollback.

At minimum, --no-alt-screen should avoid behavior that clears or purges normal-buffer scrollback.

Additional information

I already opened an xterm.js issue here:
https://github.com/xtermjs/xterm.js/issues/5745

In that thread, an xterm.js maintainer suggested the current behavior may be caused by Codex explicitly issuing clear / purge sequences on the normal buffer, and that stricter terminals may therefore be
behaving as designed.

If that analysis is correct, the request here is not "please change xterm.js", but rather one of the following on the Codex side:

  • make --no-alt-screen a true scrollback-preserving mode in the normal buffer, or
  • provide a separate inline / append-only renderer mode that does not rely on full-screen redraw plus clear/purge behavior, or
  • clarify in the documentation that --no-alt-screen does not guarantee usable native scrollback in strict terminals.

Potentially relevant Codex source reference discussed in the xterm.js thread:
https://github.com/openai/codex/blob/2bc3e52a91bb88a0e067a95f8f8559f8711d30e6/codex-rs/tui/src/custom_terminal.rs#L469

I can provide logs or a minimal reproduction if that would help.

参考

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗