fix(desktop): guard IME confirm Enter in ask inputs and small inputs - #8251
Open
complyue wants to merge 2 commits into
Open
fix(desktop): guard IME confirm Enter in ask inputs and small inputs#8251complyue wants to merge 2 commits into
complyue wants to merge 2 commits into
Conversation
Composer had the guard; the other Enter-submitting inputs (ask card, command palette, rule/note/rename/add inputs) still sent on IME confirm Enter. Add a shared compositionend listener in lib/imeComposition.ts and one isImeEvent() check per keydown.
The IME guard adds 2-3 lines to three legacy files that already sit at their ratchet file-size budget (ApprovalModal 1040, MemoryPanel 1891, SettingsPanel 7570 lines). Raise their budgets 238->240, 1088->1091, 6768->6770. Full -update was rejected to keep the PR diff focused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
WebKit(桌面端内嵌 WebView)的 IME 事件时序特殊:输入法确认 Enter 时,
compositionend先于确认的keydown触发(此时isComposing=false、keyCode=13),导致所有"回车即提交"的小输入框在中文等输入法确认候选词时误发送。Composer 此前已有防护(上游已通过
lib/composerKeyboard.ts的isImeKeyEvent合入),但 ask 卡片、命令面板、规则/笔记/重命名/添加等小输入框没有防护,IME 用户在这些输入框敲回车确认候选词时会把半截内容提交出去。目的
把 IME 防护统一扩展到所有 Enter 提交的小输入框:
lib/imeComposition.ts:共享的全局compositionend监听(isImeEvent),复用上游isImeKeyEvent的keyCode 229检查与 100ms 确认宽限期keydown处理前加一次isImeEvent(e)检查,命中则preventDefault并返回价值
ask-card-layout.test.ts(+78)、command-palette-interactions.test.tsx(+34)变更内容
11 个文件,+159:
lib/imeComposition.ts(isImeEvent,复用composerKeyboard.isImeKeyEvent)AskCard、ApprovalModal、CommandPalette、HistoryPanel、MemoryPanel、ModelSwitcher、OnboardingOverlay、SettingsPanel__tests__/ask-card-layout.test.ts、__tests__/command-palette-interactions.test.tsx另含 3 行 ratchet 边界调整(
tools/repolint/baseline.json):guard 给 3 个历史遗留大文件(ApprovalModal 1040 行 / MemoryPanel 1891 行 / SettingsPanel 7570 行)各净增 2-3 行,预算相应 238→240、1088→1091、6768→6770。已拒绝全量-update以保持 PR diff 聚焦,理由见提交信息。验证
go run ./tools/repolintclean(1957 baselined);gofmt/go vet无 Go 侧改动pnpm testCache-impact: none - 仅 desktop/frontend TS 与 repolint baseline 调整,不触及 provider 可见的系统提示前缀
Cache-guard: 未改动 internal/tool、internal/provider、internal/boot 等缓存敏感路径
Documentation-impact: none - 无 docs/*.md 改动,文档保持正确