From a70e58f44e653ea0452e8f5a5c73c3c20f13c2a8 Mon Sep 17 00:00:00 2001 From: Xing Ji <41811005+micsama@users.noreply.github.com> Date: Sun, 15 Mar 2026 13:47:21 +0800 Subject: [PATCH] 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 * fix(web): improve Safari IME comment with WebKit bug reference Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- src/channels/web/static/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/channels/web/static/app.js b/src/channels/web/static/app.js index 081b0f3a..ceab682a 100644 --- a/src/channels/web/static/app.js +++ b/src/channels/web/static/app.js @@ -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();