Bug: Codex TUI overrides terminal cursor style in Neovim :terminal
What version of Codex CLI is running?
0.129.0
What subscription do you have?
pro
Which model were you using?
No response
What platform is your computer?
No response
What terminal emulator and version are you using (if applicable)?
ghostty+neovim 0.12
What issue are you seeing?
Codex emits ESC [ 0 q (DECSCUSR reset to default cursor shape) on every frame when not in Vim insert mode. In embedded terminal emulators like Neovim's built-in :terminal, this actively overrides the host's configured cursor style (e.g. guicursor), forcing a blinking block cursor instead of the user's configured bar cursor.
Environment
- Codex CLI: v0.129.0
- Neovim: 0.11+ (built-in terminal with "actual cursor" support)
- OS: macOS (Apple Silicon)
- Terminal: Neovim :terminal buffer
What steps can reproduce the bug?
Steps to Reproduce
- Configure Neovim with a bar cursor for terminal mode: -- ~/.config/nvim/lua/init.lua vim.o.guicursor = "n-sm-ve:block-Cursor,t-i-c-ci:ver16-Cursor,r-cr-v-o:hor7-Cursor"
- Open Neovim and enter a :terminal buffer.
- Confirm the cursor is a vertical bar (as configured by t:ver16-Cursor).
- Run codex inside the terminal buffer.
- Observe the cursor changes to a blinking block, ignoring the Neovim guicursor setting.
Minimal Reproduction (without Codex)
Inside a Neovim :terminal buffer, run: printf '\033[0 q' This sends the same escape sequence Codex emits, and the cursor changes from bar to blinking block — confirming the issue is the ESC [ 0 q escape.
Expected Behavior When Codex has not intentionally changed the cursor style (i.e., not in Vim insert mode), it should not emit any cursor-shape escape sequence. The host terminal's cursor configuration should be respected.
Actual Behavior
Codex emits SetCursorStyle::DefaultUserShape (ESC [ 0 q) on every render frame as the default cursor style. In embedded terminals, this is an active reset that overrides the parent's cursor configuration, not a no-op.
Root Cause
The cursor_style() method in chat_composer.rs (line 4219) returns SetCursorStyle::DefaultUserShape for all non-Vim-insert states:
fn cursor_style(&self, _area: Rect) -> crossterm::cursor::SetCursorStyle { if self.textarea.uses_vim_insert_cursor() { crossterm::cursor::SetCursorStyle::SteadyBar } else { crossterm::cursor::SetCursorStyle::DefaultUserShape // ← the problem } }
This is also the default in renderable.rs (line 20-21) and used in custom_terminal.rs for initialization and reset.
DefaultUserShape is not "do nothing" — it actively sends ESC [ 0 q to the terminal. In standalone terminals this resolves to the user's configured default, but in embedded terminals (Neovim, tmux with cursor passthrough disabled, etc.) it resolves to "blinking block" which may not match the host's configuration.
What is the expected behavior?
No response
Additional information
No response
As far as I understand, this was introduced in 0.129.0 and is not Neovim specific. Codex suddenly started overriding the cursor style instead of respecting the cursor shape configured by the shell/terminal. For example, even when my cursor is configured as a bar, opening Codex standalone shows a block cursor. This behavior did not exist before.
As far as I understand, this was introduced in 0.129.0 and is not Neovim specific. Codex suddenly started overriding the cursor style instead of respecting the cursor shape configured by the shell/terminal. For example, even when my cursor is configured as a bar, opening Codex standalone shows a block cursor. This behavior did not exist before.
yes, starting codex in a regular xterm session will change the cursor type to a blinking block. Quitting codex leaves the cursor at this state w/o resetting original behavior.
I can confirm this issue also affects old Konsole versions.
In my case, Codex emits DECSCUSR cursor-style sequences like ESC [ 5 SPACE q. xterm handles them correctly, but Konsole 2.14.2 does not support them and renders the final "q" literally on screen.
Changing TERM or terminfo did not help, because the sequence appears to be emitted directly by Codex.
As a temporary workaround, I patched the musl binary by replacing DECSCUSR sequences with NUL bytes while preserving binary size/offsets:
https://gist.github.com/cycne/ce8754d8adf25494431239bf9e53385b
A proper fix would probably be a config option to disable cursor-style escape emission, or avoiding DECSCUSR unless the terminal is known to support it.
Blinking cursors are the worst. With 5k+ issues... I feel this issue will just get lost, and never get fixed. Such a bad quality of life bug.
Additional reproduction in JetBrains' Reworked terminal, including a dialog transition:
- Codex CLI 0.163.0
- GoLand 2026.2.3 (build 262.10968.67), Reworked terminal engine
- macOS, with caret blinking disabled in the IDE settings
The shell cursor is steady before starting Codex, but blinks after Codex starts. Outside Codex, these commands reproduce the difference:
printf '\033[2 q' # steady block
printf '\033[0 q' # blinking block, despite the IDE preference
While Codex is running, sending printf '\033[2 q' to that session's TTY from another terminal stops the blinking. It stays steady during ordinary interaction, but blinking returns after selecting a numbered option in a decision dialog and returning to the main input. This is a visual observation; I have not captured the escape sequence at that transition.
A wrapper that sends the steady-block command once after startup therefore only partially works. Restoring it after exit also works, but does not address transitions during the session. A fix needs to cover returning from dialogs as well as initial startup and exit.
Switching GoLand to the Classic terminal engine avoided the blinking in my testing.
The "every frame" description is outdated, but the bug still reproduces on 0.166.0. #44879 cached the cursor style, so ESC[0 q no longer repeats per frame. Codex still sends it even when it never set another style.
Capture: macOS arm64, raw PTY output (TERM=xterm-256color), isolated CODEX_HOME, --no-daemon, scripted input, two runs per scenario with identical sequences. I did not test inside Neovim or JetBrains; the visible effect there matches the printf '\033[0 q' repros already in this thread.
| Scenario | 0.166.0 | Prototype on main (3a2788e6fc) |
|---|---|---|
| Default | ESC[0 q x6 (startup x2, mid-session x2, exit x2) |
none |
| Vim: startup | ESC[0 q, ESC[6 q x2 |
ESC[6 q x2 |
| Vim: back to normal mode | ESC[0 q |
ESC[0 q |
| Vim: exit | ESC[0 q x2 |
ESC[0 q x2 |
Causes, from reading the code:
Frame::cursor_styledefaults toDefaultUserShapeandlast_cursor_stylestarts asNone, soset_cursor_style_with_repairtreats the first frame as a change. Thecursor_style_single_column_framessnapshot shows this.invalidate_cursor_state()clears the cache, so the reset is sent again.set_viewport_areacalls it whenever the area changes, which likely explains the mid-session emissions and the earlier report of blinking returning after a dialog. I did not instrument this path directly.Terminal::dropandrestore_commonintui.rssend the reset on exit even if the style never changed.
Approach that worked in the prototype: only send DefaultUserShape to undo a non-default style Codex actually set. Track that in a Terminal field that survives invalidation, because skipping the reset whenever the cache is None would leave the Vim bar on screen. restore_common has no Terminal access, so it reads a process-wide flag. The first-frame repaint in the JediTerm repair also goes away, since no style command is sent.
Trade-off: if an external program changes the cursor and leaves it that way, Codex no longer resets it on resume. I did not test that handoff.
codex-tui tests: the cursor tests pass with one new regression test and three updated snapshots. In the full suite, changing_directory_preserves_project_trust_permissions_history_and_hooks also fails on my machine without the change. Two others failed in the full run but pass when run alone. I have the patch available if it's useful as a reference.
Turning on VIM mode seems to at least stop the symptom. Just stay in “insert” mode and things are fine. Not a fix, I know. But I get to keep my sanity. 🤣
Thanks for the bug report. This will be addressed in an upcoming release.