codex - 💡(How to fix) Fix TUI large paste placeholder number increments after Ctrl+C clears draft [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19940Fetched 2026-04-29 06:25:05
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3unlabeled ×1

Code Example

handle_paste -> clear_for_ctrl_c -> handle_paste

---

left:  [Pasted Content 1004 chars] #2
right: [Pasted Content 1004 chars]
RAW_BUFFERClick to expand / collapse

What issue are you seeing?

In the Codex CLI TUI, large paste placeholder numbering appears to be tied to paste attempts rather than the active draft state.

If a large paste inserts a placeholder such as [Pasted Content 1004 chars], pressing Ctrl+C clears the draft, but the next same-size paste renders [Pasted Content 1004 chars] #2 instead of reusing the base placeholder. This makes a fresh draft look like it still contains state from a canceled draft.

This looks similar to #10032, but that was a closed PR, not an issue. The reproduction path here is Ctrl+C draft clearing rather than manually deleting the placeholder. #17203 is related to paste/draft undo behavior, but this is a narrower placeholder numbering bug.

What steps can reproduce the bug?

  1. Open the Codex CLI TUI.
  2. Paste text longer than LARGE_PASTE_CHAR_THRESHOLD so the composer inserts a placeholder, for example [Pasted Content 1004 chars].
  3. Press Ctrl+C to clear/cancel the draft.
  4. Paste the same text again.
  5. Observe that the placeholder becomes [Pasted Content 1004 chars] #2.

I also verified this at unit-test level on main before the fix by adding a test for:

handle_paste -> clear_for_ctrl_c -> handle_paste

The test fails with:

left:  [Pasted Content 1004 chars] #2
right: [Pasted Content 1004 chars]

What is the expected behavior?

After Ctrl+C clears the active draft and pending paste state, the next large paste should be treated as a fresh draft and should reuse the base placeholder label, for example [Pasted Content 1004 chars].

Multiple simultaneously active same-size pending pastes should still receive suffixes such as #2, #3 so they remain distinct.

Additional information

The likely cause is the monotonic large_paste_counters: HashMap<usize, usize> state in the TUI composer. A fix can compute the next suffix from currently active pending_pastes instead of from total paste attempts.

A branch with the change and before/after verification is available here: https://github.com/Sungyoun-Kim/codex/tree/fix-large-paste-placeholder-numbering

Validated locally:

  • cargo fmt --check
  • cargo test -p codex-tui large_paste_numbering
  • cargo test -p codex-tui placeholder_deletion
  • cargo test -p codex-tui deleting_duplicate_length_pastes_removes_only_target

extent analysis

TL;DR

The issue can be fixed by modifying the large_paste_counters state in the TUI composer to compute the next suffix from currently active pending_pastes instead of total paste attempts.

Guidance

  • Review the large_paste_counters: HashMap<usize, usize> state in the TUI composer to understand how it tracks paste attempts.
  • Consider updating the logic to compute the next suffix based on active pending_pastes to ensure correct placeholder numbering after Ctrl+C clears the draft.
  • Verify the fix by running the provided unit tests, such as handle_paste -> clear_for_ctrl_c -> handle_paste, to ensure the expected behavior.
  • Check the branch with the proposed change (https://github.com/Sungyoun-Kim/codex/tree/fix-large-paste-placeholder-numbering) for a working example of the fix.

Example

No code snippet is provided as the issue does not contain explicit code that needs modification, but the branch with the change can be used as a reference.

Notes

The provided branch with the change and verification tests can be used to validate the fix locally using commands like cargo fmt --check and cargo test -p codex-tui large_paste_numbering.

Recommendation

Apply the workaround by modifying the large_paste_counters state to compute the next suffix from currently active pending_pastes, as this approach addresses the root cause of the issue and ensures correct placeholder numbering after Ctrl+C clears the draft.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix TUI large paste placeholder number increments after Ctrl+C clears draft [1 participants]