fix: custom prompt expansion with large pastes #7154
+67
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
What?
Fix for slash commands (e.g., /prompts:code-review) not being recognized when large content (>3000 chars) is pasted.
Bug Report
Why?
With large pastes, slash commands were ignored, so custom prompts weren't expanded and were submitted as literal text.
How?
Refactored the early return block in handle_key_event_without_popup (lines 957-968).
Instead of returning early after replacing placeholders, the code now replaces placeholders in the textarea and continues to the normal submission flow.
This reuses the existing slash command detection and custom prompt expansion logic (lines 981-1047), avoiding duplication.
Changes:
Modified codex-rs/tui/src/bottom_pane/chat_composer.rs: refactored early return block to continue to normal flow instead of returning immediately
Added test: custom_prompt_with_large_paste_expands_correctly to verify the fix
Code Quality:
No lint warnings
Code follows existing patterns and reuses existing logic
Atomic change focused on the bug fix