fix(web): prevent Safari IME composition Enter from sending message (#1140)

* fix(web): handle Safari IME composition Enter key

Safari sets e.isComposing=false on the keydown event that ends IME
composition, unlike Chrome/Firefox. This caused pressing Enter to confirm
CJK input to immediately send the message.

Track composition state manually via compositionstart/compositionend and
guard the send condition with both e.isComposing and _isComposing.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(web): improve Safari IME comment with WebKit bug reference

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Xing Ji
2026-03-15 05:47:21 +00:00
committed by GitHub
co-authored by Claude Sonnet 4.6
parent 62d16e69ac
commit a70e58f44e
+4 -1
View File
@@ -1759,7 +1759,10 @@ chatInput.addEventListener('keydown', (e) => {
}
}
if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) {
// Safari fires compositionend before keydown, so e.isComposing is already false
// when Enter confirms IME input. keyCode 229 (VK_PROCESS) catches this case.
// See https://bugs.webkit.org/show_bug.cgi?id=165004
if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.keyCode !== 229) {
e.preventDefault();
hideSlashAutocomplete();
sendMessage();