From f570483b62057feb257d3d6d017d8795d15094c3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 16 Sep 2026 22:25:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=B0=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E6=97=B6=E8=BE=93=E5=85=A5=E6=A1=86=E8=87=AA=E5=8A=A8=E8=81=9A?= =?UTF-8?q?=E7=84=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 匹配主流IM客户端的习惯——切进一个聊天窗口应该能直接开始打字,不需要先手动 点一下输入框。只在topicId变化时聚焦一次,不依赖messages(否则每来一条新 消息就会把正在做其他操作的用户的焦点抢走)。 Co-Authored-By: Claude Sonnet 5 --- web/src/features/messages/ConversationView.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/src/features/messages/ConversationView.tsx b/web/src/features/messages/ConversationView.tsx index 84492327..9b0a3258 100644 --- a/web/src/features/messages/ConversationView.tsx +++ b/web/src/features/messages/ConversationView.tsx @@ -267,6 +267,15 @@ export function ConversationView() { // eslint-disable-next-line react-hooks/exhaustive-deps }, [topicId]); + // Switching into a chat window should let the user start typing immediately, not require an extra + // click into the input first -- matches every mainstream IM client. Deliberately NOT keyed on + // `messages` (would re-steal focus away from whatever the user is doing every time a new message + // arrives while they're already composing) -- only the initial switch itself should grab focus. + useEffect(() => { + if (!topicId) return; + textareaRef.current?.focus(); + }, [topicId]); + // Someone else dissolving the group currently open here (or this account being removed from it) // fires the SDK's `onDeleteTopic`, not `onData`/`onPres` -- those only invalidate this screen's // cached snapshots for re-render, they don't tell it the topic itself is gone. Left unhandled, the