-
Notifications
You must be signed in to change notification settings - Fork 7.1k
fix: add tui.alternate_screen config and --no-alt-screen CLI flag for Zellij scrollback #8555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: add tui.alternate_screen config and --no-alt-screen CLI flag for Zellij scrollback #8555
Conversation
Fixes openai#2558 - Zellij users cannot scroll back due to alternate screen mode. This adds: - `AltScreenMode` enum with values: auto, always, never - `tui.alternate_screen` config option (default: auto) - `--no-alt-screen` CLI flag to force inline mode - Auto-detection: When running in Zellij (detected via ZELLIJ env vars), alternate screen is automatically disabled to preserve scrollback The implementation: - Detects Zellij using existing terminal_info() infrastructure - In "auto" mode, skips enter_alt_screen() when in Zellij - In "never" mode or with --no-alt-screen flag, always uses inline mode - In "always" mode, uses alternate screen (original behavior)
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
Addresses review comments: - Resume picker now respects --no-alt-screen flag - Legacy TUI now properly wires up the flag The fix adds an alt_screen_enabled flag to the Tui struct that makes enter_alt_screen()/leave_alt_screen() no-ops when false. This ensures all call sites (resume picker, overlays, etc.) respect the setting.
|
Thanks for the diagnosis and the PR. I'm not that excited about exposing a configuration knob for this. We will probably look for a better solution. However, your diagnosis is valuable regardless. I'll need to discuss with my colleagues to decide what to do here since I'm personally not that familiar with the TUI code. Most of the codex team is on holiday break, so it may be a week or more before we have a chance to discuss and make a decision. |
|
Hey, totally understand the hesitation on the config knob - I was not thrilled about it either tbh. I spent some time digging into this to see if there is a better way. Here is what I found: On Zellij side: They intentionally disabled scrollback in alternate screen (zellij-org/zellij#1032) to follow the xterm spec strictly. This was not a bug - it is by design. The xterm spec says alternate screen buffers should not have scrollback, and Zellij follows that. There is no config option to change it and unlikely to ever be one. How others handle it: tmux has Looking at TUI2: I noticed the transcript-based architecture already prints history to scrollback on exit/suspend, which is great - but that does not help when you want to scroll back during the session without quitting. And while Ctrl+T opens the transcript pager, it is not the same as natural scrollback - you have to context-switch into a separate view. So realistically the options are:
I am happy to strip out the config options entirely and just make it pure auto-detection if that feels cleaner? No user-facing knobs, just "it works in Zellij" silently. No rush on this - enjoy the holidays! Just wanted to share what I found in case it is useful for the discussion. |
|
Hey, I hope you don't mind me chiming in. I came upon this PR because this issue has been reported quite a few times on the Zellij side. @hjanuschka 's analysis is accurate. This is one of those "you can't have your cake and eat it" sort of situations. I don't know your requirements or time/workforce availability - but I think your utopian solution would be to implement scrollback on your own. If you control all the contents in the scrollback (and don't need to include output from arbitrary programs) this should be fairly straightforward. Otherwise, you can use some sort of off-the-shelf terminal emulation solution to do it for you. Hope this helps. |
|
Just want to provide additional context on how other LLM CLI tools handle this:
|
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:
tui.alternate_screenconfig:auto(default),always,never--no-alt-screenCLI flagZELLIJenv var detection)Usage:
With default
automode, Zellij users get working scrollback without any config changes.