From ca7721358e87fa8472111365250559dc32a832f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 9 Oct 2026 10:30:38 -0400 Subject: [PATCH] Q201: an input method's Enter never picks a mention, and suggestions are announced Co-Authored-By: Claude Opus 5.5 --- src/renderer/src/i18n/zh.ts | 1 + .../src/pages/chat/MentionTextarea.tsx | 18 ++++++++-- tests/e2e/keyboard.spec.ts | 34 +++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/i18n/zh.ts b/src/renderer/src/i18n/zh.ts index df9ddbca..46cf87c4 100644 --- a/src/renderer/src/i18n/zh.ts +++ b/src/renderer/src/i18n/zh.ts @@ -698,6 +698,7 @@ export const zh: Record = { "Working…": "处理中…", "Waiting for the {name} sign-in in your browser (check {check} of {checks}).": "正在等待你在浏览器中完成 {name} 登录(第 {check}/{checks} 次检查)。", "Stop waiting": "停止等待", + "People to mention": "可提及的人", "Layout": "布局", "View": "视图", "Run status": "运行状态", diff --git a/src/renderer/src/pages/chat/MentionTextarea.tsx b/src/renderer/src/pages/chat/MentionTextarea.tsx index ecadb095..ebb7587c 100644 --- a/src/renderer/src/pages/chat/MentionTextarea.tsx +++ b/src/renderer/src/pages/chat/MentionTextarea.tsx @@ -1,4 +1,5 @@ -import { useRef, useState, type MutableRefObject } from "react"; +import { t } from "../../i18n/i18n"; +import { useId, useRef, useState, type MutableRefObject } from "react"; import { Avatar } from "../../shared/ui"; import type { AgentRecord, EmployeeRecord } from "../../../../shared/domain"; import { canonicalMentionHandle } from "../../../../shared/mention-handles"; @@ -40,6 +41,7 @@ export function MentionTextarea({ }) { const [query, setQuery] = useState(null); const [index, setIndex] = useState(0); + const listId = useId(); const anchor = useRef(0); const innerRef = useRef(null); const ref = textareaRef ?? innerRef; @@ -52,6 +54,7 @@ export function MentionTextarea({ : []; const close = () => setQuery(null); + const open = !disabled && query !== null && filtered.length > 0; const insertMention = (handle: string) => { const node = ref.current; @@ -81,6 +84,8 @@ export function MentionTextarea({ }; const handleKeyDown = (event: React.KeyboardEvent) => { + // While an input method is composing, Enter and Tab confirm its text; they never pick a person or send. + if (event.nativeEvent.isComposing || event.keyCode === 229) return; if (query !== null && filtered.length > 0) { if (event.key === "ArrowDown") { event.preventDefault(); @@ -111,8 +116,8 @@ export function MentionTextarea({ return (
- {!disabled && query !== null && filtered.length > 0 && ( -
(