## Bug: Unicode (Korean) text causes panic after pasting large content

Resolved 💬 1 comment Opened Aug 16, 2025 by devforai-creator Closed Aug 18, 2025

What version of Codex is running?

codex-cli 0.21.0

Which model were you using?

gpt-5

What platform is your computer?

wsl: ubuntu

What steps can reproduce the bug?

Steps to Reproduce

  1. Install Codex via npm: npm install -g @openai/codex
  2. Run codex in terminal
  3. Copy and paste a large Korean text (over 1000 characters)
  • The text will be displayed as [Pasted Content XXXX chars]
  1. Type some Korean characters after the pasted content (e.g., "안녕하세요")
  2. Press backspace 2 or more times
  3. Result: Panic occurs with error: thread 'main' panicked at 'byte index X is not a char boundary'

What is the expected behavior?

Backspace should delete Korean characters properly without causing panic.

What do you see instead?

Application crashes with panic error when deleting multi-byte Unicode characters.

Additional information

Root Cause Analysis

The issue occurs in tui/src/bottom_pane/chat_composer.rs where cursor movement and text deletion use byte indices instead of character boundaries. This causes problems with multi-byte UTF-8 characters (Korean, Chinese, Japanese, Emoji, etc.).

Affected Users

This bug affects all users who:

  • Use non-ASCII languages (Korean, Chinese, Japanese, etc.)
  • Use emojis in their input
  • Work with international content

Proposed Solution

The fix involves modifying cursor operations to respect UTF-8 character boundaries:

  • Add character boundary validation functions
  • Modify backspace/delete operations to work with character boundaries
  • Update cursor movement to handle multi-byte characters correctly

I have tested a working solution locally and can submit a PR if the maintainers are interested.

Additional Context

This is a critical issue for international users as it makes the tool unusable for non-English content after pasting large texts.

<img width="1102" height="86" alt="Image" src="https://github.com/user-attachments/assets/5822c17d-7f70-44ec-8345-10d80ff0876c" />

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗