Race condition during IME composition #21

Closed
opened 2026-02-16 02:17:43 -05:00 by yindo · 1 comment
Owner

Originally created by @BaiRuic on GitHub (Jun 15, 2025).

Problem

When using an IME for languages like Chinese, after selecting a candidate with a number key, the raw Pinyin text will be submitted instead of the final characters.

Solution

Introduce a small delay in the onCompositionEnd handler to keep isComposing as true long enough to prevent this race condition.

In ChatInputField, change:

- onCompositionEnd={() => setIsComposing(false)}
+ onCompositionEnd={() => { setTimeout(() => setIsComposing(false), 100); }}

This allows the IME to correctly finalize the text.

P.S. This is my first time submitting an issue. Please feel free to point out if I've done anything incorrectly.

Originally created by @BaiRuic on GitHub (Jun 15, 2025). ## Problem When using an IME for languages like Chinese, after selecting a candidate with a number key, the raw Pinyin text will be submitted instead of the final characters. ## Solution Introduce a small delay in the onCompositionEnd handler to keep isComposing as true long enough to prevent this race condition. In [ChatInputField](https://github.com/run-llama/chat-ui/blob/main/packages/chat-ui/src/chat/chat-input.tsx), change: ``` - onCompositionEnd={() => setIsComposing(false)} + onCompositionEnd={() => { setTimeout(() => setIsComposing(false), 100); }} ``` This allows the IME to correctly finalize the text. P.S. This is my first time submitting an issue. Please feel free to point out if I've done anything incorrectly.
yindo closed this issue 2026-02-16 02:17:43 -05:00
Author
Owner

@marcusschiesser commented on GitHub (Jun 16, 2025):

Cool thanks for pointing this out - you want to send a PR?

@marcusschiesser commented on GitHub (Jun 16, 2025): Cool thanks for pointing this out - you want to send a PR?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/chat-ui#21