mirror of
https://github.com/openai/codex.git
synced 2026-04-30 19:32:04 +03:00
fix: add tui.alternate_screen config and --no-alt-screen CLI flag for Zellij scrollback (#8555)
Fixes #2558 Codex uses alternate screen mode (CSI 1049) which, per xterm spec, doesn't support scrollback. Zellij follows this strictly, so users can't scroll back through output. **Changes:** - Add `tui.alternate_screen` config: `auto` (default), `always`, `never` - Add `--no-alt-screen` CLI flag - Auto-detect Zellij and skip alt screen (uses existing `ZELLIJ` env var detection) **Usage:** ```bash # CLI flag codex --no-alt-screen # Or in config.toml [tui] alternate_screen = "never" ``` With default `auto` mode, Zellij users get working scrollback without any config changes. --------- Co-authored-by: Josh McKinney <joshka@openai.com>
This commit is contained in:
@@ -80,3 +80,38 @@ pub enum TrustLevel {
|
||||
Trusted,
|
||||
Untrusted,
|
||||
}
|
||||
|
||||
/// Controls whether the TUI uses the terminal's alternate screen buffer.
|
||||
///
|
||||
/// **Background:** The alternate screen buffer provides a cleaner fullscreen experience
|
||||
/// without polluting the terminal's scrollback history. However, it conflicts with terminal
|
||||
/// multiplexers like Zellij that strictly follow the xterm specification, which defines
|
||||
/// that alternate screen buffers should not have scrollback.
|
||||
///
|
||||
/// **Zellij's behavior:** Zellij intentionally disables scrollback in alternate screen mode
|
||||
/// (see https://github.com/zellij-org/zellij/pull/1032) to comply with the xterm spec. This
|
||||
/// is by design and not configurable in Zellij—there is no option to enable scrollback in
|
||||
/// alternate screen mode.
|
||||
///
|
||||
/// **Solution:** This setting provides a pragmatic workaround:
|
||||
/// - `auto` (default): Automatically detect the terminal multiplexer. If running in Zellij,
|
||||
/// disable alternate screen to preserve scrollback. Enable it everywhere else.
|
||||
/// - `always`: Always use alternate screen mode (original behavior before this fix).
|
||||
/// - `never`: Never use alternate screen mode. Runs in inline mode, preserving scrollback
|
||||
/// in all multiplexers.
|
||||
///
|
||||
/// The CLI flag `--no-alt-screen` can override this setting at runtime.
|
||||
#[derive(
|
||||
Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq, Display, JsonSchema, TS,
|
||||
)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
pub enum AltScreenMode {
|
||||
/// Auto-detect: disable alternate screen in Zellij, enable elsewhere.
|
||||
#[default]
|
||||
Auto,
|
||||
/// Always use alternate screen (original behavior).
|
||||
Always,
|
||||
/// Never use alternate screen (inline mode only).
|
||||
Never,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user