Skip to content

TUI composer wedges on tmux paste-buffer + immediate Enter: bracketed-paste state not exited before submit (codex-cli 0.139.0) #28167

Closed as duplicate

Description

@nicholasob7

TUI composer wedges on tmux paste-buffer + immediate Enter: bracketed-paste state not exited before submit (codex-cli 0.139.0)

What version of Codex is running?

codex-cli 0.139.0

What platform is your computer?

Linux Ubuntu 24.04.4 LTS, kernel 6.17.0-35-generic, x86_64

What terminal / environment?

  • tmux 3.4 (with mouse on, allow-passthrough on)
  • TERM=xterm-256color, COLORTERM=truecolor
  • codex-cli launched as: codex -C <repo> --sandbox read-only --ask-for-approval never
  • (terminal emulator not relevant to the bug; reproduced inside a tmux session)

What steps reproduce the bug?

# 1. In a tmux session with a running codex-cli TUI pane, build a
#    multi-line payload (any text > ~1 KB triggers reliably; small
#    payloads can also trigger under fast conditions).
PAYLOAD='hello test
this is a multi-line test message
line 3
line 4'

# 2. Load + paste via tmux (standard multi-line delivery pattern).
tmux load-buffer -b repro - <<<"$PAYLOAD"
tmux paste-buffer -b repro -t %pane

# 3. Send submit immediately (this is the trigger).
tmux send-keys -t %pane Enter

What is the expected behavior?

The submit gesture sent after the paste is treated as a clean submit. The composer clears, the placeholder returns, and the message is processed.

What actually happens?

The composer renders [Pasted Content NNNN chars] #2 (and #3, #4, ... if multiple submit gestures are sent). Submit gestures (Enter, C-m) are interpreted as additional paste events — the #N counter increments. The composer is wedged; no message is submitted. The wedge persists across C-a + C-k clears of the visible composer line and is only reliably cleared by killing and relaunching the codex-cli process.

Workaround (verified)

Insert a sleep of approximately 5 seconds between the paste-buffer call and the submit gesture. The TUI then exits bracketed-paste state and accepts a clean submit:

tmux paste-buffer -b repro -t %pane
sleep 5                   # required delay; TUI exits paste state here
tmux send-keys -t %pane Enter

This is functional but inelegant. The required delay appears to scale with payload size; 5–10 seconds is a workable default.

Diagnostic observations

  • The issue is reproducible across multiple cycles.
  • A codex-cli session in the affected environment self-diagnosed: the TUI remains in (or re-enters) bracketed-paste input handling, and the submit gesture is routed through the paste path as a continuation / replay event rather than as a clean submit.
  • Web search at the time of this report returned no known openai/codex issue for the same symptom. Search performed: site:github.com/openai/codex codex-cli 0.139.0 paste Enter bracketed paste tmux.

Potentially related issues

What I haven't tested yet

  • Whether the bug reproduces outside tmux (plain terminal paste followed by immediate Enter).
  • Whether the bug reproduces with small pastes (a single line, a single word, a few bytes) — i.e., is there a size threshold?
  • Whether the bug reproduces with middle-click paste inside tmux (which may use a different code path than paste-buffer).
  • Whether codex --no-tui is supported and whether the bug is TUI-specific.
  • codex CLI debug-level logs during reproduction.
  • Whether the fix for Enter key stops responding after task completion in tmux (TUI input stuck) #12645 (PushKeyboardEnhancementFlags in tui.rs:73-79) is in 0.139.0; if it is, this bug is a different manifestation of the same input-mode state-machine issue.

Suggested fix surface

The TUI's input state machine should ensure that:

  1. A submit gesture (Enter / C-m) received after a bracketed-paste payload is always routed to the submit handler, not the paste handler.
  2. The TUI exits bracketed-paste mode within a bounded time after the paste ends, regardless of payload size.
  3. Multiple submit gestures do not produce multiple paste events (the #N counter should not increment on a submit).

A small fix in the input state machine — distinguishing "submit during settling paste" from "new paste" — would resolve this without affecting normal interactive use.

Contact

Happy to provide additional reproduction details, session logs, or testing on a candidate patch if helpful.

Activity

  1. added
    bug
    CLI
    TUI
    on Jun 14, 2026
  2. github-actions commented on Jun 14, 2026

    @github-actions
    Contributor
  3. nicholasob7 commented on Jun 14, 2026

    @nicholasob7
    Author

    Reviewed #28116. This is related, but I do not think #28167 is a straight duplicate unless maintainers confirm the same input-state failure.

    #28116 appears to describe a broader long multi-line paste freeze, with diagnostic evidence pointing to a WebSocket read loop / WouldBlock hang after submission.

    The distinguishing condition in #28167 is the tmux paste-buffer + immediate Enter sequence. The suspected failure is that the TUI composer does not fully exit bracketed-paste handling before submit, so Enter is routed through paste continuation/replay behavior rather than ordinary submit handling.

    So I am leaving #28167 open as a narrower bracketed-paste/tmux race report unless maintainers prefer consolidation.

  4. JJLiebig commented on Sep 2, 2026

    @JJLiebig

    Windows/ConPTY confirmation on upstream Codex 0.152.1

    I reproduced the same failure without tmux.

    Environment:

    • Windows 11
    • PowerShell 7 and ConPTY
    • Official upstream codex-cli 0.152.1 bundled with the OpenAI Codex Windows app
    • Unpatched Herdr master

    Reproduction:

    1. Start an idle Codex TUI.
    2. Write a 4,052-character ASCII prompt.
    3. After the PTY writer acknowledges write and flush, wait 300 ms and send Enter.

    Observed:

    • Submission returned agent_prompt_stalled after 5.37 seconds.
    • Codex remained idle.
    • The composer displayed [Pasted Content 4053 chars].
    • Sending Enter later started the turn immediately, and Codex received the complete prompt.

    This matches Codex’s paste-burst behavior. In 0.152.1, Windows uses a 60 ms idle timeout and a 120 ms Enter-suppression window. Enter received while the burst is active is appended to the paste instead of submitting it:

    https://github.com/openai/codex/blob/rust-v0.152.1/codex-rs/tui/src/bottom_pane/paste_burst.rs#L155-L168

    https://github.com/openai/codex/blob/rust-v0.152.1/codex-rs/tui/src/bottom_pane/chat_composer.rs#L3152-L3169

    The important timing detail is that a successful ConPTY write/flush only means Windows accepted the bytes. It does not mean Codex has processed the final character. For sufficiently large input, the synthetic Enter can therefore reach Codex while its paste burst is still active.

    I also tested disable_paste_burst=true:

    • A 4,052-character single-line prompt submitted successfully.
    • A controlled multiline prompt lost its line break before reaching the model.

    Therefore, disabling paste-burst detection is not a safe workaround for general prompt automation.

    The downstream Herdr report is:

    herdrdev/herdr#3187

  5. pdinc-oss commented on Oct 16, 2026

    @pdinc-oss

    While #28434 , #28116 , #27405 seem to describe my issues, this issue does it better. Our internal tracker: PDINC-13912

    codex-cli 0.162.1 does not resolve the issue.

    Out typical invocation is On WSL1 (Ubuntu 22.04.5 LTS), via cygwin bash/Mintty (wsl -d Ubuntu-22.04 -u username) then

    script -f -q -O codex.typescript -c 'codex -a never -s danger-full-access --no-alt-screen resume session-guid'

    I accidentally pasted a large single line text string, which the TUI presented as [Pasted Content 1024 chars] (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XXXXXXXXXXXXXXXXXXXXXXXXXvY2lkMS5kb21haW4ub2Mx
    
      GPT-6-Astra low 
    
    
    
    Image

    after kill -9 from other terminal, vt100 reinitialization, the same Mintty window can be re-used.

    005a91b0  6e 1b 5b 36 36 3b 32 39  48 69 6e 67 20 c2 b7 20  |n.[66;29Hing .. |
    005a91c0  2f 70 73 20 74 6f 20 76  69 65 77 20 c2 b7 20 2f  |/ps to view .. /|
    005a91d0  73 74 6f 70 20 74 6f 20  63 6c 6f 73 65 1b 5b 33  |stop to close.[3|
    005a91e0  39 6d 1b 5b 34 39 6d 1b  5b 30 6d 1b 5b 36 39 3b  |9m.[49m.[0m.[69;|
    005a91f0  33 37 48 1b 5b 3f 32 35  68 1b 5b 3f 32 30 32 36  |37H.[?25h.[?2026|
    005a9200  6c 1b 5b 3f 32 30 32 36  68 1b 5b 36 35 3b 31 48  |l.[?2026h.[65;1H|
    005a9210  1b 5b 4a 1b 5b 3f 32 35  6c 1b 5b 36 35 3b 32 48  |.[J.[?25l.[65;2H|
    005a9220  1b 5b 30 6d 1b 5b 34 39  6d 1b 5b 4b 1b 5b 36 36  |.[0m.[49m.[K.[66|
    005a9230  3b 32 48 1b 5b 30 6d 1b  5b 34 39 6d 1b 5b 4b 1b  |;2H.[0m.[49m.[K.|
    005a9240  5b 36 37 3b 33 37 48 1b  5b 30 6d 1b 5b 34 39 6d  |[67;37H.[0m.[49m|
    005a9250  1b 5b 4b 1b 5b 36 38 3b  32 48 1b 5b 30 6d 1b 5b  |.[K.[68;2H.[0m.[|
    005a9260  34 39 6d 1b 5b 4b 1b 5b  36 39 3b 32 34 34 48 1b  |49m.[K.[69;244H.|
    005a9270  5b 30 6d 1b 5b 34 39 6d  1b 5b 4b 1b 5b 36 35 3b  |[0m.[49m.[K.[65;|
    005a9280  31 48 20 1b 5b 36 36 3b  31 48 20 1b 5b 36 37 3b  |1H .[66;1H .[67;|
    005a9290  31 48 1b 5b 31 6d e2 80  ba 1b 5b 32 32 6d 20 74  |1H.[1m....[22m t|
    005a92a0  6f 6b 65 6e 3a 20 1b 5b  33 38 3b 35 3b 36 3b 34  |oken: .[38;5;6;4|
    005a92b0  39 6d 5b 50 61 73 74 65  64 20 43 6f 6e 74 65 6e  |9m[Pasted Conten|
    005a92c0  74 20 31 30 32 34 20 63  68 61 72 73 5d 1b 5b 36  |t 1024 chars].[6|
    005a92d0  38 3b 31 48 1b 5b 33 39  3b 34 39 6d 20 1b 5b 36  |8;1H.[39;49m .[6|
    005a92e0  39 3b 31 48 20 20 1b 5b  33 38 3b 35 3b 32 32 33  |9;1H  .[38;5;223|
    005a92f0  3b 34 39 6d 47 50 54 2d  36 2d 41 73 74 72 61 20  |;49mGPT-6-Astra |
    005a9300  6c 6f 77 1b 5b 33 39 3b  34 39 6d 20 c2 b7 20 1b  |low.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLITUIbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions