Skip to content

fix(tui): reduce cursor jumpiness while streaming / stabilize bottom-anchored flex layout - #11064

Open
anujsaharan wants to merge 4 commits into
openai:mainfrom
anujsaharan:pr/01-cursor-jank
Open

anujsaharan wants to merge 4 commits into
openai:mainfrom
anujsaharan:pr/01-cursor-jank

Conversation

@anujsaharan

Copy link
Copy Markdown

// Very low blast radius and benign problem

Linked issue

Bug report / enhancement request: #11063

Fixes visible cursor jank during streaming/scroll updates in the TUI.

1) Hide cursor during scrollback injection

  • File: codex-rs/tui/src/insert_history.rs
  • Change: queue Hide before we reposition/move the terminal cursor to write wrapped output into scrollback.
  • Why: when the cursor is visible during those intermediate MoveTo operations, users can see cursor jumping/blinking while output is streaming.

2) Make flex layout consistent for render/cursor placement

  • File: codex-rs/tui/src/render/renderable.rs
  • Change: split flex allocation into two modes:
  • FitContent for desired_height() (preserves intrinsic/content-based sizing)
  • FillAssignedExtent for render() and cursor_pos() (fills allocated flex extent, keeps fixed children anchored)
  • Why: previously, render/cursor layout reused content-fit allocation, which could under-fill flex space and allow fixed bottom children (composer/footer) to drift instead of staying anchored.

3) Add tests for regressions

  • File: codex-rs/tui/src/render/renderable.rs
  • Added tests:
  • flex_render_anchors_fixed_child_to_bottom
  • flex_desired_height_remains_content_based

Validation run

  • cargo test -p codex-tui render::renderable::tests::flex_
  • cargo test -p codex-tui insert_history::tests::vt100_blockquote_wrap_preserves_color_on_all_wrapped_lines
    Both pass locally.

@github-actions

github-actions Bot commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@anujsaharan

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Feb 8, 2026
@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Feb 8, 2026
@Magicalmeow

Copy link
Copy Markdown

Still reproducing in codex-cli 0.120.0 on Windows 11, this time inside Zellij 0.44.1 — also tracked in #16687.

Symptoms:

  • Cursor jumps to the header path (working-directory line) when pressing space/backspace in the composer.
  • Cursor visibly follows the "Working…" spinner between frames while Codex is processing.

--no-alt-screen (the Zellij-recommended mode per codex --help) makes it less frequent but does not eliminate it; alt-screen is actually worse because of the higher redraw cadence — more intermediate MoveTo positions painted per second.

The fix in this PR (Hide before mid-frame MoveTo in insert_history.rs) matches the observed mechanism exactly. Terminal emulators that render cursor movement eagerly (Zellij's VT engine, xterm.js-based VSCode integrated terminal per #16687) paint every intermediate cursor position, while native Windows conhost hides the glitch by rendering lazily.

Could this be rebased against main? It's currently in merge conflict and hasn't had a review since 2026-03-11. Happy to test a rebased build against the Zellij + Windows 11 repro.

@vrnrn vrnrn left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[deleted]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants