MoonshotAI / MoonshotAI/kimi-cli
[kimi web] Enter pressed during IME composition is treated as 'send message'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Bug 描述 / Description
在使用中文/日文/韩文输入法(IME)于 kimi web 的输入框打字时,组词状态下按回车(本意是确认拼音/字母上屏)会被误判为「发送消息」,导致没打完的内容被直接发出去。
When typing with a CJK IME in the kimi web input box, pressing Enter while the composition is still active (intended to confirm the composed text) is treated as "send message", submitting incomplete input.
复现步骤 / Steps to Reproduce
kimi web启动后在浏览器(或内嵌 WKWebView)中打开任一会话- 切换到中文输入法(macOS 自带拼音 / 搜狗等均可)
- 输入拼音,如
nihao,保持候选框处于显示状态 - 按回车确认上屏
预期 / Expected:拼音确认上屏,消息不发送
实际 / Actual:消息被直接发送出去
原因分析 / Analysis
Web 标准做法是在处理 Enter 提交前检查输入法组合状态:
if (event.isComposing || event.keyCode === 229) return; // IME composition in progress
当前前端 bundle 中虽有部分 isComposing 检查,但发送路径上似乎存在遗漏(在 WKWebView 中 isComposing 时序与 Chrome 略有差异,更容易触发)。
临时绕过 / Workaround
我在自己内嵌 kimi web 的原生壳(KimiDesk)里注入了捕获阶段的拦截脚本,验证有效:
window.addEventListener('keydown', function(e) {
if ((e.key === 'Enter' || e.keyCode === 13) && (e.isComposing || e.keyCode === 229)) {
e.stopImmediatePropagation();
}
}, true);
(只阻止 JS 处理器收到事件,不影响输入法自身的上屏行为)
环境 / Environment
- kimi-cli 1.50.0(
kimi web) - macOS 26,WKWebView(Safari 内核);系统拼音输入法与搜狗输入法均可复现
建议 / Suggestion
在所有把 Enter 映射为「发送」的 keydown 处理器入口统一加上 isComposing / keyCode === 229 守卫;或者用 compositionstart/compositionend 维护组合状态标志再做判断。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the kimi web input and message-send keydown entry points, then inspect the existing isComposing checks and reproduce with a CJK IME in both a browser and WKWebView. Done means Enter during active composition confirms the text without sending, while ordinary Enter still sends; verify the behavior against the reported reproduction steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100