TUI user shell output not limited when lines are extremely long
What version of Codex is running?
codex-cli 0.63.0
What subscription do you have?
API
Which model were you using?
gpt-5.1-codex
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64 (Windows 11 host with WSL2 Ubuntu)
What issue are you seeing?
In the TUI, when the "user shell" tool returns a small number of extremely long logical lines, the user shell output panel can overflow the viewport and effectively "flood" the screen. The TUI is supposed to limit this output via USER_SHELL_TOOL_CALL_MAX_LINES and middle truncation, but because truncation currently happens before line wrapping, a few very long lines can wrap into hundreds of on-screen lines and bypass the limit.
This means that commands which produce a lot of text on a small number of lines can push almost all other content out of view.
What steps can reproduce the bug?
- Start Codex in a project and open the TUI.
- Ask Codex to run a tool call that prints a single extremely long line, for example using Python to print ~50,000 characters:
- Natural language prompt (roughly): "Execute a tool call that uses Python to print a single very long line (around 50,000 characters). I want to test how the project displays long text."
- The resulting tool call might look like:
python - << 'PY' ... print("x" * 50000) ... PY.
- Wait for the tool to finish and observe the rendered "User shell" output.
- You will see that the output wraps into a huge number of screen lines and effectively takes over the entire viewport. The middle truncation that should be controlled by
USER_SHELL_TOOL_CALL_MAX_LINESdoes not appear to take effect.
In real-world usage this also happens with commands like:
Ran bash -lc "grep -R --line-number 'maskAssetId' ."
When such commands produce a small number of very long lines, the TUI wraps them into many visual lines, but does not limit the number of screen lines shown.
What is the expected behavior?
The user shell output panel should be limited based on the number of visible screen lines, not just the number of logical lines. Long lines should be wrapped first, and then the wrapped screen lines should be truncated (with middle truncation) so that:
- The output is constrained by
USER_SHELL_TOOL_CALL_MAX_LINES. - The layout's
output_max_linesstill applies. - The user shell output never floods the viewport, even for very long lines.
Additional information
I have a fork where I experimented with a fix in the TUI:
- In
codex-rs/tui/src/exec_cell/render.rs, when rendering user shell output, each logical line is first wrapped usingword_wrap_lineinto multiple screen lines.truncate_lines_middleis then applied to these screen lines, withUSER_SHELL_TOOL_CALL_MAX_LINEScontrolling the maximum number of screen lines. USER_SHELL_TOOL_CALL_MAX_LINEScontinues to be the single cap, but it now applies to screen lines instead of logical lines.- I added a test
user_shell_output_is_limited_by_screen_linesincodex-rs/tui/src/exec_cell/render.rsthat constructs two extremely long user shell output lines that wrap into many screen lines at a narrow width. The test counts the rendered lines containing a marker string and asserts thatoutput_screen_lines <= USER_SHELL_TOOL_CALL_MAX_LINES, guarding against regressions of this bug.
With this change, user shell output is limited by the actual visible screen lines, and commands that produce very long lines (like the grep example above) no longer flood the TUI.