Can't enter alternate screen buffer
What version of Codex CLI is running?
codex-cli 0.133.0
What subscription do you have?
gpt-5.5
Which model were you using?
gpt-5.5
What platform is your computer?
Linux 6.19.10-300.fc44.x86_64 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
screen/tmux
Codex doctor report
What issue are you seeing?
Subject
TUI fails to enter Alternate Screen Buffer when tui.alternate_screen = "always" on Linux/Fedora
Describe the Bug
Even when tui.alternate_screen is explicitly set to "always" in ~/.codex/config.toml (or passed via CLI overrides), Codex CLI (v0.133.0) fails to transition to the terminal's alternate screen buffer.
Instead of taking over the viewport in a clean, full-screen mode (like vim), the TUI continues to render inline directly within the primary screen buffer (main scrollback). Upon exiting the CLI (via /exit or Ctrl+C), the welcome banner, help prompts, and interactive history are not cleared and remain permanently in the terminal's scrollback history, polluting the shell.
Environment
- Codex CLI Version: v0.133.0
- Operating System: Fedora Linux (Workstation)
- Terminal Emulator: [Please insert your terminal name here, e.g., GNOME Terminal, Alacritty, iTerm2]
- TERM Variable:
xterm-256color/xterm
Steps to Reproduce
- Configure
~/.codex/config.tomlwith the following:
```toml
[tui]
alternate_screen = "always"
What steps can reproduce the bug?
start codex-cli
What is the expected behavior?
_No response_
Additional information
_No response_
4 Comments
One focused triage note from a local repo read: the config path appears to be fairly direct:
config.tui_alternate_screenis passed throughdetermine_alt_screen_mode(), and anything other thanAltScreenMode::Neverenables alt-screen unless--no-alt-screenis set. The actual enter path then callsEnterAlternateScreenincodex-rs/tui/src/tui.rs, but currently ignores the crossterm result.That makes this issue especially useful if the reporter can add:
~/.codex/config.tomlsnippet, including whether it is under[tui]codex --config tui.alternate_screen=alwayschanges behaviorecho $TERM,infocmp | grep -E "smcup|rmcup", and whether tmux/screen has terminal overrides that disable alternate-screen switchingIf this turns out to be terminal capability related, a small product improvement might be to stop swallowing
EnterAlternateScreen/LeaveAlternateScreenfailures and surface a warning incodex doctoror startup diagnostics whenalwaysis configured but the terminal does not actually switch buffers.I have the exact same issue on Mac.
I have set
tui.alternate_screento"always"in~/.codex/config.tomlas well. Runningcodex --config tui.alternate_screen=alwayshad no effect, the issue still occurs.infocmp | grep -E "smcup|rmcup"- both present.I was not using screen/tmux/zellij. My Copilot CLI and Claude code and other programs are able to use alternate screen in the same terminal, so i don't think it's a terminal capability related issue.
This my tui settings in
~/.codex/config.toml, if it helps.I can reproduce this on codex-cli 0.144.6 on macOS 26.3.2.
Terminals tested:
Configuration:
I verified that the configuration is recognized:
codex --strict-config doctor --jsonreportsconfig.load: ok. These were fresh Codex sessions, with no--no-alt-screenflag and no tmux, Zellij, or screen involved.In both terminals, scrolling moves the entire Codex UI, including the composer/input box, as if Codex were still rendering in the primary terminal buffer. Setting
alternate_screen = "always"does not change the behavior.This suggests the issue is still present in 0.144.6 and is not specific to a particular macOS terminal emulator.
Follow-up after additional iTerm2 testing (2026-07-22): this owned-screen series correctly establishes a retained full-screen viewport, pinned composer, paused follow state, and jump control, but its current fixed-step virtual wheel scroller does not yet match Claude Code’s mature fullscreen scrolling behavior. Please treat this branch as an experimental prototype rather than a production-ready parity claim. For natural iTerm2 scrolling and selection today, use the isolated native-scrollback branch: https://github.com/Andrewwilliamross/codex/tree/agent/fix-iterm2-native-scrollback.
I confirmed this is not a missing terminal capability: the current
tui.alternate_screen = "always"path does not give Codex ownership of a retained full-screen viewport.I ported OpenAI’s public
fcoury/owned-alt-screen-text-selectionprototype onto currentmain, preserving Felipe Coury’s authorship, and completed the user-facing interaction:always: Codex physically owns the alternate screen and retains the conversation viewportauto: existing overlay-only inline behavior remains unchangednever/--no-alt-screen: native terminal scrollback remains availableJump to bottom (click) ↓control restores the latest output and follow stateExperimental branch: https://github.com/Andrewwilliamross/codex/tree/agent/fix-iterm2-scrollback
The owned-screen foundation is split into the original-author commits
642345cdf339throughf653664b5586; the jump control and current-maincompatibility are indfa4ccd3d19e.Functional verification: 3,259
codex-tuitests passed, 4 skipped, package fixer/formatter passed, and the basic scroll/pause/draft/click/resume flow passed manual iTerm2 testing. Further human testing identified the scroll-feel limitation described above.If this architecture matches the intended semantics for
always, I’m happy to continue refining it or split the series however maintainers prefer.